From: Gary V. Vaughan Date: Tue, 14 Oct 2003 21:46:13 +0000 (+0000) Subject: spurious commit abort earlier :-( X-Git-Tag: release-1-9b~303 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ae292f6672f6a60ce91cd7ffbaa78159f4d9e705;p=thirdparty%2Flibtool.git spurious commit abort earlier :-( --- diff --git a/tests/Makefile.am b/tests/Makefile.am index ab3c34bfd..7f867562d 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -10,43 +10,42 @@ CXX_TESTS = \ F77_TESTS = \ f77demo-static.test f77demo-make.test f77demo-exec.test \ f77demo-conf.test f77demo-make.test f77demo-exec.test \ - f77demo-shared.test f77demo-make.test f77demo-exec.test + f77demo-shared.test f77demo-make.test f77demo-exec.test COMMON_TESTS = \ + assign.test link.test link-2.test nomode.test \ + quote.test sh.test suffix.test \ cdemo-static.test cdemo-make.test cdemo-exec.test \ demo-static.test demo-make.test demo-exec.test \ demo-inst.test demo-unst.test \ - depdemo-static.test depdemo-make.test \ - depdemo-exec.test depdemo-inst.test depdemo-unst.test \ + depdemo-static.test depdemo-make.test depdemo-exec.test \ + depdemo-inst.test depdemo-unst.test \ mdemo-static.test mdemo-make.test mdemo-exec.test \ mdemo-inst.test mdemo-unst.test \ cdemo-conf.test cdemo-make.test cdemo-exec.test \ demo-conf.test demo-make.test demo-exec.test \ - demo-inst.test demo-unst.test deplibs.test \ - depdemo-conf.test depdemo-make.test \ - depdemo-exec.test depdemo-inst.test depdemo-unst.test \ + demo-inst.test demo-unst.test demo-deplibs.test \ + depdemo-conf.test depdemo-make.test depdemo-exec.test \ + depdemo-inst.test depdemo-unst.test \ mdemo-conf.test mdemo-make.test mdemo-exec.test \ - mdemo-inst.test mdemo-unst.test dryrun.test \ + mdemo-inst.test mdemo-unst.test mdemo-dryrun.test \ + mdemo2-conf.test mdemo2-make.test mdemo2-exec.test \ + pdemo-conf.test pdemo-make.test pdemo-exec.test \ + pdemo-inst.test pdemo-unst.test \ demo-nofast.test demo-make.test demo-exec.test \ demo-inst.test demo-unst.test \ + depdemo-nofast.test depdemo-make.test depdemo-exec.test \ + depdemo-inst.test depdemo-unst.test \ demo-pic.test demo-make.test demo-exec.test \ demo-nopic.test demo-make.test demo-exec.test \ - depdemo-nofast.test depdemo-make.test \ - depdemo-exec.test depdemo-inst.test depdemo-unst.test \ cdemo-shared.test cdemo-make.test cdemo-exec.test \ demo-shared.test demo-make.test demo-exec.test demo-inst.test \ - hardcode.test build-relink.test noinst-link.test demo-unst.test \ - depdemo-shared.test depdemo-make.test \ - depdemo-exec.test depdemo-inst.test build-relink2.test \ - depdemo-unst.test \ + demo-hardcode.test demo-relink.test demo-noinst-link.test \ + demo-unst.test \ + depdemo-shared.test depdemo-make.test depdemo-exec.test \ + depdemo-inst.test depdemo-relink.test depdemo-unst.test \ mdemo-shared.test mdemo-make.test mdemo-exec.test \ - mdemo-inst.test mdemo-unst.test \ - assign.test link.test link-2.test nomode.test \ - quote.test sh.test suffix.test pdemo-conf.test \ - pdemo-make.test pdemo-exec.test pdemo-inst.test \ - mdemo-conf.test mdemo-make.test mdemo2-conf.test \ - mdemo2-make.test mdemo2-exec.test - + mdemo-inst.test mdemo-unst.test if HAVE_CXX if HAVE_F77 @@ -67,28 +66,61 @@ demo-conf.test: $(top_builddir)/libtool $(top_builddir)/libtool: cd $(top_builddir) && $(MAKE) all -# We should export these variables when we build the libtool script. -CFLAGS = @CFLAGS@ -CPPFLAGS = @CPPFLAGS@ -LDFLAGS = @LDFLAGS@ -LIBS = @LIBS@ -FFLAGS = @FFLAGS@ - # Be sure to reexport important environment variables. TESTS_ENVIRONMENT = MAKE="$(MAKE)" CC="$(CC)" CFLAGS="$(CFLAGS)" \ CPPFLAGS="$(CPPFLAGS)" LD="$(LD)" LDFLAGS="$(LDFLAGS)" \ LIBS="$(LIBS)" LN_S="$(LN_S)" NM="$(NM)" RANLIB="$(RANLIB)" \ - OBJEXT="$(OBJEXT)" EXEEXT="$(EXEEXT)" FFLAGS="$(FFLAGS)" + OBJEXT="$(OBJEXT)" EXEEXT="$(EXEEXT)" FFLAGS="$(FFLAGS)" EXTRA_DIST = defs $(COMMON_TESTS) $(CXX_TESTS) $(F77_TESTS) # We need to remove any files that the above tests created. clean-local: - -test -f ../pdemo/Makefile && cd ../pdemo && $(MAKE) distclean - -test -f ../cdemo/Makefile && cd ../cdemo && $(MAKE) distclean - -test -f ../demo/Makefile && cd ../demo && $(MAKE) distclean - -test -f ../depdemo/Makefile && cd ../depdemo && $(MAKE) distclean - -test -f ../mdemo/Makefile && cd ../mdemo && $(MAKE) distclean - -test -f ../tagdemo/Makefile && cd ../tagdemo && $(MAKE) distclean - -test -f ../f77demo/Makefile && cd ../f77demo && $(MAKE) distclean + -for dir in cdemo demo depdemo f77demo mdemo mdemo2 pdemo tagdemo; \ + do \ + test -f $$dir/Makefile && ( cd $$dir && $(MAKE) distclean; ); \ + done rm -rf _inst + +## ------------ ## +## package.m4. ## +## ------------ ## + +$(srcdir)/package.m4: $(top_srcdir)/configure.ac + { \ + echo '# Signature of the current package.'; \ + echo 'm4_define([AT_PACKAGE_NAME], [@PACKAGE_NAME@])'; \ + echo 'm4_define([AT_PACKAGE_TARNAME], [@PACKAGE_TARNAME@])'; \ + echo 'm4_define([AT_PACKAGE_VERSION], [@PACKAGE_VERSION@])'; \ + echo 'm4_define([AT_PACKAGE_STRING], [@PACKAGE_STRING@])'; \ + echo 'm4_define([AT_PACKAGE_BUGREPORT], [@PACKAGE_BUGREPORT@])'; \ + } >$(srcdir)/package.m4 + +## ------------ ## +## Test suite. ## +## ------------ ## + +TESTSUITE_AT = \ + testsuite.at \ + demo.at fortran.at tools.at +TESTSUITE = testsuite + +#EXTRA_DIST = $(TESTSUITE_AT) local.at atlocal.in package.m4 + +#check-local: atconfig $(TESTSUITE) +# $(SHELL) $(srcdir)/$(TESTSUITE) + +#clean-local: +# $(srcdir)/testsuite --clean + +AUTOM4TE = autom4te +AUTOTEST = $(AUTOM4TE) --language=autotest +$(srcdir)/$(TESTSUITE): $(srcdir)/package.m4 local.at $(TESTSUITE_AT) + $(AUTOTEST) -I $(srcdir) testsuite.at -o $@ + +atconfig: $(top_builddir)/config.status + cd $(top_builddir) && ./config.status tests/$@ + +# Run the test suite on the *installed* tree. +#installcheck-local: + $(SHELL) $(srcdir)/$(TESTSUITE) AUTOTEST_PATH=$(exec_prefix)/bin diff --git a/tests/assign.test b/tests/assign.test index b9704973f..120a67786 100755 --- a/tests/assign.test +++ b/tests/assign.test @@ -2,19 +2,34 @@ # assign.test - check that we don't put break or continue on the same # line as an assignment -# Test script header. -need_prefix=no +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. + if test -z "$srcdir"; then srcdir=`echo "$0" | sed 's%/[^/]*$%%'` test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes fi . $srcdir/defs || exit 1 # Check that test -e isn't used in our portable shell scripts. -if $EGREP -n '[^ ]=[^ ].*(break|continue)' $srcdir/../ltmain.sh; then - echo "cannot use \`break' or \`continue' on the same line as an assignment" - exit 1 -fi +$EGREP -n '[^ ]=[^ ].*(break|continue)' $srcdir/../ltmain.sh \ + && func_fail "cannot use \`break' or \`continue' on the same line as an assignment" -exit 0 +exit $EXIT_SUCCESS diff --git a/tests/build-relink.test b/tests/build-relink.test deleted file mode 100755 index 015c8862d..000000000 --- a/tests/build-relink.test +++ /dev/null @@ -1,120 +0,0 @@ -#! /bin/sh -# build-relink.test - check to see whether shlibpath overrides runpath - -# Test script header. -need_prefix=yes -if test -z "$srcdir"; then - srcdir=`echo "$0" | sed 's%/[^/]*$%%'` - test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes -fi -. $srcdir/defs || exit 1 - -# Check that things are built. -if test -f $prefix/lib/libhello.la && cd ../demo && test -f libhello.la; then : -else - echo "You must run demo-inst.test before $0" 1>&2 - exit 77 -fi - -# Check to make sure we have a dynamic library. -library_names=NONE -eval `grep '^library_names=' ./libhello.la 2>/dev/null` - -if test "$library_names" = NONE; then - echo "library_names not set in ../demo/libhello.la" 1>&2 - exit 1 -elif test -z "$library_names"; then - echo "= Exiting: ../demo/libhello.la is not a shared library" - exit 77 -fi - -# Unfortunately, we need access to libtool internals for this test. -objdir=NONE -eval `grep '^objdir=' ./libtool 2>/dev/null` -if test "$objdir" = NONE; then - echo "objdir not set in ../demo/libtool" 1>&2 - exit 1 -fi - -shlibpath_overrides_runpath=NONE -eval `grep '^shlibpath_overrides_runpath=' ./libtool 2>/dev/null` -if test "$shlibpath_overrides_runpath" = NONE; then - echo "shlibpath_overrides_runpath not set in ../demo/libtool" 1>&2 - exit 1 -fi - -hardcode_action=NONE -eval `grep '^hardcode_action=' ./libtool 2>/dev/null` -if test "$hardcode_action" = NONE; then - echo "hardcode_action not set in ../demo/libtool" 1>&2 - exit 1 -fi - -hardcode_direct=NONE -eval `grep '^hardcode_direct=' ./libtool 2>/dev/null` -if test "$hardcode_direct" = NONE; then - echo "hardcode_direct not set in ../demo/libtool" 1>&2 - exit 1 -fi - -hardcode_into_libs=NONE -eval `grep '^hardcode_into_libs=' ./libtool 2>/dev/null` -if test "$hardcode_into_libs" = NONE; then - echo "hardcode_into_libs not set in ../demo/libtool" 1>&2 - exit 1 -fi - -./hell # so that it links on-demand if needed - -echo "removing libhello.la from ../demo" -rm -f libhello.la $objdir/libhello.* - -echo "running ../demo/hell" -if ./hell; then - : -elif test "x,$hardcode_action,$hardcode_direct" = x,relink,yes; then - echo "Ok, uninstalled programs fail after uninstalled libraries are removed" - echo "This works in other configurations, but not in this particular one" -else - echo "= Exiting: ../demo/hell does not run, maybe libhello was not installed" - exit 1 -fi - -echo "linking a broken ../demo/libhello.la" -if $make libhello.la libhello_la_OBJECTS=hello.lo; then - : -else - echo "= Exiting: cannot link broken libhello.la" - exit 1 -fi -rm -f libhello.la - -echo "running ../demo/hell with broken libhello.la" -if (./hell) 2>&1; then - echo "= Exiting: ../demo/hell runs even though libhello.la is incomplete" - echo "shlibpath_overrides_runpath should be set to no" - exit 1 -else - echo "Failed, as expected" -fi - -if test "x$hardcode_action" = xrelink; then - echo "= Exiting: install-time relinking is required" - exit 0 -fi - -if test "$shlibpath_overrides_runpath" != yes; then - rm -f $objdir/lt-hell$EXEEXT || exit 1 - cp $objdir/hell$EXEEXT $objdir/lt-hell$EXEEXT || exit 1 - echo "running ../demo/hell with installed libhello.la" - if ./hell; then - echo "Worked, as expected" - else - echo "shlibpath_overrides_runpath should be set to yes" - status=1 - fi - rm -f $objdir/lt-hell$EXEEXT -fi - -exit $status diff --git a/tests/build-relink2.test b/tests/build-relink2.test deleted file mode 100755 index d0e7c7257..000000000 --- a/tests/build-relink2.test +++ /dev/null @@ -1,126 +0,0 @@ -#! /bin/sh -# build-relink2.test - check to see whether shlibpath overrides runpath - -# Test script header. -need_prefix=yes -if test -z "$srcdir"; then - srcdir=`echo "$0" | sed 's%/[^/]*$%%'` - test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes -fi -. $srcdir/defs || exit 1 - -# Check that things are built. -if (test -f $prefix/lib/extra/libl3.la || test -f $prefix/lib/libl3.la) \ - && cd ../depdemo && test -f l3/libl3.la; then : -else - echo "You must run depdemo-inst.test before $0" 1>&2 - exit 77 -fi - -# Check to make sure we have a dynamic library. -library_names=NONE -eval `grep '^library_names=' ./l3/libl3.la 2>/dev/null` - -if test "$library_names" = NONE; then - echo "library_names not set in ../depdemo/l3/libl3.la" 1>&2 - exit 1 -elif test -z "$library_names"; then - echo "= Exiting: ../depdemo/l3/libl3.la is not a shared library" - exit 77 -fi - -# Unfortunately, we need access to libtool internals for this test. -objdir=NONE -eval `grep '^objdir=' ./libtool 2>/dev/null` -if test "$objdir" = NONE; then - echo "objdir not set in ../depdemo/libtool" 1>&2 - exit 1 -fi - -shlibpath_overrides_runpath=NONE -eval `grep '^shlibpath_overrides_runpath=' ./libtool 2>/dev/null` -if test "$shlibpath_overrides_runpath" = NONE; then - echo "shlibpath_overrides_runpath not set in ../depdemo/libtool" 1>&2 - exit 1 -fi - -hardcode_action=NONE -eval `grep '^hardcode_action=' ./libtool 2>/dev/null` -if test "$hardcode_action" = NONE; then - echo "hardcode_action not set in ../depdemo/libtool" 1>&2 - exit 1 -fi - -hardcode_direct=NONE -eval `grep '^hardcode_direct=' ./libtool 2>/dev/null` -if test "$hardcode_direct" = NONE; then - echo "hardcode_direct not set in ../depdemo/libtool" 1>&2 - exit 1 -fi - -hardcode_into_libs=NONE -eval `grep '^hardcode_into_libs=' ./libtool 2>/dev/null` -if test "$hardcode_into_libs" = NONE; then - echo "hardcode_into_libs not set in ../depdemo/libtool" 1>&2 - exit 1 -fi - -./depdemo # so that it links on-demand if needed - -echo "removing libl3.la from ../depdemo/l3" -rm -rf l3/libl3.la l3/$objdir - -echo "running ../depdemo/depdemo" -if ./depdemo || - # On AIX 4.1, when the installed copy of libl3 is loaded, it brings - # with it the installed copies of libl1 and libl2, with disjoint - # counters var_l1 and var_l2. This is arguably acceptable behavior, - # but it's definitely not enough of a reason for the test to fail. - ./depdemo -alt; then - : -elif test "x,$hardcode_action,$hardcode_direct" = x,relink,yes; then - echo "Ok, uninstalled programs fail after uninstalled libraries are removed" - echo "This works in other configurations, but not in this particular one" -else - echo "= Exiting: ../depdemo/depdemo does not run, maybe libl3 was not installed" - exit 1 -fi - -echo "linking a broken ../depdemo/l3/libl3.la" -if (cd l3; $make libl3.la libl3_la_OBJECTS=../l2/l2.lo); then - : -else - echo "= Exiting: cannot link broken libl3.la" - exit 1 -fi -rm -f l3/libl3.la - -echo "running ../depdemo/depdemo with broken libl3.la" -if (./depdemo) 2>&1; then - echo "= Exiting: ../depdemo/depdemo runs even though libl3.la is incomplete" - echo "shlibpath_overrides_runpath should be set to no" - exit 1 -else - echo "Failed, as expected" -fi - -if test "x$hardcode_action" = xrelink; then - echo "= Exiting: install-time relinking is required" - exit 0 -fi - -if test "$shlibpath_overrides_runpath" != yes; then - rm -f $objdir/lt-depdemo || exit 1 - cp $objdir/depdemo $objdir/lt-depdemo || exit 1 - echo "running ../depdemo/depdemo with installed libl3.la" - if ./depdemo; then - echo "Worked, as expected" - else - echo "shlibpath_overrides_runpath should be set to yes" - status=1 - fi - rm -f $objdir/lt-depdemo -fi - -exit $status diff --git a/tests/cdemo-conf.test b/tests/cdemo-conf.test index be65b7691..6df86fd05 100755 --- a/tests/cdemo-conf.test +++ b/tests/cdemo-conf.test @@ -1,35 +1,36 @@ #! /bin/sh -# cdemo-conf.test - try configuring the ../cdemo subdirectory +# cdemo-conf.test - try configuring the cdemo subdirectory + +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. -# Test script header. -need_prefix=yes if test -z "$srcdir"; then srcdir=`echo "$0" | sed 's%/[^/]*$%%'` test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes fi . $srcdir/defs || exit 1 -# Maybe we have a VPATH build, in which case, create a new subdir. -test -d ../cdemo || mkdir ../cdemo - -# Change to our build directory. -cd ../cdemo || exit 1 - -# Possibly clean up the distribution. -if test -f Makefile; then - echo "= Running $make distclean in ../demo" - $make distclean -fi -rm -f config.cache - -# Configure the demonstration. -echo "= Configuring in ../cdemo (prefix=$prefix)" -${CONFIG_SHELL-/bin/sh} $srcdir/../cdemo/configure --srcdir=$srcdir/../cdemo --prefix=$prefix || exit 1 - -if grep '^build_old_libs=yes' libtool > /dev/null && - grep '^build_libtool_libs=yes' libtool > /dev/null; then : -else rm -f Makefile && exit 77 -fi +func_mkprefixdir +func_cd "cdemo" +func_make_distclean +func_configure +func_check_static_shared "yes" "yes" exit 0 diff --git a/tests/cdemo-exec.test b/tests/cdemo-exec.test index f558fdc23..612162995 100755 --- a/tests/cdemo-exec.test +++ b/tests/cdemo-exec.test @@ -1,28 +1,36 @@ #! /bin/sh -# cdemo-exec.test - check that programs in the ../cdemo subdirectory are viable +# cdemo-exec.test - check that programs in the cdemo subdirectory are viable + +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. -# Test script header. -need_prefix=no if test -z "$srcdir"; then srcdir=`echo "$0" | sed 's%/[^/]*$%%'` test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes fi . $srcdir/defs || exit 1 -if test -f ../cdemo/cdemo$EXEEXT; then : -else - echo "You must run cdemo-make.test before running $0" 1>&2 - exit 77 -fi +func_require "cdemo-make" "cdemo/cdemo$EXEEXT" -# Check to see if the programs really run. -echo "Executing uninstalled programs in ../cdemo" - -if ../cdemo/cdemo; then : -else - echo "$0: cannot execute ../cdemo/cdemo" 1>&2 - status=1 -fi +func_rmprefixdir +func_exec_init "uninstalled" +func_exec "cdemo/cdemo" -exit $status +exit $exec_status diff --git a/tests/cdemo-make.test b/tests/cdemo-make.test index 7a357000c..cb7d5dd43 100755 --- a/tests/cdemo-make.test +++ b/tests/cdemo-make.test @@ -1,25 +1,36 @@ #! /bin/sh -# cdemo-make.test - try building in the ../cdemo subdirectory +# cdemo-make.test - try building in the cdemo subdirectory + +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. -# Test script header. -need_prefix=no if test -z "$srcdir"; then srcdir=`echo "$0" | sed 's%/[^/]*$%%'` test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes fi . $srcdir/defs || exit 1 -if test -f ../cdemo/Makefile; then : -else - echo "You must run cdemo-conf.test before running $0" 1>&2 - exit 77 -fi +func_require "cdemo-conf" "cdemo/Makefile" -# Change to our build directory. -cd ../cdemo || exit 1 +func_rmprefixdir +func_cd "cdemo" +func_make -# Do the actual build. -echo "Making in ../cdemo" -$make || exit 1 exit 0 diff --git a/tests/cdemo-shared.test b/tests/cdemo-shared.test index 3b38df30e..87704da62 100755 --- a/tests/cdemo-shared.test +++ b/tests/cdemo-shared.test @@ -1,35 +1,36 @@ #! /bin/sh -# cdemo-conf.test - try configuring the ../cdemo subdirectory +# cdemo-shared.test - try configuring the cdemo subdirectory for shared libs + +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. -# Test script header. -need_prefix=yes if test -z "$srcdir"; then srcdir=`echo "$0" | sed 's%/[^/]*$%%'` test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes fi . $srcdir/defs || exit 1 -# Maybe we have a VPATH build, in which case, create a new subdir. -test -d ../cdemo || mkdir ../cdemo - -# Change to our build directory. -cd ../cdemo || exit 1 - -# Possibly clean up the distribution. -if test -f Makefile; then - echo "= Running $make distclean in ../demo" - $make distclean -fi -rm -f config.cache - -# Configure the demonstration. -echo "= Configuring in ../cdemo (prefix=$prefix) with --disable-static" -${CONFIG_SHELL-/bin/sh} $srcdir/../cdemo/configure --srcdir=$srcdir/../cdemo --prefix=$prefix --disable-static || exit 1 - -if grep '^build_old_libs=no' libtool > /dev/null && - grep '^build_libtool_libs=yes' libtool > /dev/null; then : -else rm -f Makefile && exit 77 -fi +func_mkprefixdir +func_cd "cdemo" +func_make_distclean +func_configure "--disable-static" +func_check_static_shared "no" "yes" exit 0 diff --git a/tests/cdemo-static.test b/tests/cdemo-static.test index e81b40651..447a4cb77 100755 --- a/tests/cdemo-static.test +++ b/tests/cdemo-static.test @@ -1,35 +1,36 @@ #! /bin/sh -# cdemo-conf.test - try configuring the ../cdemo subdirectory +# cdemo-static.test - try configuring the cdemo subdirectory for static libs + +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. -# Test script header. -need_prefix=yes if test -z "$srcdir"; then srcdir=`echo "$0" | sed 's%/[^/]*$%%'` test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes fi . $srcdir/defs || exit 1 -# Maybe we have a VPATH build, in which case, create a new subdir. -test -d ../cdemo || mkdir ../cdemo - -# Change to our build directory. -cd ../cdemo || exit 1 - -# Possibly clean up the distribution. -if test -f Makefile; then - echo "= Running $make distclean in ../demo" - $make distclean -fi -rm -f config.cache - -# Configure the demonstration. -echo "= Configuring in ../cdemo (prefix=$prefix) with --disable-shared" -${CONFIG_SHELL-/bin/sh} $srcdir/../cdemo/configure --srcdir=$srcdir/../cdemo --prefix=$prefix --disable-shared || exit 1 - -if grep '^build_old_libs=yes' libtool > /dev/null && - grep '^build_libtool_libs=no' libtool > /dev/null; then : -else rm -f Makefile && exit 77 -fi +func_mkprefixdir +func_cd "cdemo" +func_make_distclean +func_configure "--disable-shared" +func_check_static_shared "yes" "no" exit 0 diff --git a/tests/cdemo/.cvsignore b/tests/cdemo/.cvsignore new file mode 100644 index 000000000..90cb96432 --- /dev/null +++ b/tests/cdemo/.cvsignore @@ -0,0 +1,14 @@ +.deps +.libs +Makefile +Makefile.in +acinclude.m4 +aclocal.m4 +autom4te.cache +configure +config.* +conftest* +libtool +*.lo +*.la +cdemo diff --git a/tests/cdemo/Makefile.am b/tests/cdemo/Makefile.am new file mode 100644 index 000000000..3ac137d48 --- /dev/null +++ b/tests/cdemo/Makefile.am @@ -0,0 +1,40 @@ +## Makefile.am -- Process this file with automake to produce Makefile.in +## +## Copyright (C) 2003 Free Software Foundation +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2 of the License, or +## (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program; see the file COPYING. If not, write to +## the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +## Boston, MA 02111-1307, USA. + +top_distdir = ../.. + +AUTOMAKE_OPTIONS = no-dependencies foreign +ACLOCAL_AMFLAGS = -I $(top_distdir)/m4 + +noinst_LTLIBRARIES = libfoo.la + +libfoo_la_SOURCES = foo.c +libfoo_la_LIBADD = $(LIBM) +libfoo_la_LDFLAGS = -no-undefined + +noinst_HEADERS = foo.h + +bin_PROGRAMS = cdemo + +cdemo_SOURCES = main.c +cdemo_LDADD = libfoo.la + +$(OBJECTS): libtool +libtool: $(LIBTOOL_DEPS) + $(SHELL) ./config.status --recheck diff --git a/tests/cdemo/README b/tests/cdemo/README new file mode 100644 index 000000000..fd3e418c1 --- /dev/null +++ b/tests/cdemo/README @@ -0,0 +1,4 @@ +This is cdemo, an example package that uses GNU libtool with an +Automake-generated environment to build two simple libraries and programs. + +It demonstrates how to build convenience libraries diff --git a/tests/cdemo/configure.ac b/tests/cdemo/configure.ac new file mode 100644 index 000000000..0f3830de9 --- /dev/null +++ b/tests/cdemo/configure.ac @@ -0,0 +1,65 @@ +## Process this file with autoconf to create configure. -*- autoconf -*- +# Copyright (C) 2001, 2003 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +# 02111-1307 USA + +AC_PREREQ(2.50) + +## ------------------------ ## +## Autoconf initialisation. ## +## ------------------------ ## +AC_INIT([cdemo], [0.1], [bug-libtool@gnu.org]) +AC_CONFIG_SRCDIR([main.c]) +AC_CONFIG_AUX_DIR([../../config]) + + +## ------------------------ ## +## Automake Initialisation. ## +## ------------------------ ## +AM_INIT_AUTOMAKE(AC_PACKAGE_TARNAME, AC_PACKAGE_VERSION) + + +## ------------------ ## +## C compiler checks. ## +## ------------------ ## +AC_PROG_CC + + +## ----------------------- ## +## Libtool initialisation. ## +## ----------------------- ## +AM_PROG_LIBTOOL +AC_SUBST([LIBTOOL_DEPS]) + + +## ---------------------------- ## +## C headers required by cdemo. ## +## ---------------------------- ## +AC_CHECK_HEADERS([math.h]) + + +## ---------------------------- ## +## Libraries required by cdemo. ## +## ---------------------------- ## +AC_CHECK_LIBM +AC_SUBST([LIBM]) + + +## -------- ## +## Outputs. ## +## -------- ## +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT diff --git a/tests/cdemo/foo.c b/tests/cdemo/foo.c new file mode 100644 index 000000000..3854c4354 --- /dev/null +++ b/tests/cdemo/foo.c @@ -0,0 +1,40 @@ +/* foo.c -- trivial test library + Copyright (C) 1998-1999 Free Software Foundation, Inc. + Originally by Thomas Tanner + This file is part of GNU Libtool. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +USA. */ + +#include "foo.h" +#include + +#ifdef HAVE_MATH_H +#include +#endif + +int +foo() +{ + printf ("cos (0.0) = %g\n", (double) cos ((double) 0.0)); + return FOO_RET; +} + +int +hello() +{ + printf ("** This is libfoo **\n"); + return HELLO_RET; +} diff --git a/tests/cdemo/foo.h b/tests/cdemo/foo.h new file mode 100644 index 000000000..48dc9127e --- /dev/null +++ b/tests/cdemo/foo.h @@ -0,0 +1,29 @@ +/* foo.h -- interface to the libfoo* libraries + Copyright (C) 1998-1999 Free Software Foundation, Inc. + Originally by Thomas Tanner + This file is part of GNU Libtool. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +USA. */ + +/* Only include this header file once. */ +#ifndef _FOO_H_ +#define _FOO_H_ 1 + +/* Silly constants that the functions return. */ +#define HELLO_RET 0xe110 +#define FOO_RET 0xf00 + +#endif /* !_FOO_H_ */ diff --git a/tests/cdemo/main.c b/tests/cdemo/main.c new file mode 100644 index 000000000..89da831bb --- /dev/null +++ b/tests/cdemo/main.c @@ -0,0 +1,43 @@ +/* main.c -- cdemo test program + Copyright (C) 1998-1999 Free Software Foundation, Inc. + Originally by Thomas Tanner + This file is part of GNU Libtool. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +USA. */ + +#include "foo.h" +#include + + +int +main (argc,argv) + int argc; + char **argv; +{ + int value; + + printf ("Welcome to GNU libtool cdemo!\n"); + + value = hello(); + printf ("hello returned: %i\n", value); + if (value == HELLO_RET) + printf("hello is ok!\n"); + + if (foo () == FOO_RET) + printf("foo is ok!\n"); + + return 0; +} diff --git a/tests/defs b/tests/defs index 8713e853f..3ad5d6c8c 100644 --- a/tests/defs +++ b/tests/defs @@ -1,6 +1,7 @@ # -*- sh -*- # Defines for Libtool testing environment. # Gord Matzigkeit , 1996 +# Gary V. Vaughan , 2003 # Check that srcdir is set to an absolute path. case "$srcdir" in @@ -8,11 +9,16 @@ case "$srcdir" in *) srcdir=`cd $srcdir && pwd` ;; esac -progname=`echo "$0" | sed 's%^.*/%%'` +sed_basename='s,^.*/,,g' +sed_dirname='s,/[^/]*$,,' + +progname=`echo "$0" | sed "$sed_basename"` libtool="../libtool" +prefix="./_inst" make="${MAKE-make}" SHELL="${CONFIG_SHELL-/bin/sh}" +MKDIR="${MKDIR-mkdir}" if echo a | (grep -E '(a|b)') >/dev/null 2>&1; then EGREP='grep -E' @@ -25,22 +31,6 @@ else FGREP='fgrep' fi -prefix="./_inst" -if test "$need_prefix" = yes; then - # An absolute path to a test installation directory. - test -d $prefix || mkdir $prefix - prefix=`cd $prefix && pwd` -else - test -d $prefix && rm -rf $prefix - prefix=NONE -fi - -# Extract CC from the libtool configuration -eval `$libtool --config | grep '^CC='` - -# Extract host from the libtool configuration -eval `$libtool --config | grep '^host='` - # Disable usage of config.site for autoconf, unless DJGPP is present. # The DJGPP port of autoconf requires config.site, to work correctly. if test -z "$DJGPP"; then @@ -48,10 +38,272 @@ if test -z "$DJGPP"; then fi # See how redirections should work. +test "${VERBOSE+set}" != "set" && VERBOSE=no case "$VERBOSE" in NO | no | 0 | "") exec > /dev/null 2>&1 ;; esac + +EXIT_SUCCESS=0 +EXIT_FAILURE=1 +EXIT_SKIP=77 + +# func_msg arg... +# Echo message with prefix. +func_msg () +{ + echo "=" ${1+"$@"} +} + +# func_error arg... +# Echo message to standard error. +func_error () +{ + echo ${1+"$@"} 1>&2 +} + +# func_skip arg... +# Echo message to standard error, and skip the rest of this test. +func_skip () +{ + func_error ${1+"$@"} + exit $EXIT_SKIP +} + +# func_fail arg... +# Echo message to standard error, and fail this test. +func_fail () +{ + func_error ${1+"$@"} + exit $EXIT_FAILURE +} + +# func_get_config varname_list src [failp] [regex] +func_get_config () +{ + my_varname_list="$1" + my_src="$2" + my_failp="false"; test -z "$3" || my_failp=: + my_regex="$4" + + my_exitp=false + for my_varname in $my_varname_list; do + test -z "$4" && my_regex="^${my_varname}=" + + eval $my_varname=NONE + eval `eval $my_src | eval grep \"$my_regex\"` + + if eval test x\"\$$my_varname\" = xNONE; then + func_error "$my_varname not set in \`$my_src'" + $my_failp && my_exitp=: + fi + done + + $my_exitp && exit $EXIT_FAILURE +} + + +# Extract objext from the libtool configuration +func_get_config "objext" "$libtool --config" ": fatal" + +# Extract objdir from the libtool configuration +func_get_config "objdir" "$libtool --config" ": fatal" + +# Extract CC from the libtool configuration +func_get_config "CC" "$libtool --config" ": fatal" + +# Extract host from the libtool configuration +func_get_config "host" "$libtool --config" ": fatal" + + +# func_grep expression filename +# Check whether EXPRESSION matches any line of FILENAME, without output. +func_grep () +{ + grep "$1" "$2" >/dev/null 2>&1 +} + +# func_mkdir_p dir +# Make sure the entire path to DIR is available. +func_mkdir_p () +{ + my_dir=$1 + my_dirs= + + while test ! -d "$my_dir"; do + my_dirs="$my_dir $my_dirs" + case $my_dir in */*) ;; *) break ;; esac + my_dir=`echo "$my_dir" | sed "$sed_dirname"` + done + test ! -n "$my_dirs" || $MKDIR $my_dirs +} + +# func_mkprefixdir +func_mkprefixdir () +{ + # An absolute path to a test installation directory. + func_mkdir_p "$prefix" + prefix=`cd $prefix && pwd` +} + +# func_rmprefixdir +func_rmprefixdir () +{ + test -d $prefix && rm -rf $prefix + prefix=NONE +} + +# func_cd dir +# Make sure a directory exists, and then change to it. +func_cd () +{ + my_dir="$1" + + # Maybe we have a VPATH build, in which case, create a new subdir. + func_mkdir_p "$my_dir" + + # Change to our build directory. + cd "$my_dir" || exit 1 +} + + +# func_require prereq file [...] +# If FILE does not exist, give a fatal error regarding running PREREQ first. +func_require () +{ + my_prereq="$1"; shift + my_files=${1+"$@"} + + for my_file in $my_files; do + test -f "$my_file" \ + || func_skip "You must run ${my_prereq}.test before running $0" + done +} + +# func_configure [args ...] +# Configure the demonstration. +func_configure () +{ + my_args=${1+"$@"} + my_dir=`pwd | sed "$sed_basename"` + my_testdir="$srcdir/$my_dir" + + test -n "$my_args" && my_args=" $my_args" + func_msg "Configuring in $my_dir (--prefix=$prefix$my_args)" + + my_args="--srcdir="\""$my_testdir"\"" --prefix="\""$prefix"\""$my_args" + + eval $SHELL "$my_testdir/configure" $my_args || exit $EXIT_FAILURE +} + +# func_check_static_shared staticp sharedp +# Determine whether the generated libtool script is configured properly +# for the expected STATICP and SHAREDP library building +func_check_static_shared () +{ + my_staticp="$1" + my_sharedp="$2" + + if func_grep "^build_old_libs=$staticp" libtool && + func_grep "^build_libtool_libs=$sharedp" libtool; then : + else + rm -f Makefile + exit $EXIT_FAIL + fi +} + + +# func_make [args ...] +# Do the actual build. +func_make () +{ + my_args=${1+"$@"} + my_dir=`pwd | sed "$sed_basename"` + + func_msg "Running \`$make $my_args' in $my_dir" + + eval $make $my_args || exit $EXIT_FAIL +} + + +# func_distclean +# Possibly clean up the distribution. +func_make_distclean () +{ + if test -f Makefile; then + func_make distclean + fi + rm -rf autom4te.cache config.cache +} + + +# func_make_uninstall +# See that there were no files leftover in $prefix. +# Ignore dotfiles, so that .nfsXXX files don't screw up the test. +func_make_uninstall () +{ + func_make uninstall + + leftovers=`find $prefix ! -type d ! -name '.*' -print` + if test -n "$leftovers"; then + func_msg "Leftover after make uninstall:" + ls -l $leftovers + exit 1 + fi +} + + +# func_exec_init mode +func_exec_init () +{ + func_msg "Executing $1 programs in $my_dir" + + # Windows hosts search for dlls in the command path + PATH=$prefix/lib:$PATH + + exec_status=$EXIT_SUCCESS +} + +# func_exec_check program [msg ...] +# Check to see if PROGRAM was built. If not display MSG. +func_exec_check () +{ + my_program="$1" + + if test -f "$my_program"; then : + else + shift + func_error "$0: $my_program did not build ${1+$@}" + exec_status=$EXIT_FAILURE + fi +} + +# func_exec program [exp_output] [msg ...] +# Check to see if PROGRAM really runs, and produces EXP_OUTPUT if given. +# If not display MSG. +func_exec () +{ + my_program="$1" + my_exp_output="$2" + my_dir=`pwd | sed "$sed_basename"` + + test -n "$my_exp_output" \ + && my_exp_output="| $EGREP -e "\""$my_exp_output"\" + + if eval $my_program $my_exp_output; then : + else + shift; shift + func_error "$0: cannot execute $my_program ${1+$@}" + + # Simple check to see if they are superuser. + if test $exec_status = $EXIT_FAILURE || test -w /; then : + else + func_msg "You may need to run $0 as the superuser." + fi + exec_status=$EXIT_FAILURE + fi +} + echo "=== Running $progname" diff --git a/tests/demo-conf.test b/tests/demo-conf.test index 689644528..3ca4d4754 100755 --- a/tests/demo-conf.test +++ b/tests/demo-conf.test @@ -1,35 +1,36 @@ #! /bin/sh -# demo-conf.test - try configuring the ../demo subdirectory +# demo-conf.test - try configuring the demo subdirectory + +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. -# Test script header. -need_prefix=yes if test -z "$srcdir"; then srcdir=`echo "$0" | sed 's%/[^/]*$%%'` test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes fi . $srcdir/defs || exit 1 -# Maybe we have a VPATH build, in which case, create a new subdir. -test -d ../demo || mkdir ../demo - -# Change to our build directory. -cd ../demo || exit 1 - -# Possibly clean up the distribution. -if test -f Makefile; then - echo "= Running $make distclean in ../demo" - $make distclean -fi -rm -f config.cache - -# Configure the demonstration. -echo "= Configuring in ../demo (prefix=$prefix)" -${CONFIG_SHELL-/bin/sh} $srcdir/../demo/configure --srcdir=$srcdir/../demo --prefix=$prefix --build=$host || exit 1 - -if grep '^build_old_libs=yes' libtool > /dev/null && - grep '^build_libtool_libs=yes' libtool > /dev/null; then : -else rm -f Makefile && exit 77 -fi +func_mkprefixdir +func_cd "demo" +func_make_distclean +func_configure +func_check_static_shared "yes" "yes" exit 0 diff --git a/tests/demo-deplibs.test b/tests/demo-deplibs.test new file mode 100755 index 000000000..d0aec516d --- /dev/null +++ b/tests/demo-deplibs.test @@ -0,0 +1,40 @@ +#! /bin/sh +# demo-deplibs.test - check whether the shared library check method is OK + +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. + +if test -z "$srcdir"; then + srcdir=`echo "$0" | sed 's%/[^/]*$%%'` + test "$srcdir" = "$0" && srcdir=. +fi +. $srcdir/defs || exit 1 + +func_require "demo-conf" "demo/libhello.la" + +func_mkprefixdir +func_cd "demo" +echo "linking a shared library against a static library" +func_make "deplibs-check" +func_exec_init "uninstalled" +func_exec_check "hell0$EXEEXT" "check your deplibs_check_method" +func_exec "./hell0" "" "check your deplibs_check_method" + +exit $exec_status diff --git a/tests/demo-exec.test b/tests/demo-exec.test index 9402f443c..b262d96ca 100755 --- a/tests/demo-exec.test +++ b/tests/demo-exec.test @@ -1,41 +1,38 @@ #! /bin/sh # demo-exec.test - check that programs in the ../demo subdirectory are viable -# Test script header. -need_prefix=no +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. + if test -z "$srcdir"; then srcdir=`echo "$0" | sed 's%/[^/]*$%%'` test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes fi . $srcdir/defs || exit 1 -if test -f ../demo/hell$EXEEXT; then : -else - echo "You must run demo-make.test before running $0" 1>&2 - exit 77 -fi +func_require "demo-make" "demo/hell$EXEEXT" -# Check to see if the programs really run. -echo "Executing uninstalled programs in ../demo" - -status=0 -if ../demo/hell_static| grep 'Welcome to GNU Hell'; then : -else - echo "$0: cannot execute ../demo/hell_static" 1>&2 - status=1 -fi - -if ../demo/hell | grep 'Welcome to GNU Hell'; then : -else - echo "$0: cannot execute ../demo/hell" 1>&2 - status=1 -fi - -if ../demo/helldl | $EGREP -e '(Welcome to .*GNU Hell|unsupported)'; then : -else - echo "$0: cannot execute ../demo/helldl" 1>&2 - status=1 -fi +func_rmprefixdir +func_exec_init "uninstalled" +func_exec "demo/hell_static" 'Welcome to GNU Hell' +func_exec "demo/hell" 'Welcome to GNU Hell' +func_exec "demo/helldl" '(Welcome to .*GNU Hell|unsupported)' -exit $status +exit $exec_status diff --git a/tests/hardcode.test b/tests/demo-hardcode.test similarity index 52% rename from tests/hardcode.test rename to tests/demo-hardcode.test index f264e03bd..3ab67eae7 100755 --- a/tests/hardcode.test +++ b/tests/demo-hardcode.test @@ -1,83 +1,57 @@ #! /bin/sh -# hardcode.test - check to see what the system linker hardcodes +# demo-hardcode.test - check to see what the system linker hardcodes + +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. -# Test script header. -need_prefix=yes if test -z "$srcdir"; then srcdir=`echo "$0" | sed 's%/[^/]*$%%'` test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes fi . $srcdir/defs || exit 1 -# Check that things are built. -if test -f $prefix/lib/libhello.la && cd ../demo; then : -else - echo "You must run demo-inst.test before $0" 1>&2 - exit 77 -fi +func_require "demo-inst" "$prefix/lib/libhello.la" -# Unfortunately, we need access to libtool internals for this test. -objdir=NONE -eval `grep '^objdir=' ./libtool 2>/dev/null` -if test "$objdir" = NONE; then - echo "objdir not set in ../demo/libtool" 1>&2 - exit 1 -fi +func_mkprefixdir +func_cd "demo" # Check to make sure we have a dynamic library. -library_names=NONE -eval `grep '^library_names=' ./libhello.la 2>/dev/null` - -if test "$library_names" = NONE; then - echo "library_names not set in ../demo/libhello.la" 1>&2 - exit 1 -elif test -z "$library_names"; then - echo "= Exiting: ../demo/libhello.la is not a shared library" - exit 0 -fi - -echo "= Running $make hardcode in ../demo" -$make hardcode || exit 1 +func_get_config "library_names" "cat ./libhello.la" +test -z "$library_names" \ + && func_skip "Exiting: demo/libhello.la is not a shared library" -echo "= Finding libtool.m4's guesses at hardcoding values" -status=0 -hardcode_direct=NONE -hardcode_minus_L=NONE -hardcode_shlibpath_var=NONE -hardcode_libdir_flag_spec=NONE +func_make "hardcode" # Suck in all the hardcode_* variable settings. -eval `./libtool --config | grep '^hardcode_' 2>/dev/null` - -if test "$hardcode_direct" = NONE; then - echo "hardcode_direct not set in ../demo/libtool" 1>&2 - status=1 -fi - -if test "$hardcode_minus_L" = NONE; then - echo "hardcode_minus_L not set in ../demo/libtool" 1>&2 - status=1 -fi - -if test "$hardcode_shlibpath_var" = NONE; then - echo "hardcode_shlibpath_var not set in ../demo/libtool" 1>&2 - status=1 -fi - -if test "$hardcode_libdir_flag_spec" = NONE; then - echo "hardcode_libdir_flag_spec not set in ../demo/libtool" 1>&2 - status=1 -fi - -test $status -eq 0 || exit $status +func_msg "Finding libtool.m4's guesses at hardcoding values" +func_get_config 'hardcode_direct +hardcode_minus_L +hardcode_shlibpath_var +hardcode_libdir_flag_spec' "libtool --config" ": fatal" echo "= Searching for hardcoded library directories in each program" for file in hc-*; do case "$file" in - hc-direct) expected="$hardcode_direct" ;; + hc-direct) expected="$hardcode_direct" ;; hc-libpath) expected="$hardcode_shlibpath_var" ;; - hc-minusL) expected="$hardcode_minus_L" ;; + hc-minusL) expected="$hardcode_minus_L" ;; hc-libflag) if test -n "$hardcode_libdir_flag_spec"; then @@ -117,7 +91,7 @@ for file in hc-*; do echo "$objdir was hardcoded in \`$file', as libtool expected" else echo "$objdir was hardcoded in \`$file', which fooled libtool" 1>&2 - status=1 + exit_status=1 fi ;; @@ -126,7 +100,7 @@ for file in hc-*; do echo "$objdir was not hardcoded in \`$file', as libtool expected" else echo "$objdir was not hardcoded in \`$file', which fooled libtool" 1>&2 - status=1 + exit_status=1 fi ;; @@ -135,10 +109,10 @@ for file in hc-*; do echo "\`$file' was not linked properly, as libtool expected" else echo "\`$file' was not linked properly, which fooled libtool" 1>&2 - status=1 + exit_status=1 fi ;; esac done -exit $status +exit $exit_status diff --git a/tests/demo-inst.test b/tests/demo-inst.test index 9e38d9d0e..98e762aea 100755 --- a/tests/demo-inst.test +++ b/tests/demo-inst.test @@ -1,58 +1,40 @@ #! /bin/sh -# demo-inst.test - try installing from the ../demo subdirectory +# demo-inst.test - try installing from the demo subdirectory + +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. -# Test script header. -need_prefix=yes if test -z "$srcdir"; then srcdir=`echo "$0" | sed 's%/[^/]*$%%'` test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes fi . $srcdir/defs || exit 1 -# Check that things are built. -if test -f ../demo/hell$EXEEXT; then : -else - echo "You must run demo-make.test before $0" 1>&2 - exit 77 -fi - -# Change to our build directory. -cd ../demo || exit 1 - -echo "= Running $make install in ../demo" -$make install || exit 1 - -echo "= Executing installed programs" -status=0 -if $prefix/bin/hell_static | grep 'Welcome to GNU Hell'; then : -else - echo "$0: cannot execute $prefix/bin/hell_static" 1>&2 - status=1 -fi +func_require "demo-make" "demo/hell$EXEEXT" -if $prefix/bin/hell | grep 'Welcome to GNU Hell'; then : -else - echo "$0: cannot execute $prefix/bin/hell" 1>&2 - - # Simple check to see if they are superuser. - if test -w /; then : - else - echo "You may need to run $0 as the superuser." - fi - status=1 -fi - -if $prefix/bin/helldl | $EGREP -e '(Welcome to .*GNU Hell|unsupported)'; then : -else - echo "$0: cannot execute $prefix/bin/helldl" 1>&2 - - # Simple check to see if they are superuser. - if test -w /; then : - else - echo "You may need to run $0 as the superuser." - fi - status=1 -fi +func_mkprefixdir +func_cd "demo" +func_make "install" +func_exec_init "installed" +func_exec "$prefix/bin/hell_static" 'Welcome to GNU Hell' +func_exec "$prefix/bin/hell" 'Welcome to GNU Hell' +func_exec "$prefix/bin/helldl" '(Welcome to .*GNU Hell|unsupported)' exit $status diff --git a/tests/demo-make.test b/tests/demo-make.test index 8a4a4ba85..7dedcbf6a 100755 --- a/tests/demo-make.test +++ b/tests/demo-make.test @@ -1,25 +1,36 @@ #! /bin/sh -# demo-make.test - try building in the ../demo subdirectory +# demo-make.test - try building in the demo subdirectory + +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. -# Test script header. -need_prefix=no if test -z "$srcdir"; then srcdir=`echo "$0" | sed 's%/[^/]*$%%'` test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes fi . $srcdir/defs || exit 1 -if test -f ../demo/Makefile; then : -else - echo "You must run demo-conf.test before running $0" 1>&2 - exit 77 -fi +func_require "demo-conf" "demo/Makefile" -# Change to our build directory. -cd ../demo || exit 1 +func_rmprefixdir +func_cd "demo" +func_make -# Do the actual build. -echo "Making in ../demo" -$make || exit 1 exit 0 diff --git a/tests/demo-nofast.test b/tests/demo-nofast.test index 73ed59fd7..01af96389 100755 --- a/tests/demo-nofast.test +++ b/tests/demo-nofast.test @@ -1,34 +1,40 @@ #! /bin/sh # demo-nofast.test - try configuring the ../demo subdirectory -# Test script header. -need_prefix=yes +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. + if test -z "$srcdir"; then srcdir=`echo "$0" | sed 's%/[^/]*$%%'` test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes fi . $srcdir/defs || exit 1 -# Maybe we have a VPATH build, in which case, create a new subdir. -test -d ../demo || mkdir ../demo - -# Change to our build directory. -cd ../demo || exit 1 - -# Possibly clean up the distribution. -if test -f Makefile; then - echo "= Running $make distclean in ../demo" - $make distclean -fi -rm -f config.cache - -# Configure the demonstration. -echo "= Configuring in ../demo (prefix=$prefix)" -${CONFIG_SHELL-/bin/sh} $srcdir/../demo/configure --srcdir=$srcdir/../demo --prefix=$prefix --build=$host --enable-fast-install=no || exit 1 +func_mkprefixdir +func_cd "demo" +func_make_distclean +func_configure "--enable-fast-install=no" -if grep '^hardcode_action=relink' libtool > /dev/null; then - rm -f Makefile && exit 77 +if func_grep '^hardcode_action=relink' libtool; then + rm -f Makefile + exit 77 fi exit 0 diff --git a/tests/demo-noinst-link.test b/tests/demo-noinst-link.test new file mode 100755 index 000000000..f87f740f5 --- /dev/null +++ b/tests/demo-noinst-link.test @@ -0,0 +1,62 @@ +#! /bin/sh +# demo-noinst-link.test - make sure we do not link with an installed +# library when an uninstalled one is to be used + +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. + +if test -z "$srcdir"; then + srcdir=`echo "$0" | sed 's%/[^/]*$%%'` + test "$srcdir" = "$0" && srcdir=. +fi +. $srcdir/defs || exit 1 + +func_restore_files () +{ + mv -f "$objdir"/temp/libs/* "$objdir" + mv -f "$objdir/temp/libhello.la" "$objdir/temp/hell$EXEEXT" . + rm -rf "$objdir/temp" +} + +func_save_files () +{ + func_mkdir_p "$objdir/temp/libs" + cp -f libhello.la "hell$EXEEXT" "$objdir/temp" + cp -f "$objdir"/* "$objdir"/temp/libs + trap "func_restore_files" 0 1 2 13 15 +} + +func_require "demo-inst" "$prefix/lib/libhello.la" + +func_mkprefixdir +func_cd "demo" +func_save_files + +func_msg "removing \`libhello.la' and \`hell' from demo" +rm -f libhello.la "hell$EXEEXT" + +status=$EXIT_SUCCESS +func_msg "linking \`hell' with a broken \`demo/libhello.la'" +if $make "hell$EXEEXT" libhello_la_OBJECTS=hello.lo; then + func_msg "Succeeded: this means the installed library was used, which is wrong" + status=$EXIT_FAILURE +fi + +exit $status diff --git a/tests/demo-nopic.test b/tests/demo-nopic.test index f2a4fa662..c31e18116 100755 --- a/tests/demo-nopic.test +++ b/tests/demo-nopic.test @@ -1,30 +1,35 @@ #! /bin/sh # demo-nopic.test - try configuring the ../demo subdirectory -# Test script header. -need_prefix=no +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. + if test -z "$srcdir"; then srcdir=`echo "$0" | sed 's%/[^/]*$%%'` test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes fi . $srcdir/defs || exit 1 -# Maybe we have a VPATH build, in which case, create a new subdir. -test -d ../demo || mkdir ../demo - -# Change to our build directory. -cd ../demo || exit 1 - -# Possibly clean up the distribution. -if test -f Makefile; then - echo "= Running $make distclean in ../demo" - $make distclean -fi -rm -f config.cache - -# Configure the demonstration. -echo "= Configuring in ../demo (prefix=$prefix) with --without-pic" -${CONFIG_SHELL-/bin/sh} $srcdir/../demo/configure --srcdir=$srcdir/../demo --prefix=$prefix --build=$host --with-pic=no || exit 1 +func_rmprefixdir +func_cd "demo" +func_make_distclean +func_configure "--with-pic=no" exit 0 diff --git a/tests/demo-pic.test b/tests/demo-pic.test index 69565bc61..cd4c4f91c 100755 --- a/tests/demo-pic.test +++ b/tests/demo-pic.test @@ -1,30 +1,35 @@ #! /bin/sh # demo-pic.test - try configuring the ../demo subdirectory -# Test script header. -need_prefix=no +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. + if test -z "$srcdir"; then srcdir=`echo "$0" | sed 's%/[^/]*$%%'` test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes fi . $srcdir/defs || exit 1 -# Maybe we have a VPATH build, in which case, create a new subdir. -test -d ../demo || mkdir ../demo - -# Change to our build directory. -cd ../demo || exit 1 - -# Possibly clean up the distribution. -if test -f Makefile; then - echo "= Running $make distclean in ../demo" - $make distclean -fi -rm -f config.cache - -# Configure the demonstration. -echo "= Configuring in ../demo (prefix=$prefix) with --with-pic" -${CONFIG_SHELL-/bin/sh} $srcdir/../demo/configure --srcdir=$srcdir/../demo --prefix=$prefix --build=$host --with-pic=yes || exit 1 +func_rmprefixdir +func_cd "demo" +func_make_distclean +func_configure "--with-pic=yes" exit 0 diff --git a/tests/demo-relink.test b/tests/demo-relink.test new file mode 100755 index 000000000..5162069af --- /dev/null +++ b/tests/demo-relink.test @@ -0,0 +1,106 @@ +#! /bin/sh +# demo-relink.test - check to see whether shlibpath overrides runpath + +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. + +if test -z "$srcdir"; then + srcdir=`echo "$0" | sed 's%/[^/]*$%%'` + test "$srcdir" = "$0" && srcdir=. +fi +. $srcdir/defs || exit 1 + +func_restore_files () +{ + mv -f "$objdir"/temp/libs/* "$objdir" + mv -f "$objdir/temp/libhello.la" . + rm -rf "$objdir/temp" +} + +func_save_files () +{ + func_mkdir_p "$objdir/temp/libs" + cp -f libhello.la "$objdir/temp" + cp -f "$objdir"/libhello.* "$objdir/lt-hell$EXEEXT" "$objdir/temp/libs" + trap "func_restore_files" 0 1 2 13 15 +} + +func_require "demo-inst" "$prefix/lib/libhello.la" "demo/libhello.la" + +func_mkprefixdir +func_cd "demo" +func_save_files + +# Check to make sure we have a dynamic library. +func_get_config "library_names" "cat libhello.la" +test -z "$library_names" \ + && func_fatal_error "Exiting: demo/libhello.la is not a shared library" + +func_get_config 'shlibpath_overrides_runpath +hardcode_action +hardcode_direct +hardcode_into_libs' "./libtool --config" ": fatal" + +./hell # so that it links on-demand if needed + +func_msg "removing libhello.la from demo" +rm -f libhello.la "$objdir"/libhello.* + +func_msg "running demo/hell" +if ./hell; then + : +elif test "x,$hardcode_action,$hardcode_direct" = x,relink,yes; then + func_msg "Ok, uninstalled programs fail after uninstalled libraries are removed." + func_msg "This works in other configurations, but not in this particular one." +else + func_fail "Exiting: demo/hell does not run, maybe libhello was not installed" +fi + +func_msg "linking a broken demo/libhello.la" +func_make libhello.la libhello_la_OBJECTS=hello.lo \ + || func_fail "Exiting: cannot link broken libhello.la" +rm -f libhello.la + +func_msg "running demo/hell with broken libhello.la" +if (./hell) 2>&1; then + func_msg "Exiting: demo/hell runs even though libhello.la is incomplete" + func_fail "shlibpath_overrides_runpath should be set to no" +else + func_msg "Failed, as expected" +fi + +if test "x$hardcode_action" = xrelink; then + func_msg "Exiting: install-time relinking is required" + exit $EXIT_SUCCESS +fi + +if test "$shlibpath_overrides_runpath" != yes; then + rm -f $objdir/lt-hell$EXEEXT || exit $EXIT_FAILURE + cp $objdir/hell$EXEEXT $objdir/lt-hell$EXEEXT || exit $EXIT_FAILURE + func_msg "running demo/hell with installed libhello.la" + if ./hell; then + func_msg "Worked, as expected" + else + func_msg "shlibpath_overrides_runpath should be set to yes" + status=$EXIT_FAILURE + fi +fi + +exit $status diff --git a/tests/demo-shared.test b/tests/demo-shared.test index 2f00da0e8..248ecc5e5 100755 --- a/tests/demo-shared.test +++ b/tests/demo-shared.test @@ -1,35 +1,36 @@ #! /bin/sh -# demo-conf.test - try configuring the ../demo subdirectory +# demo-shared.test - try configuring the demo subdirectory for shared libs + +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. -# Test script header. -need_prefix=yes if test -z "$srcdir"; then srcdir=`echo "$0" | sed 's%/[^/]*$%%'` test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes fi . $srcdir/defs || exit 1 -# Maybe we have a VPATH build, in which case, create a new subdir. -test -d ../demo || mkdir ../demo - -# Change to our build directory. -cd ../demo || exit 1 - -# Possibly clean up the distribution. -if test -f Makefile; then - echo "= Running $make distclean in ../demo" - $make distclean -fi -rm -f config.cache - -# Configure the demonstration. -echo "= Configuring in ../demo (prefix=$prefix) with --disable-static" -${CONFIG_SHELL-/bin/sh} $srcdir/../demo/configure --srcdir=$srcdir/../demo --prefix=$prefix --build=$host --disable-static || exit 1 - -if grep '^build_old_libs=no' libtool > /dev/null && - grep '^build_libtool_libs=yes' libtool > /dev/null; then : -else rm -f Makefile && exit 77 -fi +func_mkprefixdir +func_cd "demo" +func_make_distclean +func_configure "--disable-static" +func_check_static_shared "no" "yes" exit 0 diff --git a/tests/demo-static.test b/tests/demo-static.test index 58d9544ed..b32c5f9f9 100755 --- a/tests/demo-static.test +++ b/tests/demo-static.test @@ -1,35 +1,17 @@ #! /bin/sh -# demo-conf.test - try configuring the ../demo subdirectory +# demo-static.test - try configuring the demo subdirectory # Test script header. -need_prefix=yes if test -z "$srcdir"; then srcdir=`echo "$0" | sed 's%/[^/]*$%%'` test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes fi . $srcdir/defs || exit 1 -# Maybe we have a VPATH build, in which case, create a new subdir. -test -d ../demo || mkdir ../demo - -# Change to our build directory. -cd ../demo || exit 1 - -# Possibly clean up the distribution. -if test -f Makefile; then - echo "= Running $make distclean in ../demo" - $make distclean -fi -rm -f config.cache - -# Configure the demonstration. -echo "= Configuring in ../demo (prefix=$prefix) with --disable-shared" -${CONFIG_SHELL-/bin/sh} $srcdir/../demo/configure --srcdir=$srcdir/../demo --prefix=$prefix --build=$host --disable-shared || exit 1 - -if grep '^build_old_libs=yes' libtool > /dev/null && - grep '^build_libtool_libs=no' libtool > /dev/null; then : -else rm -f Makefile && exit 77 -fi +func_mkprefixdir +func_cd "demo" +func_make_distclean +func_configure "--disable-shared" +func_check_static_shared "yes" "no" exit 0 diff --git a/tests/demo-unst.test b/tests/demo-unst.test index 172c19b1a..6aca67590 100755 --- a/tests/demo-unst.test +++ b/tests/demo-unst.test @@ -1,32 +1,36 @@ #! /bin/sh -# demo.test - try uninstalling in the ../demo subdirectory +# demo-unst.test - try uninstalling in the demo subdirectory + +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. -# Test script header. -need_prefix=yes if test -z "$srcdir"; then srcdir=`echo "$0" | sed 's%/[^/]*$%%'` test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes fi . $srcdir/defs || exit 1 -# Make sure it was installed already -if test "$prefix/bin/hell" && cd ../demo && test -f Makefile; then : -else - echo "You must run demo-inst.test before $0." 1>&2 - exit 77 -fi +func_require "demo-inst" "$prefix/bin/hell$EXEEXT" "demo/Makefile" -echo "= Running $make uninstall in ../demo" -$make uninstall || exit 1 - -# See that there were no files leftover in $prefix. -# Ignore dotfiles, so that .nfsXXX files don't screw up the test. -leftovers=`find $prefix ! -type d ! -name '.*' -print` -if test -n "$leftovers"; then - echo "= Leftover after make uninstall:" - ls -l $leftovers - exit 1 -fi +func_mkprefixdir +func_cd "demo" +func_make_uninstall exit 0 diff --git a/tests/demo/.cvsignore b/tests/demo/.cvsignore new file mode 100644 index 000000000..244811270 --- /dev/null +++ b/tests/demo/.cvsignore @@ -0,0 +1,20 @@ +.deps +.libs +Makefile +Makefile.in +acinclude.m4 +aclocal.m4 +autom4te.cache +configure +config.* +conftest* +hc-direct +hc-libflag +hc-libpath +hc-minusL +libtool +*.lo +*.la +hell +hell_static +helldl diff --git a/tests/demo/Makefile.am b/tests/demo/Makefile.am new file mode 100644 index 000000000..87fd42a48 --- /dev/null +++ b/tests/demo/Makefile.am @@ -0,0 +1,163 @@ +## Makefile.am -- Process this file with automake to produce Makefile.in +## +## Copyright (C) 2003 Free Software Foundation +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2 of the License, or +## (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program; see the file COPYING. If not, write to +## the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +## Boston, MA 02111-1307, USA. + +top_distdir = ../.. + +AUTOMAKE_OPTIONS = no-dependencies foreign +ACLOCAL_AMFLAGS = -I$(top_distdir)/m4 + +# Build a libtool library, libhello.la for installation in libdir. +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 + +include_HEADERS = foo.h + +if BINARY_HELLDL +BUILD_helldl = helldl +else +BUILD_helldl = +endif + +bin_PROGRAMS = hell hell_static $(BUILD_helldl) + +# Build hell from main.c and libhello.la +hell_SOURCES = main.c +hell_LDADD = libhello.la + +# Create a statically linked version of hell. +hell_static_SOURCES = main.c +hell_static_LDADD = libhello.la +hell_static_LDFLAGS = $(STATIC) + +if BINARY_HELLDL + +# Create a version of hell that does a preloaded dlopen. +helldl_SOURCES = dlmain.c +helldl_LDFLAGS = -export-dynamic -dlpreopen libhello.la +helldl_DEPENDENCIES = libhello.la + +else + +bin_SCRIPTS = helldl +# create a script that says that -dlopen is not supported +helldl helldl$(EXEEXT): + rm -f $@ + echo '#! /bin/sh' > $@ + echo '-dlopen is unsupported' >> $@ + chmod +x $@ +endif + +$(OBJECTS): libtool +libtool: $(LIBTOOL_DEPS) + $(SHELL) ./config.status --recheck + +#---------------------------------------------------------------------- +# The following declarations are only used in the testsuite: +#---------------------------------------------------------------------- + +hardcode_tests = hc-direct hc-libflag hc-libpath hc-minusL +CLEANFILES = $(hardcode_tests) + +# Unfortunately, in order to test libtool thoroughly, we need access +# to its private directory. +objdir = `$(LIBTOOL) --config | sed -n -e 's/^objdir=\(.*\)$$/\1/p'` + +# The following rules are only for the libtool demo and tests. +# Regenerate our acinclude.m4 only if it doesn't exist. +$(srcdir)/acinclude.m4: + rm -f $(srcdir)/acinclude.m4 + cd $(srcdir) && $(LN_S) ../libtool.m4 acinclude.m4 + + +# Test programs to see what gets hardcoded. +.PHONY: hardcode +hardcode: $(hardcode_tests) +SET_HARDCODE_FLAGS = \ + eval `$(LIBTOOL) --config | sed -n -e '/^hardcode_.*=/p; /^wl=/p'` +hc-direct: $(hell_OBJECTS) $(hell_DEPENDENCIES) $(libdir)/libhello.la + @rm -f hc-direct + @echo "You may ignore any linking errors from the following command:" + @shlib=./$(objdir)/libhello.a; \ + eval "`grep '^library_names' libhello.la`"; \ + for lib in $$library_names; do \ + shlib="./$(objdir)/$$lib"; \ + done; \ + $(SET_HARDCODE_FLAGS); \ + libdir=$(libdir); \ + flag=`eval echo \"$$hardcode_libdir_flag_spec\"`; \ + echo "$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(hell_OBJECTS) $$shlib $(LIBS) $(LIBM) $$flag || echo unsupported > $@"; \ + eval "$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(hell_OBJECTS) $$shlib $(LIBS) $(LIBM) $$flag || echo unsupported > $@" + +hc-libflag: $(hell_OBJECTS) $(hell_DEPENDENCIES) $(libdir)/libhello.la + @$(SET_HARDCODE_FLAGS); \ + libdir=`pwd`/$(objdir); \ + flag=`eval echo \"$$hardcode_libdir_flag_spec\"`; \ + if test -z "$$flag"; then \ + echo "echo unsupported > $@"; \ + echo unsupported > $@ || status="$$?"; \ + else \ + echo "$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(hell_OBJECTS) $$flag -L$(libdir) -lhello $(LIBS) $(LIBM)"; \ + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(hell_OBJECTS) $$flag -L$(libdir) -lhello $(LIBS) $(LIBM) || status="$$?"; \ + fi; \ + exit $$status + +hc-libpath: $(hell_OBJECTS) $(hell_DEPENDENCIES) $(libdir)/libhello.la + @rm -f hc-libpath + @echo "You may ignore any linking errors from the following command:" + @$(SET_HARDCODE_FLAGS); \ + eval `$(LIBTOOL) --config | grep '^shlibpath_var='`; \ + libdir=$(libdir); \ + flag=`eval echo \"$$hardcode_libdir_flag_spec\"`; \ + echo "$$shlibpath_var=./$(objdir) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(hell_OBJECTS) -lhello $(LIBS) $(LIBM) $$flag || echo unsupported > $@"; \ + eval "$$shlibpath_var=./$(objdir) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(hell_OBJECTS) -lhello $(LIBS) $(LIBM) $$flag || echo unsupported > $@" + +hc-minusL: $(hell_OBJECTS) $(hell_DEPENDENCIES) + @rm -f hc-minusL + @$(SET_HARDCODE_FLAGS); \ + libdir=$(libdir); \ + flag=`eval echo \"$$hardcode_libdir_flag_spec\"`; \ + echo "$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(hell_OBJECTS) -L./$(objdir) -lhello $(LIBS) $(LIBM) $$flag || echo unsupported > $@"; \ + eval "$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(hell_OBJECTS) -L./$(objdir) -lhello $(LIBS) $(LIBM) $$flag || echo unsupported > $@" + +# This is one of the essential tests for deplibs_check_method=pass_all. +# If this one passes with pass_all, it is likely that pass_all works +EXTRA_LIBRARIES = libhell0.a +libhell0_a_SOURCES = hello.c foo.c +EXTRA_LTLIBRARIES = libhell1.la libhell2.la +libhell1_la_SOURCES = hell1.c +libhell1_la_LIBADD = -L. -lhell0 +libhell1_la_LDFLAGS = -no-undefined -rpath $(libdir) +libhell1_la_DEPENDENCIES = libhell0.a +libhell2_la_SOURCES = hell2.c +libhell2_la_LIBADD = -L. -lhell0 +libhell2_la_LDFLAGS = -no-undefined -rpath $(libdir) +libhell2_la_DEPENDENCIES = libhell0.a +EXTRA_PROGRAMS = hell0 +hell0_SOURCES = main.c +hell0_LDADD = libhell1.la libhell2.la $(LIBM) + +# 'hell0' in EXTRA_PROGRAMS gets translated to 'hell0.exe'; but we +# must explicitly list the wrapper script 'hell0'. (bin_PROGRAMS +# are handled seamlessly by automake rules; the extra step is only +# necessary for EXTRA_PROGRAMS) +CLEANFILES += $(EXTRA_LIBRARIES) $(EXTRA_LTLIBRARIES) $(EXTRA_PROGRAMS) hell0 + +deplibs-check: hell0$(EXEEXT) diff --git a/tests/demo/README b/tests/demo/README new file mode 100644 index 000000000..511fd8398 --- /dev/null +++ b/tests/demo/README @@ -0,0 +1,9 @@ +This is GNU hell, an example package that uses GNU libtool with an +Automake-generated environment to build a simple library and program. + +Admittedly, it would be better if this was a more realistic example, +say, a program that actually did something useful, but we can't have +everything. + +Send bug reports and comments about GNU hell to the libtool mailing +list . diff --git a/tests/demo/configure.ac b/tests/demo/configure.ac new file mode 100644 index 000000000..a079e9e4f --- /dev/null +++ b/tests/demo/configure.ac @@ -0,0 +1,80 @@ +## Process this file with autoconf to create configure. -*- autoconf -*- +# Copyright (C) 2001, 2003 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +# 02111-1307 USA + +AC_PREREQ(2.50) + + +## ------------------------ ## +## Autoconf initialisation. ## +## ------------------------ ## +AC_INIT([demo], [1.0], [bug-libtool@gnu.org]) +AC_CONFIG_SRCDIR([hello.c]) +AC_CONFIG_AUX_DIR([../../config]) + + +## ------------------------ ## +## Automake Initialisation. ## +## ------------------------ ## +AM_INIT_AUTOMAKE(AC_PACKAGE_TARNAME, AC_PACKAGE_VERSION) + + +## ---------------- ## +## compiler checks. ## +## ---------------- ## +AC_PROG_CC +AC_C_CONST +AC_EXEEXT + + +## ----------------------- ## +## Libtool initialisation. ## +## ----------------------- ## +AC_LIBTOOL_DLOPEN +AC_LIBTOOL_WIN32_DLL +AM_PROG_LIBTOOL +AC_SUBST([LIBTOOL_DEPS]) + +if ./libtool --features | grep '^enable static libraries$' > /dev/null 2>&1; then + STATIC=-static +else + STATIC= +fi +AC_SUBST([STATIC]) + +AM_CONDITIONAL([BINARY_HELLDL], + [grep '^global_symbol_pipe=..*$' ./libtool >/dev/null]) + + +## ---------------------------- ## +## C headers required by cdemo. ## +## ---------------------------- ## +AC_CHECK_HEADERS([string.h math.h]) + + +## --------------------------- ## +## Libraries required by demo. ## +## --------------------------- ## +AC_CHECK_LIBM +AC_SUBST([LIBM]) + + +## -------- ## +## Outputs. ## +## -------- ## +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT diff --git a/tests/demo/dlmain.c b/tests/demo/dlmain.c new file mode 100644 index 000000000..7c123bb8e --- /dev/null +++ b/tests/demo/dlmain.c @@ -0,0 +1,95 @@ +/* dlmain.c -- hello test program that uses simulated dynamic linking + Copyright (C) 1996-1999 Free Software Foundation, Inc. + This file is part of GNU Libtool. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +USA. */ + +#include "foo.h" +#include + +#ifdef HAVE_STRING_H +#include +#endif + +struct lt_symlist +{ + const char *name; + lt_ptr_t address; +}; + +extern const struct lt_symlist lt_preloaded_symbols[]; + +int +main (argc, argv) + int argc; + char **argv; +{ + const struct lt_symlist *s; + int (*pfoo)() = 0; + int (*phello)() = 0; + int *pnothing = 0; + + printf ("Welcome to *modular* GNU Hell!\n"); + + /* Look up the symbols we require for this demonstration. */ + s = lt_preloaded_symbols; + while (s->name) + { + if (s->address) { + const char *name = s->name; + printf ("found symbol: %s\n", name); + if (!strcmp ("hello", name)) + phello = (int(*)())s->address; + else if (!strcmp ("foo", name)) + pfoo = (int(*)())s->address; + else if (!strcmp ("nothing", name)) +#ifndef _WIN32 + /* In an ideal world we could do this... */ + pnothing = (int*)s->address; +#else /* !_WIN32 */ + /* In an ideal world a shared lib would be able to export data */ + pnothing = (int*)¬hing; +#endif + } else + printf ("found file: %s\n", s->name); + s ++; + } + + /* Try assigning to the nothing variable. */ + if (pnothing) + *pnothing = 1; + else + fprintf (stderr, "did not find the `nothing' variable\n"); + + /* Just call the functions and check return values. */ + if (pfoo) + { + if ((*pfoo) () != FOO_RET) + return 1; + } + else + fprintf (stderr, "did not find the `foo' function\n"); + + if (phello) + { + if ((*phello) () != HELLO_RET) + return 3; + } + else + fprintf (stderr, "did not find the `hello' function\n"); + + return 0; +} diff --git a/tests/demo/foo.c b/tests/demo/foo.c new file mode 100644 index 000000000..55fa9d973 --- /dev/null +++ b/tests/demo/foo.c @@ -0,0 +1,37 @@ +/* foo.c -- trivial test function for libfoo + Copyright (C) 1996-1999 Free Software Foundation, Inc. + Gordon Matzigkeit , 1996 + This file is part of GNU Libtool. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +USA. */ + +#include "foo.h" + +#include + +#ifdef HAVE_MATH_H +#include +#endif + +/* Give a global variable definition. */ +int nothing = FOO_RET; + +int +foo () +{ + printf ("cos (0.0) = %g\n", (double) cos ((double) 0.0)); + return FOO_RET; +} diff --git a/tests/demo/foo.h b/tests/demo/foo.h new file mode 100644 index 000000000..d1c084f29 --- /dev/null +++ b/tests/demo/foo.h @@ -0,0 +1,73 @@ +/* foo.h -- interface to the libfoo library + Copyright (C) 1996-1999 Free Software Foundation, Inc. + Gordon Matzigkeit , 1996 + This file is part of GNU Libtool. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +USA. */ + +/* Only include this header file once. */ +#ifndef _FOO_H_ +#define _FOO_H_ 1 + +/* At some point, cygwin will stop defining __CYGWIN32__, but b19 and + * earlier do not define __CYGWIN__. This snippit allows us to check + * for __CYGWIN__ reliably for both current, old, and (probable) future + * releases. + */ +#ifdef __CYGWIN32__ +# ifndef __CYGWIN__ +# define __CYGWIN__ +# endif +#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. */ +#undef __BEGIN_DECLS +#undef __END_DECLS +#ifdef __cplusplus +# define __BEGIN_DECLS extern "C" { +# define __END_DECLS } +#else +# define __BEGIN_DECLS /* empty */ +# define __END_DECLS /* empty */ +#endif + +/* LTDL_PARAMS is a macro used to wrap function prototypes, so that compilers + that don't understand ANSI C prototypes still work, and ANSI C + compilers can issue warnings about type mismatches. */ +#undef LTDL_PARAMS +#if defined (__STDC__) || defined (_AIX) || (defined (__mips) && defined (_SYSTYPE_SVR4)) || defined(__CYGWIN__) || defined(__cplusplus) +# define LT_PARAMS(protos) protos +# define lt_ptr_t void* +#else +# define LT_PARAMS(protos) () +# define lt_ptr_t char* +#endif + +/* Silly constants that the functions return. */ +#define HELLO_RET 0xe110 +#define FOO_RET 0xf00 + + +/* Declarations. Note the wonderful use of the above macros. */ +__BEGIN_DECLS +int foo LT_PARAMS((void)); +int hello LT_PARAMS((void)); +extern int nothing; +__END_DECLS + +#endif /* !_FOO_H_ */ diff --git a/tests/demo/hell1.c b/tests/demo/hell1.c new file mode 100644 index 000000000..52e5148d3 --- /dev/null +++ b/tests/demo/hell1.c @@ -0,0 +1 @@ +int hell1() { return 1; } diff --git a/tests/demo/hell2.c b/tests/demo/hell2.c new file mode 100644 index 000000000..c1ff477e0 --- /dev/null +++ b/tests/demo/hell2.c @@ -0,0 +1 @@ +int hell2() { return 2; } diff --git a/tests/demo/hello.c b/tests/demo/hello.c new file mode 100644 index 000000000..3858528dc --- /dev/null +++ b/tests/demo/hello.c @@ -0,0 +1,30 @@ +/* hello.c -- trivial test function for libfoo + Copyright (C) 1996-1999 Free Software Foundation, Inc. + This file is part of GNU Libtool. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +USA. */ + +/* Written by Gordon Matzigkeit */ +#include "foo.h" + +#include + +int +hello () +{ + printf ("** This is not GNU Hello. There is no built-in mail reader. **\n"); + return HELLO_RET; +} diff --git a/tests/demo/main.c b/tests/demo/main.c new file mode 100644 index 000000000..d40dc5929 --- /dev/null +++ b/tests/demo/main.c @@ -0,0 +1,42 @@ +/* main.c -- trivial hello test program + Copyright (C) 1996-1999 Free Software Foundation, Inc. + This file is part of GNU Libtool. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +USA. */ + +/* Written by Gordon Matzigkeit */ +#include "foo.h" +#include + +int +main (argc, argv) + int argc; + char **argv; +{ + printf ("Welcome to GNU Hell!\n"); + + /* Try assigning to the nothing variable */ + nothing = 1; + + /* Just call the functions and check return values. */ + if (foo () != FOO_RET) + return 1; + + if (hello () != HELLO_RET) + return 2; + + return 0; +} diff --git a/tests/depdemo-conf.test b/tests/depdemo-conf.test index da24f98fb..985e70280 100755 --- a/tests/depdemo-conf.test +++ b/tests/depdemo-conf.test @@ -1,35 +1,36 @@ #! /bin/sh -# depdemo-conf.test - try configuring the ./depdemo subdirectory +# depdemo-conf.test - try configuring the depdemo subdirectory + +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. -# Test script header. -need_prefix=yes if test -z "$srcdir"; then srcdir=`echo "$0" | sed 's%/[^/]*$%%'` test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes fi . $srcdir/defs || exit 1 -# Maybe we have a VPATH build, in which case, create a new subdir. -test -d ../depdemo || mkdir ../depdemo - -# Change to our build directory. -cd ../depdemo || exit 1 - -# Possibly clean up the distribution. -if test -f Makefile; then - echo "= Running $make distclean in ../depdemo" - $make distclean -fi -rm -f config.cache - -# Configure the demonstration. -echo "= Configuring in ../depdemo (prefix=$prefix)" -${CONFIG_SHELL-/bin/sh} $srcdir/../depdemo/configure --srcdir=$srcdir/../depdemo --prefix=$prefix --build=$host || exit 1 - -if grep '^build_old_libs=yes' libtool > /dev/null && - grep '^build_libtool_libs=yes' libtool > /dev/null; then : -else rm -f Makefile && exit 77 -fi +func_mkprefixdir +func_cd "depdemo" +func_make_distclean +func_configure +func_check_static_shared "yes" "yes" exit 0 diff --git a/tests/depdemo-exec.test b/tests/depdemo-exec.test index b299c4cb6..71c768b15 100755 --- a/tests/depdemo-exec.test +++ b/tests/depdemo-exec.test @@ -1,35 +1,37 @@ #! /bin/sh -# depdemo-exec.test - check that programs in the ../depdemo subdirectory are viable +# depdemo-exec.test - check that programs in the depdemo subdirectory are viable + +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. -# Test script header. -need_prefix=no if test -z "$srcdir"; then srcdir=`echo "$0" | sed 's%/[^/]*$%%'` test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes fi . $srcdir/defs || exit 1 -if test -f ../depdemo/depdemo$EXEEXT; then : -else - echo "You must run depdemo-make.test before running $0" 1>&2 - exit 77 -fi - -# Check to see if the programs really run. -echo "Executing uninstalled programs in ../depdemo" +func_require "depdemo-make" "depdemo/depdemo$EXEEXT" -status=0 -if ../depdemo/depdemo_static; then : -else - echo "$0: cannot execute ../depdemo/depdemo_static" 1>&2 - status=1 -fi - -if ../depdemo/depdemo; then : -else - echo "$0: cannot execute ../depdemo/depdemo" 1>&2 - status=1 -fi +func_rmprefixdir +func_exec_init "uninstalled" +func_exec "depdemo/depdemo_static" +func_exec "depdemo/depdemo" -exit $status +exit $exec_status diff --git a/tests/depdemo-inst.test b/tests/depdemo-inst.test index 85c73b3fc..884534182 100755 --- a/tests/depdemo-inst.test +++ b/tests/depdemo-inst.test @@ -1,47 +1,39 @@ #! /bin/sh -# depdemo-inst.test - try installing from the ../depdemo subdirectory +# depdemo-inst.test - try installing from the depdemo subdirectory + +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. -# Test script header. -need_prefix=yes if test -z "$srcdir"; then srcdir=`echo "$0" | sed 's%/[^/]*$%%'` test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes fi . $srcdir/defs || exit 1 -# Check that things are built. -if test -f ../depdemo/depdemo$EXEEXT; then : -else - echo "You must run depdemo-make.test before $0" 1>&2 - exit 77 -fi - -# Change to our build directory. -cd ../depdemo || exit 1 - -echo "= Running $make install in ../depdemo" -$make install || exit 1 - -echo "= Executing installed programs" +func_require "depdemo-make" "depdemo/depdemo$EXEEXT" -status=0 -if $prefix/bin/depdemo_static; then : -else - echo "$0: cannot execute $prefix/bin/depdemo_static" 1>&2 - status=1 -fi - -if $prefix/bin/depdemo; then : -else - echo "$0: cannot execute $prefix/bin/depdemo" 1>&2 - - # Simple check to see if they are superuser. - if test -w /; then : - else - echo "You may need to run $0 as the superuser." - fi - status=1 -fi +func_mkprefixdir +func_cd "depdemo" +func_make "install" +func_exec_init "installed" +func_exec "$prefix/bin/depdemo_static" +func_exec "$prefix/bin/depdemo" exit $status diff --git a/tests/depdemo-make.test b/tests/depdemo-make.test index 5f9b6e8ca..a9727d5a2 100755 --- a/tests/depdemo-make.test +++ b/tests/depdemo-make.test @@ -1,25 +1,36 @@ #! /bin/sh -# depdemo-make.test - try building in the ../depdemo subdirectory +# depdemo-make.test - try building in the depdemo subdirectory + +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. -# Test script header. -need_prefix=no if test -z "$srcdir"; then srcdir=`echo "$0" | sed 's%/[^/]*$%%'` test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes fi . $srcdir/defs || exit 1 -if test -f ../depdemo/Makefile; then : -else - echo "You must run depdemo-conf.test before running $0" 1>&2 - exit 77 -fi +func_require "depdemo-conf" "depdemo/Makefile" -# Change to our build directory. -cd ../depdemo || exit 1 +func_rmprefixdir +func_cd "depdemo" +func_make -# Do the actual build. -echo "Making in ../depdemo" -$make || exit 1 exit 0 diff --git a/tests/depdemo-nofast.test b/tests/depdemo-nofast.test index 2cbb25d2f..ee04e9a6a 100755 --- a/tests/depdemo-nofast.test +++ b/tests/depdemo-nofast.test @@ -1,34 +1,40 @@ #! /bin/sh -# depdemo-conf.test - try configuring the ./depdemo subdirectory +# depdemo-nofast.test - try configuring the ./depdemo subdirectory + +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. -# Test script header. -need_prefix=yes if test -z "$srcdir"; then srcdir=`echo "$0" | sed 's%/[^/]*$%%'` test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes fi . $srcdir/defs || exit 1 -# Maybe we have a VPATH build, in which case, create a new subdir. -test -d ../depdemo || mkdir ../depdemo - -# Change to our build directory. -cd ../depdemo || exit 1 - -# Possibly clean up the distribution. -if test -f Makefile; then - echo "= Running $make distclean in ../depdemo" - $make distclean -fi -rm -f config.cache - -# Configure the demonstration. -echo "= Configuring in ../depdemo (prefix=$prefix)" -${CONFIG_SHELL-/bin/sh} $srcdir/../depdemo/configure --srcdir=$srcdir/../depdemo --prefix=$prefix --build=$host --enable-fast-install=no || exit 1 +func_mkprefixdir +func_cd "depdemo" +func_make_distclean +func_configure "--enable-fast-install=no" -if grep '^hardcode_action=relink' libtool > /dev/null; then - rm -f Makefile && exit 77 +if func_grep '^hardcode_action=relink' libtool; then + rm -f Makefile + exit 77 fi exit 0 diff --git a/tests/depdemo-relink.test b/tests/depdemo-relink.test new file mode 100755 index 000000000..60c54332f --- /dev/null +++ b/tests/depdemo-relink.test @@ -0,0 +1,114 @@ +#! /bin/sh +# depdemo-relink.test - check to see whether shlibpath overrides runpath + +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. + +if test -z "$srcdir"; then + srcdir=`echo "$0" | sed 's%/[^/]*$%%'` + test "$srcdir" = "$0" && srcdir=. +fi +. $srcdir/defs || exit 1 + +func_restore_files () +{ + func_mkdir_p "$objdir" + mv -f _fnord/temp/libs/* "l3/$objdir" + mv -f "_fnord/temp/libl3.la" "l3" + mv -f "_fnord/temp/lt-depdemo$EXEXT" "_fnord/temp/depdemo$EXEXT" "$objdir" + rm -rf "_fnord" +} + +func_save_files () +{ + func_mkdir_p "_fnord/temp/libs" + cp -f "$objdir/lt-depdemo$EXEEXT" "$objdir/depdemo$EXEEXT" "_fnord/temp" + cp -f l3/libl3.la "_fnord/temp" + cp -f l3/"$objdir"/* "_fnord/temp/libs" + trap "func_restore_files" 0 1 2 13 15 +} + +func_require "depdemo-inst" "$prefix/lib/libl3.la" "depdemo/l3/libl3.la" + +func_mkprefixdir +func_cd "depdemo" +func_save_files + +# Check to make sure we have a dynamic library. +func_get_config "library_names" "cat l3/libl3.la" +test -z "$library_names" \ + && func_fatal_error "Exiting: depdemo/l3/libl3.la is not a shared library" + +func_get_config 'shlibpath_overrides_runpath +hardcode_action +hardcode_direct +hardcode_into_libs' "./libtool --config" ": fatal" + +./depdemo # so that it links on-demand if needed + +func_msg "removing libl3.la from depdemo/l3" +rm -rf l3/libl3.la l3/$objdir + +func_msg "running depdemo/depdemo" +if ./depdemo || + # On AIX 4.1, when the installed copy of libl3 is loaded, it brings + # with it the installed copies of libl1 and libl2, with disjoint + # counters var_l1 and var_l2. This is arguably acceptable behavior, + # but it's definitely not enough of a reason for the test to fail. + ./depdemo -alt; then + : +elif test "x,$hardcode_action,$hardcode_direct" = x,relink,yes; then + func_msg "Ok, uninstalled programs fail after uninstalled libraries are removed" + func_msg "This works in other configurations, but not in this particular one" +else + func_fail "Exiting: depdemo/depdemo does not run, maybe libl3 was not installed" +fi + +func_msg "linking a broken depdemo/l3/libl3.la" +(cd l3 && $make libl3.la libl3_la_OBJECTS=../l2/l2.lo) \ + || func_fail "Exiting: cannot link broken libl3.la" +rm -f l3/libl3.la + +func_msg "running depdemo/depdemo with broken libl3.la" +if (./depdemo) 2>&1; then + func_msg "Exiting: depdemo/depdemo runs even though libl3.la is incomplete" + func_fail "shlibpath_overrides_runpath should be set to no" +else + func_msg "Failed, as expected" +fi + +if test "x$hardcode_action" = xrelink; then + func_msg "Exiting: install-time relinking is required" + exit $EXIT_SUCCESS +fi + +if test "$shlibpath_overrides_runpath" != yes; then + rm -f $objdir/lt-depdemo || exit $EXIT_FAILURE + cp $objdir/depdemo $objdir/lt-depdemo || exit $EXIT_FAILURE + func_msg "running depdemo/depdemo with installed libl3.la" + if ./depdemo; then + func_msg "Worked, as expected" + else + func_msg "shlibpath_overrides_runpath should be set to yes" + status=$EXIT_FAILURE + fi +fi + +exit $status diff --git a/tests/depdemo-shared.test b/tests/depdemo-shared.test index e411fee66..a4269afb1 100755 --- a/tests/depdemo-shared.test +++ b/tests/depdemo-shared.test @@ -1,35 +1,36 @@ #! /bin/sh -# depdemo-conf.test - try configuring the ../depdemo subdirectory +# depdemo-shared.test - try configuring the depdemo subdirectory for shared libs + +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. -# Test script header. -need_prefix=yes if test -z "$srcdir"; then srcdir=`echo "$0" | sed 's%/[^/]*$%%'` test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes fi . $srcdir/defs || exit 1 -# Maybe we have a VPATH build, in which case, create a new subdir. -test -d ../depdemo || mkdir ../depdemo - -# Change to our build directory. -cd ../depdemo || exit 1 - -# Possibly clean up the distribution. -if test -f Makefile; then - echo "= Running $make distclean in ../depdemo" - $make distclean -fi -rm -f config.cache - -# Configure the demonstration. -echo "= Configuring in ../depdemo (prefix=$prefix) with --disable-static" -${CONFIG_SHELL-/bin/sh} $srcdir/../depdemo/configure --srcdir=$srcdir/../depdemo --prefix=$prefix --build=$host --disable-static || exit 1 - -if grep '^build_old_libs=no' libtool > /dev/null && - grep '^build_libtool_libs=yes' libtool > /dev/null; then : -else rm -f Makefile && exit 77 -fi +func_mkprefixdir +func_cd "depdemo" +func_make_distclean +func_configure "--disable-static" +func_check_static_shared "no" "yes" exit 0 diff --git a/tests/depdemo-static.test b/tests/depdemo-static.test index c0bd763c2..efbc2e7af 100755 --- a/tests/depdemo-static.test +++ b/tests/depdemo-static.test @@ -1,35 +1,36 @@ #! /bin/sh -# depdemo-conf.test - try configuring the ../depdemo subdirectory +# depdemo-static.test - try configuring the depdemo subdirectory for static libs + +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. -# Test script header. -need_prefix=yes if test -z "$srcdir"; then srcdir=`echo "$0" | sed 's%/[^/]*$%%'` test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes fi . $srcdir/defs || exit 1 -# Maybe we have a VPATH build, in which case, create a new subdir. -test -d ../depdemo || mkdir ../depdemo - -# Change to our build directory. -cd ../depdemo || exit 1 - -# Possibly clean up the distribution. -if test -f Makefile; then - echo "= Running $make distclean in ../depdemo" - $make distclean -fi -rm -f config.cache - -# Configure the demonstration. -echo "= Configuring in ../depdemo (prefix=$prefix) with --disable-shared" -${CONFIG_SHELL-/bin/sh} $srcdir/../depdemo/configure --srcdir=$srcdir/../depdemo --prefix=$prefix --build=$host --disable-shared || exit 1 - -if grep '^build_old_libs=yes' libtool > /dev/null && - grep '^build_libtool_libs=no' libtool > /dev/null; then : -else rm -f Makefile && exit 77 -fi +func_mkprefixdir +func_cd "depdemo" +func_make_distclean +func_configure "--disable-shared" +func_check_static_shared "yes" "no" exit 0 diff --git a/tests/depdemo-unst.test b/tests/depdemo-unst.test index 34d54231b..ec13602b1 100755 --- a/tests/depdemo-unst.test +++ b/tests/depdemo-unst.test @@ -1,33 +1,36 @@ #! /bin/sh -# depdemo.test - try uninstalling in the ../depdemo subdirectory +# depdemo-unst.test - try uninstalling in the depdemo subdirectory + +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. -# Test script header. -need_prefix=yes if test -z "$srcdir"; then srcdir=`echo "$0" | sed 's%/[^/]*$%%'` test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes fi . $srcdir/defs || exit 1 -# Make sure it was installed already -if test "$prefix/bin/hell" && cd ../depdemo && test -f Makefile; then : -else - echo "You must run depdemo-inst.test before $0." 1>&2 - exit 77 -fi +func_require "depdemo-inst" "$prefix/bin/depdemo$EXEEXT" "depdemo/Makefile" -echo "= Running $make uninstall in ../depdemo" -$make uninstall || exit 1 - -# See that there were no files leftover in $prefix. -# Ignore dotfiles, so that .nfsXXX files don't screw up the test. -leftovers=`find $prefix ! -type d ! -name '.*' -print` -if test -n "$leftovers"; then - echo "= Leftover after make uninstall:" - ls -l $leftovers - ls -l $leftovers > ~/devel/savannah/arse - exit 1 -fi +func_mkprefixdir +func_cd "depdemo" +func_make_uninstall exit 0 diff --git a/tests/depdemo/.cvsignore b/tests/depdemo/.cvsignore new file mode 100644 index 000000000..b416949b7 --- /dev/null +++ b/tests/depdemo/.cvsignore @@ -0,0 +1,15 @@ +.deps +.libs +Makefile +Makefile.in +acinclude.m4 +aclocal.m4 +autom4te.cache +configure +config.* +conftest* +libtool +*.lo +*.la +depdemo +depdemo_static diff --git a/tests/depdemo/Makefile.am b/tests/depdemo/Makefile.am new file mode 100644 index 000000000..2acf50b5b --- /dev/null +++ b/tests/depdemo/Makefile.am @@ -0,0 +1,44 @@ +## Makefile.am -- Process this file with automake to produce Makefile.in +## +## Copyright (C) 2003 Free Software Foundation +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2 of the License, or +## (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program; see the file COPYING. If not, write to +## the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +## Boston, MA 02111-1307, USA. + +top_distdir = ../.. + +AUTOMAKE_OPTIONS = no-dependencies foreign +ACLOCAL_AMFLAGS = -I $(top_distdir)/m4 + +SUBDIRS = l1 l2 l3 l4 + +EXTRA_DIST = sysdep.h + +bin_PROGRAMS = depdemo depdemo_static + +depdemo_SOURCES = main.c +depdemo_LDADD = $(top_builddir)/l1/libl1.la $(top_builddir)/l2/libl2.la \ + $(top_builddir)/l4/libl4.la +depdemo_DEPENDENCIES = $(top_builddir)/l1/libl1.la \ + $(top_builddir)/l2/libl2.la $(top_builddir)/l4/libl4.la + +depdemo_static_SOURCES = $(depdemo_SOURCES) +depdemo_static_LDADD = $(depdemo_LDADD) +depdemo_static_DEPENDENCIES = $(depdemo_DEPENDENCIES) +depdemo_static_LDFLAGS = $(STATIC) + +$(OBJECTS): libtool +libtool: $(LIBTOOL_DEPS) + $(SHELL) ./config.status --recheck diff --git a/tests/depdemo/README b/tests/depdemo/README new file mode 100644 index 000000000..30d716684 --- /dev/null +++ b/tests/depdemo/README @@ -0,0 +1,11 @@ +This is depdemo, an example package that uses GNU libtool with an +Automake-generated environment to build many interdependent libraries +and a test program. + +There are four libraries: l1, l2, l3 and l4. +l1 depends on nothing. +l2 depends on l1. +l3 depends on l1 and l2. +l4 depends on l3 and libm. + +The test program uses l1, l2 and l4. diff --git a/tests/depdemo/configure.ac b/tests/depdemo/configure.ac new file mode 100644 index 000000000..17a9e7597 --- /dev/null +++ b/tests/depdemo/configure.ac @@ -0,0 +1,76 @@ +## Process this file with autoconf to create configure. -*- autoconf -*- +# Copyright (C) 2001, 2003 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +# 02111-1307 USA + +AC_PREREQ(2.50) + + +## ------------------------ ## +## Autoconf initialisation. ## +## ------------------------ ## +AC_INIT([depdemo], [0.1], [bug-libtool@gnu.org]) +AC_CONFIG_SRCDIR([main.c]) +AC_CONFIG_AUX_DIR([../../config]) + + +## ------------------------ ## +## Automake Initialisation. ## +## ------------------------ ## +AM_INIT_AUTOMAKE(AC_PACKAGE_TARNAME, AC_PACKAGE_VERSION) + + +## ---------------- ## +## compiler checks. ## +## ---------------- ## +AC_PROG_CC +AC_EXEEXT + +## ----------------------- ## +## Libtool initialisation. ## +## ----------------------- ## +AC_LIBTOOL_WIN32_DLL +AM_PROG_LIBTOOL +AC_SUBST([LIBTOOL_DEPS]) + +## ------------------------------- ## +## depdemo specific configuration. ## +## ------------------------------- ## +if ${CONFIG_SHELL} ./libtool --features | grep "enable static" >/dev/null; then + STATIC=-static +else + STATIC= +fi +AC_SUBST([STATIC]) + +## ---------------------------- ## +## C headers required by cdemo. ## +## ---------------------------- ## +AC_CHECK_HEADERS([math.h]) + + +## ---------------------------- ## +## Libraries required by cdemo. ## +## ---------------------------- ## +AC_CHECK_LIBM +AC_SUBST([LIBM]) + + +## -------- ## +## Outputs. ## +## -------- ## +AC_CONFIG_FILES([Makefile l1/Makefile l2/Makefile l3/Makefile l4/Makefile]) +AC_OUTPUT diff --git a/tests/depdemo/l1/.cvsignore b/tests/depdemo/l1/.cvsignore new file mode 100644 index 000000000..09980ae6b --- /dev/null +++ b/tests/depdemo/l1/.cvsignore @@ -0,0 +1,6 @@ +.deps +.libs +Makefile +Makefile.in +*.lo +*.la diff --git a/tests/depdemo/l1/Makefile.am b/tests/depdemo/l1/Makefile.am new file mode 100644 index 000000000..673b07260 --- /dev/null +++ b/tests/depdemo/l1/Makefile.am @@ -0,0 +1,28 @@ +## Makefile.am -- Process this file with automake to produce Makefile.in +## +## Copyright (C) 2003 Free Software Foundation +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2 of the License, or +## (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program; see the file COPYING. If not, write to +## the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +## Boston, MA 02111-1307, USA. + +top_distdir = ../.. + +AUTOMAKE_OPTIONS = no-dependencies foreign + +AM_CPPFLAGS = -I$(top_srcdir) + +lib_LTLIBRARIES = libl1.la +libl1_la_SOURCES = l1.c l1.h +libl1_la_LDFLAGS = -no-undefined diff --git a/tests/depdemo/l1/l1.c b/tests/depdemo/l1/l1.c new file mode 100644 index 000000000..ba2fa7734 --- /dev/null +++ b/tests/depdemo/l1/l1.c @@ -0,0 +1,36 @@ +/* l1.c -- trivial test library + Copyright (C) 1998-1999 Thomas Tanner + This file is part of GNU Libtool. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +USA. */ + +#include "l1/l1.h" +#include + +int var_l1 = 0; + +int +func_l1(indent) + int indent; +{ + int i; + + for (i = 0; i < indent; i++) + putchar(' '); + printf("l1 (%i)\n", var_l1); + var_l1++; + return 0; +} diff --git a/tests/depdemo/l1/l1.h b/tests/depdemo/l1/l1.h new file mode 100644 index 000000000..fa70bb8b0 --- /dev/null +++ b/tests/depdemo/l1/l1.h @@ -0,0 +1,31 @@ +/* l1.h -- interface to a trivial library + Copyright (C) 1998-1999 Thomas Tanner + This file is part of GNU Libtool. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +USA. */ + +/* Only include this header file once. */ +#ifndef _L1_H_ +#define _L1_H_ 1 + +#include "sysdep.h" + +__BEGIN_DECLS +extern int var_l1; +int func_l1 __P((int)); +__END_DECLS + +#endif /* !_L1_H_ */ diff --git a/tests/depdemo/l2/.cvsignore b/tests/depdemo/l2/.cvsignore new file mode 100644 index 000000000..09980ae6b --- /dev/null +++ b/tests/depdemo/l2/.cvsignore @@ -0,0 +1,6 @@ +.deps +.libs +Makefile +Makefile.in +*.lo +*.la diff --git a/tests/depdemo/l2/Makefile.am b/tests/depdemo/l2/Makefile.am new file mode 100644 index 000000000..bf64d8d94 --- /dev/null +++ b/tests/depdemo/l2/Makefile.am @@ -0,0 +1,29 @@ +## Makefile.am -- Process this file with automake to produce Makefile.in +## +## Copyright (C) 2003 Free Software Foundation +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2 of the License, or +## (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program; see the file COPYING. If not, write to +## the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +## Boston, MA 02111-1307, USA. + +top_distdir = ../.. + +AUTOMAKE_OPTIONS = no-dependencies foreign + +AM_CPPFLAGS = -I$(top_srcdir) + +lib_LTLIBRARIES = libl2.la +libl2_la_SOURCES = l2.c l2.h +libl2_la_LDFLAGS = -no-undefined +libl2_la_LIBADD = $(top_builddir)/l1/libl1.la diff --git a/tests/depdemo/l2/l2.c b/tests/depdemo/l2/l2.c new file mode 100644 index 000000000..555d0688f --- /dev/null +++ b/tests/depdemo/l2/l2.c @@ -0,0 +1,39 @@ +/* l2.c -- trivial test library + Copyright (C) 1998-1999 Thomas Tanner + This file is part of GNU Libtool. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +USA. */ + +#include "l2/l2.h" + +#include "l1/l1.h" +#include + +int var_l2 = 0; + +int +func_l2(indent) + int indent; +{ + int i; + + for (i = 0; i < indent; i++) + putchar(' '); + printf("l2 (%i)\n", var_l2); + func_l1(indent+1); + var_l2 += var_l1; + return 0; +} diff --git a/tests/depdemo/l2/l2.h b/tests/depdemo/l2/l2.h new file mode 100644 index 000000000..893e26bde --- /dev/null +++ b/tests/depdemo/l2/l2.h @@ -0,0 +1,31 @@ +/* l2.h -- interface to a trivial library + Copyright (C) 1998-1999 Thomas Tanner + This file is part of GNU Libtool. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +USA. */ + +/* Only include this header file once. */ +#ifndef _L2_H_ +#define _L2_H_ 1 + +#include "sysdep.h" + +__BEGIN_DECLS +extern int var_l2; +int func_l2 __P((int)); +__END_DECLS + +#endif /* !_L2_H_ */ diff --git a/tests/depdemo/l3/.cvsignore b/tests/depdemo/l3/.cvsignore new file mode 100644 index 000000000..09980ae6b --- /dev/null +++ b/tests/depdemo/l3/.cvsignore @@ -0,0 +1,6 @@ +.deps +.libs +Makefile +Makefile.in +*.lo +*.la diff --git a/tests/depdemo/l3/Makefile.am b/tests/depdemo/l3/Makefile.am new file mode 100644 index 000000000..093869306 --- /dev/null +++ b/tests/depdemo/l3/Makefile.am @@ -0,0 +1,30 @@ +## Makefile.am -- Process this file with automake to produce Makefile.in +## +## Copyright (C) 2003 Free Software Foundation +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2 of the License, or +## (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program; see the file COPYING. If not, write to +## the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +## Boston, MA 02111-1307, USA. + +top_distdir = ../.. +extradir = $(libdir)/extra + +AUTOMAKE_OPTIONS = no-dependencies foreign + +AM_CPPFLAGS = -I$(top_srcdir) + +lib_LTLIBRARIES = libl3.la +libl3_la_SOURCES = l3.c l3.h +libl3_la_LDFLAGS = -no-undefined +libl3_la_LIBADD = $(top_builddir)/l1/libl1.la $(top_builddir)/l2/libl2.la diff --git a/tests/depdemo/l3/l3.c b/tests/depdemo/l3/l3.c new file mode 100644 index 000000000..de75bd6f3 --- /dev/null +++ b/tests/depdemo/l3/l3.c @@ -0,0 +1,41 @@ +/* l3.c -- trivial test library + Copyright (C) 1998-1999 Thomas Tanner + This file is part of GNU Libtool. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +USA. */ + +#include "l3/l3.h" + +#include "l1/l1.h" +#include "l2/l2.h" +#include + +int var_l3 = 0; + +int +func_l3(indent) + int indent; +{ + int i; + + for (i = 0; i < indent; i++) + putchar(' '); + printf("l3 (%i)\n", var_l3); + func_l1(indent+1); + func_l2(indent+1); + var_l3 += var_l1 + var_l2; + return 0; +} diff --git a/tests/depdemo/l3/l3.h b/tests/depdemo/l3/l3.h new file mode 100644 index 000000000..d9b79fb08 --- /dev/null +++ b/tests/depdemo/l3/l3.h @@ -0,0 +1,31 @@ +/* l3.h -- interface to a trivial library + Copyright (C) 1998-1999 Thomas Tanner + This file is part of GNU Libtool. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +USA. */ + +/* Only include this header file once. */ +#ifndef _L3_H_ +#define _L3_H_ 1 + +#include "sysdep.h" + +__BEGIN_DECLS +extern int var_l3; +int func_l3 __P((int)); +__END_DECLS + +#endif /* !_L3_H_ */ diff --git a/tests/depdemo/l4/.cvsignore b/tests/depdemo/l4/.cvsignore new file mode 100644 index 000000000..09980ae6b --- /dev/null +++ b/tests/depdemo/l4/.cvsignore @@ -0,0 +1,6 @@ +.deps +.libs +Makefile +Makefile.in +*.lo +*.la diff --git a/tests/depdemo/l4/Makefile.am b/tests/depdemo/l4/Makefile.am new file mode 100644 index 000000000..64933bd45 --- /dev/null +++ b/tests/depdemo/l4/Makefile.am @@ -0,0 +1,29 @@ +## Makefile.am -- Process this file with automake to produce Makefile.in +## +## Copyright (C) 2003 Free Software Foundation +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2 of the License, or +## (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program; see the file COPYING. If not, write to +## the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +## Boston, MA 02111-1307, USA. + +top_distdir = ../.. + +AUTOMAKE_OPTIONS = no-dependencies foreign + +AM_CPPFLAGS = -I$(top_srcdir) + +lib_LTLIBRARIES = libl4.la +libl4_la_SOURCES = l4.c l4.h +libl4_la_LDFLAGS = -no-undefined +libl4_la_LIBADD = $(top_builddir)/l3/libl3.la $(LIBM) diff --git a/tests/depdemo/l4/l4.c b/tests/depdemo/l4/l4.c new file mode 100644 index 000000000..d99d0200e --- /dev/null +++ b/tests/depdemo/l4/l4.c @@ -0,0 +1,46 @@ +/* l4.c -- trivial test library + Copyright (C) 1998-1999 Thomas Tanner + This file is part of GNU Libtool. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +USA. */ + +#include "l4/l4.h" + +#include "l3/l3.h" +#include + +#ifdef HAVE_MATH_H +#include +#endif + +int var_l4 = 0; + +int +func_l4(indent) + int indent; +{ + int i; + + for (i = 0; i < indent; i++) + putchar(' '); + printf("l4 (%i)\n", var_l4); + func_l3(indent+1); + for (i = 0; i <= indent; i++) + putchar(' '); + printf("libm [sin(1.5) = %f]\n", sin(1.5)); + var_l4 += var_l3; + return 0; +} diff --git a/tests/depdemo/l4/l4.h b/tests/depdemo/l4/l4.h new file mode 100644 index 000000000..17ab6ea22 --- /dev/null +++ b/tests/depdemo/l4/l4.h @@ -0,0 +1,31 @@ +/* l4.h -- interface to a trivial library + Copyright (C) 1998-1999 Thomas Tanner + This file is part of GNU Libtool. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +USA. */ + +/* Only include this header file once. */ +#ifndef _L4_H_ +#define _L4_H_ 1 + +#include "sysdep.h" + +__BEGIN_DECLS +extern int var_l4; +int func_l4 __P((int)); +__END_DECLS + +#endif /* !_L4_H_ */ diff --git a/tests/depdemo/main.c b/tests/depdemo/main.c new file mode 100644 index 000000000..ef2458d3a --- /dev/null +++ b/tests/depdemo/main.c @@ -0,0 +1,46 @@ +/* main.c -- inter-library dependency test program + Copyright (C) 1998, 1999, 2000 Free Software Foundation + by Thomas Tanner + This file is part of GNU Libtool. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +USA. */ + +#include "l1/l1.h" +#include "l2/l2.h" +#include "l4/l4.h" +#include +#include + +int +main (argc,argv) + int argc; + char **argv; +{ + printf("dependencies:\n"); + func_l1(0); + func_l2(0); + func_l4(0); + if (argc == 2 && strcmp (argv[1], "-alt") == 0 + && var_l1 + var_l2 + var_l4 == 8) + return 0; + printf("var_l1(%d) + var_l2(%d) + var_l4(%d) == %d\n",var_l1,var_l2,var_l4, var_l1 + var_l2 + var_l4); + if (var_l1 + var_l2 + var_l4 != 20) + { + printf("var_l1(%d) + var_l2(%d) + var_l4(%d) != 20\n",var_l1,var_l2,var_l4); + return 1; + } + return 0; +} diff --git a/tests/depdemo/sysdep.h b/tests/depdemo/sysdep.h new file mode 100644 index 000000000..40dcfbd4f --- /dev/null +++ b/tests/depdemo/sysdep.h @@ -0,0 +1,47 @@ +/* sysdep.h -- system dependent declarations + Copyright (C) 1998-1999 Thomas Tanner + This file is part of GNU Libtool. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +USA. */ + +/* Only include this header file once. */ +#ifndef _SYSDEP_H_ +#define _SYSDEP_H_ 1 + +/* __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. */ +#undef __BEGIN_DECLS +#undef __END_DECLS +#ifdef __cplusplus +# define __BEGIN_DECLS extern "C" { +# define __END_DECLS } +#else +# define __BEGIN_DECLS /* empty */ +# define __END_DECLS /* empty */ +#endif + +/* __P is a macro used to wrap function prototypes, so that compilers + that don't understand ANSI C prototypes still work, and ANSI C + compilers can issue warnings about type mismatches. */ +#undef __P +#if defined (__STDC__) || defined (_AIX) || (defined (__mips) && defined (_SYSTYPE_SVR4)) || defined(WIN32) || defined(__cplusplus) +# define __P(protos) protos +#else +# define __P(protos) () +#endif + +#endif /* !_SYSDEP_H_ */ diff --git a/tests/deplibs.test b/tests/deplibs.test deleted file mode 100755 index 9b3b06da4..000000000 --- a/tests/deplibs.test +++ /dev/null @@ -1,34 +0,0 @@ -#! /bin/sh -# deplibs.test - check whether the shared library check method is OK - -# Test script header. -need_prefix=yes -if test -z "$srcdir"; then - srcdir=`echo "$0" | sed 's%/[^/]*$%%'` - test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes -fi -. $srcdir/defs || exit 1 - -# Check that things are built. -if test -f ../demo/libhello.la && cd ../demo; then : -else - echo "You must run demo-conf.test before $0" 1>&2 - exit 77 -fi - -echo "linking a shared library against a static library" -if $make deplibs-check && test -f hell0; then : -else - echo "= cannot build the test program, check your deplibs_check_method" - status=1 -fi - -echo "executing the test program" -if ./hell0; then : -else - echo "= cannot execute the test program, check your deplibs_check_method" - status=1 -fi - -exit $status diff --git a/tests/f77demo-conf.test b/tests/f77demo-conf.test index 23d7af7b7..606dcf9a2 100755 --- a/tests/f77demo-conf.test +++ b/tests/f77demo-conf.test @@ -1,35 +1,36 @@ #! /bin/sh -# f77demo-conf.test - try configuring the ../f77demo subdirectory +# f77demo-conf.test - try configuring the f77demo subdirectory + +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. -# Test script header. -need_prefix=yes if test -z "$srcdir"; then srcdir=`echo "$0" | sed 's%/[^/]*$%%'` test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes fi . $srcdir/defs || exit 1 -# Maybe we have a VPATH build, in which case, create a new subdir. -test -d ../f77demo || mkdir ../f77demo - -# Change to our build directory. -cd ../f77demo || exit 1 - -# Possibly clean up the distribution. -if test -f Makefile; then - echo "= Running $make distclean in ../f77demo" - $make distclean -fi -rm -f config.cache - -# Configure the demonstration. -echo "= Configuring in ../f77demo (prefix=$prefix)" -${CONFIG_SHELL-/bin/sh} $srcdir/../f77demo/configure --srcdir=$srcdir/../f77demo --prefix=$prefix || exit 1 - -if $EGREP '^build_old_libs=yes' libtool > /dev/null && - $EGREP '^build_libtool_libs=yes' libtool > /dev/null; then : -else rm -f Makefile && exit 77 -fi +func_mkprefixdir +func_cd "f77demo" +func_make_distclean +func_configure +func_check_static_shared "yes" "yes" exit 0 diff --git a/tests/f77demo-exec.test b/tests/f77demo-exec.test index ac6b85348..7a23f68a2 100755 --- a/tests/f77demo-exec.test +++ b/tests/f77demo-exec.test @@ -1,34 +1,37 @@ #! /bin/sh -# f77demo-exec.test - check that programs in the ../f77demo subdirectory are viable +# f77demo-exec.test - check that programs in the f77demo subdirectory are viable + +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. -# Test script header. -need_prefix=no if test -z "$srcdir"; then srcdir=`echo "$0" | sed 's%/[^/]*$%%'` test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes fi . $srcdir/defs || exit 1 -if test -f ../f77demo/fprogram$EXEEXT && test -f ../f77demo/cprogram$EXEEXT; then : -else - echo "You must run f77demo-make.test before running $0" 1>&2 - exit 77 -fi - -# Check to see if the programs really run. -echo "Executing uninstalled programs in ../f77demo" +func_require "f77demo-make" "f77demo/fprogram$EXEEXT" "f77demo/cprogram$EXEEXT" -if ../f77demo/fprogram ; then : -else - echo "$0: cannot execute ../f77demo/fprogram" 1>&2 - status=1 -fi - -if ../f77demo/cprogram ; then : -else - echo "$0: cannot execute ../f77demo/cprogram" 1>&2 - status=1 -fi +func_rmprefixdir +func_exec_init "uninstalled" +func_exec "f77demo/fprogram" +func_exec "f77demo/cprogram" -exit $status +exit $exec_status diff --git a/tests/f77demo-make.test b/tests/f77demo-make.test index 5191d77ee..362e4f9ce 100755 --- a/tests/f77demo-make.test +++ b/tests/f77demo-make.test @@ -1,25 +1,36 @@ #! /bin/sh -# f77demo-make.test - try building in the ../f77demo subdirectory +# f77demo-make.test - try building in the f77demo subdirectory + +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. -# Test script header. -need_prefix=no if test -z "$srcdir"; then srcdir=`echo "$0" | sed 's%/[^/]*$%%'` test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes fi . $srcdir/defs || exit 1 -if test -f ../f77demo/Makefile; then : -else - echo "You must run f77demo-conf.test before running $0" 1>&2 - exit 77 -fi +func_require "f77demo-conf" "f77demo/Makefile" -# Change to our build directory. -cd ../f77demo || exit 1 +func_rmprefixdir +func_cd "f77demo" +func_make -# Do the actual build. -echo "Making in ../f77demo" -$make || exit 1 exit 0 diff --git a/tests/f77demo-shared.test b/tests/f77demo-shared.test index a54eeec83..43fb4c12a 100755 --- a/tests/f77demo-shared.test +++ b/tests/f77demo-shared.test @@ -1,35 +1,36 @@ #! /bin/sh -# f77demo-conf.test - try configuring the ../f77demo subdirectory +# f77demo-shared.test - try configuring the f77demo subdirectory for shared libs + +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. -# Test script header. -need_prefix=yes if test -z "$srcdir"; then srcdir=`echo "$0" | sed 's%/[^/]*$%%'` test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes fi . $srcdir/defs || exit 1 -# Maybe we have a VPATH build, in which case, create a new subdir. -test -d ../f77demo || mkdir ../f77demo - -# Change to our build directory. -cd ../f77demo || exit 1 - -# Possibly clean up the distribution. -if test -f Makefile; then - echo "= Running $make distclean in ../f77demo" - $make distclean -fi -rm -f config.cache - -# Configure the demonstration. -echo "= Configuring in ../f77demo (prefix=$prefix) with --disable-static" -${CONFIG_SHELL-/bin/sh} $srcdir/../f77demo/configure --srcdir=$srcdir/../f77demo --prefix=$prefix --disable-static || exit 1 - -if $EGREP '^build_old_libs=no' libtool > /dev/null && - $EGREP '^build_libtool_libs=yes' libtool > /dev/null; then : -else rm -f Makefile && exit 77 -fi +func_mkprefixdir +func_cd "f77demo" +func_make_distclean +func_configure "--disable-static" +func_check_static_shared "no" "yes" exit 0 diff --git a/tests/f77demo-static.test b/tests/f77demo-static.test index 3e710366d..b16ccb9b3 100755 --- a/tests/f77demo-static.test +++ b/tests/f77demo-static.test @@ -1,44 +1,36 @@ #! /bin/sh -# f77demo-conf.test - try configuring the ../f77demo subdirectory +# f77demo-static.test - try configuring the f77demo subdirectory for static libs + +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. -# Test script header. -need_prefix=yes if test -z "$srcdir"; then srcdir=`echo "$0" | sed 's%/[^/]*$%%'` test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes fi . $srcdir/defs || exit 1 -# Maybe we have a VPATH build, in which case, create a new subdir. -test -d ../f77demo || mkdir ../f77demo - -# Change to our build directory. -cd ../f77demo || exit 1 - -# Possibly clean up the distribution. -if test -f Makefile; then - echo "= Running $make distclean in ../f77demo" - $make distclean -fi -rm -f config.cache - -# Configure the demonstration. -echo "= Configuring in ../f77demo (prefix=$prefix) with --disable-shared" -${CONFIG_SHELL-/bin/sh} $srcdir/../f77demo/configure --srcdir=$srcdir/../f77demo --prefix=$prefix --disable-shared || exit 1 - -if $EGREP '^build_old_libs=yes' libtool > /dev/null && - $EGREP '^build_libtool_libs=no' libtool > /dev/null; then : -else rm -f Makefile && exit 77 -fi +func_mkprefixdir +func_cd "f77demo" +func_make_distclean +func_configure "--disable-shared" +func_check_static_shared "yes" "no" exit 0 - - - - - - - - - diff --git a/tests/f77demo/.cvsignore b/tests/f77demo/.cvsignore new file mode 100644 index 000000000..30c894452 --- /dev/null +++ b/tests/f77demo/.cvsignore @@ -0,0 +1,17 @@ +.deps +.libs +Makefile +Makefile.in +acinclude.m4 +aclocal.m4 +autom4te.cache +configure +config.* +config-h.in +conftest* +libtool +*.lo +*.la +stamp-h* +cprogram +fprogram diff --git a/tests/f77demo/Makefile.am b/tests/f77demo/Makefile.am new file mode 100644 index 000000000..2757a0979 --- /dev/null +++ b/tests/f77demo/Makefile.am @@ -0,0 +1,45 @@ +## Makefile.am -- Process this file with automake to produce Makefile.in +## +## Copyright (C) 2003 Free Software Foundation +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2 of the License, or +## (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program; see the file COPYING. If not, write to +## the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +## Boston, MA 02111-1307, USA. + +top_distdir = ../.. + +AUTOMAKE_OPTIONS = no-dependencies foreign +ACLOCAL_AMFLAGS = -I $(top_distdir)/m4 + +noinst_LTLIBRARIES = libfoo.la libmix.la + +libfoo_la_SOURCES = foof.f +libfoo_la_LDFLAGS = -no-undefined + +libmix_la_SOURCES = foof.f fooc.c +libmix_la_LDFLAGS = -no-undefined + +noinst_HEADERS = foo.h + +bin_PROGRAMS = fprogram cprogram + +fprogram_SOURCES = fprogram.f +fprogram_LDADD = libfoo.la + +cprogram_SOURCES = cprogram.c +cprogram_LDADD = libmix.la + +$(OBJECTS): libtool +libtool: $(LIBTOOL_DEPS) + $(SHELL) ./config.status --recheck diff --git a/tests/f77demo/README b/tests/f77demo/README new file mode 100644 index 000000000..11df06c77 --- /dev/null +++ b/tests/f77demo/README @@ -0,0 +1,16 @@ +This is a short demo of the fortran support in libtool. + +fprogram is a pure-fortran program which is linked +against the fortran-only library libfoo.la + +cprogram is a C program, which is linked against the +mixed C and fortran library libmix.la. The program +calls a C function, which in turn calls a fortran +function. + +This demo requires GNU autoconf, automake, +libtool with the F77 tag and quite obvious Fortran 77. + + + + diff --git a/tests/f77demo/config.h b/tests/f77demo/config.h new file mode 100644 index 000000000..7780fc723 --- /dev/null +++ b/tests/f77demo/config.h @@ -0,0 +1,70 @@ +/* config.h. Generated by configure. */ +/* config-h.in. Generated from configure.ac by autoheader. */ + +/* Define to dummy `main' function (if any) required to link to the Fortran + libraries. */ +/* #undef F77_DUMMY_MAIN */ + +/* Define to a macro mangling the given C identifier (in lower and upper + case), which must not contain underscores, for linking with Fortran. */ +#define F77_FUNC(name,NAME) name ## _ + +/* As F77_FUNC, but for C identifiers containing underscores. */ +#define F77_FUNC_(name,NAME) name ## __ + +/* Define if F77 and FC dummy `main' functions are identical. */ +/* #undef FC_DUMMY_MAIN_EQ_F77 */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_DLFCN_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Name of package */ +#define PACKAGE "f77demo" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "bug-libtool@gnu.org" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "f77demo" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "f77demo 0.1" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "f77demo" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "0.1" + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Version number of package */ +#define VERSION "0.1" diff --git a/tests/f77demo/configure.ac b/tests/f77demo/configure.ac new file mode 100644 index 000000000..a1ddbacb7 --- /dev/null +++ b/tests/f77demo/configure.ac @@ -0,0 +1,71 @@ +## Process this file with autoconf to create configure. -*- autoconf -*- +# Copyright (C) 2001, 2003 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +# 02111-1307 USA + +AC_PREREQ(2.50) + +## ------------------------ ## +## Autoconf initialisation. ## +## ------------------------ ## +AC_INIT([f77demo], [0.1], [bug-libtool@gnu.org]) +AC_CONFIG_HEADERS([config.h:config-h.in]) +AC_CONFIG_SRCDIR([foof.f]) +AC_CONFIG_AUX_DIR([../../config]) + +## ------------------------ ## +## Automake Initialisation. ## +## ------------------------ ## +AM_INIT_AUTOMAKE(AC_PACKAGE_TARNAME, AC_PACKAGE_VERSION) + + +## ------------------ ## +## C compiler checks. ## +## ------------------ ## +AC_PROG_CC + +## ------------------------ ## +## Fortran compiler checks. ## +## ------------------------ ## +AC_PROG_F77 +dnl Check the flags needed to link f77 programs with ld (i.e. cc) +AC_F77_LIBRARY_LDFLAGS +dnl Check for underscoring of external names +AC_F77_WRAPPERS + +# As of the writing of this demo, GNU Autoconf's AC_OBJEXT and +# AC_EXEEXT macros only works for C compilers! +# Libtool's setup macro calls AC_OBJEXT and AC_EXEEXT without setting +# the test language to C. We do it before any libtool setup macros are +# called so that the proper values are cached beforehand. We also do +# it before any linker flags (LDFLAGS) are set so that fortran specific +# ones don't break the tests. +AC_LANG_PUSH([C]) +AC_OBJEXT +AC_EXEEXT +AC_LANG_POP + +## ----------------------- ## +## Libtool initialisation. ## +## ----------------------- ## +AM_PROG_LIBTOOL +AC_SUBST([LIBTOOL_DEPS]) + +## -------- ## +## Outputs. ## +## -------- ## +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT diff --git a/tests/f77demo/cprogram.c b/tests/f77demo/cprogram.c new file mode 100644 index 000000000..64edc84d9 --- /dev/null +++ b/tests/f77demo/cprogram.c @@ -0,0 +1,46 @@ +/* +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +USA. */ + +#include "foo.h" + +int +main(int argc, char **argv) +{ + int arg,cres,fres; + + printf ("Welcome to GNU libtool mixed C/Fortran demo!\n"); + + arg=2; + + cres=csub(arg); + + printf ("The C subroutine returned, claiming that 2*%d = %d\n",arg,cres); + + if(cres==2*arg) + printf ("The C subroutine is ok!\n"); + + printf("\nCalling the C wrapper routine...\n"); + fres=fwrapper(arg); + + printf ("The C wrapper to the fortran subroutine returned,\n" + "claiming that 2*%d = %d\n",arg,fres); + + if(fres==2*arg) + printf ("The Fortran 77 subroutine is ok!\n"); + + return 0; +} + diff --git a/tests/f77demo/foo.h b/tests/f77demo/foo.h new file mode 100644 index 000000000..4fd21eab6 --- /dev/null +++ b/tests/f77demo/foo.h @@ -0,0 +1,47 @@ +/* foo.h -- interface to fortran and C libraries + Copyright (C) 1998-1999 Free Software Foundation, Inc. + This file is part of GNU Libtool. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +USA. */ + +#ifndef _FOO_H_ +#define _FOO_H_ 1 + +/* config.h is necessary for the fortran name mangling */ +#ifdef HAVE_CONFIG_H +#include +#endif + +/* csub is an extremely useful subroutine that + * returns the argument multiplied by two :-) + */ +extern int csub(int); + +/* This routine performs the same action, but + * calls the fortran subroutine fsub to do the + * real work. + */ +extern int fwrapper(int); + +/* fsub does the same thing as csub, i.e. res=arg*2. + * Use autoconf macro for fortran function names. + * Note that fortran passes args by reference, so + * you need to provide pointers to your ints. + */ +extern void F77_FUNC(fsub,FSUB)(int *arg, int *res); + + +#endif diff --git a/tests/f77demo/fooc.c b/tests/f77demo/fooc.c new file mode 100644 index 000000000..eac944d4d --- /dev/null +++ b/tests/f77demo/fooc.c @@ -0,0 +1,17 @@ +#include "foo.h" + + +int csub(int arg) +{ + return (2*arg); +} + + +int fwrapper(int arg) +{ + int res; + printf("Calling the Fortran 77 subroutine from the C wrapper...\n"); + F77_FUNC(fsub,FSUB)(&arg,&res); + printf("Returned from the Fortran 77 subroutine...\n"); + return res; +} diff --git a/tests/f77demo/foof.f b/tests/f77demo/foof.f new file mode 100644 index 000000000..6e631fbff --- /dev/null +++ b/tests/f77demo/foof.f @@ -0,0 +1,13 @@ +C +C This program is free software; you can redistribute it and/or +C modify it under the terms of the GNU General Public License +C as published by the Free Software Foundation; either version 2 +C of the License, or (at your option) any later version. +C + + subroutine fsub(arg,res) + implicit none + integer*4 arg,res + res=arg*2 + return + end diff --git a/tests/f77demo/fprogram.f b/tests/f77demo/fprogram.f new file mode 100644 index 000000000..bf882f6e1 --- /dev/null +++ b/tests/f77demo/fprogram.f @@ -0,0 +1,27 @@ +C +C This program is free software; you can redistribute it and/or +C modify it under the terms of the GNU General Public License +C as published by the Free Software Foundation; either version 2 +C of the License, or (at your option) any later version. +C + + program fprogram + implicit none + integer*4 arg,res + + write(*,*) 'Welcome to GNU libtool Fortran demo!' + write(*,*) 'Real programmers write in FORTRAN.' + arg=2 + + call fsub(arg,res) + + write(*,*) 'fsub returned, saying that 2 *',arg,' =',res + + if (res.eq.4) then + write(*,*) 'fsub is ok!' + endif + + stop + end + + diff --git a/tests/link-2.test b/tests/link-2.test index 55f360a24..33b17d828 100755 --- a/tests/link-2.test +++ b/tests/link-2.test @@ -1,12 +1,29 @@ #! /bin/sh -# link.test - check that .lo files aren't made into programs. +# link-2.test - check that .lo files aren't made into programs. + +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. -# Test script header. -need_prefix=no if test -z "$srcdir"; then srcdir=`echo "$0" | sed 's%/[^/]*$%%'` test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes fi . $srcdir/defs || exit 1 @@ -19,18 +36,17 @@ EOF # Try a sample link command. linkresult=`$libtool -n --mode=link $CC -o something foo.o hell.lo` - res=$? rm -f hell.lo -test $res -eq 0 || exit 1 +test $res -eq 0 || exit $EXIT_FAILURE echo "$linkresult" case "$linkresult" in *".lo "*) - echo "$0: .lo files should not be linked into programs" - exit 1 + func_fail "$progname: .lo files should not be linked into programs" ;; esac -exit 0 + +exit $EXIT_SUCCESS diff --git a/tests/link.test b/tests/link.test index 4b208487c..64fe88984 100755 --- a/tests/link.test +++ b/tests/link.test @@ -1,25 +1,41 @@ #! /bin/sh # link.test - make sure that linking against libraries is legal. -# Test script header. -need_prefix=no +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. + if test -z "$srcdir"; then srcdir=`echo "$0" | sed 's%/[^/]*$%%'` test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes fi . $srcdir/defs || exit 1 # Try a sample link command. linkresult=`$libtool -n --mode=link $CC -o gettext ../lib/libnlsut.a` -test $? -eq 0 || exit 1 +test $? -eq 0 || exit $EXIT_FAILURE echo "$linkresult" case "$linkresult" in *../lib/libnlsut.a) ;; *) - echo "$progname: ../lib/libnlsut.a was not used as expected in linking" - exit 1 + func_fail "$progname: ../lib/libnlsut.a was not used as expected in linking" ;; esac -exit 0 +exit $EXIT_SUCCESS diff --git a/tests/mdemo-conf.test b/tests/mdemo-conf.test index acfe747dc..7a39d506c 100755 --- a/tests/mdemo-conf.test +++ b/tests/mdemo-conf.test @@ -1,35 +1,36 @@ #! /bin/sh -# mdemo-conf.test - try configuring the ../mdemo subdirectory +# mdemo-conf.test - try configuring the mdemo subdirectory + +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. -# Test script header. -need_prefix=yes if test -z "$srcdir"; then srcdir=`echo "$0" | sed 's%/[^/]*$%%'` test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes fi . $srcdir/defs || exit 1 -# Maybe we have a VPATH build, in which case, create a new subdir. -test -d ../mdemo || mkdir ../mdemo - -# Change to our build directory. -cd ../mdemo || exit 1 - -# Possibly clean up the distribution. -if test -f Makefile; then - echo "= Running $make distclean in ../mdemo" - $make distclean -fi -rm -f config.cache - -# Configure the demonstration. -echo "= Configuring in ../mdemo (prefix=$prefix)" -${CONFIG_SHELL-/bin/sh} $srcdir/../mdemo/configure --srcdir=$srcdir/../mdemo --prefix=$prefix || exit 1 - -if grep '^build_old_libs=yes' libtool > /dev/null && - grep '^build_libtool_libs=yes' libtool > /dev/null; then : -else rm -f Makefile && exit 77 -fi +func_mkprefixdir +func_cd "mdemo" +func_make_distclean +func_configure +func_check_static_shared "yes" "yes" exit 0 diff --git a/tests/dryrun.test b/tests/mdemo-dryrun.test similarity index 54% rename from tests/dryrun.test rename to tests/mdemo-dryrun.test index 0428904b9..3d3fa1bac 100755 --- a/tests/dryrun.test +++ b/tests/mdemo-dryrun.test @@ -1,37 +1,44 @@ #! /bin/sh -# dryrun.test - check whether the --dry-run mode works properly +# mdemo-dryrun.test - check whether the --dry-run mode works properly + +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. -# Test script header. -need_prefix=yes if test -z "$srcdir"; then srcdir=`echo "$0" | sed 's%/[^/]*$%%'` test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes fi . $srcdir/defs || exit 1 -if test -f ../mdemo/Makefile; then : -else - echo "You must run mdemo-conf.test before running $0" 1>&2 - exit 77 -fi - -# Change to our build directory. -cd ../mdemo || exit 1 - -echo "= Running $make clean in ../mdemo" -$make clean || exit 1 +func_require "mdemo-conf" "mdemo/Makefile" -eval `$libtool --config | grep "^objdir="` +func_mkprefixdir +func_cd "mdemo" +func_make "clean" # create `before' and `after' in a directory deep within objdir, # so that their creation and removal does not modify even a timestamp # in the output of `ls -l . $objdir' -for d in $objdir $objdir/temp $objdir/temp/temp; do - test -d $d || mkdir $d -done -before=$d/before -after=$d/after +func_mkdir_p "$objdir/temp/temp" +before=$objdir/temp/temp/before +after=$objdir/temp/temp/after # Create a new libtool script that will enter dry run if the environment # variable force_dry_run is set @@ -44,39 +51,36 @@ mv $objdir/libtool.new libtool # main.o is not compiled with libtool, but it depends on it, so make # sure it is up-to-date. libfoo2.la is linked with libsub.la, so make # sure it exists, otherwise libtool will complain. -$make main.$OBJEXT || exit 1 +func_make main.$objext -echo "= Making object files in ../mdemo (dry run)" +func_msg "Making object files in mdemo (dry run)" ls -l . $objdir | grep -v total > $before force_dry_run=yes $make foo1.lo foo2.lo sub.lo || exit $? ls -l . $objdir | grep -v total > $after cmp $before $after > /dev/null || exit 1 # Now really make them -echo "= Making object files in ../mdemo" -$make foo1.lo foo2.lo libsub.la || exit 1 +func_make foo1.lo foo2.lo libsub.la -echo "= Making libraries in ../mdemo (dry run)" +func_msg "Making libraries in mdemo (dry run)" ls -l . $objdir | grep -v total > $before force_dry_run=yes $make foo1.la libfoo2.la || exit $? ls -l . $objdir | grep -v total > $after cmp $before $after > /dev/null || exit 1 # Now really make them -echo "= Making libraries in ../mdemo" -$make foo1.la libfoo2.la || exit 1 +func_make foo1.la libfoo2.la -echo "= Making programs in ../mdemo (dry run)" +func_msg "Making programs in ../mdemo (dry run)" ls -l . $objdir | grep -v total > $before force_dry_run=yes $make mdemo$EXEEXT mdemo_static$EXEEXT 1>&2 || exit $? ls -l . $objdir | grep -v total > $after cmp $before $after > /dev/null || exit 1 # Now really make them -echo "= Making programs in ../mdemo" -$make mdemo$EXEEXT mdemo_static$EXEEXT || exit 1 +func_make mdemo$EXEEXT mdemo_static$EXEEXT -echo "= Running $make install in ../mdemo (dry run)" +func_msg "Running $make install in ../mdemo (dry run)" # Libtool does not create these directories -mkdir $prefix/bin -mkdir $prefix/lib +func_mkdir_p "$prefix/bin" +func_mkdir_p "$prefix/lib" ls -l . $objdir | grep -v total > $before ls -lR $prefix | grep -v total >> $before force_dry_run=yes $make install 1>&2 || exit 1 @@ -84,12 +88,11 @@ ls -l . $objdir | grep -v total > $after ls -lR $prefix | grep -v total >> $after cmp $before $after > /dev/null || exit 1 # Now really run it -echo "= Running $make install in ../mdemo" -$make install || exit 1 +func_make install -echo "= Running $make uninstall in ../mdemo (dry run)" +func_msg "Running $make uninstall in ../mdemo (dry run)" # Libtool does not uninstall the programs, remove them first -rm -f $prefix/bin/mdemo$EXEEXT $prefix/bin/mdemo_static$EXEEXT +rm -f "$prefix/bin/mdemo$EXEEXT" "$prefix/bin/mdemo_static$EXEEXT" ls -l . $objdir | grep -v total > $before ls -lR $prefix | grep -v total >> $before force_dry_run=yes $make uninstall 1>&2 || exit $? @@ -97,8 +100,7 @@ ls -l . $objdir | grep -v total > $after ls -lR $prefix | grep -v total >> $after cmp $before $after > /dev/null || exit 1 # Now really run it -echo "= Running $make uninstall in ../mdemo" -$make uninstall || exit 1 +func_make uninstall rm -f $before $after libtool mv $objdir/libtool libtool diff --git a/tests/mdemo-exec.test b/tests/mdemo-exec.test index 26834b3df..e6ef81e1e 100755 --- a/tests/mdemo-exec.test +++ b/tests/mdemo-exec.test @@ -1,35 +1,37 @@ #! /bin/sh -# mdemo-exec.test - check that programs in the ../mdemo subdirectory are viable +# mdemo-exec.test - check that programs in the mdemo subdirectory are viable + +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. -# Test script header. -need_prefix=no if test -z "$srcdir"; then srcdir=`echo "$0" | sed 's%/[^/]*$%%'` test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes fi . $srcdir/defs || exit 1 -if test -f ../mdemo/mdemo$EXEEXT; then : -else - echo "You must run mdemo-make.test before running $0" 1>&2 - exit 77 -fi - -# Check to see if the programs really run. -echo "Executing uninstalled programs in ../mdemo" +func_require "mdemo-make" "mdemo/mdemo$EXEEXT" -status=0 -if ../mdemo/mdemo_static ../mdemo/foo1.la ../mdemo/libfoo2.la; then : -else - echo "$0: execution of ../mdemo/mdemo_static failed" 1>&2 - status=1 -fi - -if ../mdemo/mdemo ../mdemo/foo1.la ../mdemo/libfoo2.la; then : -else - echo "$0: execution of ../mdemo/mdemo failed" 1>&2 - status=1 -fi +func_rmprefixdir +func_exec_init "uninstalled" +func_exec "mdemo/mdemo_static mdemo/foo1.la mdemo/libfoo2.la" +func_exec "mdemo/mdemo mdemo/foo1.la mdemo/libfoo2.la" -exit $status +exit $exec_status diff --git a/tests/mdemo-inst.test b/tests/mdemo-inst.test index 2e02e2c64..90c69a197 100755 --- a/tests/mdemo-inst.test +++ b/tests/mdemo-inst.test @@ -1,50 +1,39 @@ #! /bin/sh -# mdemo-inst.test - try installing from the ../mdemo subdirectory +# mdemo-inst.test - try installing from the mdemo subdirectory + +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. -# Test script header. -need_prefix=yes if test -z "$srcdir"; then srcdir=`echo "$0" | sed 's%/[^/]*$%%'` test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes fi . $srcdir/defs || exit 1 -# Check that things are built. -if test -f ../mdemo/mdemo$EXEEXT; then : -else - echo "You must run mdemo-make.test before $0" 1>&2 - exit 77 -fi - -# Change to our build directory. -cd ../mdemo || exit 1 - -echo "= Running $make install in ../mdemo" -$make install || exit 1 - -echo "= Executing installed programs" -path_old=$PATH -PATH=$prefix/lib:$PATH +func_require "mdemo-make" "mdemo/mdemo$EXEEXT" -status=0 -if $prefix/bin/mdemo_static $prefix/lib/foo1.la $prefix/lib/libfoo2.la; then : -else - echo "$0: cannot execute $prefix/bin/mdemo_static" 1>&2 - status=1 -fi - -if $prefix/bin/mdemo $prefix/lib/foo1.la $prefix/lib/libfoo2.la; then : -else - echo "$0: cannot execute $prefix/bin/mdemo" 1>&2 - - # Simple check to see if they are superuser. - if test -w /; then : - else - echo "You may need to run $0 as the superuser." - fi - status=1 -fi +func_mkprefixdir +func_cd "mdemo" +func_make "install" +func_exec_init "installed" +func_exec "$prefix/bin/mdemo_static $prefix/lib/foo1.la $prefix/lib/libfoo2.la" +func_exec "$prefix/bin/mdemo $prefix/lib/foo1.la $prefix/lib/libfoo2.la" -PATH=$path_old exit $status diff --git a/tests/mdemo-make.test b/tests/mdemo-make.test index c54b907fc..25a7127fb 100755 --- a/tests/mdemo-make.test +++ b/tests/mdemo-make.test @@ -1,25 +1,36 @@ #! /bin/sh -# mdemo-make.test - try building in the ../mdemo subdirectory +# mdemo-make.test - try building in the mdemo subdirectory + +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. -# Test script header. -need_prefix=no if test -z "$srcdir"; then srcdir=`echo "$0" | sed 's%/[^/]*$%%'` test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes fi . $srcdir/defs || exit 1 -if test -f ../mdemo/Makefile; then : -else - echo "You must run mdemo-conf.test before running $0" 1>&2 - exit 77 -fi +func_require "mdemo-conf" "mdemo/Makefile" -# Change to our build directory. -cd ../mdemo || exit 1 +func_rmprefixdir +func_cd "mdemo" +func_make -# Do the actual build. -echo "Making in ../mdemo" -$make || exit 1 exit 0 diff --git a/tests/mdemo-shared.test b/tests/mdemo-shared.test index b23a2348f..08507cf42 100755 --- a/tests/mdemo-shared.test +++ b/tests/mdemo-shared.test @@ -1,35 +1,36 @@ #! /bin/sh -# mdemo-conf.test - try configuring the ../mdemo subdirectory +# mdemo-shared.test - try configuring the mdemo subdirectory for shared libs + +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. -# Test script header. -need_prefix=yes if test -z "$srcdir"; then srcdir=`echo "$0" | sed 's%/[^/]*$%%'` test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes fi . $srcdir/defs || exit 1 -# Maybe we have a VPATH build, in which case, create a new subdir. -test -d ../mdemo || mkdir ../mdemo - -# Change to our build directory. -cd ../mdemo || exit 1 - -# Possibly clean up the distribution. -if test -f Makefile; then - echo "= Running $make distclean in ../mdemo" - $make distclean -fi -rm -f config.cache - -# Configure the demonstration. -echo "= Configuring in ../mdemo (prefix=$prefix) with --disable-static" -${CONFIG_SHELL-/bin/sh} $srcdir/../mdemo/configure --srcdir=$srcdir/../mdemo --prefix=$prefix --disable-static || exit 1 - -if grep '^build_old_libs=no' libtool > /dev/null && - grep '^build_libtool_libs=yes' libtool > /dev/null; then : -else rm -f Makefile && exit 77 -fi +func_mkprefixdir +func_cd "mdemo" +func_make_distclean +func_configure "--disable-static" +func_check_static_shared "no" "yes" exit 0 diff --git a/tests/mdemo-static.test b/tests/mdemo-static.test index 6e0292292..bd4acd11d 100755 --- a/tests/mdemo-static.test +++ b/tests/mdemo-static.test @@ -1,35 +1,36 @@ #! /bin/sh -# mdemo-conf.test - try configuring the ../mdemo subdirectory +# mdemo-static.test - try configuring the mdemo subdirectory for static libs + +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. -# Test script header. -need_prefix=yes if test -z "$srcdir"; then srcdir=`echo "$0" | sed 's%/[^/]*$%%'` test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes fi . $srcdir/defs || exit 1 -# Maybe we have a VPATH build, in which case, create a new subdir. -test -d ../mdemo || mkdir ../mdemo - -# Change to our build directory. -cd ../mdemo || exit 1 - -# Possibly clean up the distribution. -if test -f Makefile; then - echo "= Running $make distclean in ../mdemo" - $make distclean -fi -rm -f config.cache - -# Configure the demonstration. -echo "= Configuring in ../mdemo (prefix=$prefix) with --disable-shared" -${CONFIG_SHELL-/bin/sh} $srcdir/../mdemo/configure --srcdir=$srcdir/../mdemo --prefix=$prefix --disable-shared || exit 1 - -if grep '^build_old_libs=yes' libtool > /dev/null && - grep '^build_libtool_libs=no' libtool > /dev/null; then : -else rm -f Makefile && exit 77 -fi +func_mkprefixdir +func_cd "mdemo" +func_make_distclean +func_configure "--disable-shared" +func_check_static_shared "yes" "no" exit 0 diff --git a/tests/mdemo-unst.test b/tests/mdemo-unst.test index 2ffe4f9f1..15b6a4925 100755 --- a/tests/mdemo-unst.test +++ b/tests/mdemo-unst.test @@ -1,32 +1,36 @@ #! /bin/sh -# mdemo.test - try uninstalling in the ../mdemo subdirectory +# mdemo-unst.test - try uninstalling in the mdemo subdirectory + +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. -# Test script header. -need_prefix=yes if test -z "$srcdir"; then srcdir=`echo "$0" | sed 's%/[^/]*$%%'` test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes fi . $srcdir/defs || exit 1 -# Make sure it was installed already -if test "$prefix/bin/hell" && cd ../mdemo && test -f Makefile; then : -else - echo "You must run mdemo-inst.test before $0." 1>&2 - exit 77 -fi +func_require "mdemo-inst" "$prefix/bin/mdemo$EXEEXT" "mdemo/Makefile" -echo "= Running $make uninstall in ../mdemo" -$make uninstall || exit 1 - -# See that there were no files leftover in $prefix. -# Ignore dotfiles, so that .nfsXXX files don't screw up the test. -leftovers=`find $prefix ! -type d ! -name '.*' -print` -if test -n "$leftovers"; then - echo "= Leftover after make uninstall:" - ls -l $leftovers - exit 1 -fi +func_mkprefixdir +func_cd "mdemo" +func_make_uninstall exit 0 diff --git a/tests/mdemo/.cvsignore b/tests/mdemo/.cvsignore new file mode 100644 index 000000000..47c0c4b33 --- /dev/null +++ b/tests/mdemo/.cvsignore @@ -0,0 +1,15 @@ +.deps +.libs +Makefile +Makefile.in +acinclude.m4 +aclocal.m4 +autom4te.cache +configure +config.* +conftest* +libtool +*.lo +*.la +mdemo +mdemo_static diff --git a/tests/mdemo/Makefile.am b/tests/mdemo/Makefile.am new file mode 100644 index 000000000..a005d167c --- /dev/null +++ b/tests/mdemo/Makefile.am @@ -0,0 +1,75 @@ +## Makefile.am -- Process this file with automake to produce Makefile.in +## +## Copyright (C) 2003 Free Software Foundation +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2 of the License, or +## (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program; see the file COPYING. If not, write to +## the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +## Boston, MA 02111-1307, USA. + +top_distdir = ../.. + +AUTOMAKE_OPTIONS = no-dependencies foreign +ACLOCAL_AMFLAGS = -I $(top_distdir)/m4 + +INCLUDES = $(INCLTDL) + +lib_LTLIBRARIES = libsub.la foo1.la libfoo2.la libmlib.la + +foo1_la_SOURCES = foo1.c +foo1_la_LIBADD = $(LIBM) libsub.la +foo1_la_LDFLAGS = -no-undefined -module -avoid-version + +libfoo2_la_SOURCES = foo2.c +libfoo2_la_LIBADD = $(LIBM) libsub.la +libfoo2_la_LDFLAGS = -no-undefined -module -export-symbols-regex "libfoo2.*" + +libsub_la_SOURCES = sub.c +libsub_la_LDFLAGS = -no-undefined + +libmlib_la_SOURCES = mlib.c +libmlib_la_LIBADD = @LIBLTDL@ "-dlopen" foo1.la "-dlopen" libfoo2.la +libmlib_la_LDFLAGS = -no-undefined +libmlib_la_DEPENDENCIES = @LIBLTDL@ libsub.la foo1.la libfoo2.la + +noinst_HEADERS = foo.h + +bin_PROGRAMS = mdemo mdemo_static + +## use @LIBLTDL@ because some broken makes do not accept macros in targets +## we can only do this because our LIBLTDL does not contain ${top_builddir} +@LIBLTDL@: $(top_distdir)/libtool $(top_distdir)/libltdl/libtool \ + $(top_distdir)/libltdl/config.h $(srcdir)/$(top_distdir)/libltdl/ltdl.c \ + $(srcdir)/$(top_distdir)/libltdl/ltdl.h + (cd $(top_distdir)/libltdl; $(MAKE) `echo $(LIBLTDL) | sed 's,.*\.\./libltdl/,,g'`) +# Without the following line, the check may fail if libltdl/libtool is +# removed after libltdl is configured +$(top_distdir)/libltdl/libtool $(top_distdir)/libltdl/config.h: + +# Create a version of mdemo that does dlopen. +mdemo_SOURCES = main.c +mdemo_LDFLAGS = -export-dynamic +## The quotes around -dlopen below fool automake into accepting it +mdemo_LDADD = @LIBLTDL@ libsub.la "-dlopen" self \ + "-dlopen" foo1.la "-dlopen" libfoo2.la +mdemo_DEPENDENCIES = @LIBLTDL@ libsub.la foo1.la libfoo2.la + +# Create a statically linked version of mdemo. +mdemo_static_SOURCES = $(mdemo_SOURCES) +mdemo_static_LDFLAGS = $(STATIC) $(mdemo_LDFLAGS) +mdemo_static_LDADD = $(mdemo_LDADD) +mdemo_static_DEPENDENCIES = $(mdemo_DEPENDENCIES) + +$(OBJECTS): libtool +libtool: $(LIBTOOL_DEPS) + $(SHELL) ./config.status --recheck diff --git a/tests/mdemo/README b/tests/mdemo/README new file mode 100644 index 000000000..936396a9b --- /dev/null +++ b/tests/mdemo/README @@ -0,0 +1,17 @@ +This is mdemo, an example package that uses GNU libtool with an +Automake-generated environment to build two simple modules and +a program. + +It demonstrates how to build both dynamic and static libraries +that can be dlopened. mdemo uses libtool's portable dlopen +wrapper called "libltdl". +All exported symbols are prefixed with "libname_LTX_" to avoid +symbols conflicts, especially when linking statically. +libltdl will automatically cut the prefix off to get the real name. + +Note that on Windows, for the purposes of illustrating ltdl, the +libraries *are* built as dll's, but do not have the __declspec +machinery to make them suitable for loading at link time. This is +only for clarity inside this example, look at the example in ../demo +to see how the __declspec macros should be set up. + diff --git a/tests/mdemo/configure.ac b/tests/mdemo/configure.ac new file mode 100644 index 000000000..792918cea --- /dev/null +++ b/tests/mdemo/configure.ac @@ -0,0 +1,80 @@ +## Process this file with autoconf to create configure. -*- autoconf -*- +# Copyright (C) 2001, 2003 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +# 02111-1307 USA + +AC_PREREQ(2.50) + + +## ------------------------ ## +## Autoconf initialisation. ## +## ------------------------ ## +AC_INIT([mdemo], [0.1], [bug-libtool@gnu.org]) +AC_CONFIG_SRCDIR([main.c]) +AC_CONFIG_AUX_DIR([../../config]) + + +## ------------------------ ## +## Automake Initialisation. ## +## ------------------------ ## +AM_INIT_AUTOMAKE(AC_PACKAGE_TARNAME, AC_PACKAGE_VERSION) + + +## ------------------ ## +## C compiler checks. ## +## ------------------ ## +AC_PROG_CC +AC_C_CONST + + +## ----------------------- ## +## Libtool initialisation. ## +## ----------------------- ## +AC_LIBLTDL_CONVENIENCE([../../libltdl]) +AC_SUBST([INCLTDL]) +AC_SUBST([LIBLTDL]) + +AC_LIBTOOL_WIN32_DLL +AC_LIBTOOL_DLOPEN +AM_PROG_LIBTOOL +AC_SUBST(LIBTOOL_DEPS) + +if ${CONFIG_SHELL} ./libtool --features | grep "enable static" >/dev/null; then + STATIC=-static +else + STATIC= +fi +AC_SUBST([STATIC]) + + +## ---------------------------- ## +## C headers required by mdemo. ## +## ---------------------------- ## +AC_CHECK_HEADERS([math.h]) + + +## ---------------------------- ## +## Libraries required by cdemo. ## +## ---------------------------- ## +AC_CHECK_LIBM +AC_SUBST([LIBM]) + + +## -------- ## +## Outputs. ## +## -------- ## +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT diff --git a/tests/mdemo/foo.h b/tests/mdemo/foo.h new file mode 100644 index 000000000..be28c770b --- /dev/null +++ b/tests/mdemo/foo.h @@ -0,0 +1,31 @@ +/* foo.h -- interface to the libfoo* libraries + Copyright (C) 1998-1999 Free Software Foundation, Inc. + Originally by Thomas Tanner + This file is part of GNU Libtool. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +USA. */ + +/* Only include this header file once. */ +#ifndef _FOO_H_ +#define _FOO_H_ 1 + +/* Silly constants that the functions return. */ +#define HELLO_RET 0xe110 +#define FOO_RET 0xf00 + +extern void sub(); + +#endif /* !_FOO_H_ */ diff --git a/tests/mdemo/foo1.c b/tests/mdemo/foo1.c new file mode 100644 index 000000000..e09c5f8da --- /dev/null +++ b/tests/mdemo/foo1.c @@ -0,0 +1,57 @@ +/* foo1.c -- trivial test library + Copyright (C) 1998-1999 Free Software Foundation, Inc. + Originally by Thomas Tanner + This file is part of GNU Libtool. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +USA. */ + +#include "foo.h" +#include + +#ifdef HAVE_MATH_H +#include +#endif + +#define nothing foo1_LTX_nothing +#define foo1 foo1_LTX_foo1 +#define hello foo1_LTX_hello + +/* Give a global variable definition. */ +int nothing; + +/* private function */ +int +_foo1_helper() +{ + sub(); + return FOO_RET; +} + +/* exported functions */ + +int +foo1() +{ + printf ("cos (0.0) = %g\n", (double) cos ((double) 0.0)); + return _foo1_helper(); +} + +int +hello() +{ + printf ("** This is foolib 1 **\n"); + return HELLO_RET; +} diff --git a/tests/mdemo/foo2.c b/tests/mdemo/foo2.c new file mode 100644 index 000000000..443994d6d --- /dev/null +++ b/tests/mdemo/foo2.c @@ -0,0 +1,57 @@ +/* foo2.c -- trivial test library + Copyright (C) 1998-1999 Free Software Foundation, Inc. + Originally by Thomas Tanner + This file is part of GNU Libtool. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +USA. */ + +#include "foo.h" +#include + +#ifdef HAVE_MATH_H +#include +#endif + +#define nothing libfoo2_LTX_nothing +#define foo2 libfoo2_LTX_foo2 +#define hello libfoo2_LTX_hello + +/* Give a global variable definition. */ +int nothing; + +/* private function */ +int +_foo2_helper() +{ + sub(); + return FOO_RET; +} + +/* exported functions */ + +int +foo2() +{ + printf ("sin (0.0) = %g\n", (double) sin ((double) 0.0)); + return _foo2_helper(); +} + +int +hello() +{ + printf ("** This is foolib 2 **\n"); + return HELLO_RET; +} diff --git a/tests/mdemo/main.c b/tests/mdemo/main.c new file mode 100644 index 000000000..312fd10ed --- /dev/null +++ b/tests/mdemo/main.c @@ -0,0 +1,195 @@ +/* main.c -- mdemo test program + Copyright (C) 1998-2000 Free Software Foundation, Inc. + Originally by Thomas Tanner + This file is part of GNU Libtool. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +USA. */ + +#include "foo.h" +#include "ltdl.h" +#include + +int +test_dl (filename) + char *filename; +{ + lt_dlhandle handle; + const lt_dlinfo *info; + int (*pfoo1)() = 0; + int (*pfoo2)() = 0; + int (*phello)() = 0; + int *pnothing = 0; + int ret = 0; + + handle = lt_dlopen(filename); + if (!handle) { + fprintf (stderr, "can't open the module %s!\n", filename); + fprintf (stderr, "error was: %s\n", lt_dlerror()); + return 1; + } + + info = lt_dlgetinfo(handle); + if (!info) { + fprintf (stderr, "can't get module info: %s\n", lt_dlerror()); + return 1; + } + if (info->name) { + printf ("module name: %s\n", info->name); + } else { + printf ("module is not a libtool module\n"); + } + printf ("module filename: %s\n", info->filename); + printf ("module reference count: %i\n", info->ref_count); + + phello = (int(*)())lt_dlsym(handle, "hello"); + if (phello) + { + int value = (*phello) (); + + printf ("hello returned: %i\n", value); + if (value == HELLO_RET) + printf("hello is ok!\n"); + } + else + { + fprintf (stderr, "did not find the `hello' function\n"); + fprintf (stderr, "error was: %s\n", lt_dlerror()); + ret = 1; + } + + pnothing = (int*)lt_dlsym(handle, "nothing"); + /* Try assigning to the nothing variable. */ + if (pnothing) + *pnothing = 1; + else + { + fprintf (stderr, "did not find the `nothing' variable\n"); + fprintf (stderr, "error was: %s\n", lt_dlerror()); + ret = 1; + } + + pfoo1 = (int(*)())lt_dlsym(handle, "foo1"); + /* Just call the functions and check return values. */ + if (pfoo1) + { + if ((*pfoo1) () == FOO_RET) + printf("foo1 is ok!\n"); + else + ret = 1; + } + else { + pfoo2 = (int(*)())lt_dlsym(handle, "foo2"); + if (pfoo2) + { + if ((*pfoo2) () == FOO_RET) + printf("foo2 is ok!\n"); + else ret = 1; + } + else + { + fprintf (stderr, "did not find any of the `foo' functions\n"); + fprintf (stderr, "error was: %s\n", lt_dlerror()); + ret = 1; + } + } + lt_dlclose(handle); + return ret; +} + +int +myfunc () +{ + return HELLO_RET; +} + +int myvar; + +int +test_dlself () +{ + lt_dlhandle handle; + int (*pmyfunc)() = 0; + int *pmyvar = 0; + int ret = 0; + + handle = lt_dlopen(0); + if (!handle) { + fprintf (stderr, "can't dlopen the program!\n"); + fprintf (stderr, "error was: %s\n", lt_dlerror()); + return 1; + } + + pmyfunc = (int(*)())lt_dlsym(handle, "myfunc"); + if (pmyfunc) + { + int value = (*pmyfunc) (); + + printf ("myfunc returned: %i\n", value); + if (value == HELLO_RET) + printf("myfunc is ok!\n"); + } + else + { + fprintf (stderr, "did not find the `myfunc' function\n"); + fprintf (stderr, "error was: %s\n", lt_dlerror()); + ret = 1; + } + + pmyvar = (int*)lt_dlsym(handle, "myvar"); + /* Try assigning to the variable. */ + if (pmyvar) + *pmyvar = 1; + else + { + fprintf (stderr, "did not find the `myvar' variable\n"); + fprintf (stderr, "error was: %s\n", lt_dlerror()); + ret = 1; + } + + lt_dlclose(handle); + return ret; +} + +int +main (argc, argv) + int argc; + char **argv; +{ + int i; + int ret = 0; + + printf ("Welcome to GNU libtool mdemo!\n"); + + if (argc < 2) { + fprintf (stderr, "usage: %s module [module...]\n", argv[0]); + } + + LTDL_SET_PRELOADED_SYMBOLS(); + if (lt_dlinit() != 0) { + fprintf (stderr, "error during initialization: %s\n", lt_dlerror()); + return 1; + } + + for (i = 1; i < argc; i++) + if (test_dl(argv[i])) + ret = 1; + + if (test_dlself()) + ret = 1; + + lt_dlexit(); + return ret; +} diff --git a/tests/mdemo/mlib.c b/tests/mdemo/mlib.c new file mode 100644 index 000000000..bb859d3e6 --- /dev/null +++ b/tests/mdemo/mlib.c @@ -0,0 +1,134 @@ +/* main.c -- mlib library + Copyright (C) 2002 Free Software Foundation, Inc. + Originally by greg Eisenhauer + Extracted from mdemo.c + This file is part of GNU Libtool. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +USA. */ + +#include "foo.h" +#include "ltdl.h" +#include + +int +test_dl (filename) + char *filename; +{ + lt_dlhandle handle; + const lt_dlinfo *info; + int (*pfoo1)() = 0; + int (*pfoo2)() = 0; + int (*phello)() = 0; + int *pnothing = 0; + int ret = 0; + + handle = lt_dlopen(filename); + if (!handle) { + fprintf (stderr, "can't open the module %s!\n", filename); + fprintf (stderr, "error was: %s\n", lt_dlerror()); + return 1; + } + + info = lt_dlgetinfo(handle); + if (!info) { + fprintf (stderr, "can't get module info: %s\n", lt_dlerror()); + return 1; + } + if (info->name) { + printf ("module name: %s\n", info->name); + } else { + printf ("module is not a libtool module\n"); + } + printf ("module filename: %s\n", info->filename); + printf ("module reference count: %i\n", info->ref_count); + + phello = (int(*)())lt_dlsym(handle, "hello"); + if (phello) + { + int value = (*phello) (); + + printf ("hello returned: %i\n", value); + if (value == HELLO_RET) + printf("hello is ok!\n"); + } + else + { + fprintf (stderr, "did not find the `hello' function\n"); + fprintf (stderr, "error was: %s\n", lt_dlerror()); + ret = 1; + } + + pnothing = (int*)lt_dlsym(handle, "nothing"); + /* Try assigning to the nothing variable. */ + if (pnothing) + *pnothing = 1; + else + { + fprintf (stderr, "did not find the `nothing' variable\n"); + fprintf (stderr, "error was: %s\n", lt_dlerror()); + ret = 1; + } + + pfoo1 = (int(*)())lt_dlsym(handle, "foo1"); + /* Just call the functions and check return values. */ + if (pfoo1) + { + if ((*pfoo1) () == FOO_RET) + printf("foo1 is ok!\n"); + else + ret = 1; + } + else { + pfoo2 = (int(*)())lt_dlsym(handle, "foo2"); + if (pfoo2) + { + if ((*pfoo2) () == FOO_RET) + printf("foo2 is ok!\n"); + else ret = 1; + } + else + { + fprintf (stderr, "did not find any of the `foo' functions\n"); + fprintf (stderr, "error was: %s\n", lt_dlerror()); + ret = 1; + } + } + lt_dlclose(handle); + return ret; +} +int +mlib_func(argc, argv) +int argc; +char **argv; +{ + int ret = 0; + int i; + /* + * Would be nice if this somehow worked for libraries, not just executables. + * LTDL_SET_PRELOADED_SYMBOLS(); + */ + if (lt_dlinit() != 0) { + fprintf (stderr, "error during initialization: %s\n", lt_dlerror()); + return 1; + } + + for (i = 1; i < argc; i++) + if (test_dl(argv[i])) + ret = 1; + + lt_dlexit(); + return ret; +} diff --git a/tests/mdemo/sub.c b/tests/mdemo/sub.c new file mode 100644 index 000000000..75dc497da --- /dev/null +++ b/tests/mdemo/sub.c @@ -0,0 +1,27 @@ +/* sub.c -- trivial test library + Copyright (C) 1998-1999 Free Software Foundation, Inc. + Originally by Thomas Tanner + This file is part of GNU Libtool. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +USA. */ + +#include + +void +sub() +{ + printf ("sub() called\n"); +} diff --git a/tests/mdemo2-conf.test b/tests/mdemo2-conf.test index b92dd2247..5229db868 100755 --- a/tests/mdemo2-conf.test +++ b/tests/mdemo2-conf.test @@ -1,35 +1,36 @@ #! /bin/sh -# mdemo2-conf.test - try configuring the ../mdemo2 subdirectory +# mdemo2-conf.test - try configuring the mdemo2 subdirectory + +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. -# Test script header. -need_prefix=yes if test -z "$srcdir"; then srcdir=`echo "$0" | sed 's%/[^/]*$%%'` test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes fi . $srcdir/defs || exit 1 -# Maybe we have a VPATH build, in which case, create a new subdir. -test -d ../mdemo2 || mkdir ../mdemo2 - -# Change to our build directory. -cd ../mdemo2 || exit 1 - -# Possibly clean up the distribution. -if test -f Makefile; then - echo "= Running $make distclean in ../mdemo2" - $make distclean -fi -rm -f config.cache - -# Configure the demonstration. -echo "= Configuring in ../mdemo2 (prefix=$prefix)" -CONFIG_SITE=/nonexistent ${CONFIG_SHELL-/bin/sh} $srcdir/../mdemo2/configure --srcdir=$srcdir/../mdemo2 --prefix=$prefix || exit 1 - -if grep '^build_old_libs=yes' libtool > /dev/null && - grep '^build_libtool_libs=yes' libtool > /dev/null; then : -else rm -f Makefile && exit 77 -fi +func_mkprefixdir +func_cd "mdemo2" +func_make_distclean +func_configure +func_check_static_shared "yes" "yes" exit 0 diff --git a/tests/mdemo2-exec.test b/tests/mdemo2-exec.test index 74aaacf69..8b4eb2362 100755 --- a/tests/mdemo2-exec.test +++ b/tests/mdemo2-exec.test @@ -1,35 +1,37 @@ #! /bin/sh -# mdemo2-exec.test - check that programs in the ../mdemo2 subdirectory are viable +# mdemo2-exec.test - check that programs in the mdemo2 subdirectory are viable + +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. -# Test script header. -need_prefix=no if test -z "$srcdir"; then srcdir=`echo "$0" | sed 's%/[^/]*$%%'` test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes fi . $srcdir/defs || exit 1 -if test -f ../mdemo2/mdemo2; then : -else - echo "You must run mdemo2-make.test before running $0" 1>&2 - exit 77 -fi - -# Check to see if the programs really run. -echo "Executing uninstalled programs in ../mdemo2" +func_require "mdemo2-make" "mdemo2/mdemo2$EXEEXT" -status=0 -if ../mdemo2/mdemo2_static ../mdemo/foo1.la ../mdemo/libfoo2.la; then : -else - echo "$0: execution of ../mdemo2/mdemo2_static failed" 1>&2 - status=1 -fi - -if ../mdemo2/mdemo2 ../mdemo/foo1.la ../mdemo/libfoo2.la; then : -else - echo "$0: execution of ../mdemo2/mdemo2 failed" 1>&2 - status=1 -fi +func_rmprefixdir +func_exec_init "uninstalled" +func_exec "mdemo2/mdemo2_static mdemo/foo1.la mdemo/libfoo2.la" +func_exec "mdemo2/mdemo2 mdemo/foo1.la mdemo/libfoo2.la" -exit $status +exit $exec_status diff --git a/tests/mdemo2-make.test b/tests/mdemo2-make.test index ebaf8b37b..650d7cf0f 100755 --- a/tests/mdemo2-make.test +++ b/tests/mdemo2-make.test @@ -1,31 +1,37 @@ #! /bin/sh -# mdemo2-make.test - try building in the ../mdemo2 subdirectory +# mdemo2-make.test - try building in the mdemo2 subdirectory + +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. -# Test script header. -need_prefix=no if test -z "$srcdir"; then srcdir=`echo "$0" | sed 's%/[^/]*$%%'` test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes fi . $srcdir/defs || exit 1 -if test -f ../mdemo2/Makefile; then : -else - echo "You must run mdemo2-conf.test before running $0" 1>&2 - exit 77 -fi - -if test -f ../mdemo/libmlib.la; then : -else - echo "You must run mdemo-make.test before running $0" 1>&2 - exit 77 -fi +func_require "mdemo2-conf" "mdemo2/Makefile" +func_require "mdemo-make" "mdemo/libmlib.la" -# Change to our build directory. -cd ../mdemo2 || exit 1 +func_rmprefixdir +func_cd "mdemo2" +func_make -# Do the actual build. -echo "Making in ../mdemo2" -$make || exit 1 exit 0 diff --git a/tests/mdemo2/.cvsignore b/tests/mdemo2/.cvsignore new file mode 100644 index 000000000..fd7a07947 --- /dev/null +++ b/tests/mdemo2/.cvsignore @@ -0,0 +1,15 @@ +.deps +.libs +Makefile +Makefile.in +acinclude.m4 +aclocal.m4 +autom4te.cache +configure +config.* +conftest* +libtool +*.lo +*.la +mdemo2 +mdemo2_static diff --git a/tests/mdemo2/Makefile.am b/tests/mdemo2/Makefile.am new file mode 100644 index 000000000..f68e950b2 --- /dev/null +++ b/tests/mdemo2/Makefile.am @@ -0,0 +1,42 @@ +## Makefile.am -- Process this file with automake to produce Makefile.in +## +## Copyright (C) 2003 Free Software Foundation +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2 of the License, or +## (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program; see the file COPYING. If not, write to +## the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +## Boston, MA 02111-1307, USA. + +top_distdir = ../.. + +AUTOMAKE_OPTIONS = no-dependencies foreign +ACLOCAL_AMFLAGS = -I $(top_distdir)/m4 + +AM_CPPFLAGS = -I$(top_distdir)/libltdl + +bin_PROGRAMS = mdemo2 mdemo2_static + +# Create a version of mdemo2 that links a library that does dlopen. +mdemo2_SOURCES = main.c +mdemo2_LDFLAGS = -export-dynamic "-dlopen" force +mdemo2_LDADD = ../mdemo/libmlib.la + +# Create a statically linked version of mdemo. +mdemo2_static_SOURCES = $(mdemo2_SOURCES) +mdemo2_static_LDFLAGS = $(STATIC) $(mdemo2_LDFLAGS) +mdemo2_static_LDADD = $(mdemo2_LDADD) +mdemo2_static_DEPENDENCIES = $(mdemo2_DEPENDENCIES) + +$(OBJECTS): libtool +libtool: $(LIBTOOL_DEPS) + $(SHELL) ./config.status --recheck diff --git a/tests/mdemo2/README b/tests/mdemo2/README new file mode 100644 index 000000000..8a1e18ba8 --- /dev/null +++ b/tests/mdemo2/README @@ -0,0 +1,5 @@ +This is mdemo2, an example package that attempts to use GNU libtool to +link with a library that itself does dlopening of libtool modules. + +This demo depends upon the libraries generated in ../mdemo. + diff --git a/tests/mdemo2/configure.ac b/tests/mdemo2/configure.ac new file mode 100644 index 000000000..5a28908da --- /dev/null +++ b/tests/mdemo2/configure.ac @@ -0,0 +1,72 @@ +## Process this file with autoconf to create configure. -*- autoconf -*- +# Copyright (C) 2001, 2003 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +# 02111-1307 USA + +AC_PREREQ(2.50) + + +## ------------------------ ## +## Autoconf initialisation. ## +## ------------------------ ## +AC_INIT([mdemo2], [0.1], [bug-libtool@gnu.org]) +AC_CONFIG_SRCDIR([main.c]) +AC_CONFIG_AUX_DIR([../../config]) + + +## ------------------------ ## +## Automake Initialisation. ## +## ------------------------ ## +AM_INIT_AUTOMAKE(AC_PACKAGE_TARNAME, AC_PACKAGE_VERSION) + + +## ------------------ ## +## C compiler checks. ## +## ------------------ ## +AC_PROG_CC +AC_C_CONST + + +## ----------------------- ## +## Libtool initialisation. ## +## ----------------------- ## +AC_LIBTOOL_DLOPEN +AM_PROG_LIBTOOL +AC_SUBST(LIBTOOL_DEPS) + +if ${CONFIG_SHELL} ./libtool --features | grep "enable static" >/dev/null; then + STATIC=-static +else + STATIC= +fi +AC_SUBST([STATIC]) + + +## ---------------------------- ## +## C headers required by mdemo2. ## +## ---------------------------- ## + + +## ---------------------------- ## +## Libraries required by cdemo. ## +## ---------------------------- ## + + +## -------- ## +## Outputs. ## +## -------- ## +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT diff --git a/tests/mdemo2/main.c b/tests/mdemo2/main.c new file mode 100644 index 000000000..7e85a438c --- /dev/null +++ b/tests/mdemo2/main.c @@ -0,0 +1,42 @@ +/* main.c -- mdemo2 test program + Copyright (C) 2003 Free Software Foundation, Inc. + Originally by Greg Eisenhauer < eisen at cc.gatech.edu > + This file is part of GNU Libtool. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +USA. */ + +#include +#include "ltdl.h" + +int +main (argc, argv) + int argc; + char **argv; +{ + int ret = 0; + + printf ("Welcome to GNU libtool mdemo2!\n"); + if (argc < 2) { + fprintf (stderr, "usage: %s module [module...]\n", argv[0]); + } + +/* This must be called in the program to get the preloaded symbols */ + LTDL_SET_PRELOADED_SYMBOLS(); + + ret = mlib_func(argc, argv); + + return ret; +} diff --git a/tests/noinst-link.test b/tests/noinst-link.test deleted file mode 100755 index edf3c3fb9..000000000 --- a/tests/noinst-link.test +++ /dev/null @@ -1,35 +0,0 @@ -#! /bin/sh -# noinst-link.test - make sure we do not link with an installed -# library when an uninstalled one is to be used - -# Test script header. -need_prefix=yes -if test -z "$srcdir"; then - srcdir=`echo "$0" | sed 's%/[^/]*$%%'` - test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes -fi -. $srcdir/defs || exit 1 - -# Check that things are built. -if test -f $prefix/lib/libhello.la; then : -else - echo "You must run demo-inst.test before $0" 1>&2 - exit 77 -fi - -# Change to our build directory. -cd ../demo || exit 77 - -echo "removing libhello.la and hell from ../demo" -rm -f libhello.la hell$EXEEXT - -echo "linking hell with a broken ../demo/libhello.la" -if $make hell$EXEEXT libhello_la_OBJECTS=hello.lo; then - echo "= Succeeded: this means the installed library was used, which is wrong" - status=1 -fi - -rm -f libhello.la hell$EXEEXT - -exit $status diff --git a/tests/nomode.test b/tests/nomode.test index 55c9cd246..16822abf4 100755 --- a/tests/nomode.test +++ b/tests/nomode.test @@ -1,27 +1,44 @@ #! /bin/sh # nomode.test - check that we can actually get help -# Test script header. -need_prefix=no +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. + if test -z "$srcdir"; then srcdir=`echo "$0" | sed 's%/[^/]*$%%'` test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes fi . $srcdir/defs || exit 1 -status=0 +status=$EXIT_SUCCESS if $libtool --help 2>&1 | grep '^Usage:' >/dev/null; then : else echo "cannot get top-level help" - status=1 + status=$EXIT_FAILURE fi # The emoticon below works around a nasty bug in Ultrix /bin/sh if ($libtool 2>&1; :) | grep 'you must specify a MODE' >/dev/null; then : else echo "invalid error when no mode is specified" - status=1 + status=$EXIT_FAILURE fi exit $status diff --git a/tests/pdemo-conf.test b/tests/pdemo-conf.test index 655b81831..30a79add9 100755 --- a/tests/pdemo-conf.test +++ b/tests/pdemo-conf.test @@ -1,36 +1,37 @@ #! /bin/sh -# pdemo-conf.test - try configuring the ../pdemo subdirectory +# pdemo-conf.test - try configuring the pdemo subdirectory + +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. -# Test script header. -need_prefix=yes if test -z "$srcdir"; then srcdir=`echo "$0" | sed 's%/[^/]*$%%'` test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes fi . $srcdir/defs || exit 1 -# Maybe we have a VPATH build, in which case, create a new subdir. -test -d ../pdemo || mkdir ../pdemo - -# Change to our build directory. -cd ../pdemo || exit 1 - -# Possibly clean up the distribution. -if test -f Makefile; then - echo "= Running $make distclean in ../pdemo" - $make distclean -fi -rm -f config.cache - -# Configure the demonstration. -echo "= Configuring in ../pdemo (prefix=$prefix)" -${CONFIG_SHELL-/bin/sh} $srcdir/../pdemo/configure --srcdir=$srcdir/../pdemo --prefix=$prefix || exit 1 - -if grep '^build_old_libs=yes' libtool > /dev/null && - grep '^build_libtool_libs=yes' libtool > /dev/null; then : -else rm -f Makefile && exit 77 -fi +func_mkprefixdir +func_cd "pdemo" +func_make_distclean +func_configure +func_check_static_shared "yes" "yes" if test -f ./libtool ; then sed 's/^max_cmd_len=*/max_cmd_len=24 # /g' ./libtool > ltnew diff --git a/tests/pdemo-exec.test b/tests/pdemo-exec.test index 64d129c16..b5bf7a4b0 100755 --- a/tests/pdemo-exec.test +++ b/tests/pdemo-exec.test @@ -1,41 +1,38 @@ #! /bin/sh -# pdemo-exec.test - check that programs in the ../pdemo subdirectory are viable +# pdemo-exec.test - check that programs in the pdemo subdirectory are viable + +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. -# Test script header. -need_prefix=no if test -z "$srcdir"; then srcdir=`echo "$0" | sed 's%/[^/]*$%%'` test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes fi . $srcdir/defs || exit 1 -if test -f ../pdemo/hell$EXEEXT; then : -else - echo "You must run pdemo-make.test before running $0" 1>&2 - exit 77 -fi +func_require "pdemo-make" "pdemo/hell$EXEEXT" -# Check to see if the programs really run. -echo "Executing uninstalled programs in ../pdemo" - -status=0 -if ../pdemo/hell_static| grep 'Welcome to GNU Hell'; then : -else - echo "$0: cannot execute ../pdemo/hell_static" 1>&2 - status=1 -fi - -if ../pdemo/hell | grep 'Welcome to GNU Hell'; then : -else - echo "$0: cannot execute ../pdemo/hell" 1>&2 - status=1 -fi - -if ../pdemo/helldl | $EGREP -e '(Welcome to .*GNU Hell|unsupported)'; then : -else - echo "$0: cannot execute ../pdemo/helldl" 1>&2 - status=1 -fi +func_rmprefixdir +func_exec_init "uninstalled" +func_exec "pdemo/hell_static" 'Welcome to GNU Hell' +func_exec "pdemo/hell" 'Welcome to GNU Hell' +func_exec "pdemo/helldl" '(Welcome to .*GNU Hell|unsupported)' -exit $status +exit $exec_status diff --git a/tests/pdemo-inst.test b/tests/pdemo-inst.test index 9310356e9..98e762aea 100755 --- a/tests/pdemo-inst.test +++ b/tests/pdemo-inst.test @@ -1,58 +1,40 @@ #! /bin/sh -# pdemo-inst.test - try installing from the ../pdemo subdirectory +# demo-inst.test - try installing from the demo subdirectory + +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. -# Test script header. -need_prefix=yes if test -z "$srcdir"; then srcdir=`echo "$0" | sed 's%/[^/]*$%%'` test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes fi . $srcdir/defs || exit 1 -# Check that things are built. -if test -f ../pdemo/hell$EXEEXT; then : -else - echo "You must run pdemo-make.test before $0" 1>&2 - exit 77 -fi - -# Change to our build directory. -cd ../pdemo || exit 1 - -echo "= Running $make install in ../pdemo" -$make install || exit 1 - -echo "= Executing installed programs" -status=0 -if $prefix/bin/hell_static | grep 'Welcome to GNU Hell'; then : -else - echo "$0: cannot execute $prefix/bin/hell_static" 1>&2 - status=1 -fi +func_require "demo-make" "demo/hell$EXEEXT" -if $prefix/bin/hell | grep 'Welcome to GNU Hell'; then : -else - echo "$0: cannot execute $prefix/bin/hell" 1>&2 - - # Simple check to see if they are superuser. - if test -w /; then : - else - echo "You may need to run $0 as the superuser." - fi - status=1 -fi - -if $prefix/bin/helldl | $EGREP -e '(Welcome to .*GNU Hell|unsupported)'; then : -else - echo "$0: cannot execute $prefix/bin/helldl" 1>&2 - - # Simple check to see if they are superuser. - if test -w /; then : - else - echo "You may need to run $0 as the superuser." - fi - status=1 -fi +func_mkprefixdir +func_cd "demo" +func_make "install" +func_exec_init "installed" +func_exec "$prefix/bin/hell_static" 'Welcome to GNU Hell' +func_exec "$prefix/bin/hell" 'Welcome to GNU Hell' +func_exec "$prefix/bin/helldl" '(Welcome to .*GNU Hell|unsupported)' exit $status diff --git a/tests/pdemo-make.test b/tests/pdemo-make.test index 553299e52..70a8b844c 100755 --- a/tests/pdemo-make.test +++ b/tests/pdemo-make.test @@ -1,25 +1,36 @@ #! /bin/sh -# pdemo-make.test - try building in the ../pdemo subdirectory +# pdemo-make.test - try building in the pdemo subdirectory + +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. -# Test script header. -need_prefix=no if test -z "$srcdir"; then srcdir=`echo "$0" | sed 's%/[^/]*$%%'` test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes fi . $srcdir/defs || exit 1 -if test -f ../pdemo/Makefile; then : -else - echo "You must run pdemo-conf.test before running $0" 1>&2 - exit 77 -fi +func_require "pdemo-conf" "pdemo/Makefile" -# Change to our build directory. -cd ../pdemo || exit 1 +func_rmprefixdir +func_cd "pdemo" +func_make -# Do the actual build. -echo "Making in ../pdemo" -$make || exit 1 exit 0 diff --git a/tests/pdemo/.cvsignore b/tests/pdemo/.cvsignore new file mode 100644 index 000000000..244811270 --- /dev/null +++ b/tests/pdemo/.cvsignore @@ -0,0 +1,20 @@ +.deps +.libs +Makefile +Makefile.in +acinclude.m4 +aclocal.m4 +autom4te.cache +configure +config.* +conftest* +hc-direct +hc-libflag +hc-libpath +hc-minusL +libtool +*.lo +*.la +hell +hell_static +helldl diff --git a/tests/pdemo/Makefile.am b/tests/pdemo/Makefile.am new file mode 100644 index 000000000..a8fcc4dff --- /dev/null +++ b/tests/pdemo/Makefile.am @@ -0,0 +1,157 @@ +## Makefile.am -- Process this file with automake to produce Makefile.in +## +## Copyright (C) 2003 Free Software Foundation +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2 of the License, or +## (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program; see the file COPYING. If not, write to +## the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +## Boston, MA 02111-1307, USA. + +top_distdir = ../.. + +AUTOMAKE_OPTIONS = no-dependencies foreign +ACLOCAL_AMFLAGS = -I $(top_distdir)/m4 + +# Build a libtool library, libhello.la for installation in libdir. +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 + +include_HEADERS = foo.h + +if BINARY_HELLDL +BUILD_helldl = helldl +else +BUILD_helldl = +endif + +bin_PROGRAMS = hell hell_static $(BUILD_helldl) + +# Build hell from longer_file_name_main.c and libhello.la +hell_SOURCES = longer_file_name_main.c +hell_LDADD = libhello.la + +# Create a statically linked version of hell. +hell_static_SOURCES = longer_file_name_main.c +hell_static_LDADD = libhello.la +hell_static_LDFLAGS = $(STATIC) + +if BINARY_HELLDL + +# Create a version of hell that does a preloaded dlopen. +helldl_SOURCES = longer_file_name_dlmain.c +helldl_LDFLAGS = -export-dynamic -dlpreopen libhello.la +helldl_DEPENDENCIES = libhello.la + +else + +bin_SCRIPTS = helldl +# create a script that says that -dlopen is not supported +helldl helldl$(EXEEXT): + rm -f $@ + echo '#! /bin/sh' > $@ + echo '-dlopen is unsupported' >> $@ + chmod +x $@ +endif + +$(OBJECTS): libtool +libtool: $(LIBTOOL_DEPS) + $(SHELL) ./config.status --recheck + +#---------------------------------------------------------------------- +# The following declarations are only used in the testsuite: +#---------------------------------------------------------------------- + +hardcode_tests = hc-direct hc-libflag hc-libpath hc-minusL +CLEANFILES = $(hardcode_tests) + +# Unfortunately, in order to test libtool thoroughly, we need access +# to its private directory. +objdir = `$(LIBTOOL) --config | sed -n -e 's/^objdir=\(.*\)$$/\1/p'` + +# Test programs to see what gets hardcoded. +.PHONY: hardcode +hardcode: $(hardcode_tests) +SET_HARDCODE_FLAGS = \ + eval `$(LIBTOOL) --config | sed -n -e '/^hardcode_.*=/p; /^wl=/p'` +hc-direct: $(hell_OBJECTS) $(hell_DEPENDENCIES) $(libdir)/libhello.la + @rm -f hc-direct + @echo "You may ignore any linking errors from the following command:" + @shlib=./$(objdir)/libhello.a; \ + eval "`grep '^library_names' libhello.la`"; \ + for lib in $$library_names; do \ + shlib="./$(objdir)/$$lib"; \ + done; \ + $(SET_HARDCODE_FLAGS); \ + libdir=$(libdir); \ + flag=`eval echo \"$$hardcode_libdir_flag_spec\"`; \ + echo "$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(hell_OBJECTS) $$shlib $(LIBS) $(LIBM) $$flag || echo unsupported > $@"; \ + eval "$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(hell_OBJECTS) $$shlib $(LIBS) $(LIBM) $$flag || echo unsupported > $@" + +hc-libflag: $(hell_OBJECTS) $(hell_DEPENDENCIES) $(libdir)/libhello.la + @$(SET_HARDCODE_FLAGS); \ + libdir=`pwd`/$(objdir); \ + flag=`eval echo \"$$hardcode_libdir_flag_spec\"`; \ + if test -z "$$flag"; then \ + echo "echo unsupported > $@"; \ + echo unsupported > $@ || status="$$?"; \ + else \ + echo "$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(hell_OBJECTS) $$flag -L$(libdir) -lhello $(LIBS) $(LIBM)"; \ + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(hell_OBJECTS) $$flag -L$(libdir) -lhello $(LIBS) $(LIBM) || status="$$?"; \ + fi; \ + exit $$status + +hc-libpath: $(hell_OBJECTS) $(hell_DEPENDENCIES) $(libdir)/libhello.la + @rm -f hc-libpath + @echo "You may ignore any linking errors from the following command:" + @$(SET_HARDCODE_FLAGS); \ + eval `$(LIBTOOL) --config | grep '^shlibpath_var='`; \ + libdir=$(libdir); \ + flag=`eval echo \"$$hardcode_libdir_flag_spec\"`; \ + echo "$$shlibpath_var=./$(objdir) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(hell_OBJECTS) -lhello $(LIBS) $(LIBM) $$flag || echo unsupported > $@"; \ + eval "$$shlibpath_var=./$(objdir) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(hell_OBJECTS) -lhello $(LIBS) $(LIBM) $$flag || echo unsupported > $@" + +hc-minusL: $(hell_OBJECTS) $(hell_DEPENDENCIES) + @rm -f hc-minusL + @$(SET_HARDCODE_FLAGS); \ + libdir=$(libdir); \ + flag=`eval echo \"$$hardcode_libdir_flag_spec\"`; \ + echo "$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(hell_OBJECTS) -L./$(objdir) -lhello $(LIBS) $(LIBM) $$flag || echo unsupported > $@"; \ + eval "$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(hell_OBJECTS) -L./$(objdir) -lhello $(LIBS) $(LIBM) $$flag || echo unsupported > $@" + +# This is one of the essential tests for deplibs_check_method=pass_all. +# If this one passes with pass_all, it is likely that pass_all works +EXTRA_LIBRARIES = libhell0.a +libhell0_a_SOURCES = +libhell0_a_LIBADD = longer_file_name_hello.o longer_file_name_foo.o +EXTRA_LTLIBRARIES = libhell1.la libhell2.la +libhell1_la_SOURCES = longer_file_name_hell1.c +libhell1_la_LIBADD = -L. -lhell0 +libhell1_la_LDFLAGS = -no-undefined -rpath $(libdir) +libhell1_la_DEPENDENCIES = libhell0.a +libhell2_la_SOURCES = longer_file_name_hell2.c +libhell2_la_LIBADD = -L. -lhell0 +libhell2_la_LDFLAGS = -no-undefined -rpath $(libdir) +libhell2_la_DEPENDENCIES = libhell0.a +EXTRA_PROGRAMS = hell0 +hell0_SOURCES = longer_file_name_main.c +hell0_LDADD = libhell1.la libhell2.la $(LIBM) + +# 'hell0' in EXTRA_PROGRAMS gets translated to 'hell0.exe'; but we +# must explicitly list the wrapper script 'hell0'. (bin_PROGRAMS +# are handled seamlessly by automake rules; the extra step is only +# necessary for EXTRA_PROGRAMS) +CLEANFILES += $(EXTRA_LIBRARIES) $(EXTRA_LTLIBRARIES) $(EXTRA_PROGRAMS) hell0 + +deplibs-check: hell0 diff --git a/tests/pdemo/configure.ac b/tests/pdemo/configure.ac new file mode 100644 index 000000000..d13e533d4 --- /dev/null +++ b/tests/pdemo/configure.ac @@ -0,0 +1,78 @@ +## Process this file with autoconf to create configure. -*- autoconf -*- +# Copyright (C) 2001, 2003 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +# 02111-1307 USA + +AC_PREREQ(2.50) + + +## ------------------------ ## +## Autoconf initialisation. ## +## ------------------------ ## +AC_INIT([pdemo], [0.1], [bug-libtool@gnu.org]) +AC_CONFIG_SRCDIR([longer_file_name_hello.c]) +AC_CONFIG_AUX_DIR([../../config]) + + +## ------------------------ ## +## Automake Initialisation. ## +## ------------------------ ## +AM_INIT_AUTOMAKE(hell,1.0) + + +## ------------------ ## +## C compiler checks. ## +## ------------------ ## +AC_PROG_CC +AC_C_CONST + + +## ----------------------- ## +## Libtool initialisation. ## +## ----------------------- ## +AC_LIBTOOL_DLOPEN +AM_PROG_LIBTOOL +AC_SUBST([LIBTOOL_DEPS]) + +if ${CONFIG_SHELL} ./libtool --features | grep "enable static" >/dev/null; then + STATIC=-static +else + STATIC= +fi +AC_SUBST([STATIC]) + +AM_CONDITIONAL([BINARY_HELLDL], + [grep '^global_symbol_pipe=..*$' ./libtool >/dev/null]) + + +## ---------------------------- ## +## C headers required by cdemo. ## +## ---------------------------- ## +AC_CHECK_HEADERS([string.h math.h]) + + +## ---------------------------- ## +## Libraries required by cdemo. ## +## ---------------------------- ## +AC_CHECK_LIBM +AC_SUBST([LIBM]) + + +## -------- ## +## Outputs. ## +## -------- ## +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT diff --git a/tests/pdemo/foo.h b/tests/pdemo/foo.h new file mode 100644 index 000000000..6d4fee709 --- /dev/null +++ b/tests/pdemo/foo.h @@ -0,0 +1,90 @@ +/* foo.h -- interface to the libfoo library + Copyright (C) 1996-1999 Free Software Foundation, Inc. + Gordon Matzigkeit , 1996 + This file is part of GNU Libtool. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +USA. */ + +/* Only include this header file once. */ +#ifndef _FOO_H_ +#define _FOO_H_ 1 + +/* At some point, cygwin will stop defining __CYGWIN32__, but b19 and + * earlier do not define __CYGWIN__. This snippit allows us to check + * for __CYGWIN32__ reliably for both old and (probable) future releases. + */ +#ifdef __CYGWIN__ +# ifndef __CYGWIN32__ +# define __CYGWIN32__ +# endif +#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. */ +#undef __BEGIN_DECLS +#undef __END_DECLS +#ifdef __cplusplus +# define __BEGIN_DECLS extern "C" { +# define __END_DECLS } +#else +# define __BEGIN_DECLS /* empty */ +# define __END_DECLS /* empty */ +#endif + +/* LTDL_PARAMS is a macro used to wrap function prototypes, so that compilers + that don't understand ANSI C prototypes still work, and ANSI C + compilers can issue warnings about type mismatches. */ +#undef LTDL_PARAMS +#if defined (__STDC__) || defined (_AIX) || (defined (__mips) && defined (_SYSTYPE_SVR4)) || defined(__CYGWIN32__) || defined(__cplusplus) +# define LT_PARAMS(protos) protos +# define lt_ptr_t void* +#else +# define LT_PARAMS(protos) () +# define lt_ptr_t char* +#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 +# endif +#else +# define EXTERN extern +#endif + +/* Silly constants that the functions return. */ +#define HELLO_RET 0xe110 +#define FOO_RET 0xf00 + + +/* Declarations. Note the wonderful use of the above macros. */ +__BEGIN_DECLS +int foo LT_PARAMS((void)); +int hello LT_PARAMS((void)); +EXTERN int nothing; +__END_DECLS + +#endif /* !_FOO_H_ */ diff --git a/tests/pdemo/longer_file_name_dlmain.c b/tests/pdemo/longer_file_name_dlmain.c new file mode 100644 index 000000000..7c123bb8e --- /dev/null +++ b/tests/pdemo/longer_file_name_dlmain.c @@ -0,0 +1,95 @@ +/* dlmain.c -- hello test program that uses simulated dynamic linking + Copyright (C) 1996-1999 Free Software Foundation, Inc. + This file is part of GNU Libtool. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +USA. */ + +#include "foo.h" +#include + +#ifdef HAVE_STRING_H +#include +#endif + +struct lt_symlist +{ + const char *name; + lt_ptr_t address; +}; + +extern const struct lt_symlist lt_preloaded_symbols[]; + +int +main (argc, argv) + int argc; + char **argv; +{ + const struct lt_symlist *s; + int (*pfoo)() = 0; + int (*phello)() = 0; + int *pnothing = 0; + + printf ("Welcome to *modular* GNU Hell!\n"); + + /* Look up the symbols we require for this demonstration. */ + s = lt_preloaded_symbols; + while (s->name) + { + if (s->address) { + const char *name = s->name; + printf ("found symbol: %s\n", name); + if (!strcmp ("hello", name)) + phello = (int(*)())s->address; + else if (!strcmp ("foo", name)) + pfoo = (int(*)())s->address; + else if (!strcmp ("nothing", name)) +#ifndef _WIN32 + /* In an ideal world we could do this... */ + pnothing = (int*)s->address; +#else /* !_WIN32 */ + /* In an ideal world a shared lib would be able to export data */ + pnothing = (int*)¬hing; +#endif + } else + printf ("found file: %s\n", s->name); + s ++; + } + + /* Try assigning to the nothing variable. */ + if (pnothing) + *pnothing = 1; + else + fprintf (stderr, "did not find the `nothing' variable\n"); + + /* Just call the functions and check return values. */ + if (pfoo) + { + if ((*pfoo) () != FOO_RET) + return 1; + } + else + fprintf (stderr, "did not find the `foo' function\n"); + + if (phello) + { + if ((*phello) () != HELLO_RET) + return 3; + } + else + fprintf (stderr, "did not find the `hello' function\n"); + + return 0; +} diff --git a/tests/pdemo/longer_file_name_foo.c b/tests/pdemo/longer_file_name_foo.c new file mode 100644 index 000000000..4b6773997 --- /dev/null +++ b/tests/pdemo/longer_file_name_foo.c @@ -0,0 +1,39 @@ +/* foo.c -- trivial test function for libfoo + Copyright (C) 1996-1999 Free Software Foundation, Inc. + Gordon Matzigkeit , 1996 + This file is part of GNU Libtool. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +USA. */ + +#define _LIBFOO_COMPILATION_ +#include "foo.h" +#undef _LIBFOO_COMPILATION_ + +#include + +#ifdef HAVE_MATH_H +#include +#endif + +/* Give a global variable definition. */ +int nothing = FOO_RET; + +int +foo () +{ + printf ("cos (0.0) = %g\n", (double) cos ((double) 0.0)); + return FOO_RET; +} diff --git a/tests/pdemo/longer_file_name_foo2.c b/tests/pdemo/longer_file_name_foo2.c new file mode 100644 index 000000000..0b7473121 --- /dev/null +++ b/tests/pdemo/longer_file_name_foo2.c @@ -0,0 +1,36 @@ +/* foo.c -- trivial test function for libfoo + Copyright (C) 1996-1999 Free Software Foundation, Inc. + Gordon Matzigkeit , 1996 + This file is part of GNU Libtool. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +USA. */ + +#define _LIBFOO_COMPILATION_ +#include "foo.h" +#undef _LIBFOO_COMPILATION_ + +#include + +#ifdef HAVE_MATH_H +#include +#endif + +int +foo2() +{ + printf ("foo2 cos (0.0) = %g\n", (double) cos ((double) 0.0)); + return FOO_RET; +} diff --git a/tests/pdemo/longer_file_name_hell1.c b/tests/pdemo/longer_file_name_hell1.c new file mode 100644 index 000000000..52e5148d3 --- /dev/null +++ b/tests/pdemo/longer_file_name_hell1.c @@ -0,0 +1 @@ +int hell1() { return 1; } diff --git a/tests/pdemo/longer_file_name_hell2.c b/tests/pdemo/longer_file_name_hell2.c new file mode 100644 index 000000000..c1ff477e0 --- /dev/null +++ b/tests/pdemo/longer_file_name_hell2.c @@ -0,0 +1 @@ +int hell2() { return 2; } diff --git a/tests/pdemo/longer_file_name_hello.c b/tests/pdemo/longer_file_name_hello.c new file mode 100644 index 000000000..ec9a639b9 --- /dev/null +++ b/tests/pdemo/longer_file_name_hello.c @@ -0,0 +1,32 @@ +/* hello.c -- trivial test function for libfoo + Copyright (C) 1996-1999 Free Software Foundation, Inc. + This file is part of GNU Libtool. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +USA. */ + +/* Written by Gordon Matzigkeit */ +#define _LIBFOO_COMPILATION +#include "foo.h" +#undef _LIBFOO_COMPILATION + +#include + +int +hello () +{ + printf ("** This is not GNU Hello. There is no built-in mail reader. **\n"); + return HELLO_RET; +} diff --git a/tests/pdemo/longer_file_name_main.c b/tests/pdemo/longer_file_name_main.c new file mode 100644 index 000000000..09aa5ee03 --- /dev/null +++ b/tests/pdemo/longer_file_name_main.c @@ -0,0 +1,45 @@ +/* main.c -- trivial hello test program + Copyright (C) 1996-1999 Free Software Foundation, Inc. + This file is part of GNU Libtool. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +USA. */ + +/* Written by Gordon Matzigkeit */ +#include "foo.h" +#include + +int +main (argc, argv) + int argc; + char **argv; +{ + printf ("Welcome to GNU Hell!\n"); + + /* Try assigning to the nothing variable */ + nothing = 1; + + /* Just call the functions and check return values. */ + if (foo () != FOO_RET) + return 1; + + if (foo2() != FOO_RET) + return 1; + + if (hello () != HELLO_RET) + return 2; + + return 0; +} diff --git a/tests/quote.test b/tests/quote.test index e77317a61..e7e8487b0 100755 --- a/tests/quote.test +++ b/tests/quote.test @@ -1,56 +1,36 @@ #! /bin/sh # quote.test - make sure that shell metacharacters do not blow up libtool -# Test script header. -need_prefix=no +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. + if test -z "$srcdir"; then srcdir=`echo "$0" | sed 's%/[^/]*$%%'` test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes fi . $srcdir/defs || exit 1 # Do the torture test. -status=0 +status=$EXIT_SUCCESS -echo=echo -if test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then : -else - # The Solaris, AIX, and Digital Unix default echo programs unquote - # backslashes. This makes it impossible to quote backslashes using - # echo "$something" | sed 's/\\/\\\\/g' - # - # So, first we look for a working echo in the user's PATH. - IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}:" - for dir in $PATH /usr/ucb; do - if test -f $dir/echo && test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t'; then - echo="$dir/echo" - break - fi - done - IFS="$save_ifs" - - if test "X$echo" = Xecho; then - # We didn't find a better echo, so look for alternatives. - if test "X`(print -r '\t') 2>/dev/null`" = 'X\t'; then - # This shell has a builtin print -r that does the trick. - echo='print -r' - elif test -f /bin/ksh && test "X$CONFIG_SHELL" != X/bin/ksh; then - # If we have ksh, try running $0 again with it. - CONFIG_SHELL=/bin/ksh - export CONFIG_SHELL - exec "$CONFIG_SHELL" "$0" --no-reexec ${1+"$@"} - else - # Try using printf. - echo='printf %s\n' - if test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then : - else - # Oops. We lost completely, so just stick with echo. - echo=echo - fi - fi - fi -fi +func_get_config "echo" "../libtool --config" for mode in compile link install; do $echo "== $mode mode" @@ -85,7 +65,7 @@ for mode in compile link install; do # Trivial. $echo "= trying: no quoting" - result=`$libtool -n --mode=$mode $preargs ${preflag}"${flag}test" $postargs` || status=1 + result=`$libtool -n --mode=$mode $preargs ${preflag}"${flag}test" $postargs` || status=$EXIT_FAILURE # We used to have the contents of $match in the case statement, # without an intermediate variable, but it would fail on at least # Solaris' and HP-UX's /bin/sh. Ugh! @@ -96,14 +76,14 @@ for mode in compile link install; do ;; *) $echo "= failed: $result" - status=1 + status=$EXIT_FAILURE ;; esac # Metacharacters that should be backslashified. for mchar in \\ \" \` \$; do $echo "= trying: \\$mchar quoting" - result=`$libtool -n --mode=$mode $preargs ${preflag}"${flag}${mchar}test${mchar}" $postargs` || status=1 + result=`$libtool -n --mode=$mode $preargs ${preflag}"${flag}${mchar}test${mchar}" $postargs` || status=$EXIT_FAILURE match="$preargs ${preflag}${flag}\\${mchar}test\\${mchar} " case "$result" in *"$match"*) @@ -111,7 +91,7 @@ for mode in compile link install; do ;; *) $echo "= failed: $result" - status=1 + status=$EXIT_FAILURE ;; esac done @@ -121,7 +101,7 @@ for mode in compile link install; do "'" " " " "; do $echo "= trying: \"$mchar\" quoting" - result=`$libtool -n --mode=$mode $preargs ${preflag}"${flag}${mchar}test${mchar}" $postargs` || status=1 + result=`$libtool -n --mode=$mode $preargs ${preflag}"${flag}${mchar}test${mchar}" $postargs` || status=$EXIT_FAILURE match="$preargs ${preflag}\"${flag}${mchar}test${mchar}\" " case "$result" in *"$match"*) @@ -129,7 +109,7 @@ for mode in compile link install; do ;; *) $echo "= failed: $result" - status=1 + status=$EXIT_FAILURE ;; esac done diff --git a/tests/sh.test b/tests/sh.test index 95907442b..ffd719e55 100755 --- a/tests/sh.test +++ b/tests/sh.test @@ -1,77 +1,94 @@ #! /bin/sh # sh.test - check that we haven't forgotten a `test' command -# Test script header. -need_prefix=no +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. + if test -z "$srcdir"; then srcdir=`echo "$0" | sed 's%/[^/]*$%%'` test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes fi . $srcdir/defs || exit 1 # Check all the "portable" shell scripts. -status=0 -scripts="$srcdir/../ltmain.sh" +status=$EXIT_SUCCESS +scripts="$srcdir/../config/ltmain.sh $srcdir/../libtoolize" # Check for bad binary operators. if $EGREP -n -e "if[ ]+[\"']?\\$.*(=|-[lg][te]|-eq|-ne)" $scripts; then echo "use \`if test \$something =' instead of \`if \$something ='" - status=1 + status=$EXIT_FAILURE fi # Check for bad unary operators. if $EGREP -n -e 'if[ ]+-' $scripts; then echo "use \`if test -X' instead of \`if -X'" - status=1 + status=$EXIT_FAILURE fi # Check for using `[' instead of `test'. if $EGREP -n -e 'if[ ]+\[' $scripts; then echo "use \`if test' instead of \`if ['" - status=1 + status=$EXIT_FAILURE fi if $EGREP -n -e 'test[ ]+(![ ])?(-.[ ]+)?"?[.,_x]' $scripts; then echo "use \`test \"X...\"' instead of \`test \"x...\"'" - status=1 + status=$EXIT_FAILURE fi # Check for using test X... instead of test "X... if $EGREP -n -e 'test[ ]+(![ ])?(-.[ ]+)?X' $scripts; then echo "use \`test \"X...\"' instead of \`test X'" - status=1 + status=$EXIT_FAILURE fi # Check for using test $... instead of test "$... if $EGREP -n -e 'test[ ]+(![ ])?(-.[ ]+)?X?\$' $scripts; then echo "use \`test \"\$...\"' instead of \`test \$'" - status=1 + status=$EXIT_FAILURE fi # Never use test -e. if $EGREP -n -e 'test[ ]+(![ ])?-e' $scripts; then echo "use \`test -f' instead of \`test -e'" - status=1 + status=$EXIT_FAILURE fi # Check for problems with variable assignments. if $EGREP -n -e '[^ ]=[^ ].*(break|continue)' $scripts; then echo "assignments on the same line as a \`break' or \`continue' may have no effect" - status=1 + status=$EXIT_FAILURE fi # Check for uses of Xsed without corresponding echo "X if $EGREP -n -e '\$Xsed' $scripts | $EGREP -v -n -e '\$echo \\*"X'; then echo "occurrences of \`\$Xsed\' without \`echo \"X\' on the same line" - status=1 + status=$EXIT_FAILURE fi # Check for quotes within backquotes within quotes "`"bar"`" if $EGREP -n -e '"[^`"]*`[^"`]*"[^"`]*".*`[^`"]*"' $scripts | \ $EGREP -v "### testsuite: skip nested quoting test$"; then echo "nested quotes are dangerous" - status=1 + status=$EXIT_FAILURE fi exit $status diff --git a/tests/suffix.test b/tests/suffix.test index 11498e05b..1712847f1 100755 --- a/tests/suffix.test +++ b/tests/suffix.test @@ -1,25 +1,42 @@ #! /bin/sh # suffix.test - check that libtool knows how to transform source suffices. +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. + # Extensions taken from the ones that Automake recognizes, plus Objective C, # and GNU Ada. extensions="C F S ada adb ads asm c c++ cc cpp cxx f f90 for m s" bad_names="foo." -# Test script header. -need_prefix=no if test -z "$srcdir"; then srcdir=`echo "$0" | sed 's%/[^/]*$%%'` test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes fi . $srcdir/defs || exit 1 -status=0 +status=$EXIT_SUCCESS for ext in $extensions; do # Try a sample compile command. if ($libtool -n --mode=compile compiler -c foo.$ext 2>&1; exit 0) | grep 'cannot'; then - status=1 + status=$EXIT_FAILURE else echo "recognized foo.$ext as a valid source file" fi @@ -30,7 +47,7 @@ for name in $bad_names; do if ($libtool -n --mode=compile compiler -c $name 2>&1; exit 0) | grep 'cannot'; then : else echo "incorrectly recognized $name as a valid source file" - status=1 + status=$EXIT_FAILURE fi done diff --git a/tests/tagdemo-conf.test b/tests/tagdemo-conf.test index 06edb6ef8..eda394624 100755 --- a/tests/tagdemo-conf.test +++ b/tests/tagdemo-conf.test @@ -1,35 +1,36 @@ #! /bin/sh -# tagdemo-conf.test - try configuring the ../tagdemo subdirectory +# tagdemo-conf.test - try configuring the tagdemo subdirectory + +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. -# Test script header. -need_prefix=yes if test -z "$srcdir"; then srcdir=`echo "$0" | sed 's%/[^/]*$%%'` test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes fi . $srcdir/defs || exit 1 -# Maybe we have a VPATH build, in which case, create a new subdir. -test -d ../tagdemo || mkdir ../tagdemo - -# Change to our build directory. -cd ../tagdemo || exit 1 - -# Possibly clean up the distribution. -if test -f Makefile; then - echo "= Running $make distclean in ../tagdemo" - $make distclean -fi -rm -f config.cache - -# Configure the demonstration. -echo "= Configuring in ../tagdemo (prefix=$prefix)" -${CONFIG_SHELL-/bin/sh} $srcdir/../tagdemo/configure --srcdir=$srcdir/../tagdemo --prefix=$prefix || exit 1 - -if grep '^build_old_libs=yes' libtool > /dev/null && - grep '^build_libtool_libs=yes' libtool > /dev/null; then : -else rm -f Makefile && exit 77 -fi +func_mkprefixdir +func_cd "tagdemo" +func_make_distclean +func_configure +func_check_static_shared "yes" "yes" exit 0 diff --git a/tests/tagdemo-exec.test b/tests/tagdemo-exec.test index a72636e5e..66ee6cf66 100755 --- a/tests/tagdemo-exec.test +++ b/tests/tagdemo-exec.test @@ -1,28 +1,36 @@ #! /bin/sh -# tagdemo-exec.test - check that programs in the ../tagdemo subdirectory are viable +# tagdemo-exec.test - check that programs in the tagdemo subdirectory are viable + +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. -# Test script header. -need_prefix=no if test -z "$srcdir"; then srcdir=`echo "$0" | sed 's%/[^/]*$%%'` test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes fi . $srcdir/defs || exit 1 -if test -f ../tagdemo/tagdemo$EXEEXT; then : -else - echo "You must run tagdemo-make.test before running $0" 1>&2 - exit 77 -fi +func_require "tagdemo-make" "tagdemo/tagdemo$EXEEXT" -# Check to see if the programs really run. -echo "Executing uninstalled programs in ../tagdemo" - -if ../tagdemo/tagdemo; then : -else - echo "$0: cannot execute ../tagdemo/tagdemo" 1>&2 - status=1 -fi +func_rmprefixdir +func_exec_init "uninstalled" +func_exec "tagdemo/tagdemo" -exit $status +exit $exec_status diff --git a/tests/tagdemo-make.test b/tests/tagdemo-make.test index 5cf0d87e6..476ca39a4 100755 --- a/tests/tagdemo-make.test +++ b/tests/tagdemo-make.test @@ -1,25 +1,36 @@ #! /bin/sh -# tagdemo-make.test - try building in the ../tagdemo subdirectory +# tagdemo-make.test - try building in the tagdemo subdirectory + +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. -# Test script header. -need_prefix=no if test -z "$srcdir"; then srcdir=`echo "$0" | sed 's%/[^/]*$%%'` test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes fi . $srcdir/defs || exit 1 -if test -f ../tagdemo/Makefile; then : -else - echo "You must run tagdemo-conf.test before running $0" 1>&2 - exit 77 -fi +func_require "tagdemo-conf" "tagdemo/Makefile" -# Change to our build directory. -cd ../tagdemo || exit 1 +func_rmprefixdir +func_cd "tagdemo" +func_make -# Do the actual build. -echo "Making in ../tagdemo" -$make || exit 1 exit 0 diff --git a/tests/tagdemo-shared.test b/tests/tagdemo-shared.test index 46c06992b..abe4e11f5 100755 --- a/tests/tagdemo-shared.test +++ b/tests/tagdemo-shared.test @@ -1,35 +1,36 @@ #! /bin/sh -# tagdemo-conf.test - try configuring the ../tagdemo subdirectory +# tagdemo-shared.test - try configuring the tagdemo subdirectory for shared libs + +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. -# Test script header. -need_prefix=yes if test -z "$srcdir"; then srcdir=`echo "$0" | sed 's%/[^/]*$%%'` test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes fi . $srcdir/defs || exit 1 -# Maybe we have a VPATH build, in which case, create a new subdir. -test -d ../tagdemo || mkdir ../tagdemo - -# Change to our build directory. -cd ../tagdemo || exit 1 - -# Possibly clean up the distribution. -if test -f Makefile; then - echo "= Running $make distclean in ../tagdemo" - $make distclean -fi -rm -f config.cache - -# Configure the demonstration. -echo "= Configuring in ../tagdemo (prefix=$prefix) with --disable-static" -${CONFIG_SHELL-/bin/sh} $srcdir/../tagdemo/configure --srcdir=$srcdir/../tagdemo --prefix=$prefix --disable-static || exit 1 - -if grep '^build_old_libs=no' libtool > /dev/null && - grep '^build_libtool_libs=yes' libtool > /dev/null; then : -else rm -f Makefile && exit 77 -fi +func_mkprefixdir +func_cd "tagdemo" +func_make_distclean +func_configure "--disable-static" +func_check_static_shared "no" "yes" exit 0 diff --git a/tests/tagdemo-static.test b/tests/tagdemo-static.test index 9f6d85606..4d1ef4b4c 100755 --- a/tests/tagdemo-static.test +++ b/tests/tagdemo-static.test @@ -1,35 +1,36 @@ #! /bin/sh -# tagdemo-conf.test - try configuring the ../tagdemo subdirectory +# tagdemo-static.test - try configuring tagdemo subdirectory for static libs + +# Copyright (C) 2003 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, a copy can be downloaded from +# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. -# Test script header. -need_prefix=yes if test -z "$srcdir"; then srcdir=`echo "$0" | sed 's%/[^/]*$%%'` test "$srcdir" = "$0" && srcdir=. - test "${VERBOSE+set}" != "set" && VERBOSE=yes fi . $srcdir/defs || exit 1 -# Maybe we have a VPATH build, in which case, create a new subdir. -test -d ../tagdemo || mkdir ../tagdemo - -# Change to our build directory. -cd ../tagdemo || exit 1 - -# Possibly clean up the distribution. -if test -f Makefile; then - echo "= Running $make distclean in ../tagdemo" - $make distclean -fi -rm -f config.cache - -# Configure the demonstration. -echo "= Configuring in ../tagdemo (prefix=$prefix) with --disable-shared" -${CONFIG_SHELL-/bin/sh} $srcdir/../tagdemo/configure --srcdir=$srcdir/../tagdemo --prefix=$prefix --disable-shared || exit 1 - -if grep '^build_old_libs=yes' libtool > /dev/null && - grep '^build_libtool_libs=no' libtool > /dev/null; then : -else rm -f Makefile && exit 77 -fi +func_mkprefixdir +func_cd "tagdemo" +func_make_distclean +func_configure "--disable-shared" +func_check_static_shared "yes" "no" exit 0 diff --git a/tests/tagdemo/.cvsignore b/tests/tagdemo/.cvsignore new file mode 100644 index 000000000..4b6013da4 --- /dev/null +++ b/tests/tagdemo/.cvsignore @@ -0,0 +1,14 @@ +.deps +.libs +Makefile +Makefile.in +autom4te.cache +acinclude.m4 +aclocal.m4 +configure +config.* +conftest* +libtool +*.lo +*.la +tagdemo diff --git a/tests/tagdemo/Makefile.am b/tests/tagdemo/Makefile.am new file mode 100644 index 000000000..f8f804ca5 --- /dev/null +++ b/tests/tagdemo/Makefile.am @@ -0,0 +1,46 @@ +## Makefile.am -- Process this file with automake to produce Makefile.in +## +## Copyright (C) 2003 Free Software Foundation +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2 of the License, or +## (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program; see the file COPYING. If not, write to +## the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +## Boston, MA 02111-1307, USA. + +top_distdir = ../.. + +AUTOMAKE_OPTIONS = no-dependencies foreign +ACLOCAL_AMFLAGS = -I $(top_distdir)/m4 + +noinst_LTLIBRARIES = libfoo.la +lib_LTLIBRARIES = libbaz.la + +libfoo_la_SOURCES = foo.cpp +libfoo_la_LDFLAGS = -no-undefined +libfoo_la_LIBADD = $(LIBM) + +# Test some of the ILD support when using tagged configurations. +libbaz_la_SOURCES = baz.cpp +libbaz_la_LDFLAGS = -no-undefined +libbaz_la_LIBADD = libfoo.la + +noinst_HEADERS = foo.h baz.h + +bin_PROGRAMS = tagdemo + +tagdemo_SOURCES = main.cpp +tagdemo_LDADD = libbaz.la + +$(OBJECTS): libtool +libtool: $(LIBTOOL_DEPS) + $(SHELL) ./config.status --recheck diff --git a/tests/tagdemo/README b/tests/tagdemo/README new file mode 100644 index 000000000..09e04a7c9 --- /dev/null +++ b/tests/tagdemo/README @@ -0,0 +1,8 @@ +# $Id$ + +This directory contains a sample package that demonstrates the use of +GNU Libtool's multi-language support through the use of configuration +tags. It requires GNU autoconf, automake and of course libtool. + +The demonstration generates a libraries using the same libtool script, +which is then linked to a C++ program. diff --git a/tests/tagdemo/baz.cpp b/tests/tagdemo/baz.cpp new file mode 100644 index 000000000..51a56347a --- /dev/null +++ b/tests/tagdemo/baz.cpp @@ -0,0 +1,35 @@ +// -*- C++ -*- +// baz.cpp -- a slightly more complicated test library +// Copyright (C) 1998-2000 Free Software Foundation, Inc. +// Originally by Thomas Tanner +// This file is part of GNU Libtool. + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +// USA. + +#include "foo.h" +#include "baz.h" + +// -------------------------------------------------------------------- +// Our C++ derived class methods. + + +int +barbaz_derived::baz(void) +{ + foobar_derived FB; + + return FB.foo(); +} diff --git a/tests/tagdemo/baz.h b/tests/tagdemo/baz.h new file mode 100644 index 000000000..1c1be2b4e --- /dev/null +++ b/tests/tagdemo/baz.h @@ -0,0 +1,43 @@ +// -*- C++ -*- +// baz.h -- interface to the libfoo* libraries +// Copyright (C) 1998-1999 Free Software Foundation, Inc. +// Originally by Thomas Tanner +// This file is part of GNU Libtool. + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +// USA. + +// Only include this header file once. +#ifndef _BAZ_H_ +#define _BAZ_H_ 1 + +// Our test C++ base class. +class barbaz +{ +public: + virtual int baz(void) = 0; + // Some dummy pure virtual functions. +}; + + +// Our test C++ derived class. +class barbaz_derived : public barbaz +{ +public: + virtual int baz(void); + // Override the base class' pure virtual functions. +}; + +#endif /* !_FOO_H_ */ diff --git a/tests/tagdemo/configure.ac b/tests/tagdemo/configure.ac new file mode 100644 index 000000000..e605719ae --- /dev/null +++ b/tests/tagdemo/configure.ac @@ -0,0 +1,87 @@ +## Process this file with autoconf to create configure. -*- autoconf -*- +# Copyright 2001 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +# 02111-1307 USA + +AC_PREREQ(2.50) + + +## ------------------------ ## +## Autoconf initialisation. ## +## ------------------------ ## +AC_INIT([tagdemo], [0.1], [bug-libtool@gnu.org]) +AC_CONFIG_SRCDIR([foo.cpp]) +AC_CONFIG_AUX_DIR([../../config]) + +AC_CANONICAL_TARGET + + +## ------------------------ ## +## Automake Initialisation. ## +## ------------------------ ## +AM_INIT_AUTOMAKE(AC_PACKAGE_TARNAME, AC_PACKAGE_VERSION) + + +## ---------------- ## +## Compiler checks. ## +## ---------------- ## +AC_PROG_CC +AC_PROG_CPP +AC_PROG_CC_C_O + +AC_PROG_CXX +AC_PROG_CXXCPP + +# As of the writing of this demo, GNU Autoconf's AC_OBJEXT and +# AC_EXEEXT macros only works for C compilers! +# Libtool's setup macro calls AC_OBJEXT and AC_EXEEXT without setting +# the test language to C. We do it before any libtool setup macros are +# called so that the proper values are cached beforehand. We also do +# it before any linker flags (LDFLAGS) are set so that C++ specific +# ones don't break the tests. +AC_LANG_PUSH([C]) +AC_OBJEXT +AC_EXEEXT +AC_LANG_POP + + +## ----------------------- ## +## Libtool initialisation. ## +## ----------------------- ## + +# Set the test language to C++. +AC_LANG([C++]) +AM_PROG_LIBTOOL + + +## ---------------------------- ## +## C headers required by cdemo. ## +## ---------------------------- ## +AC_CHECK_HEADERS([math.h]) + + +## ---------------------------- ## +## Libraries required by cdemo. ## +## ---------------------------- ## +AC_CHECK_LIBM +AC_SUBST([LIBM]) + + +## -------- ## +## Outputs. ## +## -------- ## +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT diff --git a/tests/tagdemo/foo.cpp b/tests/tagdemo/foo.cpp new file mode 100644 index 000000000..ee183cf16 --- /dev/null +++ b/tests/tagdemo/foo.cpp @@ -0,0 +1,59 @@ +// -*- C++ -*- +// foo.cpp -- trivial test library +// Copyright (C) 1998-2000 Free Software Foundation, Inc. +// Originally by Thomas Tanner +// This file is part of GNU Libtool. + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +// USA. + +#include "foo.h" +#include + +#ifdef HAVE_MATH_H +#include +#endif + +// Our C functions. +int +foo(void) +{ + cout << "cos (0.0) = " << (double) cos ((double) 0.0) << endl; + return FOO_RET; +} + +int +hello(void) +{ + cout << "** This is libfoo (tagdemo) **" << endl; + return HELLO_RET; +} + + +// -------------------------------------------------------------------- +// Our C++ derived class methods. + + +int +foobar_derived::foo(void) +{ + return ::foo(); +} + +int +foobar_derived::hello(void) +{ + return ::hello(); +} diff --git a/tests/tagdemo/foo.h b/tests/tagdemo/foo.h new file mode 100644 index 000000000..2f1f09ec1 --- /dev/null +++ b/tests/tagdemo/foo.h @@ -0,0 +1,56 @@ +// -*- C++ -*- +// foo.h -- interface to the libfoo* libraries +// Copyright (C) 1998-1999 Free Software Foundation, Inc. +// Originally by Thomas Tanner +// This file is part of GNU Libtool. + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +// USA. + +// Only include this header file once. +#ifndef _FOO_H_ +#define _FOO_H_ 1 + +// Silly constants that the functions return. +#define HELLO_RET 0xe110 +#define FOO_RET 0xf00 + +// Our C test functions. +extern "C" +{ + int foo(void); + int hello(void); +} + +// Our test C++ base class. +class foobar +{ +public: + virtual int foo(void) = 0; + virtual int hello(void) = 0; + // Some dummy pure virtual functions. +}; + + +// Our test C++ derived class. +class foobar_derived : public foobar +{ +public: + virtual int foo(void); + virtual int hello(void); + // Override the base class' pure virtual functions. +}; + +#endif /* !_FOO_H_ */ diff --git a/tests/tagdemo/main.cpp b/tests/tagdemo/main.cpp new file mode 100644 index 000000000..676acecae --- /dev/null +++ b/tests/tagdemo/main.cpp @@ -0,0 +1,63 @@ +// -*- C++ -*- +// main.cpp -- tagdemo test program +// Copyright (C) 1998-2000 Free Software Foundation, Inc. +// Originally by Thomas Tanner +// This file is part of GNU Libtool. + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +// USA. + + +#include "foo.h" +#include "baz.h" +#include + + +int +main (int, char *[]) +{ + cout << "Welcome to GNU libtool tagdemo C++!" << endl; + + foobar_derived FB; + // Instantiate the derived class. + + foobar *fb = &FB; + // Have some fun with polymorphism. + + int value = fb->hello(); + + cout << "foobar::hello returned: " << value << endl; + if (value == HELLO_RET) + cout << "foobar::hello is ok!" << endl; + + if (fb->foo() == FOO_RET) + cout << "foobar::foo is ok!" << endl; + + // -------------- + + barbaz_derived BB; + // Instantiate the derived class. + + barbaz *bb = &BB; + // Have some fun with polymorphism. + + + // barbaz_derived::baz() should return FOO_RET since it calls + // foobar_derived::foo(), which in turn calls ::foo(). + if (bb->baz() == FOO_RET) + cout << "barbaz::baz is ok!" << endl; + + return 0; +}