From 7ad201bb30517298f74e082df932d6d584d08560 Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Sun, 9 Jun 2002 11:12:35 +0000 Subject: [PATCH] For PR automake/318: * tests/nobase.test: Rewrite to test _HEADERS, _DATA, _SCRIPTS, _PROGRAMS, _LIBRARIES, and _LTLIBRARIES. * lib/am/scripts.am (install-%DIR%SCRIPTS, uninstall-%DIR%SCRIPTS): Honor nobase_; strip the directory by default. (?%DIR%SCRIPT_INSTALL): New variable. * lib/am/header-vars.am (install_sh_SCRIPT): New variable. Reported by Eric Siegerman. --- ChangeLog | 12 +++++++ lib/am/header-vars.am | 1 + lib/am/scripts.am | 24 ++++++++----- tests/nobase.test | 99 +++++++++++++++++++++++++++++++++++++++++++++++---- 4 files changed, 121 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index b880cd8..ee92a02 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2002-06-09 Alexandre Duret-Lutz + + For PR automake/318: + * tests/nobase.test: Rewrite to test _HEADERS, _DATA, _SCRIPTS, + _PROGRAMS, _LIBRARIES, and _LTLIBRARIES. + * lib/am/scripts.am (install-%DIR%SCRIPTS, + uninstall-%DIR%SCRIPTS): Honor nobase_; strip the directory by + default. + (?%DIR%SCRIPT_INSTALL): New variable. + * lib/am/header-vars.am (install_sh_SCRIPT): New variable. + Reported by Eric Siegerman. + 2002-06-08 Alexandre Duret-Lutz * automake.in (lang_yacc_target_hook): Add rule to recover from diff --git a/lib/am/header-vars.am b/lib/am/header-vars.am index 58cd39f..3810ba1 100644 --- a/lib/am/header-vars.am +++ b/lib/am/header-vars.am @@ -43,6 +43,7 @@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd INSTALL = @INSTALL@ install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) ## These are defined because otherwise make on NetBSD V1.1 will print diff --git a/lib/am/scripts.am b/lib/am/scripts.am index 821aa26..b50e19d 100644 --- a/lib/am/scripts.am +++ b/lib/am/scripts.am @@ -24,6 +24,8 @@ if %?INSTALL% ## if doesn't work properly for Automake variables yet. _am_installdirs += $(DESTDIR)$(%NDIR%dir) +?BASE?%DIR%SCRIPT_INSTALL = $(INSTALL_SCRIPT) +?!BASE?%DIR%SCRIPT_INSTALL = $(install_sh_SCRIPT) ?EXEC?.PHONY install-exec-am: install-%DIR%SCRIPTS ?!EXEC?.PHONY install-data-am: install-%DIR%SCRIPTS install-%DIR%SCRIPTS: $(%DIR%_SCRIPTS) @@ -32,13 +34,17 @@ install-%DIR%SCRIPTS: $(%DIR%_SCRIPTS) ## Funny invocation because Makefile variable can be empty, leading to ## a syntax error in sh. @list='$(%DIR%_SCRIPTS)'; for p in $$list; do \ - f="`echo $$p|sed '$(transform)'`"; \ - if test -f $$p; then \ - echo " $(INSTALL_SCRIPT) $$p $(DESTDIR)$(%NDIR%dir)/$$f"; \ - $(INSTALL_SCRIPT) $$p $(DESTDIR)$(%NDIR%dir)/$$f; \ - elif test -f $(srcdir)/$$p; then \ - echo " $(INSTALL_SCRIPT) $(srcdir)/$$p $(DESTDIR)$(%NDIR%dir)/$$f"; \ - $(INSTALL_SCRIPT) $(srcdir)/$$p $(DESTDIR)$(%NDIR%dir)/$$f; \ +## A file can be in the source directory or the build directory. + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ +## If the _SCRIPTS variable has an entry like foo/bar, install it as +## $(destdir)/bar, not $(destdir)/foo/bar. The user can make a +## new dir variable or use a nobase_ target for the latter case. +?BASE? f="`echo $$p | sed -e 's|^.*/||'`"; \ +?!BASE? f="$$p"; \ + if test -f $$d$$p; then \ + f="`echo $$f|sed '$(transform)'`"; \ + echo " $(%DIR%SCRIPT_INSTALL) $$d$$p $(DESTDIR)$(%NDIR%dir)/$$f"; \ + $(%DIR%SCRIPT_INSTALL) $$d$$p $(DESTDIR)$(%NDIR%dir)/$$f; \ else :; fi; \ done endif %?INSTALL% @@ -53,7 +59,9 @@ if %?INSTALL% uninstall-%DIR%SCRIPTS: @$(NORMAL_UNINSTALL) @list='$(%DIR%_SCRIPTS)'; for p in $$list; do \ - f="`echo $$p|sed '$(transform)'`"; \ +?BASE? f="`echo $$p | sed -e 's|^.*/||'`"; \ +?!BASE? f="$$p"; \ + f="`echo $$f|sed '$(transform)'`"; \ echo " rm -f $(DESTDIR)$(%NDIR%dir)/$$f"; \ rm -f $(DESTDIR)$(%NDIR%dir)/$$f; \ done diff --git a/tests/nobase.test b/tests/nobase.test index a9bf79b..fa3fb1e 100755 --- a/tests/nobase.test +++ b/tests/nobase.test @@ -1,25 +1,110 @@ #! /bin/sh -# Test to make sure nobase_*_HEADERS work. +# Make sure nobase_* works. +required=libtoolize . $srcdir/defs || exit 1 +set -e + cat >> configure.in <<'EOF' +AC_PROG_CC +AC_PROG_LIBTOOL AC_OUTPUT EOF cat > Makefile.am << 'EOF' foodir = $(prefix)/foo -nobase_foo_HEADERS = bar/baz.h +fooexecdir = $(prefix)/foo + +foo_HEADERS = sub/base.h +nobase_foo_HEADERS = sub/nobase.h + +foo_DATA = sub/base.dat +nobase_foo_DATA = sub/nobase.dat + +fooexec_SCRIPTS = sub/base.sh +nobase_fooexec_SCRIPTS = sub/nobase.sh + +fooexec_PROGRAMS = sub/base +nobase_fooexec_PROGRAMS = sub/nobase +sub_base_SOURCES = source.c +sub_nobase_SOURCES = source.c + +fooexec_LIBRARIES = sub/libbase.a +nobase_fooexec_LIBRARIES = sub/libnobase.a +sub_libbase_a_SOURCES = source.c +sub_libnobase_a_SOURCES = source.c + +fooexec_LTLIBRARIES = sub/libbase.la +nobase_fooexec_LTLIBRARIES = sub/libnobase.la +sub_libbase_la_SOURCES = source2.c +sub_libnobase_la_SOURCES = source2.c EOF -mkdir bar -: > bar/baz.h +mkdir sub -set -e +: > sub/base.h +: > sub/nobase.h +: > sub/base.dat +: > sub/nobase.dat +: > sub/base.sh +: > sub/nobase.sh +cat >source.c <<'EOF' +int +main (int argc, char *argv[]) +{ + return 0; +} +EOF +cp source.c source2.c + +libtoolize $ACLOCAL $AUTOCONF $AUTOMAKE -a -./configure --prefix `pwd`/install +./configure --prefix `pwd`/inst + +$MAKE $MAKE install-data -test -f install/foo/bar/baz.h + +test -f inst/foo/sub/nobase.h +test ! -f inst/foo/nobase.h +test -f inst/foo/base.h + +test -f inst/foo/sub/nobase.dat +test ! -f inst/foo/nobase.dat +test -f inst/foo/base.dat + +test ! -f inst/foo/sub/nobase.sh +test ! -f inst/foo/base.sh +test ! -f inst/foo/sub/nobase +test ! -f inst/foo/base +test ! -f inst/foo/sub/libnobase.a +test ! -f inst/foo/libbase.a +test ! -f inst/foo/sub/libnobase.la +test ! -f inst/foo/libbase.la + +$MAKE install-exec + +test -f inst/foo/sub/nobase.sh +test ! -f inst/foo/nobase.sh +test -f inst/foo/base.sh + +test -f inst/foo/sub/nobase +test ! -f inst/foo/nobase +test -f inst/foo/base + +test -f inst/foo/sub/libnobase.a +test ! -f inst/foo/libnobase.a +test -f inst/foo/libbase.a + +test -f inst/foo/sub/libnobase.la +test ! -f inst/foo/libnobase.la +test -f inst/foo/libbase.la + +$MAKE uninstall + +test `find inst/foo -type f -print | wc -l` = 0 + +$MAKE install-strip -- 2.7.4