OSDN Git Service

Preserve order of tests for integrity of header files.
[mingw/mingw-org-wsl.git] / w32api / tests / Makefile.in
1 # @configure_input@
2 #
3 # Makefile template for MinGW.org Win32 API testsuite
4 #
5 # $Id$
6 #
7 # Written by Keith Marshall <keithmarshall@users.sourceforge.net>
8 # Copyright (C) 2017, 2019, 2020, 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: W32API_AT_ENUM := W32API_AT_PACKAGE_HEADERS
86 headers.at.pretest: %.pretest:
87         sed '/^m4_define(\[$(W32API_AT_ENUM)],/q' ${srcdir}/$* > $@
88         $(call enum_headers,${top_srcdir}/include) >> $@
89         $(call enum_header_subdirs,${top_srcdir}/include,$(HEADER_SUBDIRS))
90         sed -n '/^])# $(W32API_AT_ENUM)/,$$p' ${srcdir}/$* >> $@
91         cmp -s $@ ${srcdir}/$* || cp -f $@ ${srcdir}/$*
92         $(RM) $@
93
94 enum_header_subdirs = $(foreach d,$2,$(call enum_headers,$1,$d) >> $@;)
95 enum_headers = printf '%s dnl\n' $(call list_headers,$1$(2:%=/%),$(2:%=%/))
96 list_headers = $(addprefix $2,$(sort $(notdir $(wildcard $1/*.h))))
97
98 # Compile the testsuite, from autotest sources.
99 #
100 AUTOTEST_COMPILE = $(autotest_@AUTOTEST_COMPILE@)
101 autotest_command = autom4te --language autotest --include ${srcdir}
102 autotest_missing = $(call missing,autom4te,Unable to compile the testsuite)
103
104 testsuite: %: %.at
105         $(AUTOTEST_COMPILE) -o $* $<
106
107 testsuite: $(notdir $(wildcard ${srcdir}/*.at))
108
109 # Display a diagnostic message, explaining that any specified program
110 # is required, but has not been installed.
111 #
112 define missing
113 $(warning The program '$1' does not appear to be installed.)
114 $(call $1_description)$(error $2)
115 endef
116
117 # Describe the circumstances under which the autom4te program may be
118 # required for building the testsuite, as an adjunct to the diagnostic
119 # notification that it may need to be installed.
120 #
121 define autom4te_description
122 $(info )
123 $(info This program is used to compile the testsuite driver script, from)
124 $(info original autotest source files.  You need it when you are building)
125 $(info the testsuite from a checked-out clone of the source code repository;)
126 $(info otherwise, you should need it only if you have modified any of those)
127 $(info testsuite source files, or you have changed the package content in)
128 $(info any way which may cause any of these files to be regenerated.)
129 $(info )
130 $(info If you do need it, you may obtain it by installing GNU autoconf.)
131 $(info )
132 endef
133
134 # Install a local copy of the package components to be tested; we need
135 # the full w32api package, and also the mingwrt headers, including a stub
136 # for <features.h>, to ensure that we are testing what we've built, and
137 # not those which were installed with whatever compiler we are using
138 # for the build.
139 #
140 testsuite.install: install-w32api install-mingwrt-headers
141
142 install-w32api:
143         $(MAKE) -C .. --no-print-directory prefix=${CURDIR} $@
144
145 chkconfig = ($1/config.status --version | grep $2) 2>&1 > /dev/null
146 install-mingwrt-headers:
147         >> include/features.h
148         @for dir in ../../mingwrt*; do \
149           if $(call chkconfig,$$dir,'MinGW C Runtime'); then \
150              $(MAKE) -C $$dir --no-print-directory prefix=${CURDIR} $@; break; \
151              fi; \
152           done
153
154 # $RCSfile$: end of file