OSDN Git Service

b6d7b836536b2b01568cafc02c30bec1925ac2b7
[mingw/mingw-org-wsl.git] / w32api / Makefile.in
1 # @configure_input@
2 # $Id$
3 #
4 # Makefile template for MinGW.org MS-Windows API Package
5
6 PACKAGE_TARNAME := @PACKAGE_TARNAME@
7 PACKAGE_VERSION := @PACKAGE_VERSION@
8
9 # Written by Keith Marshall <keithmarshall@users.sourceforge.net>
10 # Copyright (C) 2014-2017, MinGW.org Project
11 #
12 #
13 # Permission is hereby granted, free of charge, to any person obtaining a
14 # copy of this software and associated documentation files (the "Software"),
15 # to deal in the Software without restriction, including without limitation
16 # the rights to use, copy, modify, merge, publish, distribute, sublicense,
17 # and/or sell copies of the Software, and to permit persons to whom the
18 # Software is furnished to do so, subject to the following conditions:
19 #
20 # The above copyright notice and this permission notice (including the next
21 # paragraph) shall be included in all copies or substantial portions of the
22 # Software.
23 #
24 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27 # AUTHORS OR THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30 # DEALINGS IN THE SOFTWARE.
31
32
33 # The default target is "all"; declare it early, to avoid any possible
34 # inadvertent override from any included file.
35 #
36 all:
37 PACKAGE_RELEASE :=
38 PACKAGE_RELEASE_TAG := $(PACKAGE_VERSION)$(PACKAGE_RELEASE:%=-%)-mingw32
39
40 # Establish the minimum version of Windows which this build is required
41 # to support; note that we fix the default as WinNT4, but we define it in
42 # a manner which will allow a command line override, and may be adapted,
43 # ultimately, to support a configure time assignment.
44 #
45 NTDDI_VERSION := NTDDI_WINNT4
46 NTDDI_VERSION_SPEC := $(NTDDI_VERSION:%=-D NTDDI_VERSION=%)
47
48 # Build paths and macros.
49 #
50 srcdir = @srcdir@
51 top_srcdir = @top_srcdir@
52 mingwrt_srcdir = @mingwrt_srcdir@
53 w32api_srcdir = @srcdir@
54 abs_builddir = @abs_builddir@
55
56 CC = @CC@
57 CFLAGS = @CFLAGS@
58 CPPFLAGS = @CPPFLAGS@
59 AS = @AS@
60
61 OBJEXT = @OBJEXT@
62
63 AR = @AR@
64 ARFLAGS = @ARFLAGS@
65 RANLIB = @RANLIB@
66
67 DLLTOOL = @DLLTOOL@
68 STRIP = @STRIP@
69
70 # Installation paths and macros.
71 #
72 prefix = @prefix@
73 exec_prefix = @exec_prefix@
74 includedir = ${DESTDIR}@includedir@
75 libdir = ${DESTDIR}@libdir@
76
77 mkinstalldirs = @MKDIR_P@ $(addprefix $1,$2)
78
79 INSTALL = @INSTALL@
80 INSTALL_DATA = @INSTALL_DATA@ $1 $2
81 LN_S = @LN_S@
82
83 # Keep the configuration in a consistent state.  Note that we assume
84 # that configure has been run initially, (otherwise we wouldn't have
85 # a Makefile to begin with); since this also creates config.status,
86 # we may normally assume that it is already available ...
87 #
88 vpath configure ${top_srcdir}
89 config.status: configure
90         $(SHELL) config.status --recheck
91
92 # ... in which case, updating Makefile should be a simple matter of
93 # running config.status ...
94 #
95 vpath Makefile.in ${top_srcdir}
96 requires_existing = $(if $(wildcard $1),$1,$1.missing)
97 Makefile: Makefile.in configure $(call requires_existing,config.status)
98         $(SHELL) config.status
99
100 .PHONY: config.status.missing
101 # ... but, in the event that this may be missing, (e.g. because it
102 # has been manually removed, or removed by "make distclean"), suggest
103 # running configure, and bail out.
104 #
105 config.status.missing:
106         $(warning *** cannot execute config.status)
107         $(error please run ${top_srcdir}/configure to regenerate it.)
108
109 # If configure itself needs to be updated, we must run autoconf in the
110 # top level source directory.
111 #
112 vpath configure.ac ${top_srcdir}
113 vpath %.m4 ${top_srcdir}/.. ${top_srcdir}
114 configure: configure.ac aclocal.m4 VERSION.m4
115         cd ${top_srcdir}; autoconf -I ..
116
117 # Propagate package version, as configured, consistently throughout
118 # the package build.
119 #
120 vpath %.h.in ${top_srcdir}/include ${mingwrt_srcdir}/include
121
122 w32api.h _mingw.h: configure.ac
123
124 PACKAGE_VERSION_SCRIPT = sed \
125   -e s"`$(call PACKAGE_VERSION_FORMAT,LONG,%d,$$3+1000*($$2+1000*$$1))`" \
126   -e s"`$(call PACKAGE_VERSION_FORMAT,MAJOR,%7d,$$1)`" \
127   -e s"`$(call PACKAGE_VERSION_FORMAT,MINOR,%7d,$$2)`" \
128   -e s"`$(call PACKAGE_VERSION_FORMAT,PATCH,%7d,$$3)`"
129
130 PACKAGE_VERSION_FORMAT = echo $(PACKAGE_VERSION).0.0 | awk -F. '{ \
131   printf ",%%PACKAGE_VERSION_$1%%,$2,", $3; \
132 }'
133
134 w32api.h _mingw.h: %.h: %.h.in
135         $(PACKAGE_VERSION_SCRIPT) $< > $@
136
137 # Capture dependencies conveyed within source files, ensuring that
138 # header files are taken from our working source tree, and not from
139 # the build-time compiler's installation path.  (Note: we use -MD,
140 # and not -MMD in DEPFLAGS; since this package furnishes system
141 # headers, we need changes therein to trigger a rebuild).
142 #
143 sinclude *.d
144 DEPFLAGS = -MD -MP
145 INCLUDES = -nostdinc -I . -I ${top_srcdir}/include -I ${mingwrt_srcdir}/include \
146   -I ${top_srcdir} -I ${top_srcdir}/profile -iwithprefixbefore include
147
148 ALL_CFLAGS = $(CFLAGS) $(DEPFLAGS) $(INCLUDES) $(NTDDI_VERSION_SPEC)
149
150 # The general case, for compiling object files from C source,
151 # requires a small adjustment to the default implicit rule.
152 #
153 %.$(OBJEXT): %.c
154         $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) -o $@ $<
155
156 deffiles = $(eval vpath %.def $1)$(notdir $(wildcard $1/*.def))
157 implibfiles = $(addprefix lib,$(subst .def,.a,$(call deffiles,$1)))
158
159 all: all-w32api-libs
160 all-w32api-libs: w32api.h _mingw.h
161 all-w32api-libs install-w32api-libs: $(call implibfiles,${srcdir}/lib)
162 all-w32api-libs install-w32api-libs: $(call implibfiles,${srcdir}/lib/directx)
163 all-w32api-libs install-w32api-libs: $(call implibfiles,${srcdir}/lib/ddk)
164 all-w32api-libs install-w32api-libs: liblargeint.a libstrmiids.a libuuid.a
165 all-w32api-libs install-w32api-libs: libdxerr8.a libdxerr9.a libdxguid.a
166 all-w32api-libs install-w32api-libs: libscrnsave.a libscrnsavw.a
167 all-w32api-libs install-w32api-libs: libdmoguids.a libvfw32.a
168
169 lib%.a: %.def
170         $(DLLTOOL) --as=$(AS) -k --output-lib $@ --def $<
171         $(if $(filter-out $<,$^),$(AR) $(ARFLAGS) $@ $(filter-out $<,$^))
172
173 vpath %.c ${srcdir}/lib
174 libuuid.a: ativscp-uuid.$(OBJEXT) cguid-uuid.$(OBJEXT)
175 libuuid.a: comcat-uuid.$(OBJEXT) devguid.$(OBJEXT) docobj-uuid.$(OBJEXT)
176 libuuid.a: exdisp-uuid.$(OBJEXT) extras-uuid.$(OBJEXT) hlguids-uuid.$(OBJEXT)
177 libuuid.a: hlink-uuid.$(OBJEXT) mlang-uuid.$(OBJEXT) mshtml-uuid.$(OBJEXT)
178 libuuid.a: msxml-uuid.$(OBJEXT) oaidl-uuid.$(OBJEXT) objidl-uuid.$(OBJEXT)
179 libuuid.a: objsafe-uuid.$(OBJEXT) ocidl-uuid.$(OBJEXT) oleacc-uuid.$(OBJEXT)
180 libuuid.a: olectlid-uuid.$(OBJEXT) oleidl-uuid.$(OBJEXT) power-uuid.$(OBJEXT)
181 libuuid.a: servprov-uuid.$(OBJEXT) unknwn-uuid.$(OBJEXT) urlmon-uuid.$(OBJEXT)
182
183 scrnsavw.$(OBJEXT): %.$(OBJEXT): scrnsave.c
184         $(CC) -c -D UNICODE $(CPPFLAGS) $(CFLAGS) $(DEPFLAGS) $(INCLUDES) -o $@ $<
185
186 libshell32.a: shell32.$(OBJEXT)
187 libgdiplus.a: gdiplus.$(OBJEXT)
188 libws2_32.a: ws2_32.$(OBJEXT)
189
190 libdmoguids.a libdxguid.a \
191 liblargeint.a libscrnsave.a libscrnsavw.a libstrmiids.a: lib%.a: %.$(OBJEXT)
192         $(AR) $(ARFLAGS) $@ $<
193
194 libuuid.a libdxerr8.a libdxerr9.a:
195         $(AR) $(ARFLAGS) $@ $^
196
197 vpath %.mri ${srcdir}/lib
198 libvfw32.a: lib%.a: %.mri libmsvfw32.a libavifil32.a libavicap32.a
199         rm -f $@ && $(AR) -M < $< && $(RANLIB) $@
200
201 vpath %.c ${srcdir}/lib/directx
202 libdinput.a libdinput8.a: dinput_joy.$(OBJEXT) dinput_joy2.$(OBJEXT) \
203   dinput_kbd.$(OBJEXT) dinput_mouse.$(OBJEXT) dinput_mouse2.$(OBJEXT)
204
205 libdxerr8.a: dxerr8.$(OBJEXT) dxerr8w.$(OBJEXT)
206 libdxerr9.a: dxerr9.$(OBJEXT) dxerr9w.$(OBJEXT)
207
208 # Installation Rules
209 # ------------------
210 #
211 # Users may expect to be able to specify DESTDIR, to stage the
212 # following stock installation directories outside of the regular
213 # "as configured" installation tree; unfortunately, this expectation
214 # MUST fail, when the stock path is in MS-Windows absolute format, so
215 # we provide an exception mechanism to forbid such usage, and we
216 # proceed to create the directories only when the exception is
217 # NOT triggered.
218 #
219 .PHONY: DESTDIR-UNSUPPORTED
220 bindir docdir includedir libdir mandir htmldir pdfdir:
221         @test -z "$(strip ${DESTDIR})" || case $($@) in ${DESTDIR}?:*) \
222           $(MAKE) --no-print-directory reject=$@ DESTDIR-UNSUPPORTED;; \
223           esac
224         $(call mkinstalldirs,,$($@))
225
226 # Note: we MUST use a recursive make invocation here, as the
227 # "error" function within the accompanying diagnostics would be
228 # triggered, irrespective of its placement in an unexecuted
229 # branch of the above exception trapping shell code.
230 #
231 DESTDIR-UNSUPPORTED:
232         $(call MSG_DESTDIR_FORBIDDEN,$(reject),$($(reject):${DESTDIR}%=%))
233
234 # The following macros, which rely heavily on GNU make's "call"
235 # function, define the diagnostics to be emitted, when the DESTDIR
236 # exception is triggered.
237 #
238 QUOTE = `$1'#'`
239 MSG_DESTDIR_FORBIDDEN = \
240   $(warning *** $(call MSG_DESTDIR_PATH_CONFLICT,$1,Win32,$2);) \
241   $(error try $(call QUOTE,$(call MSG_DESTDIR_ALTERNATIVE,$1,$2)) instead)
242 MSG_DESTDIR_BAD_PATH = DESTDIR is not supported when $1 contains $2 path $3
243 MSG_DESTDIR_PATH_CONFLICT = $(call MSG_DESTDIR_BAD_PATH,$1,$2,$(call QUOTE,$3))
244 MSG_DESTDIR_ALTERNATIVE = make install $1="$(call MSG_DESTDIR_TRANSFORM,$2)"
245 MSG_DESTDIR_TRANSFORM = ${DESTDIR}$(shell echo $1 | sed 's/^.://')
246
247 install: install-w32api
248 install-strip: install-strip-w32api
249
250 installdirs: w32api-include-dirs w32api-lib-dirs
251 install-strip-w32api: install-w32api-headers install-strip-w32api-libs
252 install-w32api: install-w32api-headers install-w32api-libs
253
254 w32api_extra_include_dirs = directx
255 w32api_include_subdirs = GL ddk gdiplus
256
257 w32api-include-dirs: includedir
258         $(call mkinstalldirs,${includedir}/,$(w32api_include_subdirs))
259
260 w32api-lib-dirs: libdir
261
262 install-headers: install-w32api-headers
263
264 obsolete_headers := winable.h pbt.h
265 winable.h pbt.h: replacement = winuser.h
266
267 $(obsolete_headers): %.h: obsolete.h.in
268         $(if $(subst ./,,$(dir $@)),mkdir -p $(@D))
269         $(obsolete_header_script) $< > $@
270
271 obsolete_header_script = sed -e 's,%HEADER%,$@,' \
272   -e "s,%PACKAGE%,$(call macro_name,$(PACKAGE_TARNAME))," \
273   -e 's,<REPLACEMENT>,$(call replace_header,$(replacement)),' \
274   -e "s,%GUARD_MACRO%,$(call macro_name,$@)," \
275   -e 's,%REPLACEMENT%,$(replacement),'
276
277 replace_header = $(if $(subst ./,,$(dir $1)),<$1>,"$1")
278 macro_name = `echo $1 | tr .a-z- _A-Z_`
279
280 w32api_generated_headers := w32api.h $(obsolete_headers)
281 w32api_dist_headers := $(w32api_generated_headers) ${srcdir}/include/*.h
282
283 install-w32api-headers: $(w32api_dist_headers)  w32api-include-dirs
284         $(call INSTALL_DATA,$(w32api_dist_headers),${includedir})
285         for dir in $(w32api_extra_include_dirs); do \
286           $(call INSTALL_DATA,${srcdir}/include/$$dir/*.h,${includedir}); \
287           done
288         for dir in $(w32api_include_subdirs); do \
289           $(call INSTALL_DATA,${srcdir}/include/$$dir/*.h,${includedir}/$$dir); \
290           done
291
292 w32api-lib-reqs: all-w32api-libs w32api-lib-dirs
293
294 install-w32api-libs: w32api-lib-reqs
295         $(call INSTALL_DATA,$(filter-out w32api-lib-reqs,$^),${libdir})
296         $(if $(STRIP_LIBS),$(call STRIP_LIBS,$(filter-out w32api-lib-reqs,$^)))
297
298 install-strip-w32api-libs:
299         $(MAKE) --no-print-directory \
300           STRIP_LIBS='cd ${libdir}; $(STRIP) --strip-unneeded $$1' \
301           install-w32api-libs
302
303 uninstall: uninstall-w32api-headers uninstall-w32api-libs
304
305 uninstall-w32api-headers:
306         cd ${includedir} && rm -f $(notdir $(wildcard ${srcdir}/include/*.h))
307         for dir in $(w32api_extra_include_dirs); do \
308           files=`cd ${srcdir}/include/$$dir && echo *.h`; \
309           (cd ${includedir} && rm -f $$files); \
310           done
311         for dir in $(w32api_include_subdirs); do \
312           files=`cd ${srcdir}/include/$$dir && echo *.h`; \
313           (cd ${includedir}/$$dir && rm -f $$files); \
314           done
315
316 uninstall-w32api-libs: un%:
317         $(MAKE) --no-print-directory mkinstalldirs= \
318           INSTALL_DATA='cd $$2 && rm -f $$1' $*
319
320
321 # Test Suite
322 # ----------
323 #
324 .PHONY: check-recursive
325 check test tests: check-recursive
326 check-recursive:
327         $(MAKE) -C tests $@
328
329
330 # Distribution
331 # ------------
332 #
333 .PHONY: dist
334 dist: bindist devdist dlldist licdist mandist srcdist
335         $(RM) -r dist/mingwrt dist/w32api
336
337 .PHONY: bindist devdist dlldist licdist mandist srcdist
338 bindist devdist dlldist licdist mandist srcdist: %dist: w32api-%dist
339
340 .PHONY: $(foreach tag,bin dev dll lic man src,mingwrt-$(tag)dist)
341 $(foreach tag,bin dev dll lic man src,mingwrt-$(tag)dist):
342
343 .PHONY: $(foreach tag,bin dev dll lic man src,w32api-$(tag)dist)
344 $(foreach tag,bin dev dll lic man src,w32api-$(tag)dist):
345
346 staged_prefix = $(addsuffix =`pwd`/dist/$1,prefix exec_prefix)
347 staged_install = $(call staged_prefix,$1) install-strip-$1
348
349 mingwrt-dist-staged w32api-dist-staged: %-dist-staged:
350         $(RM) -r dist/$*
351         $(MAKE) --no-print-directory $(call staged_install,$*)
352
353 mingwrt-srcdist w32api-srcdist: %-srcdist: %-srcdist-dir %-srcdist-files
354         cd dist && tar chf - $*-$(PACKAGE_VERSION) | \
355           xz -c > $*-$(PACKAGE_RELEASE_TAG)-src.tar.xz
356         $(RM) -r dist/$*-$(PACKAGE_VERSION)
357
358 w32api-srcdist-testsuite-files: $(wildcard ${w32api_srcdir}/tests/*.at)
359 w32api-srcdist-testsuite-files: $(wildcard ${w32api_srcdir}/tests/*.in)
360         (cd ${w32api_srcdir} && tar chf - $(addprefix tests/,$(notdir $^))) | \
361           (cd dist/$(PACKAGE_TARNAME)-$(PACKAGE_VERSION) && tar xf -)
362
363 mingwrt-srcdist-dir w32api-srcdist-dir: %-srcdist-dir:
364         $(RM) -r dist/$*-$(PACKAGE_VERSION)
365         $(call mkinstalldirs,,dist/$*-$(PACKAGE_VERSION))
366
367 w32api-srcdist-files: w32api-srcdist-config-files
368 w32api-srcdist-files: w32api-srcdist-testsuite-files
369 w32api-srcdist-files: w32api-srcdist-package-files
370
371 vpath install-sh ${top_srcdir}/.. ${top_srcdir}
372 %-srcdist-config-files: aclocal.m4 VERSION.m4 install-sh
373           cp -p $^ dist/$*-$(PACKAGE_VERSION)
374
375 %-srcdist-package-files:
376         (cd ${$*_srcdir} && tar chf - --hard-dereference $(notdir $^)) | \
377           (cd dist/$*-$(PACKAGE_VERSION) && tar xf -)
378
379 mingwrt-devdist w32api-devdist: %-devdist: %-dist-staged
380         cd dist/$* && tar chf - --hard-dereference include lib | \
381           xz -c > ../$*-$(PACKAGE_RELEASE_TAG)-dev.tar.xz
382
383 SRCDIST_ADD = $1-srcdist-package-files: $(addprefix ${$1_srcdir}/,$2)
384
385 $(call SRCDIST_ADD,w32api,ChangeLog CONTRIBUTIONS README.w32api TODO)
386 $(call SRCDIST_ADD,w32api,configure configure.ac Makefile.in include lib)
387
388 # Clean-up Rules
389 # --------------
390 #
391 clean-local: mostlyclean-local
392         $(RM) lib*.a
393
394 mostlyclean-local:
395         $(RM) *.d *.$(OBJEXT)
396
397 distclean-local: clean-local
398         $(RM) config.log config.status
399
400 maintainer-clean-warning:
401         $(warning $(MAKE) $(@:%-warning=%))
402         $(warning This command should be used by package maintainers only;)
403         $(warning it deletes files which may require special tools to rebuild.)
404
405 maintainer-clean-local: maintainer-clean-warning distclean-local
406         $(RM) -r ${srcdir}/configure ${srcdir}/autom4te.cache
407
408 clean mostlyclean distclean maintainer-clean: %clean: %clean-local
409
410 # $RCSfile$: end of file