]> git.ipfire.org Git - thirdparty/libtool.git/commitdiff
tests: clean up importing and exporting on w32.
authorPeter Rosin <peda@lysator.liu.se>
Mon, 27 Sep 2010 08:06:44 +0000 (10:06 +0200)
committerPeter Rosin <peda@lysator.liu.se>
Mon, 27 Sep 2010 08:08:05 +0000 (10:08 +0200)
Makes the touched tests pass for MSVC when DLLs are built.

* tests/demo/Makefile.am, tests/pdemo/Makefile.am: Define
BUILDING_LIBHELLO when building libhello.la.
* tests/demo/foo.h, tests/pdemo/foo.h (nothing) <MSVC>: Export
variable when building the libhello dll and import when using
libhello.  For GCC and non-w32, and when building a static
libhello, leave as an ordinary extern.
* tests/pdemo/foo.h [Cygwin]: Remove unneeded and "dead" export
and import logic (LIBFOO_DLL is always undefined).
* tests/pdemo/longer_file_name_foo.c,
tests/pdemo/longer_file_name_foo2.c (_LIBFOO_COMPILATION_): Not
useful before, even less so now.  Removed.
* tests/depdemo/l1/Makefile.am: Define BUILDING_LIBL1 when
building libl1.la.
* tests/depdemo/l2/Makefile.am: Define BUILDING_LIBL2 when
building libl2.la.
* tests/depdemo/l3/Makefile.am: Define BUILDING_LIBL3 when
building libl3.la.
* tests/depdemo/l4/Makefile.am: Define BUILDING_LIBL4 when
building libl4.la.
* tests/depdemo/l1/l1.h, tests/depdemo/l2/l2.h,
tests/depdemo/l3/l3.h, tests/depdemo/l4/l4.h <MSVC>: Export
variables when building the associated library dll and import
when using the library.  For GCC and non-w32, and when building
static libraries, leave as an ordinary extern.

Signed-off-by: Peter Rosin <peda@lysator.liu.se>
15 files changed:
ChangeLog
tests/demo/Makefile.am
tests/demo/foo.h
tests/depdemo/l1/Makefile.am
tests/depdemo/l1/l1.h
tests/depdemo/l2/Makefile.am
tests/depdemo/l2/l2.h
tests/depdemo/l3/Makefile.am
tests/depdemo/l3/l3.h
tests/depdemo/l4/Makefile.am
tests/depdemo/l4/l4.h
tests/pdemo/Makefile.am
tests/pdemo/foo.h
tests/pdemo/longer_file_name_foo.c
tests/pdemo/longer_file_name_foo2.c

index a5e49402e816731042ab2128062c4bba41b4e8a9..a486ac3eb9b25d8966bffee2344126c6112c66a8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,32 @@
+2010-09-27  Peter Rosin  <peda@lysator.liu.se>
+
+       tests: clean up importing and exporting on w32.
+       Makes the touched tests pass for MSVC when DLLs are built.
+       * tests/demo/Makefile.am, tests/pdemo/Makefile.am: Define
+       BUILDING_LIBHELLO when building libhello.la.
+       * tests/demo/foo.h, tests/pdemo/foo.h (nothing) <MSVC>: Export
+       variable when building the libhello dll and import when using
+       libhello.  For GCC and non-w32, and when building a static
+       libhello, leave as an ordinary extern.
+       * tests/pdemo/foo.h [Cygwin]: Remove unneeded and "dead" export
+       and import logic (LIBFOO_DLL is always undefined).
+       * tests/pdemo/longer_file_name_foo.c,
+       tests/pdemo/longer_file_name_foo2.c (_LIBFOO_COMPILATION_): Not
+       useful before, even less so now.  Removed.
+       * tests/depdemo/l1/Makefile.am: Define BUILDING_LIBL1 when
+       building libl1.la.
+       * tests/depdemo/l2/Makefile.am: Define BUILDING_LIBL2 when
+       building libl2.la.
+       * tests/depdemo/l3/Makefile.am: Define BUILDING_LIBL3 when
+       building libl3.la.
+       * tests/depdemo/l4/Makefile.am: Define BUILDING_LIBL4 when
+       building libl4.la.
+       * tests/depdemo/l1/l1.h, tests/depdemo/l2/l2.h,
+       tests/depdemo/l3/l3.h, tests/depdemo/l4/l4.h <MSVC>: Export
+       variables when building the associated library dll and import
+       when using the library.  For GCC and non-w32, and when building
+       static libraries, leave as an ordinary extern.
+
 2010-09-26  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
        docs: do not refer to Libtool version with dlopen functionality.
index 2aa2c0bf63848e39b2db5e306e7bc254ef3f20d4..a3c61441f578bc0e42b8fc582b4490af4a8f3435 100644 (file)
@@ -1,6 +1,6 @@
 ## Makefile.am -- Process this file with automake to produce Makefile.in
 ##
-##   Copyright (C) 2003, 2004, 2005 Free Software Foundation
+##   Copyright (C) 2003, 2004, 2005, 2010 Free Software Foundation
 ##   Written by Gary V. Vaughan, 2003
 ##
 ##   This file is part of GNU Libtool.
@@ -31,6 +31,7 @@ lib_LTLIBRARIES = libhello.la
 libhello_la_SOURCES = hello.c foo.c
 libhello_la_LIBADD = $(LIBM)
 libhello_la_LDFLAGS = -no-undefined -version-info 3:12:1
+libhello_la_AM_CPPFLAGS = $(AM_CPPFLAGS) -DBUILDING_LIBHELLO
 
 include_HEADERS = foo.h
 
index 167096a672175918fb2bec86cf66e9fb3ec81e9e..e8a2c8786eadd5fe723683828a5a79d65ecded57 100644 (file)
@@ -37,6 +37,19 @@ or obtained by writing to the Free Software Foundation, Inc.,
 #  endif
 #endif
 
+#if (defined _WIN32 || defined _WIN32_WCE) && !defined __GNUC__
+# ifdef BUILDING_LIBHELLO
+#  ifdef DLL_EXPORT
+#   define LIBHELLO_SCOPE extern __declspec (dllexport)
+#  endif
+# else
+#  define LIBHELLO_SCOPE extern __declspec (dllimport)
+# endif
+#endif
+#ifndef LIBHELLO_SCOPE
+# define LIBHELLO_SCOPE extern
+#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. */
@@ -83,7 +96,7 @@ or obtained by writing to the Free Software Foundation, Inc.,
 __BEGIN_DECLS
 int foo LT_PARAMS((void));
 int hello LT_PARAMS((void));
-extern int nothing;
+LIBHELLO_SCOPE int nothing;
 __END_DECLS
 
 #endif /* !_FOO_H_ */
index 7cca5c1a446aa90979bac6db81ece3e5ea5b334e..b2e7cb84440941bce5891118d187a686588a1b69 100644 (file)
@@ -1,6 +1,6 @@
 ## Makefile.am -- Process this file with automake to produce Makefile.in
 ##
-##   Copyright (C) 2003 Free Software Foundation
+##   Copyright (C) 2003, 2010 Free Software Foundation
 ##   Written by Gary V. Vaughan, 2003
 ##
 ##   This file is part of GNU Libtool.
@@ -26,7 +26,7 @@ top_distdir = ../..
 
 AUTOMAKE_OPTIONS = no-dependencies foreign
 
-AM_CPPFLAGS = -I$(top_srcdir)
+AM_CPPFLAGS = -I$(top_srcdir) -DBUILDING_LIBL1
 
 lib_LTLIBRARIES = libl1.la
 libl1_la_SOURCES = l1.c l1.h
index 8e773ca05bd8b9d04f4ff1005b3b2c28ceb2a71d..d357d8050383bf12c0575e3998ca533448b0cc74 100644 (file)
@@ -1,7 +1,7 @@
 /* l1.h -- interface to a trivial library
 
    Copyright (C) 1998-1999 Thomas Tanner
-   Copyright (C) 2006 Free Software Foundation, Inc.
+   Copyright (C) 2006, 2010 Free Software Foundation, Inc.
    Written by Thomas Tanner, 1998
 
    This file is part of GNU Libtool.
@@ -29,8 +29,21 @@ or obtained by writing to the Free Software Foundation, Inc.,
 
 #include "sysdep.h"
 
+#if (defined _WIN32 || defined _WIN32_WCE) && !defined __GNUC__
+# ifdef BUILDING_LIBL1
+#  ifdef DLL_EXPORT
+#   define LIBL1_SCOPE extern __declspec (dllexport)
+#  endif
+# else
+#  define LIBL1_SCOPE extern __declspec (dllimport)
+# endif
+#endif
+#ifndef LIBL1_SCOPE
+# define LIBL1_SCOPE extern
+#endif
+
 __BEGIN_DECLS
-extern int var_l1;
+LIBL1_SCOPE int var_l1;
 int    func_l1 __P((int));
 __END_DECLS
 
index ddd57e2e17557a9580581ddeb61580f679bb4111..2cb86c5b5fad2db5b9efb830e50fa98406adf74c 100644 (file)
@@ -1,6 +1,6 @@
 ## Makefile.am -- Process this file with automake to produce Makefile.in
 ##
-##   Copyright (C) 2003 Free Software Foundation
+##   Copyright (C) 2003, 2010 Free Software Foundation
 ##   Written by Gary V. Vaughan, 2003
 ##
 ##   This file is part of GNU Libtool.
@@ -26,7 +26,7 @@ top_distdir = ../..
 
 AUTOMAKE_OPTIONS = no-dependencies foreign
 
-AM_CPPFLAGS = -I$(top_srcdir)
+AM_CPPFLAGS = -I$(top_srcdir) -DBUILDING_LIBL2
 
 lib_LTLIBRARIES = libl2.la
 libl2_la_SOURCES = l2.c l2.h
index 728b1dfe8dd7a8ec74f30d03c9f70ca87dfed173..0f6b3b9e99745c4e202b0c24a62386ade2eaa255 100644 (file)
@@ -1,7 +1,7 @@
 /* l2.h -- interface to a trivial library
 
    Copyright (C) 1998-1999 Thomas Tanner
-   Copyright (C) 2006 Free Software Foundation, Inc.
+   Copyright (C) 2006, 2010 Free Software Foundation, Inc.
    Written by Thomas Tanner, 1998
 
    This file is part of GNU Libtool.
@@ -29,8 +29,21 @@ or obtained by writing to the Free Software Foundation, Inc.,
 
 #include "sysdep.h"
 
+#if (defined _WIN32 || defined _WIN32_WCE) && !defined __GNUC__
+# ifdef BUILDING_LIBL2
+#  ifdef DLL_EXPORT
+#   define LIBL2_SCOPE extern __declspec (dllexport)
+#  endif
+# else
+#  define LIBL2_SCOPE extern __declspec (dllimport)
+# endif
+#endif
+#ifndef LIBL2_SCOPE
+# define LIBL2_SCOPE extern
+#endif
+
 __BEGIN_DECLS
-extern int var_l2;
+LIBL2_SCOPE int var_l2;
 int    func_l2 __P((int));
 __END_DECLS
 
index 2dc0805128af70a016039482ca9afd38dd3e9182..341932f74bf28cf043f8e560045711297b32ebbb 100644 (file)
@@ -1,6 +1,6 @@
 ## Makefile.am -- Process this file with automake to produce Makefile.in
 ##
-##   Copyright (C) 2003 Free Software Foundation
+##   Copyright (C) 2003, 2010 Free Software Foundation
 ##   Written by Gary V. Vaughan, 2003
 ##
 ##   This file is part of GNU Libtool.
@@ -27,7 +27,7 @@ extradir    = $(libdir)/extra
 
 AUTOMAKE_OPTIONS = no-dependencies foreign
 
-AM_CPPFLAGS = -I$(top_srcdir)
+AM_CPPFLAGS = -I$(top_srcdir) -DBUILDING_LIBL3
 
 lib_LTLIBRARIES = libl3.la
 libl3_la_SOURCES = l3.c l3.h
index 6f0b446aad2bed4121dfe0c3d9c9ecde7009e62b..60fcbd520a2325aab360cf245c54b19c69134711 100644 (file)
@@ -1,7 +1,7 @@
 /* l3.h -- interface to a trivial library
 
    Copyright (C) 1998-1999 Thomas Tanner
-   Copyright (C) 2006 Free Software Foundation, Inc.
+   Copyright (C) 2006, 2010 Free Software Foundation, Inc.
    Written by Thomas Tanner, 1998
 
    This file is part of GNU Libtool.
@@ -29,8 +29,21 @@ or obtained by writing to the Free Software Foundation, Inc.,
 
 #include "sysdep.h"
 
+#if (defined _WIN32 || defined _WIN32_WCE) && !defined __GNUC__
+# ifdef BUILDING_LIBL3
+#  ifdef DLL_EXPORT
+#   define LIBL3_SCOPE extern __declspec (dllexport)
+#  endif
+# else
+#  define LIBL3_SCOPE extern __declspec (dllimport)
+# endif
+#endif
+#ifndef LIBL3_SCOPE
+# define LIBL3_SCOPE extern
+#endif
+
 __BEGIN_DECLS
-extern int var_l3;
+LIBL3_SCOPE int var_l3;
 int    func_l3 __P((int));
 __END_DECLS
 
index d274b6d2983f4eeee574254a58ad576fd76a2b21..fa0d4b2665ee6dd9ba4709489096af6ebf443252 100644 (file)
@@ -1,6 +1,6 @@
 ## Makefile.am -- Process this file with automake to produce Makefile.in
 ##
-##   Copyright (C) 2003 Free Software Foundation
+##   Copyright (C) 2003, 2010 Free Software Foundation
 ##   Written by Gary V. Vaughan, 2003
 ##
 ##   This file is part of GNU Libtool.
@@ -26,7 +26,7 @@ top_distdir = ../..
 
 AUTOMAKE_OPTIONS = no-dependencies foreign
 
-AM_CPPFLAGS = -I$(top_srcdir)
+AM_CPPFLAGS = -I$(top_srcdir) -DBUILDING_LIBL4
 
 lib_LTLIBRARIES = libl4.la
 libl4_la_SOURCES = l4.c l4.h
index bdf21d06afcdd0ef5cef78c7eeef7bd44ffbcdac..703743ffdf2c29b924c0c8aa9681e478fd13139d 100644 (file)
@@ -1,7 +1,7 @@
 /* l4.h -- interface to a trivial library
 
    Copyright (C) 1998-1999 Thomas Tanner
-   Copyright (C) 2006 Free Software Foundation, Inc.
+   Copyright (C) 2006, 2010 Free Software Foundation, Inc.
    Written by Thomas Tanner, 1998
 
    This file is part of GNU Libtool.
@@ -29,8 +29,21 @@ or obtained by writing to the Free Software Foundation, Inc.,
 
 #include "sysdep.h"
 
+#if (defined _WIN32 || defined _WIN32_WCE) && !defined __GNUC__
+# ifdef BUILDING_LIBL4
+#  ifdef DLL_EXPORT
+#   define LIBL4_SCOPE extern __declspec (dllexport)
+#  endif
+# else
+#  define LIBL4_SCOPE extern __declspec (dllimport)
+# endif
+#endif
+#ifndef LIBL4_SCOPE
+# define LIBL4_SCOPE extern
+#endif
+
 __BEGIN_DECLS
-extern int var_l4;
+LIBL4_SCOPE int var_l4;
 int    func_l4 __P((int));
 __END_DECLS
 
index 0357e47001814a8e02b61a74ae322e2e26c8335c..91fe1e26f127ec1dc62ba241d5e4112a78b6a9e9 100644 (file)
@@ -1,6 +1,6 @@
 ## Makefile.am -- Process this file with automake to produce Makefile.in
 ##
-##   Copyright (C) 2003, 2004, 2005 Free Software Foundation
+##   Copyright (C) 2003, 2004, 2005, 2010 Free Software Foundation
 ##   Written by Gary V. Vaughan, 2003
 ##
 ##   This file is part of GNU Libtool.
@@ -31,6 +31,7 @@ lib_LTLIBRARIES = libhello.la
 libhello_la_SOURCES = longer_file_name_hello.c longer_file_name_foo.c longer_file_name_foo2.c
 libhello_la_LIBADD = $(LIBM)
 libhello_la_LDFLAGS = -no-undefined -version-info 3:12:1
+libhello_la_AM_CPPFLAGS = $(AM_CPPFLAGS) -DBUILDING_LIBHELLO
 
 include_HEADERS = foo.h
 
index a2b2a4ac113cf0768702f0943c7671b000667126..d08303b58335082cb63bb961bf7685dabdd24583 100644 (file)
@@ -73,22 +73,17 @@ or obtained by writing to the Free Software Foundation, Inc.,
 # define LT_DLSYM_CONST const
 #endif
 
-#ifdef __CYGWIN32__
-#  ifdef LIBFOO_DLL
-     /* need some (as yet non-existant) automake magic to tell
-      * the object whether the libfoo it will be linked with is
-      * a dll or not, ie whether LIBFOO_DLL is defined or not.
-      */
-#    ifdef _LIBFOO_COMPILATION_
-#      define EXTERN __declspec(dllexport)
-#    else
-#      define EXTERN extern __declspec(dllimport)
-#    endif
-#  else
-#    define EXTERN extern
+#if (defined _WIN32 || defined _WIN32_WCE) && !defined __GNUC__
+# ifdef BUILDING_LIBHELLO
+#  ifdef DLL_EXPORT
+#   define LIBHELLO_SCOPE extern __declspec (dllexport)
 #  endif
-#else
-#  define EXTERN extern
+# else
+#  define LIBHELLO_SCOPE extern __declspec (dllimport)
+# endif
+#endif
+#ifndef LIBHELLO_SCOPE
+# define LIBHELLO_SCOPE extern
 #endif
 
 /* Silly constants that the functions return. */
@@ -101,7 +96,7 @@ __BEGIN_DECLS
 int foo LT_PARAMS((void));
 int foo2 LT_PARAMS((void));
 int hello LT_PARAMS((void));
-EXTERN int nothing;
+LIBHELLO_SCOPE int nothing;
 __END_DECLS
 
 #endif /* !_FOO_H_ */
index 5b10c611e76bc6b491ff4c9576af578218f5bc2a..9d9230433f83f4c5ec62fba9d3ede856c9f3ce34 100644 (file)
@@ -1,6 +1,6 @@
 /* foo.c -- trivial test function for libfoo
 
-   Copyright (C) 1996-1999, 2007 Free Software Foundation, Inc.
+   Copyright (C) 1996-1999, 2007, 2010 Free Software Foundation, Inc.
    Written by Gordon Matzigkeit, 1996
 
    This file is part of GNU Libtool.
@@ -22,9 +22,7 @@ or obtained by writing to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */
 
-#define _LIBFOO_COMPILATION_
 #include "foo.h"
-#undef _LIBFOO_COMPILATION_
 
 #include <stdio.h>
 #include <math.h>
index c7359d011825b0b9a5c3777fa992f48f1c6942d8..65d3bba30710aa70d01ffde685d608d2b9bae090 100644 (file)
@@ -1,6 +1,6 @@
 /* foo.c -- trivial test function for libfoo
 
-   Copyright (C) 1996-1999, 2007 Free Software Foundation, Inc.
+   Copyright (C) 1996-1999, 2007, 2010 Free Software Foundation, Inc.
    Written by Gordon Matzigkeit, 1996
 
    This file is part of GNU Libtool.
@@ -22,9 +22,7 @@ or obtained by writing to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */
 
-#define _LIBFOO_COMPILATION_
 #include "foo.h"
-#undef _LIBFOO_COMPILATION_
 
 #include <stdio.h>
 #include <math.h>