3 # Makefile template for MinGW.org Runtime Library testsuite
7 # Written by Keith Marshall <keithmarshall@users.sourceforge.net>
8 # Copyright (C) 2016, 2017, 2019, 2020, MinGW.org Project
11 # Permission is hereby granted, free of charge, to any person obtaining a
12 # copy of this software and associated documentation files (the "Software"),
13 # to deal in the Software without restriction, including without limitation
14 # the rights to use, copy, modify, merge, publish, distribute, sublicense,
15 # and/or sell copies of the Software, and to permit persons to whom the
16 # Software is furnished to do so, subject to the following conditions:
18 # The above copyright notice and this permission notice (including the next
19 # paragraph) shall be included in all copies or substantial portions of the
22 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25 # AUTHORS OR THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
28 # DEALINGS IN THE SOFTWARE.
31 top_srcdir = @top_srcdir@
32 top_builddir = @top_builddir@
34 # The default rule is "check"; it is a synonym for the "check-recursive"
35 # request, from the parent directory's make process, which initiates the
36 # installation of the package components to be tested, then prepares the
37 # testsuite itself, compiling it if necessary, and finally, runs it.
39 check check-recursive: check-install check-pretest check-local
41 check-local: testsuite
42 $(SHELL) $^ $(TESTSUITEFLAGS)
44 check-install: testsuite.install
45 check-pretest: testsuite.pretest headers.at.pretest
47 vpath Makefile.in ${srcdir}
48 vpath config.status ${top_builddir}
49 Makefile: %: %.in config.status
50 cd ${top_builddir}; ./config.status $(notdir ${CURDIR})/$@
54 # Favour any copy of the testsuite which already exists in the build
55 # directory, but fall back to any which may have been distributed with
58 testsuite.pretest: %.pretest: %.at.pretest
59 test -r $* || if test -r ${srcdir}/$*; then \
60 $(LN_S) ${srcdir}/$* $*; fi
62 # The primary testsuite.at source is nominally generated, when the
63 # package is configured, but is then distributed within the release
64 # tarball; update it as a side effect of running the testsuite, but
65 # only if its content differs from any distributed copy, to ensure
66 # that users building from a release tarball can do so, without a
67 # requirement to install autom4te.
70 vpath %.at.in ${srcdir}
71 testsuite.at.pretest: %.pretest: %.tmp
72 test -r $* || if test -r ${srcdir}/$*; then \
73 $(LN_S) ${srcdir}/$* $*; else touch $*; fi
74 sed '1s,tests/$<,$*,' $< > $@
75 cmp -s $@ $* || cp -f $@ $*
78 testsuite.at.tmp: %.tmp: ../config.status %.in
79 cd ..; ./config.status tests/$@
81 # The enumerated list of headers, which are to be tested, is also a
82 # candidate for dynamic update; in this case, we prefer to update the
83 # list in place, within the testsuite source tree.
85 headers.at.pretest: MINGWRT_AT_ENUM := MINGWRT_AT_PACKAGE_HEADERS
86 headers.at.pretest: %.pretest:
87 sed '/^m4_define(\[$(MINGWRT_AT_ENUM)],/q' ${srcdir}/$* > $@
88 $(call enum_headers,${top_srcdir}/include) >> $@
89 $(call enum_headers,${top_srcdir}/include, sys) >> $@
90 sed -n '/^])# $(MINGWRT_AT_ENUM)/,$$p' ${srcdir}/$* >> $@
91 cmp -s $@ ${srcdir}/$* || cp -f $@ ${srcdir}/$*
94 enum_headers = printf '%s dnl\n' $(call list_headers,$1$(2:%=/%),$(2:%=%/))
95 list_headers = $(addprefix $2,$(sort $(notdir $(wildcard $1/*.h))))
97 # Compile the testsuite, from autotest sources.
99 AUTOTEST_COMPILE = $(autotest_@AUTOTEST_COMPILE@)
100 autotest_command = autom4te --language autotest --include ${srcdir}
101 autotest_missing = $(call missing,autom4te,Unable to compile the testsuite)
104 $(AUTOTEST_COMPILE) -o $* $<
106 testsuite: $(notdir $(wildcard ${srcdir}/*.at))
108 # Display a diagnostic message, explaining that any specified program
109 # is required, but has not been installed.
112 $(warning The program '$1' does not appear to be installed.)
113 $(call $1_description)$(error $2)
116 # Describe the circumstances under which the autom4te program may be
117 # required for building the testsuite, as an adjunct to the diagnostic
118 # notification that it may need to be installed.
120 define autom4te_description
122 $(info This program is used to compile the testsuite driver script, from)
123 $(info original autotest source files. You need it when you are building)
124 $(info the testsuite from a checked-out clone of the source code repository;)
125 $(info otherwise, you should need it only if you have modified any of those)
126 $(info testsuite source files, or you have changed the package content in)
127 $(info any way which may cause any of these files to be regenerated.)
129 $(info If you do need it, you may obtain it by installing GNU autoconf.)
133 # Install a local copy of the package components to be tested; we need
134 # the full mingwrt package, including a <features.h> stub, and also the
135 # w32api headers, to ensure that we are testing what we've built, and
136 # not those which were installed with whatever compiler we are using
139 testsuite.install: install-mingwrt install-w32api-headers
142 $(MAKE) -C .. --no-print-directory prefix=${CURDIR} $@
143 >> include/features.h
145 chkconfig = ($1/config.status --version | grep $2) 2>&1 > /dev/null
146 install-w32api-headers:
147 @for dir in ../../w32api*; do \
148 if $(call chkconfig,$$dir,'MinGW Win32 API'); then \
149 $(MAKE) -C $$dir --no-print-directory prefix=${CURDIR} $@; break; \
153 # $RCSfile$: end of file