From: Gary V. Vaughan Date: Mon, 7 Nov 2005 15:37:11 +0000 (+0000) Subject: * tests/testsuite.at (_LTDL_PROJECT_FILES): Factored out from X-Git-Tag: release-2-1b~421 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8e4c3b06e66f151ec4257856c6f26c70e4b5d73b;p=thirdparty%2Flibtool.git * tests/testsuite.at (_LTDL_PROJECT_FILES): Factored out from common code to build a basic libltdl using project. * tests/old-m4-iface.at, tests/standalone.at, tests/subproject.at: Use it. --- diff --git a/ChangeLog b/ChangeLog index d930188a2..34074b228 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2005-11-07 Gary V. Vaughan + * tests/testsuite.at (_LTDL_PROJECT_FILES): Factored out from + common code to build a basic libltdl using project. + * tests/old-m4-iface.at, tests/standalone.at, tests/subproject.at: + Use it. + * doc/libtool.texi (Distributing libltdl): Document correct use of LT_CONFIG_LTDL_DIR mode argument with Autoconf and Automake. diff --git a/tests/old-m4-iface.at b/tests/old-m4-iface.at index d9f6dee17..3354df29f 100644 --- a/tests/old-m4-iface.at +++ b/tests/old-m4-iface.at @@ -91,8 +91,10 @@ AT_CLEANUP AT_SETUP([AC_WITH_LTDL]) +_LTDL_PROJECT_FILES + AT_DATA([configure.in], -[[AC_INIT(old.c) +[[AC_INIT([main.c]) AC_PROG_MAKE_SET AM_PROG_LIBTOOL AC_WITH_LTDL @@ -108,7 +110,7 @@ LTLINK = @LIBTOOL@ --mode=link @CC@ -no-undefined @CFLAGS@ @LDFLAGS@ -o $@ SHELL = @SHELL@ @SET_MAKE@ -TARGETS = libltdl/libltdlc.la module.la old@EXEEXT@ +TARGETS = libltdl/libltdlc.la module.la ltdldemo@EXEEXT@ all: $(TARGETS) @@ -118,8 +120,8 @@ libltdl/libltdlc.la: module.la: module.lo $(LTLINK) module.lo -module -avoid-version -rpath /dev/null -old@EXEEXT@: old.@OBJEXT@ - $(LTLINK) old.@OBJEXT@ -dlopen module.la @LIBLTDL@ +ltdldemo@EXEEXT@: main.@OBJEXT@ + $(LTLINK) main.@OBJEXT@ -dlopen module.la @LIBLTDL@ .SUFFIXES: .SUFFIXES: .c .@OBJEXT@ .lo @@ -131,63 +133,12 @@ old@EXEEXT@: old.@OBJEXT@ $(LTCOMPILE) -c -o $@ $< ]]) -AT_DATA([old.c], -[[#include -#include "ltdl.h" - -int main (int argc, char **argv) -{ - lt_dlhandle module; - const char *(*foo) (const char *) = 0; - int status = 1; - - LTDL_SET_PRELOADED_SYMBOLS(); - if (lt_dlinit() != 0) { - fprintf (stderr, "error during initialisation: %s\n", lt_dlerror()); - return 1; - } - - module = lt_dlopen("module.la"); - if (!module) { - fprintf (stderr, "error dlopening module.la: %s\n", lt_dlerror()); - goto finish; - } - - foo = (const char *(*)(const char *)) lt_dlsym (module, "foo"); - if (!foo) { - fprintf (stderr, "error fetching func: %s\n", lt_dlerror()); - goto finish; - } - - printf ("%s", (*foo) ("foo bar")); - status = 0; - -finish: - if (lt_dlexit() != 0) { - fprintf (stderr, "error during finalisation: %s\n", lt_dlerror()); - status = 1; - } - - return status; -} -]]) - -AT_DATA([module.c], -[[const char * -foo (const char *str) -{ - while (*str++ != ' ') - ; - return str; -} -]]) - LT_AT_LIBTOOLIZE([--ltdl --install]) LT_AT_ACLOCAL([-I libltdl/m4]) LT_AT_AUTOCONF([--force]) LT_AT_CONFIGURE LT_AT_MAKE -LT_AT_EXEC_CHECK([./old], 0, [bar]) +LT_AT_EXEC_CHECK([./ltdldemo], 0, [ignore]) AT_CLEANUP diff --git a/tests/standalone.at b/tests/standalone.at index 300b8ec8c..4270b40bf 100644 --- a/tests/standalone.at +++ b/tests/standalone.at @@ -73,83 +73,7 @@ AT_CLEANUP AT_SETUP([linking libltdl without autotools]) -AT_DATA([module.c], -[[const char * -hello (void) -{ - return "Hello!"; -} -]]) - -AT_DATA([main.c], -[[#include -#include "ltdl.h" - -int -main (int argc, char **argv) -{ - lt_dlhandle handle; - const char *(*func) (void) = 0; - int status = 1; - - LTDL_SET_PRELOADED_SYMBOLS(); - if (lt_dlinit() != 0) { - fprintf (stderr, "error during initialisation: %s\n", lt_dlerror()); - return 1; - } - - handle = lt_dlopen("module.la"); - if (!handle) { - fprintf (stderr, "error dlopening module.la: %s\n", lt_dlerror()); - goto finish; - } - - func = (const char *(*)(void)) lt_dlsym (handle, "hello"); - if (!func) { - fprintf (stderr, "error fetching func: %s\n", lt_dlerror()); - goto finish; - } - - printf ("%s\n", (*func) ()); - status = 0; - -finish: - lt_dlexit(); - - return status; -} -]]) - -AT_DATA([Makefile], -[[LIBTOOL = ./libltdl/libtool -INCLUDES = -I./libltdl -MODFLAGS = -module -avoid-version -no-undefined - -LTCOMPILE = $(LIBTOOL) --tag=CC $(LIBTOOLFLAGS) --mode=compile \ - $(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -LTLINK = $(LIBTOOL) --tag=CC $(LIBTOOLFLAGS) --mode=link \ - $(CC) $(CFLAGS) $(LDFLAGS) - -TARGETS = libltdl/libltdlc.la module.la ltdldemo$(EXEEXT) - -all: $(TARGETS) - -$(LIBTOOL) libltdl/libltdlc.la: - cd libltdl && ./configure $(CONFIGURE_OPTIONS) && $(MAKE) - -ltdldemo$(EXEEXT): $(LIBTOOL) module.la libltdl/libltdlc.la main.lo - $(LTLINK) -o ltdldemo main.lo -dlopen module.la ./libltdl/libltdlc.la - -main.lo: $(LIBTOOL) main.c - $(LTCOMPILE) -c main.c - -module.la: $(LIBTOOL) module.lo - $(LTLINK) -o module.la module.lo $(MODFLAGS) -rpath /dev/null - -module.lo: $(LIBTOOL) module.c - $(LTCOMPILE) -c module.c -]]) - +_LTDL_PROJECT_FILES([libltdl]) LT_AT_LIBTOOLIZE([--copy --ltdl]) LT_AT_MAKE([], [CC="$CC" LIBTOOLFLAGS="$LIBTOOLFLAGS" CPPFLAGS="$CPPFLAGS" \ CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" \ diff --git a/tests/subproject.at b/tests/subproject.at index 0678c78af..81994a914 100644 --- a/tests/subproject.at +++ b/tests/subproject.at @@ -116,90 +116,7 @@ AT_CLEANUP AT_SETUP([linking libltdl without autotools]) -AT_DATA([module.c], -[[const char * -hello (void) -{ - return "Hello!"; -} -]]) - -AT_DATA([main.c], -[[#include -#include "ltdl.h" - -int -main (int argc, char **argv) -{ - lt_dlhandle module; - const char *(*func) (void) = 0; - int status = 1; - - LTDL_SET_PRELOADED_SYMBOLS(); - if (lt_dlinit() != 0) { - fprintf (stderr, "error during initialisation: %s\n", lt_dlerror()); - return 1; - } - - module = lt_dlopen("module.la"); - if (!module) { - fprintf (stderr, "error dlopening module.la: %s\n", lt_dlerror()); - goto finish; - } - - func = (const char *(*)(void)) lt_dlsym (module, "hello"); - if (!func) { - fprintf (stderr, "error fetching func: %s\n", lt_dlerror()); - goto finish; - } - - printf ("%s\n", (*func) ()); - status = 0; - -finish: - if (lt_dlexit() != 0) { - fprintf (stderr, "error during finalisation: %s\n", lt_dlerror()); - status = 1; - } - - return status; -} -]]) - -AT_DATA([Makefile], -[[top_builddir = . -LIBTOOL = ./sub/ltdl/libtool -INCLUDES = -I./sub/ltdl -MODFLAGS = -module -avoid-version -no-undefined - -LTCOMPILE = $(LIBTOOL) --tag=CC $(LIBTOOLFLAGS) --mode=compile \ - $(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -LTLINK = $(LIBTOOL) --tag=CC $(LIBTOOLFLAGS) --mode=link \ - $(CC) $(CFLAGS) $(LDFLAGS) - -TARGETS = sub/ltdl/libltdlc.la module.la ltdldemo$(EXEEXT) - -all: $(TARGETS) - -$(LIBTOOL) sub/ltdl/libltdlc.la: sub/ltdl/Makefile - cd sub/ltdl && $(MAKE) - -sub/ltdl/Makefile: - cd sub/ltdl && ./configure $(CONFIGURE_OPTIONS) - -ltdldemo$(EXEEXT): $(LIBTOOL) module.la sub/ltdl/libltdlc.la main.lo - $(LTLINK) -o ltdldemo main.lo -dlopen module.la ./sub/ltdl/libltdlc.la - -main.lo: $(LIBTOOL) main.c - $(LTCOMPILE) -c main.c - -module.la: $(LIBTOOL) module.lo - $(LTLINK) -o module.la module.lo $(MODFLAGS) -rpath /dev/null - -module.lo: $(LIBTOOL) module.c - $(LTCOMPILE) -c module.c -]]) - +_LTDL_PROJECT_FILES([sub/ltdl]) LT_AT_LIBTOOLIZE([--copy --ltdl=sub/ltdl]) LT_AT_MAKE([], [CC="$CC" LIBTOOLFLAGS="$LIBTOOLFLAGS" CPPFLAGS="$CPPFLAGS" \ CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" SHELL="$SHELL" MAKE="${MAKE-make}" \ diff --git a/tests/testsuite.at b/tests/testsuite.at index 50a81a307..289d37b8e 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -133,6 +133,104 @@ AT_CHECK([test -n "[$]$1" || (exit 77)]) ]) +## ------------------------------- ## +## Files for a small ltdl project. ## +## ------------------------------- ## + +# _LTDL_PROJECT_FILES([LTDL-DIR]) +# ------------------------------- +# LTDL-DIR is needed to generate a correct Makefile. If the argument +# is omitted, then no Makefile is created. +m4_define([_LTDL_PROJECT_FILES], +[AT_DATA([module.c], +[[const char * +hello (void) +{ + return "Hello!"; +} +]]) + +AT_DATA([main.c], +[[#include +#include "ltdl.h" + +int +main (int argc, char **argv) +{ + lt_dlhandle module; + const char *(*func) (void) = 0; + int status = 1; + + LTDL_SET_PRELOADED_SYMBOLS(); + if (lt_dlinit() != 0) { + fprintf (stderr, "error during initialisation: %s\n", lt_dlerror()); + return 1; + } + + module = lt_dlopen("module.la"); + if (!module) { + fprintf (stderr, "error dlopening module.la: %s\n", lt_dlerror()); + goto finish; + } + + func = (const char *(*)(void)) lt_dlsym (module, "hello"); + if (!func) { + fprintf (stderr, "error fetching func: %s\n", lt_dlerror()); + goto finish; + } + + printf ("%s\n", (*func) ()); + status = 0; + +finish: + if (lt_dlexit() != 0) { + fprintf (stderr, "error during finalisation: %s\n", lt_dlerror()); + status = 1; + } + + return status; +} +]]) + +m4_pushdef([_ARG_DIR], m4_bpatsubst([$1], [/*$])) +m4_ifval([$1], +[AT_DATA([Makefile], +[[top_builddir = . +LIBTOOL = ./]_ARG_DIR[/libtool +INCLUDES = -I./]_ARG_DIR[ +MODFLAGS = -module -avoid-version -no-undefined + +LTCOMPILE = $(LIBTOOL) --tag=CC $(LIBTOOLFLAGS) --mode=compile \ + $(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) +LTLINK = $(LIBTOOL) --tag=CC $(LIBTOOLFLAGS) --mode=link \ + $(CC) $(CFLAGS) $(LDFLAGS) + +TARGETS = ]_ARG_DIR[/libltdlc.la module.la ltdldemo$(EXEEXT) + +all: $(TARGETS) + +$(LIBTOOL) ]_ARG_DIR[/libltdlc.la: ]_ARG_DIR[/Makefile + cd ]_ARG_DIR[ && $(MAKE) + +]_ARG_DIR[/Makefile: + cd ]_ARG_DIR[ && ./configure $(CONFIGURE_OPTIONS) + +ltdldemo$(EXEEXT): $(LIBTOOL) module.la ]_ARG_DIR[/libltdlc.la main.lo + $(LTLINK) -o ltdldemo main.lo -dlopen module.la ./]_ARG_DIR[/libltdlc.la + +main.lo: $(LIBTOOL) main.c + $(LTCOMPILE) -c main.c + +module.la: $(LIBTOOL) module.lo + $(LTLINK) -o module.la module.lo $(MODFLAGS) -rpath /dev/null + +module.lo: $(LIBTOOL) module.c + $(LTCOMPILE) -c module.c +]])]) +m4_popdef([_ARG_DIR]) +])# _LTDL_PROJECT_FILES + + # We use `dnl' in zillions of places... m4_pattern_allow([^dnl$])