From d4a41297aa7a844558d5038ddb66f07957b6593d Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 23 Jul 1999 16:09:49 +0000 Subject: [PATCH] * NEWS: Note new user visible changes. * libtool.m4 (mingw32, AC_LIBTOOL_SETUP): probe for -mdll vs -dll under cygwin/mingw. probe whether the cygwin/mingw library supplies a stub DllMain (but this information isn't yet used). * ltconfig.in (mingw32, extract_expsyms_cmds): if HOST_CC is set, use that to build impgen so we can use it when cross-compiling. use correct entry points for mingw so static C++ constructors get called for code in the DLL. * ltmain.in (impgen.c): define O_BINARY to 0 if it is not in the system headers. --- ChangeLog | 14 ++++++++++++++ NEWS | 2 ++ libtool.m4 | 23 +++++++++++++++++++++++ ltconfig.in | 36 +++++++++++++++++++++++++++--------- ltmain.in | 5 +++++ 5 files changed, 71 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6f737a05..1ae9adcb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +1999-07-24 Olly Betts + + * NEWS: Note new user visible changes. + * libtool.m4 (mingw32, AC_LIBTOOL_SETUP): probe for -mdll vs -dll + under cygwin/mingw. + probe whether the cygwin/mingw library supplies a stub DllMain + (but this information isn't yet used). + * ltconfig.in (mingw32, extract_expsyms_cmds): if HOST_CC is set, + use that to build impgen so we can use it when cross-compiling. + use correct entry points for mingw so static C++ constructors get + called for code in the DLL. + * ltmain.in (impgen.c): define O_BINARY to 0 if it is not in the + system headers. + 1999-07-24 Bert Driehuis * ltconfig.in: Updated bsdi4 soname specs to be more like diff --git a/NEWS b/NEWS index 7680ea61..d6013642 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,8 @@ NEWS - list of user-visible changes between releases of GNU Libtool New in 1.3d: 1999-??-??; CVS version 1.3c, Libtool team: +* Start of support code for cross-compiling to win32. +* Improved support for mingw32. * New --with-pic flag to control the generation of PIC/non-PIC code. * New --build flag to ltconfig to help with build cross compilation environments is inherited from --build flag passed to configure. diff --git a/libtool.m4 b/libtool.m4 index 0fb19502..3e3d533b 100644 --- a/libtool.m4 +++ b/libtool.m4 @@ -128,6 +128,29 @@ ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL], AC_CHECK_TOOL(DLLTOOL, dlltool, false) AC_CHECK_TOOL(AS, as, false) AC_CHECK_TOOL(OBJDUMP, objdump, false) + + # recent cygwin and mingw systems supply a stub DllMain which the user + # can override, but on older systems we have to supply one + AC_CACHE_CHECK([if libtool should supply DllMain function], lt_cv_need_dllmain, + [AC_TRY_LINK([DllMain (0, 0, 0);], + [extern int __attribute__((__stdcall__)) DllMain(void*, int, void*);], + [lt_cv_need_dllmain=yes],[lt_cv_need_dllmain=no])]) + + # old mingw systems require "-dll" to link a DLL, while more recent ones + # require "-mdll" + lt_nostartfiles= + case $host in + *-*-cygwin) + # on cygwin we must also not link crt.o, or else the dll will need + # a WinMain@16 definition. + lt_nostartfiles=" -nostartfiles" ;; + esac + SAVE_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -mdll$lt_nostartfiles" + AC_CACHE_CHECK([how to link DLLs], lt_cv_cc_dll_switch, + [AC_TRY_LINK([], [], [lt_cv_cc_dll_switch=-mdll],[lt_cv_cc_dll_switch=-dll])]) + lt_cv_cc_dll_switch="$lt_cv_cc_dll_switch$lt_nostartfiles" + CFLAGS="$SAVE_CFLAGS" ;; ]) esac diff --git a/ltconfig.in b/ltconfig.in index 6bf25009..e62439b6 100755 --- a/ltconfig.in +++ b/ltconfig.in @@ -462,7 +462,7 @@ if test "$verify_host" = yes; then esac ;; esac - build=`SHELL $ac_config_sub $build_alias` + build=`$SHELL $ac_config_sub $build_alias` build_cpu=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` build_vendor=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` build_os=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` @@ -1346,18 +1346,36 @@ EOF extract_expsyms_cmds='test -f $objdir/impgen.c || \ sed -e "/^# \/\* impgen\.c starts here \*\//,/^# \/\* impgen.c ends here \*\// { s/^# //; p; }" -e d < $0 > $objdir/impgen.c~ - test -f $objdir/impgen.exe || (cd $objdir && $CC -o impgen impgen.c)~ + test -f $objdir/impgen.exe || (cd $objdir && \ + if test "x$HOST_CC" != "x" ; then $HOST_CC -o impgen impgen.c ; \ + else $CC -o impgen impgen.c ; fi)~ $objdir/impgen $dir/$soname > $objdir/$soname-def' old_archive_from_expsyms_cmds='$DLLTOOL --as=$AS --dllname $soname --def $objdir/$soname-def --output-lib $objdir/$newlib' + # cygwin and mingw dlls have different entry points and sets of symbols + # to exclude. + # FIXME: what about values for MSVC? + dll_entry=__cygwin_dll_entry@12 + dll_exclude_symbols=DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12~ + case "$host_os" in + mingw*) + # mingw values + dll_entry=_DllMainCRTStartup@12 + dll_exclude_symbols=DllMain@12,DllMainCRTStartup@12,DllEntryPoint@12~ + ;; + esac + + # mingw and cygwin differ, and it's simplest to just exclude the union + # of the two symbol sets. + dll_exclude_symbols=DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12,DllMainCRTStartup@12,DllEntryPoint@12 + # Extract the symbol export list from an `--export-all' def file, # then regenerate the def file from the symbol export list, so that # the compiled dll only exports the symbol export list. export_symbols_cmds='test -f $objdir/$soname-ltdll.c || sed -e "/^# \/\* ltdll\.c starts here \*\//,/^# \/\* ltdll.c ends here \*\// { s/^# //; p; }" -e d < $0 > $objdir/$soname-ltdll.c~ test -f $objdir/$soname-ltdll.$objext || (cd $objdir && $CC -c $soname-ltdll.c)~ - $DLLTOOL --export-all --exclude-symbols DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12 --output-def $objdir/$soname-def $objdir/$soname-ltdll.$objext $libobjs $convenience~ - sed -e "1,/EXPORTS/d" -e "s/ @ [0-9]* ;.*//" < $objdir/$soname-def > $export_symbols' + $DLLTOOL --export-all --exclude-symbols '$dll_exclude_symbols' --output-def $objdir/$soname-def $objdir/$soname-ltdll.$objext $libobjs $convenience~ sed -e "1,/EXPORTS/d" -e "s/ @ [0-9]* ;.*//" < $objdir/$soname-def > $export_symbols' archive_expsym_cmds='echo EXPORTS > $objdir/$soname-def~ _lt_hint=1; @@ -1367,11 +1385,11 @@ EOF done~ test -f $objdir/$soname-ltdll.c || sed -e "/^# \/\* ltdll\.c starts here \*\//,/^# \/\* ltdll.c ends here \*\// { s/^# //; p; }" -e d < $0 > $objdir/$soname-ltdll.c~ test -f $objdir/$soname-ltdll.$objext || (cd $objdir && $CC -c $soname-ltdll.c)~ - $CC -Wl,--base-file,$objdir/$soname-base -Wl,--dll -nostartfiles -Wl,-e,__cygwin_dll_entry@12 -o $lib $objdir/$soname-ltdll.$objext $libobjs $deplibs $compiler_flags~ - $DLLTOOL --as=$AS --dllname $soname --exclude-symbols DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12 --def $objdir/$soname-def --base-file $objdir/$soname-base --output-exp $objdir/$soname-exp~ - $CC -Wl,--base-file,$objdir/$soname-base $objdir/$soname-exp -Wl,--dll -nostartfiles -Wl,-e,__cygwin_dll_entry@12 -o $lib $objdir/$soname-ltdll.$objext $libobjs $deplibs $compiler_flags~ - $DLLTOOL --as=$AS --dllname $soname --exclude-symbols DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12 --def $objdir/$soname-def --base-file $objdir/$soname-base --output-exp $objdir/$soname-exp~ - $CC $objdir/$soname-exp -Wl,--dll -nostartfiles -Wl,-e,__cygwin_dll_entry@12 -o $lib $objdir/$soname-ltdll.$objext $libobjs $deplibs $compiler_flags' + $CC -Wl,--base-file,$objdir/$soname-base '$lt_cv_cc_dll_switch' -Wl,-e,'$dll_entry' -o $lib $objdir/$soname-ltdll.$objext $libobjs $deplibs $compiler_flags~ + $DLLTOOL --as=$AS --dllname $soname --exclude-symbols '$dll_exclude_symbols' --def $objdir/$soname-def --base-file $objdir/$soname-base --output-exp $objdir/$soname-exp~ + $CC -Wl,--base-file,$objdir/$soname-base $objdir/$soname-exp '$lt_cv_cc_dll_switch' -Wl,-e,'$dll_entry' -o $lib $objdir/$soname-ltdll.$objext $libobjs $deplibs $compiler_flags~ + $DLLTOOL --as=$AS --dllname $soname --exclude-symbols '$dll_exclude_symbols' --def $objdir/$soname-def --base-file $objdir/$soname-base --output-exp $objdir/$soname-exp~ + $CC $objdir/$soname-exp '$lt_cv_cc_dll_switch' -Wl,-e,'$dll_entry' -o $lib $objdir/$soname-ltdll.$objext $libobjs $deplibs $compiler_flags' ;; netbsd*) diff --git a/ltmain.in b/ltmain.in index 33575ce5..95ae1189 100644 --- a/ltmain.in +++ b/ltmain.in @@ -705,6 +705,11 @@ compiler." # #include /* for O_RDONLY, O_BINARY */ # #include /* for strdup() */ # +# /* O_BINARY isn't required (or even defined sometimes) under Unix */ +# #ifndef O_BINARY +# #define O_BINARY 0 +# #endif +# # static unsigned int # pe_get16 (fd, offset) # int fd;