OSDN Git Service

Incorporate user-customized <features.h> configuration.
[mingw/mingw-org-wsl.git] / mingwrt / tests / Makefile.in
1 # @configure_input@
2 #
3 # Makefile template for MinGW.org Runtime Library testsuite
4 #
5 # $Id$
6 #
7 # Written by Keith Marshall <keithmarshall@users.sourceforge.net>
8 # Copyright (C) 2016, 2017, 2019, MinGW.org Project
9 #
10 #
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:
17 #
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
20 # Software.
21 #
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.
29
30 srcdir = @srcdir@
31 top_srcdir = @top_srcdir@
32 top_builddir = @top_builddir@
33
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.
38 #
39 check check-recursive: check-install check-pretest check-local
40
41 check-local: testsuite
42         $(SHELL) $^ $(TESTSUITEFLAGS)
43
44 check-install: testsuite.install
45 check-pretest: testsuite.pretest headers.at.pretest
46
47 vpath Makefile.in ${srcdir}
48 vpath config.status ${top_builddir}
49 Makefile: %: %.in config.status
50         cd ${top_builddir}; ./config.status $(notdir ${CURDIR})/$@
51
52 LN_S = @LN_S@
53
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
56 # the source package.
57 #
58 testsuite.pretest: %.pretest: %.at.pretest
59         test -r $* || if test -r ${srcdir}/$*; then \
60           $(LN_S) ${srcdir}/$* $*; fi
61
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.
68 #
69 vpath %.at ${srcdir}
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 $@ $*
76         $(RM) $@ $<
77
78 testsuite.at.tmp: %.tmp: ../config.status %.in
79         cd ..; ./config.status tests/$@
80
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.
84 #
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,hdr,${top_srcdir}/include, dnl >> $@;)
89         $(call enum_headers,hdr,${top_srcdir}/include/sys, dnl >> $@;,sys)
90         sed -n '/^])# $(MINGWRT_AT_ENUM)/,$$p' ${srcdir}/$* >> $@
91         cmp -s $@ ${srcdir}/$* || cp -f $@ ${srcdir}/$*
92         $(RM) $@
93
94 enum_headers = $(foreach $1,$(notdir $(wildcard $2/*.h)),echo $(4:%=%/)$($1)$3)
95
96 # Compile the testsuite, from autotest sources.
97 #
98 AUTOTEST_COMPILE = $(autotest_@AUTOTEST_COMPILE@)
99 autotest_command = autom4te --language autotest --include ${srcdir}
100 autotest_missing = $(call missing,autom4te,Unable to compile the testsuite)
101
102 testsuite: %: %.at
103         $(AUTOTEST_COMPILE) -o $* $<
104
105 testsuite: $(notdir $(wildcard ${srcdir}/*.at))
106
107 # Display a diagnostic message, explaining that any specified program
108 # is required, but has not been installed.
109 #
110 define missing
111 $(warning The program '$1' does not appear to be installed.)
112 $(call $1_description)$(error $2)
113 endef
114
115 # Describe the circumstances under which the autom4te program may be
116 # required for building the testsuite, as an adjunct to the diagnostic
117 # notification that it may need to be installed.
118 #
119 define autom4te_description
120 $(info )
121 $(info This program is used to compile the testsuite driver script, from)
122 $(info original autotest source files.  You need it when you are building)
123 $(info the testsuite from a checked-out clone of the source code repository;)
124 $(info otherwise, you should need it only if you have modified any of those)
125 $(info testsuite source files, or you have changed the package content in)
126 $(info any way which may cause any of these files to be regenerated.)
127 $(info )
128 $(info If you do need it, you may obtain it by installing GNU autoconf.)
129 $(info )
130 endef
131
132 # Install a local copy of the package components to be tested; we need
133 # the full mingwrt package, including a <features.h> stub, and also the
134 # w32api headers, to ensure that we are testing what we've built, and
135 # not those which were installed with whatever compiler we are using
136 # for the build.
137 #
138 testsuite.install: install-mingwrt install-w32api-headers
139
140 install-mingwrt:
141         $(MAKE) -C .. --no-print-directory prefix=${CURDIR} $@
142         >> include/features.h
143
144 chkconfig = ($1/config.status --version | grep $2) 2>&1 > /dev/null
145 install-w32api-headers:
146         @for dir in ../../w32api*; do \
147           if $(call chkconfig,$$dir,'MinGW Win32 API'); then \
148              $(MAKE) -C $$dir --no-print-directory prefix=${CURDIR} $@; break; \
149              fi; \
150           done
151
152 # $RCSfile$: end of file