2 # Copyright (c) 2005-2008 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., 465 S Mathlida Ave, Suite 300
18 # Sunnyvale, CA 94086, 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'. No
30 # files which are not substituted by config.status should be included in
31 # SCRIPTS_PERL, SCRIPTS_SHELL, or SCRIPTS_AWK. If non-generated files are listed
32 # for installation, then Automake will figure out that they should be distributed;
33 # otherwise, include them in EXTRA_DIST.
37 # include $(top_srcdir)/config/automake/vars.am
38 # include $(top_srcdir)/config/automake/scripts.am
40 # SCRIPTS_PERL = fooscript barscript perl-lib.pl perlmod.pm
41 # SCRIPTS_SHELL = shell1 shell2 sh-lib.sh
42 # SCRIPTS_AWK = talk balk chalk awk-lib.awk
43 # sbin_SCRIPTS = not-subbed
44 # EXTRA_DIST = util-script.pl
46 # with the corresponding files in the repository:
48 # fooscript.pl barscript.pl perl-lib.pl.in perlmod.pm.in
49 # shell1.sh shell2.sh sh-lib.sh.in
50 # talk.awk balk.awk chalk.awk awk-lib.awk.in
51 # not-subbed util-script.pl
53 # by default, all shell and perl scripts are syntax checked. If this is
54 # a problem (for example, perl scripts depending on Amanda extension
55 # modules), then assign to CHECK_{PERL,SHELL} the list of files you wish
56 # to be checked (which can be empty).
58 # To add extra flags to the perl checks (e.g., to add new -I flags), set
61 # Implementation note:
63 # This file uses config.status to substitute @foo@ in those scripts while
64 # converting them. It also adds the executable bits (a+x) to extensionless
65 # files. The substitution works even though the files are not listed in
69 %: %.pl $(top_builddir)/config.status
70 $(top_builddir)/config.status --file=$@:$<
72 @if test -f $(top_builddir)/perl/.libs/libCmdline.so -o -f $(top_builddir)/perl/libCmdline.so; then \
73 grep -v '^use lib' $@ > $@.nouselib; \
74 $(PERL) $(CHECK_PERL_FLAGS) -I$(top_builddir)/perl -I$(top_builddir)/perl/.libs -I$(top_srcdir)/perl -c -w -T $@.nouselib || exit 1; \
78 %.pl: %.pl.in $(top_builddir)/config.status
79 $(top_builddir)/config.status --file=$@:$<
81 %.pm: %.pm.in $(top_builddir)/config.status
82 $(top_builddir)/config.status --file=$@:$<
85 %: %.sh $(top_builddir)/config.status
86 $(top_builddir)/config.status --file=$@:$<
89 %.sh: %.sh.in $(top_builddir)/config.status
90 $(top_builddir)/config.status --file=$@:$<
93 %: %.awk $(top_builddir)/config.status
94 $(top_builddir)/config.status --file=$@:$<
97 %.awk: %.awk.in $(top_builddir)/config.status
98 $(top_builddir)/config.status --file=$@:$<
100 # config.status leaves config.log files around
101 CLEANFILES += config.log
103 # and we'll need to clean up our generated files for distclean
104 DISTCLEANFILES += $(SCRIPTS_SHELL) $(SCRIPTS_PERL) $(SCRIPTS_AWK) $(SCRIPTS_INCLUDE)
106 # syntax-check perl scripts on 'make check'
107 check-perl: $(CHECK_PERL)
108 @CHECK_PERL="$(CHECK_PERL)"; \
109 if test -f $(top_builddir)/perl/.libs/libCmdline.so -o -f $(top_builddir)/perl/libCmdline.so; then \
110 if test -n "$(PERL)"; then \
111 for perlobj in $$CHECK_PERL; do \
112 grep -v '^use lib' $$perlobj > $$perlobj.nouselib; \
113 $(PERL) $(CHECK_PERL_FLAGS) -I$(top_builddir)/perl -I$(top_builddir)/perl/.libs -I$(top_srcdir)/perl -c -w -T $$perlobj.nouselib || exit 1; \
114 rm $$perlobj.nouselib; \
118 check-local: check-perl
120 # syntax-check perl scripts on 'make installcheck'
121 installcheck-perl: $(CHECK_PERL)
122 @CHECK_PERL="$(CHECK_PERL)"; \
123 if test -n "$(PERL)"; then \
124 for perlobj in $$CHECK_PERL; do \
125 $(PERL) $(CHECK_PERL_FLAGS) -c -w -T $$perlobj || exit 1; \
128 installcheck-local: installcheck-perl
130 # syntax-check shell scripts on 'make check'
131 CHECK_SHELL = $(SCRIPTS_SHELL)
132 check-shell: $(CHECK_SHELL)
133 @CHECK_SHELL="$(CHECK_SHELL)"; \
134 if test -n "$$CHECK_SHELL"; then \
135 if test -n "$(BASH)"; then \
136 for shobj in $$CHECK_SHELL; do \
137 if $(BASH) -n $$shobj; then \
138 echo "$$shobj syntax OK"; \
140 echo "$$shobj syntax error"; \
145 echo "No 'bash' available -- cannot syntax-check shell scripts"; \
148 check-local: check-shell
150 # make sure that the sources for all shell and perl scripts get included
151 # in the distribution
153 SCRIPTS_PERL="$(SCRIPTS_PERL)"; SCRIPTS_SHELL="$(SCRIPTS_SHELL)"; SCRIPTS_AWK="$(SCRIPTS_AWK)"; \
154 for script in $$SCRIPTS_PERL; do \
155 test -f $(srcdir)/$${script}.pl && { cp -p $(srcdir)/$${script}.pl $(distdir)/ || exit 1; } \
157 for script in $$SCRIPTS_SHELL; do \
158 test -f $(srcdir)/$${script}.sh && { cp -p $(srcdir)/$${script}.sh $(distdir)/ || exit 1; } \
160 for script in $$SCRIPTS_AWK; do \
161 test -f $(srcdir)/$${script}.awk && { cp -p $(srcdir)/$${script}.awk $(distdir)/ || exit 1; } \
163 for script in $$SCRIPTS_SHELL $$SCRIPTS_PERL $$SCRIPTS_AWK; do \
164 test -f $(srcdir)/$${script}.in && { cp -p $(srcdir)/$${script}.in $(distdir)/ || exit 1; } \
167 dist-hook: dist-scripts