delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1998/05/01/04:11:20

From: ian AT cygnus DOT com
Subject: Re: Libtool that does DLL's??
1 May 1998 04:11:20 -0700 :
Message-ID: <199805010457.AAA21624.cygnus.gnu-win32@tweedledumb.cygnus.com>
References: <5010400022132455000002L052*@MHS>
To: setera AT us DOT ibm DOT com
Cc: gnu-win32 AT cygnus DOT com

>Has anyone considered (or better yet, created) a version of Libtool that
>will build DLL's for GNU-WIN32?

This is the patch, approximately to libtool 1.2, which I've thrown
together and sent to the libtool maintainer.  This is almost certainly
not the final version.  If you have any suggestions, please send them
to bug-libtool AT gnu DOT org, not to me (I'm on that list).

Ian

Index: ltconfig.in
===================================================================
RCS file: /cvs/cvsfiles/devo/libtool/ltconfig.in,v
retrieving revision 1.6
retrieving revision 1.9
diff -u -r1.6 -r1.9
--- ltconfig.in	1998/03/23 18:28:53	1.6
+++ ltconfig.in	1998/04/23 19:34:12	1.9
@@ -97,6 +97,8 @@
 old_LN_S="$LN_S"
 old_NM="$NM"
 old_RANLIB="$RANLIB"
+old_DLLTOOL="$DLLTOOL"
+old_AS="$AS"
 
 # Parse the command line options.
 args=
@@ -351,6 +353,10 @@
   old_postinstall_cmds="\$RANLIB \$oldlib;$old_postinstall_cmds"
 fi
 
+# Set sane defaults for `DLLTOOL' and `AS', used on cygwin32.
+test -z "$DLLTOOL" && DLLTOOL=dlltool
+test -z "$AS" && AS=as
+
 # Check to see if we are using GCC.
 if test "$with_gcc" != yes || test -z "$CC"; then
   # If CC is not set, then try to find GCC or a usable CC.
@@ -456,7 +462,7 @@
   aix3* | aix4* | irix5* | irix6* | osf3* | osf4*)
     # PIC is the default for these OSes.
     ;;
-  os2*)
+  cygwin32* | os2*)
     # We can build DLLs from non-PIC.
     ;;
   amigaos*)
@@ -490,7 +496,7 @@
     # PIC (with -KPIC) is the default.
     ;;
 
-  os2*)
+  cygwin32* | os2*)
     # We can build DLLs from non-PIC.
     ;;
 
@@ -702,7 +708,7 @@
 runpath_var=
 
 case "$host_os" in
-amigaos* | sunos4*)
+amigaos* | sunos4* | cygwin32*)
   # On these operating systems, we should treat GNU ld like the system ld.
   gnu_ld_acts_native=yes
   ;;
@@ -756,6 +762,27 @@
     hardcode_minus_L=yes
     ;;
 
+  cygwin32*)
+    # hardcode_libdir_flag_spec is actually meaningless, as there is
+    # no search path for DLLs.
+    hardcode_libdir_flag_spec='-L$libdir'
+    allow_undefined_flag=unsupported
+    # Very, very bogus.
+    echo '
+#include <windows.h>
+
+struct _reent *_impure_ptr;
+extern struct _reent *__imp_reent_data;
+BOOL APIENTRY
+__dll_entry (HINSTANCE hinst, DWORD reason, LPVOID reserved)
+{
+  _impure_ptr = __imp_reent_data;
+}
+' > libtool.c
+    archive_cmds='$CC -c '"`pwd`"'/libtool.c;echo EXPORTS > $soname-def;$NM$libobjs | $global_symbol_pipe | sed '\''s/.* //'\'' >> $soname-def;$LD -s --base-file $soname-base --dll -e ___dll_entry AT 12 -o $lib libtool.o$libobjs$deplibs;$DLLTOOL --as=$AS --dllname $soname --def $soname-def --base-file $soname-base --output-exp $soname-exp;$LD -s --base-file $soname-base $soname-exp --dll -e ___dll_entry AT 12 -o $lib libtool.o$libobjs$deplibs;$DLLTOOL --as=$AS --dllname $soname --def $soname-def --base-file $soname-base --output-exp $soname-exp;$LD $soname-exp --dll -e ___dll_entry AT 12 -o $lib libtool.o$libobjs$deplibs;$rm libtool.o $soname-base $soname-exp'
+    old_archive_from_new_cmds='$DLLTOOL --as=$AS --dllname $soname --def $soname-def --output-lib $objdir/$libname.a;$rm $soname-def'
+    ;;
+
   # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
   # support.  Future versions do this automatically, but an explicit c++rt0.o
   # does not break anything, and helps significantly (at the cost of a little
@@ -936,6 +963,10 @@
 aix*)
   symcode='[BCDTU]'
   ;;
+cygwin32*)
+  sympat='_\([_A-Za-z][_A-Za-z0-9]*\)'
+  symxfrm='_\1 \1'
+  ;;
 irix*)
   # Cannot use undefined symbols on IRIX because inlined functions mess us up.
   symcode='[BCDEGRST]'
@@ -950,6 +981,14 @@
   symcode='[ABCDGISTUW]'
 fi
 
+case "$host_os" in
+cygwin32*)
+  # We do not want undefined symbols on cygwin32.  The user must
+  # arrange to define them via -l arguments.
+  symcode='[ABCDGISTW]'
+  ;;
+esac
+
 # Write the raw and C identifiers.
 global_symbol_pipe="sed -n -e 's/^.* $symcode $sympat$/$symxfrm/p'"
 
@@ -1123,6 +1162,13 @@
   finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "(cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a)"; (cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a) || exit 1; done'
   ;;
 
+cygwin32*)
+  version_type=windows
+  library_names_spec='${libname}`echo ${release} | sed -e 's/[.]/-/g'`${versuffix}.dll $libname.a'
+  dynamic_linker='Win32 ld.exe'
+  shlibpath_var=PATH
+  ;;
+
 freebsd2* | freebsd3*)
   version_type=sunos
   library_names_spec='${libname}${release}.so.$versuffix $libname.so'
@@ -1285,9 +1331,9 @@
 
 # Now quote all the things that may contain metacharacters.
 for var in ltecho old_CC old_CFLAGS old_CPPFLAGS old_LD old_NM old_RANLIB \
-  old_LN_S AR CC LD LN_S NM reload_flag reload_cmds wl pic_flag \
-  link_static_flag no_builtin_flag export_dynamic_flag_spec \
-  libname_spec library_names_spec soname_spec RANLIB \
+  old_LN_S old_DLLTOOL old_AS AR CC LD LN_S NM DLLTOOL AS reload_flag \
+  reload_cmds wl pic_flag link_static_flag no_builtin_flag \
+  export_dynamic_flag_spec libname_spec library_names_spec soname_spec RANLIB \
   old_archive_cmds old_archive_from_new_cmds old_postinstall_cmds \
   old_postuninstall_cmds archive_cmds postinstall_cmds postuninstall_cmds \
   allow_undefined_flag no_undefined_flag \
@@ -1345,6 +1391,7 @@
 #
 # CC="$old_CC" CFLAGS="$old_CFLAGS" CPPFLAGS="$old_CPPFLAGS" \\
 # LD="$old_LD" NM="$old_NM" RANLIB="$old_RANLIB" LN_S="$old_LN_S" \\
+# DLLTOOL="$old_DLLTOOL" AS="$old_AS" \\
 #   $0$ltconfig_args
 #
 # Compiler and other test output produced by $progname, useful for
@@ -1390,6 +1437,12 @@
 
 # A BSD-compatible nm program.
 NM="$NM"
+
+# Used on cygwin32: DLL creation program.
+DLLTOOL="$DLLTOOL"
+
+# Used on cygwin32: assembler.
+AS="$AS"
 
 # The name of the directory that contains temporary libtool files.
 objdir="$objdir"
Index: ltmain.in
===================================================================
RCS file: /cvs/cvsfiles/devo/libtool/ltmain.in,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ltmain.in	1998/03/20 23:35:33	1.3
+++ ltmain.in	1998/04/17 20:20:14	1.4
@@ -967,6 +967,14 @@
         versuffix="$current.$revision"
         ;;
 
+      windows)
+        # Like Linux, but with '-' rather than '.', and with a leading
+        # '-', since we only want one extension on Windows 95.
+        version_vars="$version_vars major versuffix"
+        major=`expr $current - $age`
+        versuffix="-$major-$age-$revision"
+        ;;
+
       *)
         $echo "$modename: unknown library version type \`$version_type'" 1>&2
         echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
Index: libtool.m4
===================================================================
RCS file: /cvs/cvsfiles/devo/libtool/libtool.m4,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- libtool.m4	1998/04/13 16:09:14	1.11
+++ libtool.m4	1998/04/13 20:44:46	1.12
@@ -70,11 +70,17 @@
   # On SCO OpenServer 5, we need -belf to get full-featured binaries.
   CFLAGS="$CFLAGS -belf"
   ;;
+
+*-*-cygwin32*)
+  AM_SYS_LIBTOOL_CYGWIN32
+  ;;
+
 esac
 
 # Actually configure libtool.  ac_aux_dir is where install-sh is found.
 CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \
 LD="$LD" NM="$NM" RANLIB="$RANLIB" LN_S="$LN_S" \
+DLLTOOL="$DLLTOOL" AS="$AS" \
 ${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig \
 $libtool_flags --no-verify $ac_aux_dir/ltmain.sh $host \
 || AC_MSG_ERROR([libtool configure failed])
@@ -255,4 +261,10 @@
 NM="$ac_cv_path_NM"
 AC_MSG_RESULT([$NM])
 AC_SUBST(NM)
+])
+
+# AM_SYS_LIBTOOL_CYGWIN32 - find tools needed on cygwin32
+AC_DEFUN(AM_SYS_LIBTOOL_CYGWIN32,
+[AC_CHECK_TOOL(DLLTOOL, dlltool, false)
+AC_CHECK_TOOL(AS, as, false)
 ])
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019