am: do not quote `like this', as per GCS recommendation
[platform/upstream/automake.git] / lib / am / dejagnu.am
1 ## automake - create Makefile.in from Makefile.am
2 ## Copyright (C) 1994-2012 Free Software Foundation, Inc.
3
4 ## This program is free software; you can redistribute it and/or modify
5 ## it under the terms of the GNU General Public License as published by
6 ## the Free Software Foundation; either version 2, or (at your option)
7 ## any later version.
8
9 ## This program is distributed in the hope that it will be useful,
10 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 ## GNU General Public License for more details.
13
14 ## You should have received a copy of the GNU General Public License
15 ## along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17 ## Name of tool to use.  Default is the same as the package.
18 DEJATOOL = $(PACKAGE)
19
20 ## Default flags to pass to dejagnu.  The user can override this.
21 RUNTESTDEFAULTFLAGS = --tool $$tool --srcdir $$srcdir
22
23 ## In Cygnus mode, these are found in the build tree.
24 ## Otherwise they are looked for in $PATH.
25 if %?CYGNUS%
26 EXPECT = `if test -f $(top_builddir)/../expect/expect; then \
27             echo $(top_builddir)/../expect/expect; \
28           else \
29             echo expect; \
30           fi`
31
32 RUNTEST = `if test -f $(top_srcdir)/../dejagnu/runtest; then \
33              echo $(top_srcdir)/../dejagnu/runtest; \
34            else \
35              echo runtest; \
36            fi`
37 else ! %?CYGNUS%
38 EXPECT = expect
39 RUNTEST = runtest
40 endif ! %?CYGNUS%
41
42
43 .PHONY: check-DEJAGNU
44 check-DEJAGNU: site.exp
45 ## Life is easiest with an absolute srcdir, so do that.
46         srcdir='$(srcdir)'; export srcdir; \
47         EXPECT=$(EXPECT); export EXPECT; \
48 ## Allow this to work when expect and DejaGnu are in tree.
49 ## Only required when --cygnus in force.
50 ?CYGNUS?        if [ -f $(top_builddir)/../expect/expect ]; then \
51 ?CYGNUS?          TCL_LIBRARY=`$(am__cd) $(top_srcdir)/../tcl/library && pwd`; \
52 ?CYGNUS?          export TCL_LIBRARY; \
53 ?CYGNUS?        fi; \
54         runtest=$(RUNTEST); \
55 ## If runtest can't be found, print a warning but don't die.  It is
56 ## pointless to cause a failure if the tests cannot be run at all.
57         if $(SHELL) -c "$$runtest --version" > /dev/null 2>&1; then \
58           exit_status=0; l='$(DEJATOOL)'; for tool in $$l; do \
59             if $$runtest $(AM_RUNTESTFLAGS) $(RUNTESTDEFAULTFLAGS) $(RUNTESTFLAGS); \
60             then :; else exit_status=1; fi; \
61           done; \
62         else echo "WARNING: could not find 'runtest'" 1>&2; :;\
63         fi; \
64         exit $$exit_status
65
66
67 ## ------------------- ##
68 ## Building site.exp.  ##
69 ## ------------------- ##
70
71 ## Note that in the rule we don't directly generate site.exp to avoid
72 ## the possibility of a corrupted site.exp if make is interrupted.
73 ## Jim Meyering has some useful text on this topic.
74 site.exp: Makefile $(EXTRA_DEJAGNU_SITE_CONFIG)
75         @echo 'Making a new site.exp file ...'
76         @echo '## these variables are automatically generated by make ##' >site.tmp
77         @echo '# Do not edit here.  If you wish to override these values' >>site.tmp
78         @echo '# edit the last section' >>site.tmp
79         @echo 'set srcdir "$(srcdir)"' >>site.tmp
80         @echo "set objdir `pwd`" >>site.tmp
81 ## Quote the *_alias variables because they might be empty.
82 ?BUILD? @echo 'set build_alias "$(build_alias)"' >>site.tmp
83 ?BUILD? @echo 'set build_triplet $(build_triplet)' >>site.tmp
84 ?HOST?  @echo 'set host_alias "$(host_alias)"' >>site.tmp
85 ?HOST?  @echo 'set host_triplet $(host_triplet)' >>site.tmp
86 ?TARGET?        @echo 'set target_alias "$(target_alias)"' >>site.tmp
87 ?TARGET?        @echo 'set target_triplet $(target_triplet)' >>site.tmp
88 ## Allow the package author to extend site.exp.
89         @list='$(EXTRA_DEJAGNU_SITE_CONFIG)'; for f in $$list; do \
90           echo "## Begin content included from file $$f.  Do not modify. ##" \
91            && cat `test -f "$$f" || echo '$(srcdir)/'`$$f \
92            && echo "## End content included from file $$f. ##" \
93            || exit 1; \
94          done >> site.tmp
95         @echo "## End of auto-generated content; you can edit from here. ##" >> site.tmp
96         @if test -f site.exp; then \
97            sed -e '1,/^## End of auto-generated content.*##/d' site.exp >> site.tmp; \
98          fi
99         @-rm -f site.bak
100         @test ! -f site.exp || mv site.exp site.bak
101         @mv site.tmp site.exp
102
103 ## ---------- ##
104 ## Cleaning.  ##
105 ## ---------- ##
106
107 .PHONY distclean-am: distclean-DEJAGNU
108
109 distclean-DEJAGNU:
110 ## Any other cleaning must be done by the user or by the test suite
111 ## itself.  We can't predict what dejagnu or the test suite might
112 ## generate.
113         -rm -f site.exp site.bak
114         -l='$(DEJATOOL)'; for tool in $$l; do \
115           rm -f $$tool.sum $$tool.log; \
116         done