OSDN Git Service

Declare the nanosleep() function where POSIX expects it.
[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, 2015, 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
82 # Keep the configuration in a consistent state.  Note that we assume
83 # that configure has been run initially, (otherwise we wouldn't have
84 # a Makefile to begin with); since this also creates config.status,
85 # we may normally assume that it is already available ...
86 #
87 vpath configure ${top_srcdir}
88 config.status: configure
89         $(SHELL) config.status --recheck
90
91 # ... in which case, updating Makefile should be a simple matter of
92 # running config.status ...
93 #
94 vpath Makefile.in ${top_srcdir}
95 requires_existing = $(if $(wildcard $1),$1,$1.missing)
96 Makefile: Makefile.in configure $(call requires_existing,config.status)
97         $(SHELL) config.status
98
99 .PHONY: config.status.missing
100 # ... but, in the event that this may be missing, (e.g. because it
101 # has been manually removed, or removed by "make distclean"), suggest
102 # running configure, and bail out.
103 #
104 config.status.missing:
105         $(warning *** cannot execute config.status)
106         $(error please run ${top_srcdir}/configure to regenerate it.)
107
108 # If configure itself needs to be updated, we must run autoconf in the
109 # top level source directory.
110 #
111 vpath %.m4 ${top_srcdir}
112 vpath configure.ac ${top_srcdir}
113 configure: configure.ac aclocal.m4
114         cd ${top_srcdir}; autoconf
115
116 # Capture dependencies conveyed within source files, ensuring that
117 # header files are taken from our working source tree, and not from
118 # the build-time compiler's installation path.  (Note: we use -MD,
119 # and not -MMD in DEPFLAGS; since this package furnishes system
120 # headers, we need changes therein to trigger a rebuild).
121 #
122 sinclude *.d
123 DEPFLAGS = -MD -MP
124 INCLUDES = -nostdinc -I . -I ${top_srcdir}/include -I ${mingwrt_srcdir}/include \
125   -I ${top_srcdir} -I ${top_srcdir}/profile -iwithprefixbefore include
126
127 ALL_CFLAGS = $(CFLAGS) $(DEPFLAGS) $(INCLUDES) $(NTDDI_VERSION_SPEC)
128
129 # The general case, for compiling object files from C source,
130 # requires a small adjustment to the default implicit rule.
131 #
132 %.$(OBJEXT): %.c
133         $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) -o $@ $<
134
135 deffiles = $(eval vpath %.def $1)$(notdir $(wildcard $1/*.def))
136 implibfiles = $(addprefix lib,$(subst .def,.a,$(call deffiles,$1)))
137
138 all: all-w32api-libs
139 all-w32api-libs install-w32api-libs: $(call implibfiles,${srcdir}/lib)
140 all-w32api-libs install-w32api-libs: $(call implibfiles,${srcdir}/lib/directx)
141 all-w32api-libs install-w32api-libs: $(call implibfiles,${srcdir}/lib/ddk)
142 all-w32api-libs install-w32api-libs: liblargeint.a libstrmiids.a libuuid.a
143 all-w32api-libs install-w32api-libs: libdxerr8.a libdxerr9.a libdxguid.a
144 all-w32api-libs install-w32api-libs: libscrnsave.a libscrnsavw.a
145 all-w32api-libs install-w32api-libs: libdmoguids.a libvfw32.a
146
147 lib%.a: %.def
148         $(DLLTOOL) --as=$(AS) -k --output-lib $@ --def $<
149         $(if $(filter-out $<,$^),$(AR) $(ARFLAGS) $@ $(filter-out $<,$^))
150
151 vpath %.c ${srcdir}/lib
152 libuuid.a: ativscp-uuid.$(OBJEXT) cguid-uuid.$(OBJEXT)
153 libuuid.a: comcat-uuid.$(OBJEXT) devguid.$(OBJEXT) docobj-uuid.$(OBJEXT)
154 libuuid.a: exdisp-uuid.$(OBJEXT) extras-uuid.$(OBJEXT) hlguids-uuid.$(OBJEXT)
155 libuuid.a: hlink-uuid.$(OBJEXT) mlang-uuid.$(OBJEXT) mshtml-uuid.$(OBJEXT)
156 libuuid.a: msxml-uuid.$(OBJEXT) oaidl-uuid.$(OBJEXT) objidl-uuid.$(OBJEXT)
157 libuuid.a: objsafe-uuid.$(OBJEXT) ocidl-uuid.$(OBJEXT) oleacc-uuid.$(OBJEXT)
158 libuuid.a: olectlid-uuid.$(OBJEXT) oleidl-uuid.$(OBJEXT) power-uuid.$(OBJEXT)
159 libuuid.a: servprov-uuid.$(OBJEXT) unknwn-uuid.$(OBJEXT) urlmon-uuid.$(OBJEXT)
160
161 scrnsavw.$(OBJEXT): %.$(OBJEXT): scrnsave.c
162         $(CC) -c -D UNICODE $(CPPFLAGS) $(CFLAGS) $(DEPFLAGS) $(INCLUDES) -o $@ $<
163
164 libshell32.a: shell32.$(OBJEXT)
165 libgdiplus.a: gdiplus.$(OBJEXT)
166 libws2_32.a: ws2_32.$(OBJEXT)
167
168 libdmoguids.a libdxguid.a \
169 liblargeint.a libscrnsave.a libscrnsavw.a libstrmiids.a: lib%.a: %.$(OBJEXT)
170         $(AR) $(ARFLAGS) $@ $<
171
172 libuuid.a libdxerr8.a libdxerr9.a:
173         $(AR) $(ARFLAGS) $@ $^
174
175 vpath %.mri ${srcdir}/lib
176 libvfw32.a: lib%.a: %.mri libmsvfw32.a libavifil32.a libavicap32.a
177         rm -f $@ && $(AR) -M < $< && $(RANLIB) $@
178
179 vpath %.c ${srcdir}/lib/directx
180 libdinput.a libdinput8.a: dinput_joy.$(OBJEXT) dinput_joy2.$(OBJEXT) \
181   dinput_kbd.$(OBJEXT) dinput_mouse.$(OBJEXT) dinput_mouse2.$(OBJEXT)
182
183 libdxerr8.a: dxerr8.$(OBJEXT) dxerr8w.$(OBJEXT)
184 libdxerr9.a: dxerr9.$(OBJEXT) dxerr9w.$(OBJEXT)
185
186 # Installation Rules
187 # ------------------
188 #
189 # Users may expect to be able to specify DESTDIR, to stage the
190 # following stock installation directories outside of the regular
191 # "as configured" installation tree; unfortunately, this expectation
192 # MUST fail, when the stock path is in MS-Windows absolute format, so
193 # we provide an exception mechanism to forbid such usage, and we
194 # proceed to create the directories only when the exception is
195 # NOT triggered.
196 #
197 .PHONY: DESTDIR-UNSUPPORTED
198 bindir docdir includedir libdir mandir htmldir pdfdir:
199         @test -z "$(strip ${DESTDIR})" || case $($@) in ${DESTDIR}?:*) \
200           $(MAKE) --no-print-directory reject=$@ DESTDIR-UNSUPPORTED;; \
201           esac
202         $(call mkinstalldirs,,$($@))
203
204 # Note: we MUST use a recursive make invocation here, as the
205 # "error" function within the accompanying diagnostics would be
206 # triggered, irrespective of its placement in an unexecuted
207 # branch of the above exception trapping shell code.
208 #
209 DESTDIR-UNSUPPORTED:
210         $(call MSG_DESTDIR_FORBIDDEN,$(reject),$($(reject):${DESTDIR}%=%))
211
212 # The following macros, which rely heavily on GNU make's "call"
213 # function, define the diagnostics to be emitted, when the DESTDIR
214 # exception is triggered.
215 #
216 QUOTE = `$1'#'`
217 MSG_DESTDIR_FORBIDDEN = \
218   $(warning *** $(call MSG_DESTDIR_PATH_CONFLICT,$1,Win32,$2);) \
219   $(error try $(call QUOTE,$(call MSG_DESTDIR_ALTERNATIVE,$1,$2)) instead)
220 MSG_DESTDIR_BAD_PATH = DESTDIR is not supported when $1 contains $2 path $3
221 MSG_DESTDIR_PATH_CONFLICT = $(call MSG_DESTDIR_BAD_PATH,$1,$2,$(call QUOTE,$3))
222 MSG_DESTDIR_ALTERNATIVE = make install $1="$(call MSG_DESTDIR_TRANSFORM,$2)"
223 MSG_DESTDIR_TRANSFORM = ${DESTDIR}$(shell echo $1 | sed 's/^.://')
224
225 install: install-w32api
226 install-strip: install-strip-w32api
227
228 installdirs: w32api-include-dirs w32api-lib-dirs
229 install-strip-w32api: install-w32api-headers install-strip-w32api-libs
230 install-w32api: install-w32api-headers install-w32api-libs
231
232 w32api_extra_include_dirs = directx
233 w32api_include_subdirs = GL ddk gdiplus
234
235 w32api-include-dirs: includedir
236         $(call mkinstalldirs,${includedir}/,$(w32api_include_subdirs))
237
238 w32api-lib-dirs: libdir
239
240 install-headers: install-w32api-headers
241 install-w32api-headers: w32api-include-dirs
242         $(call INSTALL_DATA,${srcdir}/include/*.h,${includedir})
243         for dir in $(w32api_extra_include_dirs); do \
244           $(call INSTALL_DATA,${srcdir}/include/$$dir/*.h,${includedir}); \
245           done
246         for dir in $(w32api_include_subdirs); do \
247           $(call INSTALL_DATA,${srcdir}/include/$$dir/*.h,${includedir}/$$dir); \
248           done
249
250 w32api-lib-reqs: all-w32api-libs w32api-lib-dirs
251
252 install-w32api-libs: w32api-lib-reqs
253         $(call INSTALL_DATA,$(filter-out w32api-lib-reqs,$^),${libdir})
254         $(if $(STRIP_LIBS),$(call STRIP_LIBS,$(filter-out w32api-lib-reqs,$^)))
255
256 install-strip-w32api-libs:
257         $(MAKE) --no-print-directory $(MAKEFLAGS) \
258           STRIP_LIBS='cd ${libdir}; $(STRIP) --strip-unneeded $$1' \
259           install-w32api-libs
260
261 uninstall: uninstall-w32api-headers uninstall-w32api-libs
262
263 uninstall-w32api-headers:
264         cd ${includedir} && rm -f $(notdir $(wildcard ${srcdir}/include/*.h))
265         for dir in $(w32api_extra_include_dirs); do \
266           files=`cd ${srcdir}/include/$$dir && echo *.h`; \
267           (cd ${includedir} && rm -f $$files); \
268           done
269         for dir in $(w32api_include_subdirs); do \
270           files=`cd ${srcdir}/include/$$dir && echo *.h`; \
271           (cd ${includedir}/$$dir && rm -f $$files); \
272           done
273
274 uninstall-w32api-libs: un%:
275         $(MAKE) --no-print-directory $(MAKEFLAGS) mkinstalldirs= \
276           INSTALL_DATA='cd $$2 && rm -f $$1' $*
277
278 # Distribution
279 # ------------
280 #
281 .PHONY: dist
282 dist: bindist devdist dlldist licdist mandist srcdist
283         $(RM) -r dist/mingwrt dist/w32api
284
285 .PHONY: bindist devdist dlldist licdist mandist srcdist
286 bindist devdist dlldist licdist mandist srcdist: %dist: w32api-%dist
287
288 .PHONY: $(foreach tag,bin dev dll lic man src,mingwrt-$(tag)dist)
289 $(foreach tag,bin dev dll lic man src,mingwrt-$(tag)dist):
290
291 .PHONY: $(foreach tag,bin dev dll lic man src,w32api-$(tag)dist)
292 $(foreach tag,bin dev dll lic man src,w32api-$(tag)dist):
293
294 staged_prefix = $(addsuffix =`pwd`/dist/$1,prefix exec_prefix)
295 staged_install = $(call staged_prefix,$1) install-strip-$1
296
297 mingwrt-dist-staged w32api-dist-staged: %-dist-staged:
298         $(RM) -r dist/$*
299         $(MAKE) --no-print-directory $(call staged_install,$*)
300
301 mingwrt-srcdist w32api-srcdist: %-srcdist: %-srcdist-dir %-srcdist-files
302         cd dist && tar chf - $*-$(PACKAGE_VERSION) | \
303           xz -c > $*-$(PACKAGE_RELEASE_TAG)-src.tar.xz
304         $(RM) -r dist/$*-$(PACKAGE_VERSION)
305
306 mingwrt-srcdist-dir w32api-srcdist-dir: %-srcdist-dir:
307         $(RM) -r dist/$*-$(PACKAGE_VERSION)
308         $(call mkinstalldirs,,dist/$*-$(PACKAGE_VERSION))
309
310 mingwrt-srcdist-files w32api-srcdist-files: %-srcdist-files:
311         (cd ${$*_srcdir} && tar chf - --hard-dereference $(notdir $^)) | \
312           (cd dist/$*-$(PACKAGE_VERSION) && tar xf -)
313
314 mingwrt-devdist w32api-devdist: %-devdist: %-dist-staged
315         cd dist/$* && tar chf - --hard-dereference include lib | \
316           xz -c > ../$*-$(PACKAGE_RELEASE_TAG)-dev.tar.xz
317
318 SRCDIST_ADD = $1-srcdist-files: $(addprefix ${$1_srcdir}/,$2)
319
320 $(call SRCDIST_ADD,w32api,ChangeLog CONTRIBUTIONS README.w32api TODO)
321 $(call SRCDIST_ADD,w32api,configure configure.ac aclocal.m4 Makefile.in)
322 $(call SRCDIST_ADD,w32api,config.guess config.sub install-sh)
323 $(call SRCDIST_ADD,w32api,include lib)
324
325
326 # Clean-up Rules
327 # --------------
328 #
329 clean-local: mostlyclean-local
330         $(RM) lib*.a
331
332 mostlyclean-local:
333         $(RM) *.d *.$(OBJEXT)
334
335 distclean-local: clean-local
336         $(RM) config.log config.status
337
338 maintainer-clean-warning:
339         $(warning $(MAKE) $(@:%-warning=%))
340         $(warning This command should be used by package maintainers only;)
341         $(warning it deletes files which may require special tools to rebuild.)
342
343 maintainer-clean-local: maintainer-clean-warning distclean-local
344         $(RM) -r ${srcdir}/configure ${srcdir}/autom4te.cache
345
346 clean mostlyclean distclean maintainer-clean: %clean: %clean-local
347
348 # $RCSfile$: end of file