Imported Upstream version 3.1.0
[debian/amanda] / config / automake / scripts.am
index cb6d705b1df8cb11c1e72bcf137aaec478ad0c29..64edbc67fab90328d1375be5fd7a22f2806754d4 100644 (file)
@@ -1,21 +1,21 @@
 # vim:ft=automake
-# Copyright (c) 2005-2008 Zmanda Inc.  All Rights Reserved.
-# 
-# This library is free software; you can redistribute it and/or modify it
-# under the terms of the GNU Lesser General Public License version 2.1 as 
-# published by the Free Software Foundation.
-# 
-# This library is distributed in the hope that it will be useful, but
+# Copyright (c) 2007,2008,2009 Zmanda, Inc.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 as published
+# by the Free Software Foundation.
+#
+# 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 Lesser General Public
-# License for more details.
-# 
-# You should have received a copy of the GNU Lesser General Public License
-# along with this library; if not, write to the Free Software Foundation,
-# Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA.
-# 
-# Contact information: Zmanda Inc., 465 S Mathlida Ave, Suite 300
-# Sunnyvale, CA 94086, USA, or: http://www.zmanda.com
+# 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
+#
+# Contact information: Zmanda Inc., 465 S. Mathilda Ave., Suite 300
+# Sunnyvale, CA 94085, USA, or: http://www.zmanda.com
 
 # SYNOPSIS:
 #
 # be built down to extensionless executables (e.g., foo.pl -> foo), or to 
 # files with the usual extension (foo-lib.sh.in -> foo.sh).
 #
-# Files which support it are syntax-checked when the user invokes 'make check'.
+# Files which support it are syntax-checked when the user invokes 'make check',
+# unless the Makefile.am defines SKIP_CHECKS.
 #
-# All *target* filenames must be listed in SCRIPTS_SHELL, SCRIPTS_PERL, and 
-# SCRIPTS_AWK to support 'make check', 'make dist', and 'make distclean'. No
-# files which are not substituted by config.status should be included in
-# SCRIPTS_PERL, SCRIPTS_SHELL, or SCRIPTS_AWK.  If non-generated files are listed
-# for installation, then Automake will figure out that they should be distributed;
+# All *target* filenames must be listed in SCRIPTS_SHELL, SCRIPTS_PERL, and
+# SCRIPTS_AWK to support 'make dist', and 'make distclean'. No files which are
+# not substituted by config.status should be included in SCRIPTS_PERL,
+# SCRIPTS_SHELL, or SCRIPTS_AWK.  If non-generated files are listed for
+# installation, then Automake will figure out that they should be distributed;
 # otherwise, include them in EXTRA_DIST.
 #
+# All SCRIPTS_SHELL and SCRIPTS_PERL are syntax-checked on 'make check'.  There is
+# a fix in place to run these syntax checks against the perl modules in the build
+# tree, rather than against the (potentially old) installed perl modules.
+#
+# To emulate EXTRA_DIST for scripts, use SCRIPTS_EXTRA_DIST, e.g.,
+#   SCRIPTS_SHELL = $(selected_scripts)
+#   SCRIPTS_EXTRA_DIST = $(all_scripts)
+#
 # USAGE:
 #
 #   include $(top_srcdir)/config/automake/vars.am
@@ -41,7 +50,7 @@
 #   SCRIPTS_SHELL = shell1 shell2 sh-lib.sh
 #   SCRIPTS_AWK = talk balk chalk awk-lib.awk
 #   sbin_SCRIPTS = not-subbed
-#   EXTRA_DIST = util-script.pl
+#   SCRIPTS_EXTRA_DIST = util-script
 #
 # with the corresponding files in the repository:
 #
 #   talk.awk balk.awk chalk.awk awk-lib.awk.in
 #   not-subbed util-script.pl
 #
-# by default, all shell and perl scripts are syntax checked.  If this is
-# a problem (for example, perl scripts depending on Amanda extension 
-# modules), then assign to CHECK_{PERL,SHELL} the list of files you wish
-# to be checked (which can be empty).
-#
 # To add extra flags to the perl checks (e.g., to add new -I flags), set
 # CHECK_PERL_FLAGS.
 
 %: %.pl $(top_builddir)/config.status
        $(top_builddir)/config.status --file=$@:$<
        chmod a+x $@
+if CHECK_SCRIPTS_AT_BUILD
        @if test -f $(top_builddir)/perl/.libs/libCmdline.so -o -f $(top_builddir)/perl/libCmdline.so; then \
-               grep -v '^use lib' $@ > $@.nouselib; \
-               $(PERL) $(CHECK_PERL_FLAGS) -I$(top_builddir)/perl -I$(top_builddir)/perl/.libs -I$(top_srcdir)/perl -c -w -T $@.nouselib || exit 1; \
+               sed "s,^use lib ['\"]$(amperldir)['\"],# use lib '$(amperldir)' # nouselib," < $@ > $@.nouselib; \
+               $(PERL) $(CHECK_PERL_FLAGS) -I$(top_builddir)/perl -I$(top_builddir)/perl/.libs -I$(top_srcdir)/perl -c -w $@.nouselib || exit 1; \
                rm $@.nouselib; \
        fi
+endif
 
 %.pl: %.pl.in $(top_builddir)/config.status
        $(top_builddir)/config.status --file=$@:$<
@@ -104,36 +110,38 @@ CLEANFILES += config.log
 DISTCLEANFILES += $(SCRIPTS_SHELL) $(SCRIPTS_PERL) $(SCRIPTS_AWK) $(SCRIPTS_INCLUDE)
 
 # syntax-check perl scripts on 'make check'
-check-perl: $(CHECK_PERL)
-       @CHECK_PERL="$(CHECK_PERL)"; \
-       if test -f $(top_builddir)/perl/.libs/libCmdline.so -o -f $(top_builddir)/perl/libCmdline.so; then \
-               if test -n "$(PERL)"; then \
-                       for perlobj in $$CHECK_PERL; do \
-                               grep -v '^use lib' $$perlobj > $$perlobj.nouselib; \
-                               $(PERL) $(CHECK_PERL_FLAGS) -I$(top_builddir)/perl -I$(top_builddir)/perl/.libs -I$(top_srcdir)/perl -c -w -T $$perlobj.nouselib || exit 1; \
-                               rm $$perlobj.nouselib; \
-                       done; \
-               fi \
+check-perl: $(SCRIPTS_PERL)
+       @SCRIPTS_PERL="$(SCRIPTS_PERL)"; \
+       if test x"$(SKIP_CHECKS)" = x"" && \
+           test -f $(top_builddir)/perl/.libs/libCmdline.so -o -f $(top_builddir)/perl/libCmdline.so; then \
+           if test -n "$(PERL)"; then \
+                   for perlobj in $$SCRIPTS_PERL; do \
+                           sed "s,^use lib ['\"]$(amperldir)['\"],# use lib '$(amperldir)' # nouselib," < $$perlobj > $$perlobj.nouselib; \
+                           $(PERL) $(CHECK_PERL_FLAGS) -I$(top_builddir)/perl -I$(top_builddir)/perl/.libs -I$(top_srcdir)/perl -c -w $$perlobj.nouselib || exit 1; \
+                           rm $$perlobj.nouselib; \
+                   done; \
+           fi \
        fi
 check-local: check-perl
 
 # syntax-check perl scripts on 'make installcheck'
-installcheck-perl: $(CHECK_PERL)
-       @CHECK_PERL="$(CHECK_PERL)"; \
-       if test -n "$(PERL)"; then \
-               for perlobj in $$CHECK_PERL; do \
-                       $(PERL) $(CHECK_PERL_FLAGS) -c -w -T $$perlobj || exit 1; \
+installcheck-perl: $(SCRIPTS_PERL)
+       @SCRIPTS_PERL="$(SCRIPTS_PERL)"; \
+       if test x"$(SKIP_CHECKS)" = x"" && \
+           test -n "$(PERL)"; then \
+               for perlobj in $$SCRIPTS_PERL; do \
+                       $(PERL) $(CHECK_PERL_FLAGS) -c -w $$perlobj || exit 1; \
                done; \
        fi
 installcheck-local: installcheck-perl
 
 # syntax-check shell scripts on 'make check'
-CHECK_SHELL = $(SCRIPTS_SHELL)
-check-shell: $(CHECK_SHELL)
-       @CHECK_SHELL="$(CHECK_SHELL)"; \
-       if test -n "$$CHECK_SHELL"; then \
+check-shell: $(SCRIPTS_SHELL)
+       @SCRIPTS_SHELL="$(SCRIPTS_SHELL)"; \
+       if test x"$(SKIP_CHECKS)" = x"" && \
+           test -n "$$SCRIPTS_SHELL"; then \
                if test -n "$(BASH)"; then \
-                       for shobj in $$CHECK_SHELL; do \
+                       for shobj in $$SCRIPTS_SHELL; do \
                                if $(BASH) -n $$shobj; then \
                                        echo "$$shobj syntax OK"; \
                                else \
@@ -150,18 +158,34 @@ check-local: check-shell
 # make sure that the sources for all shell and perl scripts get included
 # in the distribution
 dist-scripts:
-       SCRIPTS_PERL="$(SCRIPTS_PERL)"; SCRIPTS_SHELL="$(SCRIPTS_SHELL)"; SCRIPTS_AWK="$(SCRIPTS_AWK)"; \
+       @SCRIPTS_PERL="$(SCRIPTS_PERL) $(SCRIPTS_EXTRA_DIST)"; \
+       SCRIPTS_SHELL="$(SCRIPTS_SHELL) $(SCRIPTS_EXTRA_DIST)"; \
+       SCRIPTS_AWK="$(SCRIPTS_AWK) $(SCRIPTS_EXTRA_DIST)"; \
+       SCRIPTS_DIST=; \
        for script in $$SCRIPTS_PERL; do \
-               test -f $(srcdir)/$${script}.pl && { cp -p $(srcdir)/$${script}.pl $(distdir)/ || exit 1; } \
+               test -f $(srcdir)/$${script}.pl && \
+                       SCRIPTS_DIST="$$SCRIPTS_DIST $${script}.pl"; \
        done; \
        for script in $$SCRIPTS_SHELL; do \
-               test -f $(srcdir)/$${script}.sh && { cp -p $(srcdir)/$${script}.sh $(distdir)/ || exit 1; } \
+               test -f $(srcdir)/$${script}.sh && \
+                       SCRIPTS_DIST="$$SCRIPTS_DIST $${script}.sh"; \
        done; \
        for script in $$SCRIPTS_AWK; do \
-               test -f $(srcdir)/$${script}.awk && { cp -p $(srcdir)/$${script}.awk $(distdir)/ || exit 1; } \
+               test -f $(srcdir)/$${script}.awk && \
+                       SCRIPTS_DIST="$$SCRIPTS_DIST $${script}.awk"; \
        done; \
        for script in $$SCRIPTS_SHELL $$SCRIPTS_PERL $$SCRIPTS_AWK; do \
-               test -f $(srcdir)/$${script}.in && { cp -p $(srcdir)/$${script}.in $(distdir)/ || exit 1; } \
+               test -f $(srcdir)/$${script}.in && \
+                       SCRIPTS_DIST="$$SCRIPTS_DIST $${script}.in"; \
+       done; \
+       for script in $$SCRIPTS_DIST; do \
+               dir=`dirname $${script}`; \
+               if test -n "$$dir" && test ! -d "$(distdir)/$$dir"; then \
+                       mkdir -p "$(distdir)/$$dir" || exit 1; \
+               fi; \
+               test -f "$(distdir)/$${script}" && continue; \
+               echo "distributing $${script}"; \
+               cp -p "$(srcdir)/$${script}" "$(distdir)/$${script}" || exit 1; \
        done; \
        true
 dist-hook: dist-scripts