]> git.ipfire.org Git - thirdparty/libtool.git/commitdiff
* tests/testsuite.at (_LTDL_PROJECT_FILES): Factored out from
authorGary V. Vaughan <gary@gnu.org>
Mon, 7 Nov 2005 15:37:11 +0000 (15:37 +0000)
committerGary V. Vaughan <gary@gnu.org>
Mon, 7 Nov 2005 15:37:11 +0000 (15:37 +0000)
common code to build a basic libltdl using project.
* tests/old-m4-iface.at, tests/standalone.at, tests/subproject.at:
Use it.

ChangeLog
tests/old-m4-iface.at
tests/standalone.at
tests/subproject.at
tests/testsuite.at

index d930188a237099da9bb9abc69bc495348fc11d37..34074b2282dee0b12546bf19fb93d4cecabe4165 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2005-11-07  Gary V. Vaughan  <gary@gnu.org>
 
+       * 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.
 
index d9f6dee1756792b081f388443091926dd872ddc8..3354df29f061f5ed5948baf5c375966b5a1c413c 100644 (file)
@@ -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 <stdio.h>
-#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
index 300b8ec8c3b1551cc0962cdb26b1419d8bf3f181..4270b40bf4da43cb8ec1b7272d1c5fa27ef1d4ac 100644 (file)
@@ -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 <stdio.h>
-#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" \
index 0678c78af3a05fc6196fe51298e0e2b231d1d067..81994a914f337fb31ebadbcb4758254096dc0cf0 100644 (file)
@@ -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 <stdio.h>
-#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}" \
index 50a81a3079b98ebd3cc33b4a385f584b5e7a8093..289d37b8e155b30c1fb3e77396f02a4d7f0bd463 100644 (file)
@@ -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 <stdio.h>
+#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$])