ltmain.in: Use func_warning for all warnings
[libtool.git] / tests / mdemo.at
blob7dfd0cd293ef83710b6cbb60d7438b9951409aa4
1 # demo.at -- Dynamic ltdl runtime loading -*- Autotest -*-
3 #   Copyright (C) 1998, 2002-2004, 2011-2019, 2021-2024 Free Software
4 #   Foundation, Inc.
5 #   Written by Thomas Tanner, 1998
6 #   Written by Greg Eisenhauer, 2002
7 #   Rewritten by Gary V. Vaughan, 2003
9 #   This file is part of GNU Libtool.
11 # GNU Libtool is free software; you can redistribute it and/or
12 # modify it under the terms of the GNU General Public License as
13 # published by the Free Software Foundation; either version 2 of
14 # the License, or (at your option) any later version.
16 # GNU Libtool is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with GNU Libtool; see the file COPYING.  If not, a copy
23 # can be downloaded from  http://www.gnu.org/licenses/gpl.html,
24 # or obtained by writing to the Free Software Foundation, Inc.,
25 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 ####
29 AT_BANNER([Dynamic ltdl runtime loading.])
31 # _LT_SETUP
32 # ---------
33 m4_define([_LT_SETUP],
34 [dnl We can't use AT_DATA here, because we need an unquoted here-
35 dnl document to splice in the path to the top level libltdl directory,
36 dnl but, we do need to double m4-quote to prevent premature expansion
37 dnl of any active m4 symbols in the here-doc content, and to maintain
38 dnl the square-bracket symbols as is.
39 [cat >configure.ac <<_EOT_
40 AC_INIT([mdemo], ]AT_PACKAGE_VERSION[, ]AT_PACKAGE_BUGREPORT[)
41 AC_CONFIG_AUX_DIR([build-aux])
42 AC_CONFIG_MACRO_DIRS([m4])
43 LT_CONFIG_LTDL_DIR([libltdl])
44 AM_INIT_AUTOMAKE
45 AC_PROG_CC
46 LT_INIT([dlopen win32-dll])
47 LTDL_INIT([nonrecursive convenience])
48 AC_SUBST([LIBTOOL_DEPS])
49 AC_SUBST([INCLTDL])
50 AC_SUBST([LIBLTDL])
51 STATIC=
52 test yes = "$enable_static" && STATIC=-static
53 AC_SUBST([STATIC])
54 LT_LIB_M
55 AC_CONFIG_FILES([Makefile])
56 AC_CONFIG_HEADERS([config.h:config.in.h])
57 AC_OUTPUT
58 _EOT_]
61 [cat >Makefile.am <<_EOT_
62 AUTOMAKE_OPTIONS = no-dependencies subdir-objects foreign
63 ACLOCAL_AMFLAGS = -I m4
64 AM_CPPFLAGS = \$(INCLTDL)
65 AM_LDFLAGS =
67 noinst_LTLIBRARIES =
68 EXTRA_LTLIBRARIES =
70 include_HEADERS =
72 EXTRA_DIST =
74 BUILT_SOURCES =
75 CLEANFILES =
76 MOSTLYCLEANFILES =
78 lib_LTLIBRARIES = libsub.la foo1.la libfoo2.la libmlib.la
80 foo1_la_SOURCES = foo1.c
81 foo1_la_LIBADD = \$(LIBM) libsub.la
82 foo1_la_LDFLAGS = -no-undefined -module -avoid-version
84 libfoo2_la_SOURCES = foo2.c
85 libfoo2_la_LIBADD = \$(LIBM) libsub.la
86 libfoo2_la_LDFLAGS = -no-undefined -module -export-symbols-regex "libfoo2.*"
88 libsub_la_SOURCES = sub.c
89 libsub_la_LDFLAGS = -no-undefined
91 ## Use -export-symbols-regex here explicitly because libltdl marks
92 ## its exported symbols, and we use libltdl as a convenience archive.
93 ## Thus, on w32, auto-exporting is turned off.
94 libmlib_la_SOURCES = mlib.c
95 libmlib_la_LIBADD = \$(LIBLTDL) "-dlopen" foo1.la "-dlopen" libfoo2.la
96 libmlib_la_LDFLAGS = -no-undefined -export-symbols-regex ".*"
97 libmlib_la_DEPENDENCIES = \$(LIBLTDL) libsub.la foo1.la libfoo2.la
99 noinst_HEADERS = foo.h
101 bin_PROGRAMS = mdemo mdemo_static
103 # Create a version of mdemo that does dlopen.
104 mdemo_SOURCES = main.c
105 mdemo_LDFLAGS = -export-dynamic
106 ## The quotes around -dlopen below fool automake into accepting it
107 mdemo_LDADD = \$(LIBLTDL) libsub.la "-dlopen" self \
108                 "-dlopen" foo1.la "-dlopen" libfoo2.la
109 mdemo_DEPENDENCIES = \$(LIBLTDL) libsub.la foo1.la libfoo2.la
111 # Create a statically linked version of mdemo.
112 mdemo_static_SOURCES = \$(mdemo_SOURCES)
113 mdemo_static_LDFLAGS = \$(STATIC) \$(mdemo_LDFLAGS)
114 mdemo_static_LDADD = \$(mdemo_LDADD)
115 mdemo_static_DEPENDENCIES = \$(mdemo_DEPENDENCIES)
117 libtool: \$(LIBTOOL_DEPS)
118         \$(SHELL) ./config.status --recheck
120 include \$(srcdir)/libltdl/ltdl.mk
121 include \$(srcdir)/mdemo.mk
122 _EOT_]
124 AT_DATA([mdemo.mk],
125 [[# Don't abort for lack of mdemo.mk
128 AT_DATA([foo.h],
129 [[#ifndef FOO_H
130 #define FOO_H
132 /* Silly constants that the functions return. */
133 #define HELLO_RET 0xe110
134 #define FOO_RET 0xf00
136 int sub (void);
138 #endif
141 AT_DATA([foo1.c],
142 [[#include <config.h>
143 #include <stdio.h>
144 #include <math.h>
146 #include "foo.h"
148 #define nothing foo1_LTX_nothing
149 #define foo1    foo1_LTX_foo1
150 #define hello   foo1_LTX_hello
152 /* Give a global variable definition. */
153 int nothing = FOO_RET;
155 /* private function */
156 int _foo1_helper (void) {
157   sub ();
158   return FOO_RET;
161 /* export functions */
162 #ifdef __cplusplus
163 extern "C" {
164 #endif
166 int foo1 (void) {
167     printf ("cos (0.0) = %g\n", (double) cos ((double) 0.0));
168     return _foo1_helper ();
171 int hello () {
172     printf ("** This is foolib 1 **\n");
173     return HELLO_RET;
176 #ifdef __cplusplus
178 #endif
181 AT_DATA([foo2.c],
182 [[#include <config.h>
183 #include <stdio.h>
184 #include <math.h>
186 #include "foo.h"
188 #define nothing libfoo2_LTX_nothing
189 #define foo2    libfoo2_LTX_foo2
190 #define hello   libfoo2_LTX_hello
192 /* Give a global variable definition. */
193 int nothing;
195 /* private function */
196 int _foo2_helper (void) {
197   sub ();
198   return FOO_RET;
201 /* export functions */
202 #ifdef __cplusplus
203 extern "C" {
204 #endif
206 int foo2 (void) {
207     printf ("sin (0.0) = %g\n", (double) sin ((double) 0.0));
208     return _foo2_helper ();
211 int hello () {
212     printf ("** This is foolib 2 **\n");
213     return HELLO_RET;
216 #ifdef __cplusplus
218 #endif
221 AT_DATA([mlib.c],
222 [[#include <config.h>
223 #include <stdio.h>
225 #include "foo.h"
226 #include "ltdl.h"
228 int test_dl (char *filename) {
229   lt_dlhandle handle;
230   const lt_dlinfo *info;
231   int (*pfoo1)() = 0;
232   int (*pfoo2)() = 0;
233   int (*phello)() = 0;
234   int *pnothing = 0;
235   int ret = 0;
237   handle = lt_dlopen(filename);
238   if (!handle) {
239     fprintf (stderr, "can't open the module %s!\n", filename);
240     fprintf (stderr, "error was: %s\n", lt_dlerror());
241     return 1;
242   }
244   info = lt_dlgetinfo(handle);
245   if (!info) {
246     fprintf (stderr, "can't get module info: %s\n", lt_dlerror());
247     return 1;
248   }
249   if (info->name) {
250     printf ("module name: %s\n", info->name);
251   } else {
252     printf ("module is not a libtool module\n");
253   }
254   printf ("module filename: %s\n", info->filename);
255   printf ("module reference count: %i\n", info->ref_count);
257   phello = (int(*)())lt_dlsym(handle, "hello");
258   if (phello)
259     {
260       int value = (*phello) ();
262       printf ("hello returned: %i\n", value);
263       if (value == HELLO_RET)
264         printf("hello is ok!\n");
265     }
266   else
267     {
268       fprintf (stderr, "did not find the 'hello' function\n");
269       fprintf (stderr, "error was: %s\n", lt_dlerror());
270       ret = 1;
271     }
273   pnothing = (int*)lt_dlsym(handle, "nothing");
274   /* Try assigning to the nothing variable. */
275   if (pnothing)
276     *pnothing = 1;
277   else
278     {
279       fprintf (stderr, "did not find the 'nothing' variable\n");
280       fprintf (stderr, "error was: %s\n", lt_dlerror());
281       ret = 1;
282     }
284   pfoo1 = (int(*)())lt_dlsym(handle, "foo1");
285   /* Just call the functions and check return values. */
286   if (pfoo1)
287     {
288       if ((*pfoo1) () == FOO_RET)
289         printf("foo1 is ok!\n");
290       else
291         ret = 1;
292     }
293   else {
294     pfoo2 = (int(*)())lt_dlsym(handle, "foo2");
295     if (pfoo2)
296       {
297         if ((*pfoo2) () == FOO_RET)
298           printf("foo2 is ok!\n");
299         else ret = 1;
300       }
301     else
302       {
303         fprintf (stderr, "did not find any of the 'foo' functions\n");
304         fprintf (stderr, "error was: %s\n", lt_dlerror());
305         ret = 1;
306       }
307   }
308   lt_dlclose(handle);
309   return ret;
313 mlib_func (int argc, char **argv)
315   int ret = 0;
316   int i;
317   /*
318    * Would be nice if this somehow worked for libraries, not just executables.
319    * LTDL_SET_PRELOADED_SYMBOLS();
320    */
321   if (lt_dlinit() != 0) {
322     fprintf (stderr, "error during initialization: %s\n", lt_dlerror());
323     return 1;
324   }
326   for (i = 1; i < argc; i++)
327     if (test_dl(argv[i]))
328        ret = 1;
330   lt_dlexit();
331   return ret;
335 AT_DATA([sub.c],
336 [[#include <config.h>
337 #include <stdio.h>
338 void sub (void) { printf ("sub() called\n"); }
341 AT_DATA([main.c],
342 [[#include <config.h>
343 #include <stdio.h>
344 #include <string.h>
346 #include "foo.h"
347 #include "ltdl.h"
349 #ifdef __cplusplus
350 #  define EXPORT extern "C"
351 #else
352 #  define EXPORT extern
353 #endif
355 EXPORT int myfunc (void);
358 test_dl (char *filename, int test_ext)
360   lt_dlhandle handle;
361   const lt_dlinfo *info;
362   int (*pfoo1)() = 0;
363   int (*pfoo2)() = 0;
364   int (*phello)() = 0;
365   int *pnothing = 0;
366   int ret = 0;
368   if (test_ext)
369     handle = lt_dlopenext (filename);
370   else
371     handle = lt_dlopen (filename);
373   if (!handle) {
374     fprintf (stderr, "can't open the module %s!\n", filename);
375     fprintf (stderr, "error was: %s\n", lt_dlerror());
376     return 1;
377   }
379   info = lt_dlgetinfo(handle);
380   if (!info) {
381     fprintf (stderr, "can't get module info: %s\n", lt_dlerror());
382     return 1;
383   }
384   if (info->name) {
385     printf ("module name: %s\n", info->name);
386   } else {
387     printf ("module is not a libtool module\n");
388   }
389   printf ("module filename: %s\n", info->filename);
390   printf ("module reference count: %i\n", info->ref_count);
392   phello = (int(*)())lt_dlsym(handle, "hello");
393   if (phello)
394     {
395       int value = (*phello) ();
397       printf ("hello returned: %i\n", value);
398       if (value == HELLO_RET)
399         printf("hello is ok!\n");
400     }
401   else
402     {
403       fprintf (stderr, "did not find the 'hello' function\n");
404       fprintf (stderr, "error was: %s\n", lt_dlerror());
405       ret = 1;
406     }
408   pnothing = (int*)lt_dlsym(handle, "nothing");
409   /* Try assigning to the nothing variable. */
410   if (pnothing)
411     *pnothing = 1;
412   else
413     {
414       fprintf (stderr, "did not find the 'nothing' variable\n");
415       fprintf (stderr, "error was: %s\n", lt_dlerror());
416       ret = 1;
417     }
419   pfoo1 = (int(*)())lt_dlsym(handle, "foo1");
420   /* Just call the functions and check return values. */
421   if (pfoo1)
422     {
423       if ((*pfoo1) () == FOO_RET)
424         printf("foo1 is ok!\n");
425       else
426         ret = 1;
427     }
428   else {
429     pfoo2 = (int(*)())lt_dlsym(handle, "foo2");
430     if (pfoo2)
431       {
432         if ((*pfoo2) () == FOO_RET)
433           printf("foo2 is ok!\n");
434         else ret = 1;
435       }
436     else
437       {
438         fprintf (stderr, "did not find any of the 'foo' functions\n");
439         fprintf (stderr, "error was: %s\n", lt_dlerror());
440         ret = 1;
441       }
442   }
443   lt_dlclose(handle);
444   return ret;
448 myfunc ()
450   return HELLO_RET;
453 int myvar;
456 test_dlself ()
458   lt_dlhandle handle;
459   int (*pmyfunc)() = 0;
460   int *pmyvar = 0;
461   int ret = 0;
463   handle = lt_dlopen(0);
464   if (!handle) {
465     fprintf (stderr, "can't dlopen the program!\n");
466     fprintf (stderr, "error was: %s\n", lt_dlerror());
467     return 1;
468   }
470   pmyfunc = (int(*)())lt_dlsym(handle, "myfunc");
471   if (pmyfunc)
472     {
473       int value = (*pmyfunc) ();
475       printf ("myfunc returned: %i\n", value);
476       if (value == HELLO_RET)
477         printf("myfunc is ok!\n");
478     }
479   else
480     {
481       fprintf (stderr, "did not find the 'myfunc' function\n");
482       fprintf (stderr, "error was: %s\n", lt_dlerror());
483       ret = 1;
484     }
486   pmyvar = (int*)lt_dlsym(handle, "myvar");
487   /* Try assigning to the variable. */
488   if (pmyvar)
489     *pmyvar = 1;
490   else
491     {
492       fprintf (stderr, "did not find the 'myvar' variable\n");
493       fprintf (stderr, "error was: %s\n", lt_dlerror());
494       ret = 1;
495     }
497   lt_dlclose(handle);
498   return ret;
501 static int
502 callback (const char *filename, void *data)
504   printf ("%s: %s\n", (char *)data, filename);
505   return 0;
508 static int
509 try_iterate (const char *search_path)
511   char *s = "try_iterate";
512   return lt_dlforeachfile (search_path, callback, s);
515 /* cheap dirname clone.  We require a '/' separator, nonempty and large
516    enough input, not ending with '/', and we will overwrite the input. */
517 static char *
518 my_dirname (char *path)
520   char *p = strrchr (path, '/');
521   if (p)
522     *p = '\0';
523   else
524     {
525       path[0] = '.';
526       path[1] = '\0';
527     }
528   return path;
532 main (int argc, char **argv)
534   int i;
535   int ret = 0;
536   char *p;
538   printf ("Welcome to GNU libtool mdemo!\n");
540   if (argc < 2) {
541     fprintf (stderr, "usage: %s module [module...]\n", argv[0]);
542   }
544   LTDL_SET_PRELOADED_SYMBOLS();
545   if (lt_dlinit() != 0) {
546     fprintf (stderr, "error during initialization: %s\n", lt_dlerror());
547     return 1;
548   }
550   for (i = 1; i < argc; i++)
551   {
552     if (test_dl(argv[i], 0))
553        ret = 1;
554     p = strrchr(argv[i], '.');
555     if (p)
556       {
557         *p = '\0';
558         if (test_dl(argv[i], 1))
559           ret = 1;
560         *p = '.';
561       }
562   }
564   if (test_dlself())
565     ret = 1;
567   for (i = 1; i < argc; i++)
568     if (argv[i][0] != '\0')
569       {
570         my_dirname (argv[i]);
571         if (try_iterate (argv[i]))
572           ret = 1;
573       }
575   lt_dlexit();
576   return ret;
580 LT_AT_HOST_DATA([expout],
581 [[Welcome to GNU Hell!
582 cos (0.0) = 1
583 ** This is not GNU Hello. There is no built-in mail reader. **
586 prefix=`pwd`/_inst
587 ]) # _LT_SETUP
590 # _LT_CHECK_EXECUTE
591 # -----------------
592 # Run the listed make rules, and check that the built binaries work.
593 m4_define([_LT_CHECK_EXECUTE],
594 [LT_AT_MAKE
595 LT_AT_EXEC_CHECK([./mdemo_static], 0, [ignore], [],
596     [./foo1.la ./libfoo2.la | $GREP '^try_iterate: '])
597 LT_AT_EXEC_CHECK([./mdemo], 0, [ignore], [],
598     [./foo1.la ./libfoo2.la | $GREP '^try_iterate: '])
599 LT_AT_EXEC_CHECK([./mdemo_static], 0, [ignore], [],
600     [`pwd`/foo1.la `pwd`/libfoo2.la | $GREP '^try_iterate: '])
601 LT_AT_EXEC_CHECK([./mdemo], 0, [ignore], [],
602     [`pwd`/foo1.la `pwd`/libfoo2.la | $GREP '^try_iterate: '])
605 # _LT_CHECK_INSTALL
606 # -----------------
607 # Run the make install rule, and check that installed binaries work too.
608 m4_define([_LT_CHECK_INSTALL],
609 [LT_AT_MAKE([install])
611 # Windows hosts search for dlls in the command path.
612 PATH=$prefix/lib:$PATH
614 LT_AT_EXEC_CHECK([$prefix/bin/mdemo_static], 0, [ignore], [],
615     [$prefix/lib/foo1.la $prefix/lib/libfoo2.la | $GREP '^try_iterate: '])
616 LT_AT_EXEC_CHECK([$prefix/bin/mdemo], 0, [ignore], [],
617     [$prefix/lib/foo1.la $prefix/lib/libfoo2.la | $GREP '^try_iterate: '])
621 ## ------------- ##
622 ## Mdemo static. ##
623 ## ------------- ##
625 AT_SETUP([dynamically ltdl preload static modules])
627 _LT_SETUP
629 LT_AT_CHECK_CONFIG([--with-included-ltdl --disable-shared],
630                    [^build_old_libs=yes], [^build_libtool_libs=no])
631 _LT_CHECK_EXECUTE
632 _LT_CHECK_INSTALL
633 LT_AT_CHECK_UNINSTALL
635 AT_CLEANUP
638 ## ------------- ##
639 ## Mdemo shared. ##
640 ## ------------- ##
642 AT_SETUP([dynamically ltdl load a shared module])
644 _LT_SETUP
646 LT_AT_CHECK_CONFIG([--with-included-ltdl --disable-static],
647                    [^build_old_libs=no], [^build_libtool_libs=yes])
648 _LT_CHECK_EXECUTE
649 _LT_CHECK_INSTALL
650 LT_AT_CHECK_UNINSTALL
652 AT_CLEANUP
655 ## ----------- ##
656 ## Mdemo conf. ##
657 ## ----------- ##
659 AT_SETUP([ltdl load shared and static modules])
661 _LT_SETUP
663 LT_AT_CHECK_CONFIG([--with-included-ltdl],
664                    [^build_old_libs=yes], [^build_libtool_libs=yes])
665 _LT_CHECK_EXECUTE
666 _LT_CHECK_INSTALL
667 LT_AT_CHECK_UNINSTALL
669 AT_CLEANUP
672 ## ------------- ##
673 ## Mdemo dryrun. ##
674 ## ------------- ##
676 AT_SETUP([ltdl dryrun])
678 _LT_SETUP
680 LT_AT_CHECK_CONFIG([--with-included-ltdl])
681 LT_AT_MAKE([all-local libltdl/libltdlc.la])
683 # create 'before' and 'after' in a directory deep within objdir,
684 # so that their creation and removal does not modify even a timestamp
685 # in the output of 'ls -l . $objdir'
686 $lt_INSTALL -d "$objdir/temp/temp"
687 before=$objdir/temp/temp/before
688 after=$objdir/temp/temp/after
690 # Create a new libtool script that will enter dry run if the environment
691 # variable force_dry_run is set
692 $SED 's|^[[      ]]*opt_dry_run=.*$|opt_dry_run=$force_dry_run|' libtool > ltnew && mv ltnew libtool
693 export force_dry_run
695 # main.o is not compiled with libtool, but it depends on it, so make
696 # sure it is up-to-date.  libfoo2.la is linked with libsub.la, so make
697 # sure it exists, otherwise libtool will complain.
698 force_dry_run=false
699 LT_AT_MAKE([main.$objext])
701 # Making object files
702 # ls -l in MSYS sometimes shows year, not time, for really fresh files.
703 sleep 1
704 ls -l . "$objdir" | $EGREP -v '(^total|testsuite.log$)' > "$before"
705 force_dry_run=:
706 LT_AT_MAKE([foo1.lo foo2.lo libsub.la])
707 ls -l . "$objdir" | $EGREP -v '(^total|testsuite.log$)' > "$after"
708 AT_CHECK([cmp "$before" "$after"], 0, [ignore])
710 # Now really make them
711 force_dry_run=false
712 LT_AT_MAKE([foo1.lo foo2.lo libsub.la])
714 # Making libraries
715 sleep 1 # for MSYS
716 ls -l . "$objdir" | $EGREP -v '(^total|testsuite.log$)' > "$before"
717 force_dry_run=:
718 LT_AT_MAKE([foo1.la libfoo2.la])
719 ls -l . "$objdir" | $EGREP -v '(^total|testsuite.log$)' > "$after"
720 AT_CHECK([cmp "$before" "$after"], 0, [ignore])
722 # Now really make them
723 force_dry_run=false
724 LT_AT_MAKE([foo1.la libfoo2.la])
726 # Making programs
727 sleep 1 # for MSYS
728 ls -l . "$objdir" | $EGREP -v '(^total|testsuite.log$)' > "$before"
729 force_dry_run=:
730 LT_AT_MAKE([mdemo$EXEEXT mdemo_static$EXEEXT])
731 ls -l . "$objdir" | $EGREP -v '(^total|testsuite.log$)' > "$after"
732 AT_CHECK([cmp "$before" "$after"], 0, [ignore])
734 # Running $MAKE install
735 # Libtool does not create these directories
736 $lt_INSTALL -d "$prefix/bin"
737 $lt_INSTALL -d "$prefix/include"
738 $lt_INSTALL -d "$prefix/lib"
740 sleep 1 # for MSYS
741 ls -l . "$objdir" | $EGREP -v '(^total|testsuite.log$)' > "$before"
742 ls -lR "$prefix" | $EGREP -v '(^total|testsuite.log$)' >> "$before"
743 force_dry_run=:
744 LT_AT_MAKE([install])
746 ls -l . "$objdir" | $EGREP -v '(^total|testsuite.log$)' > "$after"
747 ls -lR "$prefix" | $EGREP -v '(^total|testsuite.log$)' >> "$after"
748 AT_CHECK([cmp "$before" "$after"], 0, [ignore])
750 # Now really install
751 force_dry_run=false
752 LT_AT_MAKE([install])
754 # Running $MAKE uninstall
755 # Libtool does not uninstall the programs, remove them first
756 rm -f "$prefix/bin/mdemo$EXEEXT" "$prefix/bin/mdemo_static$EXEEXT"
758 sleep 1 # for MSYS
759 ls -l . "$objdir" | $EGREP -v '(^total|testsuite.log$)' > "$before"
760 ls -lR "$prefix" | $EGREP -v '(^total|testsuite.log$)' >> "$before"
761 force_dry_run=:
762 LT_AT_MAKE([uninstall])
763 ls -l . "$objdir" | $EGREP -v '(^total|testsuite.log$)' > "$after"
764 ls -lR "$prefix" | $EGREP -v '(^total|testsuite.log$)' >> "$after"
765 AT_CHECK([cmp "$before" "$after"], 0, [ignore])
767 # Now really uninstall
768 force_dry_run=false
769 LT_AT_CHECK_UNINSTALL
771 AT_CLEANUP
773 ## ------- ##
774 ## Mdemo2. ##
775 ## ------- ##
777 AT_SETUP([link with library that loads ltdl modules])
779 _LT_SETUP
781 AT_DATA([mdemo.mk],
782 [[bin_PROGRAMS += mdemo2 mdemo2_static
784 # Create a version of mdemo2 that links a library that does dlopen.
785 mdemo2_LDFLAGS = -export-dynamic "-dlopen" force
786 mdemo2_LDADD = libmlib.la
788 # Create a statically linked version of mdemo.
789 mdemo2_static_SOURCES = mdemo2.c
790 mdemo2_static_LDFLAGS = $(STATIC) $(mdemo2_LDFLAGS)
791 mdemo2_static_LDADD = $(mdemo2_LDADD)
792 mdemo2_static_DEPENDENCIES = $(mdemo2_DEPENDENCIES)
795 AT_DATA([mdemo2.c],
796 [[#include <stdio.h>
797 #include "ltdl.h"
799 extern int mlib_func (int, char **);
801 int main (int argc, char **argv)
803   int ret = 0;
805   printf ("Welcome to GNU libtool mdemo2!\n");
806   if (argc < 2) {
807     fprintf (stderr, "usage: %s module [module...]\n", argv[0]);
808   }
810   /* This must be called in the program to get the preloaded symbols */
811   LTDL_SET_PRELOADED_SYMBOLS();
813   ret = mlib_func(argc, argv);
815   return ret;
819 # Normalize line endings after $EGREP instead of using LT_AT_HOST_DATA
820 # here, since $EGREP *may* normalize line endings for us.
821 AT_DATA([expout],
822 [[Welcome to GNU libtool mdemo2!
823 module name: foo1
824 module reference count: 1
825 ** This is foolib 1 **
826 hello returned: 57616
827 hello is ok!
828 cos (0.0) = 1
829 sub() called
830 foo1 is ok!
831 module name: libfoo2
832 module reference count: 1
833 ** This is foolib 2 **
834 hello returned: 57616
835 hello is ok!
836 sin (0.0) = 0
837 sub() called
838 foo2 is ok!
841 LT_AT_CHECK_CONFIG([--with-included-ltdl])
843 LT_AT_MAKE
845 LT_AT_EXEC_CHECK([./mdemo2_static], 0, [stdout], [],
846     [./foo1.la ./libfoo2.la | $EGREP -v '^module filename: '])
847 LT_AT_UNIFY_NL([stdout])
848 LT_AT_CHECK([diff expout stdout])
850 LT_AT_EXEC_CHECK([./mdemo2], 0, [stdout], [],
851     [./foo1.la ./libfoo2.la | $EGREP -v '^module filename: '])
852 LT_AT_UNIFY_NL([stdout])
853 LT_AT_CHECK([diff expout stdout])
855 AT_CLEANUP