]> git.ipfire.org Git - thirdparty/libtool.git/commitdiff
misc win32 cleanups
authorGary V. Vaughan <gary@gnu.org>
Mon, 21 Dec 1998 13:04:14 +0000 (13:04 +0000)
committerGary V. Vaughan <gary@gnu.org>
Mon, 21 Dec 1998 13:04:14 +0000 (13:04 +0000)
ChangeLog
demo/dlmain.c
demo/foo.c
demo/foo.h
demo/hello.c
libltdl/configure.in
libtool.m4
ltconfig.in
ltmain.in

index 3cff6ec0b1665447aefb8019640c7282f056012f..d3f9583e87a666d77b6eb69a0c9d7f0d4c76e051 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,39 @@
+1998-12-21  Gary V. Vaughan  <gvaughan@oranda.demon.co.uk>
+
+       * libtool.m4 (AM_SYS_NM_PARSE): apparently  __ptr_t is predefined
+         on some systems - use lt_ptr_t instead.
+       * ltconfig.in: ditto.
+       * ltmain.in: ditto.
+
+       * libtool.m4 (AM_SYS_SYMBOL_UNDERSCORE): use an AC_SUBST to pass
+       the result of this into the compile rather than AC_DEFINE which
+       breaks when building with older versions of autoconf.
+       * ltconfig.in (symxfrm): Don't put the leading underscore back
+       with the global_symbol_pipe.
+       * demo/dlmain.c (main): No need to specialcase underscores in
+       dld_preloaded_symbols - it is fixed by symxfrm above!
+       * libltdl/configure.in: use AM_SYS_SYMBOL_UNDERSCORE from
+       libtool.m4 rather than reincent the wheel here =)O|
+
+       * ltmain.in:  Fix deplibs methods to not rely on a.out (cygwin
+       uses a.exe!).
+
+       * libltdl/configure.in: Cleanups - fix header comment and emacs
+       local-vars.
+       
+       * demo/dlmain.c (win32_force_data_import_address): a nasty hack
+       to force the address of imported data symbols into
+       dld_preloaded_symbols on win32, which does data imports
+       differently to function imports (sheesh!).  This functionality
+       needs to be moved into the dld_preloaded_symbols generation code.
+       demo/helldl with static linking is broken on win32 by this change,
+       probably until after libtool-1.3 =(O|
+       * demo/foo.h: make sure __CYGWIN32__ is always defined on cygwin32
+       systems.  Use the correct __declspec macro for lib exports/imports
+       on cygwin32.
+       * demo/foo.c, demo/hello.c: Make sure we tell foo.h that these
+       sources are inside libfoo, and want to export symbols.
+       
 1998-12-20  Thomas Tanner  <tanner@gmx.de>
 
        * autogen: configure demo, depdemo, libltdl and mdemo
index 1374aa49e5bb6e9eeac309067ee87c1732eb2807..c328e404472074664cadc52beb725489df9a9030 100644 (file)
@@ -29,6 +29,25 @@ struct dld_symlist
 
 extern struct dld_symlist dld_preloaded_symbols[];
 
+#ifdef __CYGWIN32__
+int
+win32_force_data_import_address __P((void))
+{
+  struct dld_symlist *s;
+  
+  s = dld_preloaded_symbols;
+  while (s->name)
+    {
+      if (!strcmp ("nothing", s->name))
+        s->address = &nothing;
+      s++;
+    }
+
+  return 0;
+}
+#endif
+      
+
 int
 main (argc, argv)
      int argc;
@@ -41,20 +60,17 @@ main (argc, argv)
 
   printf ("Welcome to *modular* GNU Hell!\n");
 
+#ifdef __CYGWIN32__
+  /* runtime table initialisation */
+  (void) win32_force_data_import_address();
+#endif
+
   /* Look up the symbols we require for this demonstration. */
   s = dld_preloaded_symbols;
   while (s->name)
     {
       if (s->address) {
         char *name = s->name;
-#ifdef WITH_SYMBOL_UNDERSCORE      
-        if (*name != '_')
-          {
-            fprintf(stderr, "ERROR: configure detected leading underscores incorrectly.\n");
-            exit(1);
-          }
-        name++;
-#endif      
         printf ("found symbol: %s\n", name);
         if (!strcmp ("hello", name))
          phello = s->address;
index 0a8c318abaea62be37a8e7fd20d243c25abc52d7..d700b575578100f18088e73b2cf73b319681907d 100644 (file)
@@ -18,12 +18,15 @@ along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
 USA. */
 
+#define _LIBFOO_COMPILATION_
 #include "foo.h"
+#undef _LIBFOO_COMPILATION
+
 #include <stdio.h>
 #include <math.h>
 
 /* Give a global variable definition. */
-int nothing;
+int nothing = FOO_RET;
 
 int
 foo ()
index 2a17a0ae3a3a000a1cdca12459d787c9e71c353f..b450605c408a9a6abc15b3b3bac5a206c300aa3b 100644 (file)
@@ -22,6 +22,16 @@ USA. */
 #ifndef _FOO_H_
 #define _FOO_H_ 1
 
+/* At some point, cygwin will stop defining __CYGWIN32__, but b19 and
+ * earlier do not define __CYGWIN__.  This snippit allows us to check
+ * for __CYGWIN32__ reliably for both old and (probable) future releases.
+ */
+#ifdef __CYGWIN__
+#  ifndef __CYGWIN32__
+#    define __CYGWIN32__
+#  endif
+#endif
+
 /* __BEGIN_DECLS should be used at the beginning of your declarations,
    so that C++ compilers don't mangle their names.  Use __END_DECLS at
    the end of C declarations. */
@@ -39,21 +49,32 @@ USA. */
    that don't understand ANSI C prototypes still work, and ANSI C
    compilers can issue warnings about type mismatches. */
 #undef __P
-#if defined (__STDC__) || defined (_AIX) || (defined (__mips) && defined (_SYSTYPE_SVR4)) || defined(WIN32) || defined(__cplusplus)
+#if defined (__STDC__) || defined (_AIX) || (defined (__mips) && defined (_SYSTYPE_SVR4)) || defined(__CYGWIN32__) || defined(__cplusplus)
 # define __P(protos) protos
 #else
 # define __P(protos) ()
 #endif
 
+#ifdef __CYGWIN32__
+#  ifdef _LIBFOO_COMPILATION_
+#    define EXTERN __declspec(dllexport)
+#  else
+#    define EXTERN extern __declspec(dllimport)
+#  endif
+#else
+#  define EXTERN extern
+#endif
+
 /* Silly constants that the functions return. */
 #define HELLO_RET 0xe110
 #define FOO_RET 0xf00
 
+
 /* Declarations.  Note the wonderful use of the above macros. */
 __BEGIN_DECLS
 int foo __P((void));
 int hello __P((void));
-extern int nothing;
+EXTERN int nothing;
 __END_DECLS
 
 #endif /* !_FOO_H_ */
index b82bfe5ae753222f6bafe8a708eff9207096a808..c20cb75f1c25dc1ba10beff3b22c3148e460e93c 100644 (file)
@@ -18,7 +18,10 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
 USA. */
 
 /* Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu> */
+#define _LIBFOO_COMPILATION
 #include "foo.h"
+#undef _LIBFOO_COMPILATION
+
 #include <stdio.h>
 
 int
index a1dfbb9114e3642eb2e9c7cb1b02a4161700163d..02a47097a2430fbe011d0a34a55e11575acf13e9 100644 (file)
@@ -1,4 +1,5 @@
-dnl Initialize the hell package.
+dnl Process this file with autoconf to create configure.
+dnl Initialize the ltdl package.
 AC_INIT(ltdl.c)
 AM_INIT_AUTOMAKE(libltdl,1.0)
 
@@ -32,18 +33,8 @@ AC_CHECK_FUNCS(dlopen, AC_DEFINE(HAVE_LIBDL),
 )
 AC_SUBST(LIBADD_DL)
 
-AC_CACHE_CHECK([for underscore before symbols], libltdl_cv_uscore, [
-  echo "main(){int i=1;} fnord(){int i=23; int ltuae=42;}" > conftest.c
-  ${CC} -c conftest.c > /dev/null
-  if (nm conftest.$ac_objext | grep _fnord) > /dev/null; then
-    libltdl_cv_uscore=yes
-  else
-    libltdl_cv_uscore=no
-  fi
-  rm -f conftest*
-])
-
-if test x"$libltdl_cv_uscore" = xyes; then
+AM_SYS_SYMBOL_UNDERSCORE
+if test x"$USE_SYMBOL_UNDERSCORE" = xyes; then
   if test x"$ac_cv_func_dlopen" = xyes ||
      test x"$ac_cv_lib_dl_dlopen" = xyes ; then
        AC_CACHE_CHECK([whether we have to add an underscore for dlsym],
@@ -67,3 +58,8 @@ fi
 
 dnl Output the makefile
 AC_OUTPUT(Makefile)
+
+# Local Variables:
+# mode:shell-script
+# sh-indentation:2
+# End:
index 80265f12c7b3a85ab8680d3c0dfc3333f030ec66..42c48ecb31933ca19e5b1f28e7eb698266b11984 100644 (file)
@@ -428,9 +428,9 @@ EOF
 
        cat <<EOF >> conftest.c
 #if defined (__STDC__) && __STDC__
-# define __ptr_t void *
+# define lt_ptr_t void *
 #else
-# define __ptr_t char *
+# define lt_ptr_t char *
 #endif
 
 /* The number of symbols in dld_preloaded_symbols, -1 if unsorted. */
@@ -439,16 +439,16 @@ int dld_preloaded_symbol_count = $ac_count;
 /* The mapping between symbol names and symbols. */
 struct {
   char *name;
-  __ptr_t address;
+  lt_ptr_t address;
 }
 changequote(,)dnl
 dld_preloaded_symbols[] =
 changequote([,])dnl
 {
 EOF
-        sed 's/^\(.*\) \(.*\)$/  {"\1", (__ptr_t) \&\2},/' < "$ac_nlist" >> conftest.c
+        sed 's/^\(.*\) \(.*\)$/  {"\1", (lt_ptr_t) \&\2},/' < "$ac_nlist" >> conftest.c
         cat <<\EOF >> conftest.c
-  {0, (__ptr_t) 0}
+  {0, (lt_ptr_t) 0}
 };
 
 #ifdef __cplusplus
@@ -537,8 +537,6 @@ fi
 rm -rf conftest*
 ])
 AC_MSG_RESULT($ac_cv_sys_symbol_underscore)
-if test x$ac_cv_sys_symbol_underscore = xyes; then
-  AC_DEFINE(WITH_SYMBOL_UNDERSCORE,1,
-  [define if compiled symbols have a leading underscore])
-fi
+USE_SYMBOL_UNDERSCORE=${ac_cv_sys_symbol_underscore=no}
+AC_SUBST(USE_SYMBOL_UNDERSCORE)dnl
 ])
index 19db0e5bed46065f29f8172c701654d2c3953ad2..21be389ca15d477a3e58133c01c0dad7ef812900 100755 (executable)
@@ -1382,7 +1382,6 @@ aix*)
   ;;
 sunos* | cygwin32* | mingw32*)
   sympat='_\([_A-Za-z][_A-Za-z0-9]*\)'
-  symxfrm='_\1 \1'
   ;;
 irix*)
   # Cannot use undefined symbols on IRIX because inlined functions mess us up.
@@ -1455,9 +1454,9 @@ EOF
 
        cat <<EOF >> conftest.c
 #if defined (__STDC__) && __STDC__
-# define __ptr_t void *
+# define lt_ptr_t void *
 #else
-# define __ptr_t char *
+# define lt_ptr_t char *
 #endif
 
 /* The number of symbols in dld_preloaded_symbols, -1 if unsorted. */
@@ -1466,14 +1465,14 @@ int dld_preloaded_symbol_count = $count;
 /* The mapping between symbol names and symbols. */
 struct {
   char *name;
-  __ptr_t address;
+  lt_ptr_t address;
 }
 dld_preloaded_symbols[] =
 {
 EOF
-        sed 's/^\(.*\) \(.*\)$/  {"\1", (__ptr_t) \&\2},/' < "$nlist" >> conftest.c
+        sed 's/^\(.*\) \(.*\)$/  {"\1", (lt_ptr_t) \&\2},/' < "$nlist" >> conftest.c
         cat <<\EOF >> conftest.c
-  {0, (__ptr_t) 0}
+  {0, (lt_ptr_t) 0}
 };
 
 #ifdef __cplusplus
@@ -1606,6 +1605,7 @@ cygwin32* | mingw32*)
   dynamic_linker='Win32 ld.exe'
   libname_spec='$name'
   need_lib_prefix=no
+  # FIXME: first we should search . and the directory the executable is in
   shlibpath_var=PATH
   ;;
 
index 2b80b72e73c1436bb5d230a7319b69392d41b0e4..732473b0bbbd7e18b2129e50ad4084c4cdedfcfb 100644 (file)
--- a/ltmain.in
+++ b/ltmain.in
@@ -1399,10 +1399,10 @@ compiler."
           cat > conftest.c <<EOF
           int main() { return 0; }
 EOF
-          $rm a.out
-          $C_compiler conftest.c $deplibs
+          $rm conftest
+          $C_compiler -o conftest conftest.c $deplibs
           if test $? -eq 0 ; then
-            ldd_output=`ldd a.out`
+            ldd_output=`ldd conftest`
             for i in $deplibs; do
               name="`expr $i : '-l\(.*\)'`"
               # If $name is empty we are operating on a -L argument.
@@ -1431,11 +1431,11 @@ EOF
               name="`expr $i : '-l\(.*\)'`"
              # If $name is empty we are operating on a -L argument.
               if test "$name" != "" ; then
-                $rm a.out
-                $C_compiler conftest.c $i
+                $rm conftest
+                $C_compiler -o conftest conftest.c $i
                 # Did it work?
                 if test $? -eq 0 ; then
-                  ldd_output=`ldd a.out`
+                  ldd_output=`ldd conftest`
                     libname=`eval \\$echo \"$libname_spec\"`
                     deplib_matches=`eval \\$echo \"$library_names_spec\"`
                     set dummy $deplib_matches
@@ -1838,15 +1838,15 @@ extern \"C\" {
 #undef dld_preloaded_symbols
 
 #if defined (__STDC__) && __STDC__
-# define __ptr_t void *
+# define lt_ptr_t void *
 #else
-# define __ptr_t char *
+# define lt_ptr_t char *
 #endif
 
 /* The mapping between symbol names and symbols. */
 struct {
   char *name;
-  __ptr_t address;
+  lt_ptr_t address;
 }
 dld_preloaded_symbols[] =
 {\
@@ -1854,25 +1854,25 @@ dld_preloaded_symbols[] =
 
             if test -n "$export_symbols"; then
               echo >> "$output_objdir/$dlsyms" "\
-  {\"${output}\", (__ptr_t) 0},"
-             sed 's/^\(.*\)/  {"\1", (__ptr_t) \&\1},/' < "$export_symbols" >> "$output_objdir/$dlsyms"
+  {\"${output}\", (lt_ptr_t) 0},"
+             sed 's/^\(.*\)/  {"\1", (lt_ptr_t) \&\1},/' < "$export_symbols" >> "$output_objdir/$dlsyms"
             fi
 
             for arg in $dlprefiles; do
              name=`echo "$arg" | sed -e 's%^.*/%%'`
               echo >> "$output_objdir/$dlsyms" "\
-  {\"$name\", (__ptr_t) 0},"
+  {\"$name\", (lt_ptr_t) 0},"
              eval "$NM $arg | $global_symbol_pipe > '$nlist'"
 
              if test -f "$nlist"; then
-               sed 's/^\(.*\) \(.*\)$/  {"\1", (__ptr_t) \&\2},/' < "$nlist" >> "$output_objdir/$dlsyms"
+               sed 's/^\(.*\) \(.*\)$/  {"\1", (lt_ptr_t) \&\2},/' < "$nlist" >> "$output_objdir/$dlsyms"
              else
                echo '/* NONE */' >> "$output_objdir/$dlsyms"
              fi
             done
 
            $echo >> "$output_objdir/$dlsyms" "\
-  {0, (__ptr_t) 0}
+  {0, (lt_ptr_t) 0}
 };
 
 #ifdef __cplusplus