From: Peter Rosin Date: Mon, 27 Sep 2010 08:06:44 +0000 (+0200) Subject: tests: clean up importing and exporting on w32. X-Git-Tag: v2.4.2~52 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=13608ea10fe98a7418d1392526cde4c1442f2511;p=thirdparty%2Flibtool.git 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) : 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 : 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 --- diff --git a/ChangeLog b/ChangeLog index a5e49402e..a486ac3eb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,32 @@ +2010-09-27 Peter Rosin + + 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) : 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 : 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 docs: do not refer to Libtool version with dlopen functionality. diff --git a/tests/demo/Makefile.am b/tests/demo/Makefile.am index 2aa2c0bf6..a3c61441f 100644 --- a/tests/demo/Makefile.am +++ b/tests/demo/Makefile.am @@ -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 diff --git a/tests/demo/foo.h b/tests/demo/foo.h index 167096a67..e8a2c8786 100644 --- a/tests/demo/foo.h +++ b/tests/demo/foo.h @@ -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_ */ diff --git a/tests/depdemo/l1/Makefile.am b/tests/depdemo/l1/Makefile.am index 7cca5c1a4..b2e7cb844 100644 --- a/tests/depdemo/l1/Makefile.am +++ b/tests/depdemo/l1/Makefile.am @@ -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 diff --git a/tests/depdemo/l1/l1.h b/tests/depdemo/l1/l1.h index 8e773ca05..d357d8050 100644 --- a/tests/depdemo/l1/l1.h +++ b/tests/depdemo/l1/l1.h @@ -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 diff --git a/tests/depdemo/l2/Makefile.am b/tests/depdemo/l2/Makefile.am index ddd57e2e1..2cb86c5b5 100644 --- a/tests/depdemo/l2/Makefile.am +++ b/tests/depdemo/l2/Makefile.am @@ -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 diff --git a/tests/depdemo/l2/l2.h b/tests/depdemo/l2/l2.h index 728b1dfe8..0f6b3b9e9 100644 --- a/tests/depdemo/l2/l2.h +++ b/tests/depdemo/l2/l2.h @@ -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 diff --git a/tests/depdemo/l3/Makefile.am b/tests/depdemo/l3/Makefile.am index 2dc080512..341932f74 100644 --- a/tests/depdemo/l3/Makefile.am +++ b/tests/depdemo/l3/Makefile.am @@ -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 diff --git a/tests/depdemo/l3/l3.h b/tests/depdemo/l3/l3.h index 6f0b446aa..60fcbd520 100644 --- a/tests/depdemo/l3/l3.h +++ b/tests/depdemo/l3/l3.h @@ -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 diff --git a/tests/depdemo/l4/Makefile.am b/tests/depdemo/l4/Makefile.am index d274b6d29..fa0d4b266 100644 --- a/tests/depdemo/l4/Makefile.am +++ b/tests/depdemo/l4/Makefile.am @@ -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 diff --git a/tests/depdemo/l4/l4.h b/tests/depdemo/l4/l4.h index bdf21d06a..703743ffd 100644 --- a/tests/depdemo/l4/l4.h +++ b/tests/depdemo/l4/l4.h @@ -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 diff --git a/tests/pdemo/Makefile.am b/tests/pdemo/Makefile.am index 0357e4700..91fe1e26f 100644 --- a/tests/pdemo/Makefile.am +++ b/tests/pdemo/Makefile.am @@ -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 diff --git a/tests/pdemo/foo.h b/tests/pdemo/foo.h index a2b2a4ac1..d08303b58 100644 --- a/tests/pdemo/foo.h +++ b/tests/pdemo/foo.h @@ -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_ */ diff --git a/tests/pdemo/longer_file_name_foo.c b/tests/pdemo/longer_file_name_foo.c index 5b10c611e..9d9230433 100644 --- a/tests/pdemo/longer_file_name_foo.c +++ b/tests/pdemo/longer_file_name_foo.c @@ -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 #include diff --git a/tests/pdemo/longer_file_name_foo2.c b/tests/pdemo/longer_file_name_foo2.c index c7359d011..65d3bba30 100644 --- a/tests/pdemo/longer_file_name_foo2.c +++ b/tests/pdemo/longer_file_name_foo2.c @@ -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 #include