2 # Copyright (c) 2005 Zmanda, Inc. All Rights Reserved.
4 # This library is free software; you can redistribute it and/or modify it
5 # under the terms of the GNU Lesser General Public License version 2.1 as
6 # published by the Free Software Foundation.
8 # This library is distributed in the hope that it will be useful, but
9 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
11 # License for more details.
13 # You should have received a copy of the GNU Lesser General Public License
14 # along with this library; if not, write to the Free Software Foundation,
15 # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
17 # Contact information: Zmanda Inc., 505 N Mathlida Ave, Suite 120
18 # Sunnyvale, CA 94085, USA, or: http://www.zmanda.com
22 # Automake magic to handle the various tasks of building scripts. Scripts can
23 # be built down to extensionless executables (e.g., foo.pl -> foo), or to
24 # files with the usual extension (foo-lib.sh.in -> foo.sh).
26 # Files which support it are syntax-checked when the user invokes 'make check'.
28 # All *target* filenames must be listed in SCRIPTS_SHELL, SCRIPTS_PERL, and
29 # SCRIPTS_AWK to support 'make check', 'make dist', and 'make distclean'.
33 # include $(top_srcdir)/config/automake/vars.am
34 # include $(top_srcdir)/config/automake/scripts.am
36 # SCRIPTS_PERL = fooscript barscript perl-lib.pl perlmod.pm
37 # SCRIPTS_SHELL = shell1 shell2 sh-lib.sh
38 # SCRIPTS_AWK = talk balk chalk awk-lib.awk
40 # with the corresponding files in the repository:
42 # fooscript.pl barscript.pl perl-lib.pl.in perlmod.pm.in
43 # shell1.sh shell2.sh sh-lib.sh.in
44 # talk.awk balk.awk chalk.awk awk-lib.awk.in
46 # by default, all shell and perl scripts are syntax checked. If this is
47 # a problem (for example, perl scripts depending on Amanda extension
48 # modules), then assign to CHECK_{PERL,SHELL} the list of files you wish
49 # to be checked (which can be empty).
51 # To add extra flags to the perl checks (e.g., to add new -I flags), set
54 # Implementation note:
56 # This file uses config.status to substitute @foo@ in those scripts while
57 # converting them. It also adds the executable bits (a+x) to extensionless
58 # files. The substitution works even though the files are not listed in
62 %: %.pl $(top_builddir)/config.status
63 $(top_builddir)/config.status --file=$@:$<
66 %.pl: %.pl.in $(top_builddir)/config.status
67 $(top_builddir)/config.status --file=$@:$<
69 %.pm: %.pm.in $(top_builddir)/config.status
70 $(top_builddir)/config.status --file=$@:$<
73 %: %.sh $(top_builddir)/config.status
74 $(top_builddir)/config.status --file=$@:$<
77 %.sh: %.sh.in $(top_builddir)/config.status
78 $(top_builddir)/config.status --file=$@:$<
81 %: %.awk $(top_builddir)/config.status
82 $(top_builddir)/config.status --file=$@:$<
85 %.awk: %.awk.in $(top_builddir)/config.status
86 $(top_builddir)/config.status --file=$@:$<
88 # config.status leaves config.log files around
89 CLEANFILES += config.log
91 # and we'll need to clean up our generated files for distclean
92 DISTCLEANFILES += $(SCRIPTS_SHELL) $(SCRIPTS_PERL) $(SCRIPTS_AWK)
94 # syntax-check perl scripts on 'make check'
95 check-perl: $(CHECK_PERL)
96 @CHECK_PERL="$(CHECK_PERL)"; \
97 if test -n "$(PERL)"; then \
98 for perlobj in $$CHECK_PERL; do \
99 $(PERL) $(CHECK_PERL_FLAGS) -c -w -T $$perlobj || exit 1; \
102 check-local: check-perl
104 # syntax-check shell scripts on 'make check'
105 CHECK_SHELL = $(SCRIPTS_SHELL)
106 check-shell: $(CHECK_SHELL)
107 @CHECK_SHELL="$(CHECK_SHELL)"; \
108 if test -n "$$CHECK_SHELL"; then \
109 if test -n "$(BASH)"; then \
110 for shobj in $$CHECK_SHELL; do \
111 if $(BASH) -n $$shobj; then \
112 echo "$$shobj syntax OK"; \
114 echo "$$shobj syntax error"; \
119 echo "No 'bash' available -- cannot syntax-check shell scripts"; \
122 check-local: check-shell
124 # make sure that the sources for all shell and perl scripts get included
125 # in the distribution
127 SCRIPTS_PERL="$(SCRIPTS_PERL)"; SCRIPTS_SHELL="$(SCRIPTS_SHELL)"; SCRIPTS_AWK="$(SCRIPTS_AWK)"; \
128 for script in $$SCRIPTS_PERL; do \
129 test -f $(srcdir)/$${script}.pl && { cp -p $(srcdir)/$${script}.pl $(distdir)/ || exit 1; } \
131 for script in $$SCRIPTS_SHELL; do \
132 test -f $(srcdir)/$${script}.sh && { cp -p $(srcdir)/$${script}.sh $(distdir)/ || exit 1; } \
134 for script in $$SCRIPTS_AWK; do \
135 test -f $(srcdir)/$${script}.awk && { cp -p $(srcdir)/$${script}.awk $(distdir)/ || exit 1; } \
137 for script in $$SCRIPTS_SHELL $$SCRIPTS_PERL $$SCRIPTS_AWK; do \
138 test -f $(srcdir)/$${script}.in && { cp -p $(srcdir)/$${script}.in $(distdir)/ || exit 1; } \
141 dist-hook: dist-scripts