4 # Makefile template for MinGW.org MS-Windows API Package
6 PACKAGE_TARNAME := @PACKAGE_TARNAME@
7 PACKAGE_VERSION := @PACKAGE_VERSION@
9 # Written by Keith Marshall <keithmarshall@users.sourceforge.net>
10 # Copyright (C) 2014-2017, MinGW.org Project
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:
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
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.
33 # The default target is "all"; declare it early, to avoid any possible
34 # inadvertent override from any included file.
38 PACKAGE_RELEASE_TAG := $(PACKAGE_VERSION)$(PACKAGE_RELEASE:%=-%)-mingw32
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.
45 NTDDI_VERSION := NTDDI_WINNT4
46 NTDDI_VERSION_SPEC := $(NTDDI_VERSION:%=-D NTDDI_VERSION=%)
48 # Build paths and macros.
51 top_srcdir = @top_srcdir@
52 mingwrt_srcdir = @mingwrt_srcdir@
53 w32api_srcdir = @srcdir@
54 abs_builddir = @abs_builddir@
70 # Installation paths and macros.
73 exec_prefix = @exec_prefix@
74 includedir = ${DESTDIR}@includedir@
75 libdir = ${DESTDIR}@libdir@
77 mkinstalldirs = @MKDIR_P@ $(addprefix $1,$2)
80 INSTALL_DATA = @INSTALL_DATA@ $1 $2
83 # Include the makefile content which is common to both the mingwrt,
84 # and the w32api packages; this may be included within the top level
85 # source directory for each package individually, but we must also
86 # be prepared to find it in their common parent directory.
88 shared_include_file = $1$(if $(wildcard $1/$2),,/..)/$2
89 include $(call shared_include_file,${top_srcdir},Makefile.comm)
91 # Capture dependencies conveyed within source files, ensuring that
92 # header files are taken from our working source tree, and not from
93 # the build-time compiler's installation path. (Note: we use -MD,
94 # and not -MMD in DEPFLAGS; since this package furnishes system
95 # headers, we need changes therein to trigger a rebuild).
99 INCLUDES = -nostdinc -I . -I ${top_srcdir}/include -I ${mingwrt_srcdir}/include \
100 -I ${top_srcdir} -I ${top_srcdir}/profile -iwithprefixbefore include
102 ALL_CFLAGS = $(CFLAGS) $(DEPFLAGS) $(INCLUDES) $(NTDDI_VERSION_SPEC)
104 # The general case, for compiling object files from C source,
105 # requires a small adjustment to the default implicit rule.
108 $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) -o $@ $<
110 deffiles = $(eval vpath %.def $1)$(notdir $(wildcard $1/*.def))
111 implibfiles = $(addprefix lib,$(subst .def,.a,$(call deffiles,$1)))
114 all-w32api-libs: w32api.h _mingw.h
115 all-w32api-libs install-w32api-libs: $(call implibfiles,${srcdir}/lib)
116 all-w32api-libs install-w32api-libs: $(call implibfiles,${srcdir}/lib/directx)
117 all-w32api-libs install-w32api-libs: $(call implibfiles,${srcdir}/lib/ddk)
118 all-w32api-libs install-w32api-libs: liblargeint.a libstrmiids.a libuuid.a
119 all-w32api-libs install-w32api-libs: libdxerr8.a libdxerr9.a libdxguid.a
120 all-w32api-libs install-w32api-libs: libscrnsave.a libscrnsavw.a
121 all-w32api-libs install-w32api-libs: libdmoguids.a libvfw32.a
124 $(DLLTOOL) --as=$(AS) -k --output-lib $@ --def $<
125 $(if $(filter-out $<,$^),$(AR) $(ARFLAGS) $@ $(filter-out $<,$^))
127 vpath %.c ${srcdir}/lib
128 libuuid.a: ativscp-uuid.$(OBJEXT) cguid-uuid.$(OBJEXT)
129 libuuid.a: comcat-uuid.$(OBJEXT) devguid.$(OBJEXT) docobj-uuid.$(OBJEXT)
130 libuuid.a: exdisp-uuid.$(OBJEXT) extras-uuid.$(OBJEXT) hlguids-uuid.$(OBJEXT)
131 libuuid.a: hlink-uuid.$(OBJEXT) mlang-uuid.$(OBJEXT) mshtml-uuid.$(OBJEXT)
132 libuuid.a: msxml-uuid.$(OBJEXT) oaidl-uuid.$(OBJEXT) objidl-uuid.$(OBJEXT)
133 libuuid.a: objsafe-uuid.$(OBJEXT) ocidl-uuid.$(OBJEXT) oleacc-uuid.$(OBJEXT)
134 libuuid.a: olectlid-uuid.$(OBJEXT) oleidl-uuid.$(OBJEXT) power-uuid.$(OBJEXT)
135 libuuid.a: servprov-uuid.$(OBJEXT) unknwn-uuid.$(OBJEXT) urlmon-uuid.$(OBJEXT)
137 scrnsavw.$(OBJEXT): %.$(OBJEXT): scrnsave.c
138 $(CC) -c -D UNICODE $(CPPFLAGS) $(CFLAGS) $(DEPFLAGS) $(INCLUDES) -o $@ $<
140 libshell32.a: shell32.$(OBJEXT)
141 libgdiplus.a: gdiplus.$(OBJEXT)
142 libws2_32.a: ws2_32.$(OBJEXT)
144 libdmoguids.a libdxguid.a \
145 liblargeint.a libscrnsave.a libscrnsavw.a libstrmiids.a: lib%.a: %.$(OBJEXT)
146 $(AR) $(ARFLAGS) $@ $<
148 libuuid.a libdxerr8.a libdxerr9.a:
149 $(AR) $(ARFLAGS) $@ $^
151 vpath %.mri ${srcdir}/lib
152 libvfw32.a: lib%.a: %.mri libmsvfw32.a libavifil32.a libavicap32.a
153 rm -f $@ && $(AR) -M < $< && $(RANLIB) $@
155 vpath %.c ${srcdir}/lib/directx
156 libdinput.a libdinput8.a: dinput_joy.$(OBJEXT) dinput_joy2.$(OBJEXT) \
157 dinput_kbd.$(OBJEXT) dinput_mouse.$(OBJEXT) dinput_mouse2.$(OBJEXT)
159 libdxerr8.a: dxerr8.$(OBJEXT) dxerr8w.$(OBJEXT)
160 libdxerr9.a: dxerr9.$(OBJEXT) dxerr9w.$(OBJEXT)
165 # Users may expect to be able to specify DESTDIR, to stage the
166 # following stock installation directories outside of the regular
167 # "as configured" installation tree; unfortunately, this expectation
168 # MUST fail, when the stock path is in MS-Windows absolute format, so
169 # we provide an exception mechanism to forbid such usage, and we
170 # proceed to create the directories only when the exception is
173 .PHONY: DESTDIR-UNSUPPORTED
174 bindir docdir includedir libdir mandir htmldir pdfdir:
175 @test -z "$(strip ${DESTDIR})" || case $($@) in ${DESTDIR}?:*) \
176 $(MAKE) --no-print-directory reject=$@ DESTDIR-UNSUPPORTED;; \
178 $(call mkinstalldirs,,$($@))
180 # Note: we MUST use a recursive make invocation here, as the
181 # "error" function within the accompanying diagnostics would be
182 # triggered, irrespective of its placement in an unexecuted
183 # branch of the above exception trapping shell code.
186 $(call MSG_DESTDIR_FORBIDDEN,$(reject),$($(reject):${DESTDIR}%=%))
188 # The following macros, which rely heavily on GNU make's "call"
189 # function, define the diagnostics to be emitted, when the DESTDIR
190 # exception is triggered.
193 MSG_DESTDIR_FORBIDDEN = \
194 $(warning *** $(call MSG_DESTDIR_PATH_CONFLICT,$1,Win32,$2);) \
195 $(error try $(call QUOTE,$(call MSG_DESTDIR_ALTERNATIVE,$1,$2)) instead)
196 MSG_DESTDIR_BAD_PATH = DESTDIR is not supported when $1 contains $2 path $3
197 MSG_DESTDIR_PATH_CONFLICT = $(call MSG_DESTDIR_BAD_PATH,$1,$2,$(call QUOTE,$3))
198 MSG_DESTDIR_ALTERNATIVE = make install $1="$(call MSG_DESTDIR_TRANSFORM,$2)"
199 MSG_DESTDIR_TRANSFORM = ${DESTDIR}$(shell echo $1 | sed 's/^.://')
201 install: install-w32api
202 install-strip: install-strip-w32api
204 installdirs: w32api-include-dirs w32api-lib-dirs
205 install-strip-w32api: install-w32api-headers install-strip-w32api-libs
206 install-w32api: install-w32api-headers install-w32api-libs
208 w32api_extra_include_dirs = directx
209 w32api_include_subdirs = GL ddk gdiplus
211 w32api-include-dirs: includedir
212 $(call mkinstalldirs,${includedir}/,$(w32api_include_subdirs))
214 w32api-lib-dirs: libdir
216 install-headers: install-w32api-headers
218 obsolete_headers := winable.h pbt.h
219 winable.h pbt.h: replacement = winuser.h
221 $(obsolete_headers): %.h: obsolete.h.in
222 $(if $(subst ./,,$(dir $@)),mkdir -p $(@D))
223 $(obsolete_header_script) $< > $@
225 obsolete_header_script = sed -e 's,%HEADER%,$@,' \
226 -e "s,%PACKAGE%,$(call macro_name,$(PACKAGE_TARNAME))," \
227 -e 's,<REPLACEMENT>,$(call replace_header,$(replacement)),' \
228 -e "s,%GUARD_MACRO%,$(call macro_name,$@)," \
229 -e 's,%REPLACEMENT%,$(replacement),'
231 replace_header = $(if $(subst ./,,$(dir $1)),<$1>,"$1")
232 macro_name = `echo $1 | tr .a-z- _A-Z_`
234 w32api_generated_headers := w32api.h $(obsolete_headers)
235 w32api_dist_headers := $(w32api_generated_headers) ${srcdir}/include/*.h
237 install-w32api-headers: $(w32api_dist_headers) w32api-include-dirs
238 $(call INSTALL_DATA,$(w32api_dist_headers),${includedir})
239 for dir in $(w32api_extra_include_dirs); do \
240 $(call INSTALL_DATA,${srcdir}/include/$$dir/*.h,${includedir}); \
242 for dir in $(w32api_include_subdirs); do \
243 $(call INSTALL_DATA,${srcdir}/include/$$dir/*.h,${includedir}/$$dir); \
246 w32api-lib-reqs: all-w32api-libs w32api-lib-dirs
248 install-w32api-libs: w32api-lib-reqs
249 $(call INSTALL_DATA,$(filter-out w32api-lib-reqs,$^),${libdir})
250 $(if $(STRIP_LIBS),$(call STRIP_LIBS,$(filter-out w32api-lib-reqs,$^)))
252 install-strip-w32api-libs:
253 $(MAKE) --no-print-directory \
254 STRIP_LIBS='cd ${libdir}; $(STRIP) --strip-unneeded $$1' \
257 uninstall: uninstall-w32api-headers uninstall-w32api-libs
259 uninstall-w32api-headers:
260 cd ${includedir} && rm -f $(notdir $(wildcard ${srcdir}/include/*.h))
261 for dir in $(w32api_extra_include_dirs); do \
262 files=`cd ${srcdir}/include/$$dir && echo *.h`; \
263 (cd ${includedir} && rm -f $$files); \
265 for dir in $(w32api_include_subdirs); do \
266 files=`cd ${srcdir}/include/$$dir && echo *.h`; \
267 (cd ${includedir}/$$dir && rm -f $$files); \
270 uninstall-w32api-libs: un%:
271 $(MAKE) --no-print-directory mkinstalldirs= \
272 INSTALL_DATA='cd $$2 && rm -f $$1' $*
278 .PHONY: check-recursive
279 check test tests: check-recursive
288 dist: bindist devdist dlldist licdist mandist srcdist
289 $(RM) -r dist/mingwrt dist/w32api
291 .PHONY: bindist devdist dlldist licdist mandist srcdist
292 bindist devdist dlldist licdist mandist srcdist: %dist: w32api-%dist
294 .PHONY: $(foreach tag,bin dev dll lic man src,mingwrt-$(tag)dist)
295 $(foreach tag,bin dev dll lic man src,mingwrt-$(tag)dist):
297 .PHONY: $(foreach tag,bin dev dll lic man src,w32api-$(tag)dist)
298 $(foreach tag,bin dev dll lic man src,w32api-$(tag)dist):
300 staged_prefix = $(addsuffix =`pwd`/dist/$1,prefix exec_prefix)
301 staged_install = $(call staged_prefix,$1) install-strip-$1
303 mingwrt-dist-staged w32api-dist-staged: %-dist-staged:
305 $(MAKE) --no-print-directory $(call staged_install,$*)
307 mingwrt-srcdist w32api-srcdist: %-srcdist: %-srcdist-dir %-srcdist-files
308 cd dist && tar chf - $*-$(PACKAGE_VERSION) | \
309 xz -c > $*-$(PACKAGE_RELEASE_TAG)-src.tar.xz
310 $(RM) -r dist/$*-$(PACKAGE_VERSION)
312 w32api-srcdist-testsuite-files: $(wildcard ${w32api_srcdir}/tests/*.at)
313 w32api-srcdist-testsuite-files: $(wildcard ${w32api_srcdir}/tests/*.in)
314 (cd ${w32api_srcdir} && tar chf - $(addprefix tests/,$(notdir $^))) | \
315 (cd dist/$(PACKAGE_TARNAME)-$(PACKAGE_VERSION) && tar xf -)
317 mingwrt-srcdist-dir w32api-srcdist-dir: %-srcdist-dir:
318 $(RM) -r dist/$*-$(PACKAGE_VERSION)
319 $(call mkinstalldirs,,dist/$*-$(PACKAGE_VERSION))
321 w32api-srcdist-files: w32api-srcdist-common-files
322 w32api-srcdist-files: w32api-srcdist-testsuite-files
323 w32api-srcdist-files: w32api-srcdist-package-files
325 %-srcdist-package-files:
326 (cd ${$*_srcdir} && tar chf - --hard-dereference $(notdir $^)) | \
327 (cd dist/$*-$(PACKAGE_VERSION) && tar xf -)
329 mingwrt-devdist w32api-devdist: %-devdist: %-dist-staged
330 cd dist/$* && tar chf - --hard-dereference include lib | \
331 xz -c > ../$*-$(PACKAGE_RELEASE_TAG)-dev.tar.xz
333 SRCDIST_ADD = $1-srcdist-package-files: $(addprefix ${$1_srcdir}/,$2)
335 $(call SRCDIST_ADD,w32api,ChangeLog CONTRIBUTIONS README.w32api TODO)
336 $(call SRCDIST_ADD,w32api,configure configure.ac Makefile.in include lib)
341 clean-local: mostlyclean-local
345 $(RM) *.d *.$(OBJEXT)
347 distclean-local: clean-local
348 $(RM) config.log config.status _mingw.h w32api.h
350 maintainer-clean-warning:
351 $(warning $(MAKE) $(@:%-warning=%))
352 $(warning This command should be used by package maintainers only;)
353 $(warning it deletes files which may require special tools to rebuild.)
355 maintainer-clean-local: maintainer-clean-warning distclean-local
356 $(RM) -r ${srcdir}/configure ${srcdir}/autom4te.cache
358 clean mostlyclean distclean maintainer-clean: %clean: %clean-local
360 # $RCSfile$: end of file