X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2d35020a8dd1a0908f4e76af323cc0d413d6b8c3..c017416682938c39547836051c0fad74db45e8a0:/src/os2/dllar.sh?ds=sidebyside diff --git a/src/os2/dllar.sh b/src/os2/dllar.sh old mode 100644 new mode 100755 index 8ed5b4fb6b..2dd495b9b6 --- a/src/os2/dllar.sh +++ b/src/os2/dllar.sh @@ -86,19 +86,34 @@ CleanUp() { # Kill result in case of failure as there is just to many stupid make/nmake # things out there which doesn't do this. if [ $# -eq 0 ]; then - rm -f "${outFile}.a" "${outFile}.def" "${outFile}.dll" + rm -f $arcFile $arcFile2 $defFile $dllFile fi } # Print usage and exit script with rc=1. PrintHelp() { - echo 'Usage: dllar [-o[utput] output_file] [-d[escription] "dll descrption"]' - echo ' [-cc "CC"] [-f[lags] "CFLAGS"] [-ord[inals]] -ex[clude] "symbol(s)"' + echo 'Usage: dllar.sh [-o[utput] output_file] [-i[mport] importlib_name]' + echo ' [-name-mangler-script script.sh]' + echo ' [-d[escription] "dll descrption"] [-cc "CC"] [-f[lags] "CFLAGS"]' + echo ' [-ord[inals]] -ex[clude] "symbol(s)"' echo ' [-libf[lags] "{INIT|TERM}{GLOBAL|INSTANCE}"] [-nocrt[dll]] [-nolxl[ite]]' echo ' [*.o] [*.a]' echo '*> "output_file" should have no extension.' echo ' If it has the .o, .a or .dll extension, it is automatically removed.' - echo ' The import library name is derived from this and is set to "name".a.' + echo ' The import library name is derived from this and is set to "name".a,' + echo ' unless overridden by -import' + echo '*> "importlib_name" should have no extension.' + echo ' If it has the .o, or .a extension, it is automatically removed.' + echo ' This name is used as the import library name and may be longer and' + echo ' more descriptive than the DLL name which has to follow the old ' + echo ' 8.3 convention of FAT.' + echo '*> "script.sh may be given to override the output_file name by a' + echo ' different name. It is mainly useful if the regular make process' + echo ' of some package does not take into account OS/2 restriction of' + echo ' DLL name lengths. It takes the importlib name as input and is' + echo ' supposed to procude a shorter name as output. The script should' + echo ' expect to get importlib_name without extension and should produce' + echo ' a (max.) 8 letter name without extension.' echo '*> "cc" is used to use another GCC executable. (default: gcc.exe)' echo '*> "flags" should be any set of valid GCC flags. (default: -s -Zcrtdll)' echo ' These flags will be put at the start of GCC command line.' @@ -146,7 +161,9 @@ doCommand() { # setup globals cmdLine=$* outFile="" +outimpFile="" inputFiles="" +renameScript="" description="" CC=gcc.exe CFLAGS="-s -Zcrtdll" @@ -165,6 +182,7 @@ case $curDirS in esac # Parse commandline libsToLink=0 +omfLinking=0 while [ $1 ]; do case $1 in -ord*) @@ -174,6 +192,14 @@ while [ $1 ]; do shift outFile=$1 ;; + -i*) + shift + outimpFile=$1 + ;; + -name-mangler-script) + shift + renameScript=$1 + ;; -d*) shift description=$1 @@ -203,16 +229,27 @@ while [ $1 ]; do -nolxl*) flag_USE_LXLITE=0 ;; - -* | /* | *.dll) + -* | /*) case $1 in -L* | -l*) libsToLink=1 ;; + -Zomf) + omfLinking=1 + ;; *) ;; esac EXTRA_CFLAGS=${EXTRA_CFLAGS}" "$1 ;; + *.dll) + EXTRA_CFLAGS="${EXTRA_CFLAGS} `basnam $1 .dll`" + if [ $omfLinking -eq 1 ]; then + EXTRA_CFLAGS="${EXTRA_CFLAGS}.lib" + else + EXTRA_CFLAGS="${EXTRA_CFLAGS}.a" + fi + ;; *) found=0; if [ $libsToLink -ne 0 ]; then @@ -253,6 +290,7 @@ for file in $inputFiles ; do *.lib) suffix=".lib" AR="emxomfar" + EXTRA_CFLAGS="$EXTRA_CFLAGS -Zomf" ;; *) ;; @@ -269,12 +307,12 @@ for file in $inputFiles ; do doCommand "cd $dirname; $AR x ../$file" cd $curDir found=0; - for subfile in $dirname/*.o ; do + for subfile in $dirname/*.o* ; do if [ -f $subfile ]; then found=1 if [ -s $subfile ]; then # FIXME: This should be: is file size > 32 byte, _not_ > 0! - newInputFiles="$newInputFiles $subname" + newInputFiles="$newInputFiles $subfile" fi fi done @@ -326,12 +364,37 @@ case $outFile in *) ;; esac +case $outimpFile in +*.a) + outimpFile=`basnam $outimpFile .a` + ;; +*.lib) + outimpFile=`basnam $outimpFile .lib` + ;; +*) + ;; +esac +if [ -z $outimpFile ]; then + outimpFile=$outFile +fi defFile="${outFile}.def" -dllFile="${outFile}.dll" -arcFile="${outFile}.a" +arcFile="${outimpFile}.a" +arcFile2="${outimpFile}.lib" + +#create $dllFile as something matching 8.3 restrictions, +if [ -z $renameScript ] ; then + dllFile="$outFile" +else + dllFile=`$renameScript $outimpFile` +fi -if [ $do_backup -ne 0 -a -f $arcFile ] ; then - doCommand "mv $arcFile ${outFile}_s.a" +if [ $do_backup -ne 0 ] ; then + if [ -f $arcFile ] ; then + doCommand "mv $arcFile ${outFile}_s.a" + fi + if [ -f $arcFile2 ] ; then + doCommand "mv $arcFile2 ${outFile}_s.lib" + fi fi # Extract public symbols from all the object files. @@ -342,16 +405,18 @@ for file in $inputFiles ; do *!) ;; *) - doCommand "emxexp -u $file >> $tmpdefFile" + # we do not want to export weak symbols in general, so we filter + # those out using grep. + doCommand "emxexp -u $file >> $tmpdefFile || true" ;; esac done # Create the def file. rm -f $defFile -libName=`basnam $outFile` -echo "LIBRARY `echo $libName | sed 's/\./_/'` $library_flags" >> $defFile -if [ -n $description ]; then +echo "LIBRARY `basnam $dllFile` $library_flags" >> $defFile +dllFile="${dllFile}.dll" +if [ ! -z $description ]; then echo "DESCRIPTION \"${description}\"" >> $defFile fi echo "EXPORTS" >> $defFile @@ -393,6 +458,7 @@ for file in $inputFiles ; do esac done doCommand "$CC $CFLAGS -Zdll -o $dllFile $defFile $gccCmdl $EXTRA_CFLAGS" +touch "${outFile}.dll" doCommand "emximp -o $arcFile $defFile" if [ $flag_USE_LXLITE -ne 0 ]; then @@ -400,9 +466,20 @@ if [ $flag_USE_LXLITE -ne 0 ]; then if [ $EXPORT_BY_ORDINALS -ne 0 ]; then add_flags="-ynd" fi - doCommand "lxlite -cs -t: -mrn -mln $add_flags $dllFile" + doCommand "lxlite -cs -t: $add_flags `echo $dllFile | sed 's/\//\\\\/g'`" fi +#New version of emxomf do no longer want the "-l" flag +case `emxomf` in +emxomf\ 0.6*) + omflibflag="" + ;; +*) + omflibflag=" -l" + ;; +esac +doCommand "emxomf -s$omflibflag $arcFile" + # Successful exit. CleanUp 1 exit 0