OSDN Git Service

Incorporate user-customized <features.h> configuration.
[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, 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,hdr,${top_srcdir}/include, dnl >> $@;)
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_headers = $(foreach $1,$(notdir $(wildcard $2/*.h)),echo $(4:%=%/)$($1)$3)
95 enum_header_subdirs = $(foreach d,$2,$(call enum_headers,h,$1/$d, dnl >> $3,$d))
96
97 # Compile the testsuite, from autotest sources.
98 #
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)
102
103 testsuite: %: %.at
104         $(AUTOTEST_COMPILE) -o $* $<
105
106 testsuite: $(notdir $(wildcard ${srcdir}/*.at))
107
108 # Display a diagnostic message, explaining that any specified program
109 # is required, but has not been installed.
110 #
111 define missing
112 $(warning The program '$1' does not appear to be installed.)
113 $(call $1_description)$(error $2)
114 endef
115
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.
119 #
120 define autom4te_description
121 $(info )
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.)
128 $(info )
129 $(info If you do need it, you may obtain it by installing GNU autoconf.)
130 $(info )
131 endef
132
133 # Install a local copy of the package components to be tested; we need
134 # the full w32api package, and also the mingwrt headers, including a stub
135 # for <features.h>, to ensure that we are testing what we've built, and
136 # not those which were installed with whatever compiler we are using
137 # for the build.
138 #
139 testsuite.install: install-w32api install-mingwrt-headers
140
141 install-w32api:
142         $(MAKE) -C .. --no-print-directory prefix=${CURDIR} $@
143
144 chkconfig = ($1/config.status --version | grep $2) 2>&1 > /dev/null
145 install-mingwrt-headers:
146         >> include/features.h
147         @for dir in ../../mingwrt*; do \
148           if $(call chkconfig,$$dir,'MinGW C Runtime'); then \
149              $(MAKE) -C $$dir --no-print-directory prefix=${CURDIR} $@; break; \
150              fi; \
151           done
152
153 # $RCSfile$: end of file