OSDN Git Service

eef0dbc365de54242c3ee3163a587606255ecd7a
[mingw/mingw-org-wsl.git] / mingwrt / Makefile.in
1 # @configure_input@
2 # $Id$
3 #
4 # Makefile template for MinGW.org Runtime Library 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 = @srcdir@
53 w32api_srcdir = @w32api_srcdir@
54 abs_builddir = @abs_builddir@
55
56 CC = @CC@
57 CFLAGS = @CFLAGS@
58 CPPFLAGS = @CPPFLAGS@
59
60 OBJEXT = @OBJEXT@
61
62 AR = @AR@
63 ARFLAGS = @ARFLAGS@
64 RANLIB = @RANLIB@
65
66 AS = @AS@
67 COMPILE.sx = @COMPILE_SX@
68 DLLTOOL = @DLLTOOL@
69 STRIP = @STRIP@
70 NM = @NM@
71
72 all: @DEFAULT_MAKECMDGOALS@
73 all-mingwrt-stage-1-only: _mingw.h w32api.h
74 all-mingwrt-stage-1-only: all-mingwrt-objects all-mingwrt-libs
75 all-mingwrt-stage-1-and-2: all-mingwrt-stage-1-only all-mingwrt-dll
76 all-mingwrt: all-mingwrt-stage-1-and-2
77 all-gcc: all-mingwrt-stage-1-only
78
79 active_goals = $1-$2 $(if @include_deprecated@,$1-deprecated-$2)
80 all-deprecated-mingwrt-stage-1-only: all-deprecated-mingwrt
81
82 all-stage-1-only: $(call active_goals,all,mingwrt-stage-1-only)
83 all-stage-1-and-2: $(call active_goals,all,mingwrt)
84
85 # Installation paths and macros.
86 #
87 prefix = @prefix@
88 exec_prefix = @exec_prefix@
89 bindir = ${DESTDIR}@bindir@
90
91 datarootdir = @datarootdir@
92 docdir = ${DESTDIR}${datarootdir}/doc
93 includedir = ${DESTDIR}@includedir@
94 libdir = ${DESTDIR}@libdir@
95
96 htmldir = @htmldir@
97 pdfdir = @pdfdir@
98
99 mandir = ${DESTDIR}@mandir@
100 man3dir = ${mandir}/man$(man3ext)
101
102 man3ext = 3
103
104 INSTALL = @INSTALL@
105 INSTALL_DATA = @INSTALL_DATA@ $1 $2
106
107 mkinstalldirs = @MKDIR_P@ $(addprefix $1,$2)
108 LN_S = @LN_S@
109
110 # Keep the configuration in a consistent state.  Note that we assume
111 # that configure has been run initially, (otherwise we wouldn't have
112 # a Makefile to begin with); since this also creates config.status,
113 # we may normally assume that it is already available ...
114 #
115 vpath configure ${top_srcdir}
116 config.status: configure
117         $(SHELL) config.status --recheck
118
119 # ... in which case, updating Makefile should be a simple matter of
120 # running config.status ...
121 #
122 vpath Makefile.in ${top_srcdir}
123 requires_existing = $(if $(wildcard $1),$1,$1.missing)
124 Makefile: Makefile.in configure $(call requires_existing,config.status)
125         $(SHELL) config.status
126         $(RM) Makefile.stub
127
128 .PHONY: config.status.missing
129 # ... but, in the event that this may be missing, (e.g. because it
130 # has been manually removed, or removed by "make distclean"), suggest
131 # running configure, and bail out.
132 #
133 config.status.missing:
134         $(warning *** cannot execute config.status)
135         $(error please run ${top_srcdir}/configure to regenerate it.)
136
137 # If configure itself needs to be updated, we must run autoconf in the
138 # top level source directory.
139 #
140 vpath configure.ac ${top_srcdir}
141 vpath %.m4 ${top_srcdir}/.. ${top_srcdir}
142 configure: configure.ac aclocal.m4 VERSION.m4
143         cd ${top_srcdir}; autoconf -I ..
144
145 # Propagate package version, as configured, consistently throughout
146 # the package build.
147 #
148 vpath _mingw.h.in ${top_srcdir}/include
149 vpath w32api.h.in ${w32api_srcdir}/include
150
151 _mingw.h w32api.h: configure.ac
152
153 PACKAGE_VERSION_SCRIPT = sed \
154   -e s"`$(call PACKAGE_VERSION_FORMAT,LONG,%d,$$3+1000*($$2+1000*$$1))`" \
155   -e s"`$(call PACKAGE_VERSION_FORMAT,MAJOR,%7d,$$1)`" \
156   -e s"`$(call PACKAGE_VERSION_FORMAT,MINOR,%7d,$$2)`" \
157   -e s"`$(call PACKAGE_VERSION_FORMAT,PATCH,%7d,$$3)`"
158
159 PACKAGE_VERSION_FORMAT = echo $(PACKAGE_VERSION).0.0 | awk -F. '{ \
160   printf ",%%PACKAGE_VERSION_$1%%,$2,", $3; \
161 }'
162
163 _mingw.h w32api.h: %.h: %.h.in
164         $(PACKAGE_VERSION_SCRIPT) $< > $@
165
166 # Capture dependencies conveyed within source files, ensuring that
167 # header files are taken from our working source tree, and not from
168 # the build-time compiler's installation path.  (Note: we use -MD,
169 # and not -MMD in DEPFLAGS; since this package furnishes system
170 # headers, we need changes therein to trigger a rebuild).
171 #
172 sinclude *.d
173 DEPFLAGS = -MD -MP
174 INCLUDES = -nostdinc -I . -I ${top_srcdir}/include -I ${w32api_srcdir}/include \
175   -I ${top_srcdir} -I ${top_srcdir}/profile -iwithprefixbefore include
176
177 ALL_CFLAGS = $(CFLAGS) $(DEPFLAGS) $(INCLUDES) $(NTDDI_VERSION_SPEC)
178 ALL_CPPFLAGS = $(CPPFLAGS) $(DEPFLAGS) $(INCLUDES) $(NTDDI_VERSION_SPEC)
179
180 # The general case, for compiling object files from C source,
181 # requires a small adjustment to the default implicit rule.
182 #
183 %.$(OBJEXT): %.c
184         $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) -o $@ $<
185
186 # In some cases, both ANSI and UTF-16LE enabled variants of object
187 # modules are compiled from a common source; the UTF-16LE variant is
188 # to be identified by prefixing a "w" to the object file name.
189 #
190 w%.$(OBJEXT): %.c
191         $(CC) -c -D UNICODE $(CPPFLAGS) $(ALL_CFLAGS) -o $@ $<
192
193 # Compiling object files from *.sx sources: since GCC-4.3, these
194 # have been supported as a case agnostic alternative to *.S sources,
195 # for assembly language sources requiring initial interpretation by
196 # the C preprocessor; owing to the case-insensitive nature of file
197 # naming on MS-Windows, we should prefer these, but we must tell
198 # make how to compile them.
199 #
200 %.$(OBJEXT): %.sx
201         $(COMPILE.sx) $($*_cflags) -o $@ $<
202
203 # Several components of the distributable object code base are to
204 # be provided as free-standing object modules, (rather than being
205 # encapsulated within object libraries); we classify these within
206 # two distinct groups, for support of the current MSVCRT.DLL build
207 # case and the older CRTDLL build case, (noting that, ultimately,
208 # we may wish to deprecate this latter case).
209 #
210 all-mingwrt-objects: $(call active_goals,all,crt-objects)
211 all-deprecated-mingwrt-objects: all-deprecated-crt-objects
212
213 # Further note that, in addition to specifying the build time
214 # inventories for each of these object module categories, each
215 # module should be allocated to an associated installation group,
216 # whence it may be included in the eventual distribution, via a
217 # staged installation.
218 #
219 all-crt-objects install-crt-objects: $(addsuffix .$(OBJEXT), crt2 crtmt \
220   crtst dllcrt2 gcrt2 CRT_fp8 CRT_fp10 CRT_noglob binmode txtmode)
221
222 all-deprecated-crt-objects install-deprecated-crt-objects: \
223   $(addsuffix .$(OBJEXT), crt1 dllcrt1 gcrt1)
224
225 # The crt1.$(OBJEXT) and crt2.$(OBJEXT) modules, for the (deprecated)
226 # CRTDLL and the (current) MSVCRT build cases respectively, are built
227 # from a common crt1.c source.  Similarly, the dllcrt1.$(OBJEXT) and
228 # dllcrt2.$(OBJEXT) modules share the common dllcrt1.c source.
229 #
230 # Noting that the source files are named for the deprecated build
231 # case, but that we need to specify this while compiling, we need
232 # this explicit pattern rule...
233 #
234 vpath %.c ${mingwrt_srcdir}
235 $(addsuffix .$(OBJEXT), crt1 dllcrt1): %.$(OBJEXT): %.c
236         $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) -D__CRTDLL__ -o $@ $<
237
238 # ...while, for the current build case, we need an explicit mapping
239 # to identify the disparately named source file...
240 #
241 $(addsuffix .$(OBJEXT), crt2 dllcrt2): %2.$(OBJEXT): %1.c
242         $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) -o $@ $<
243
244 # ...and for the pair of default FPU configuration selectors, we
245 # need to pass the configuration specification to the compiler, when
246 # compiling the common source for each of the two cases.
247 #
248 CRT_fp8.$(OBJEXT) CRT_fp10.$(OBJEXT): CRT_fp%.$(OBJEXT): CRT_fenv.c
249         $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) -D_CRT_FE_DFL_ENV=$* -o $@ $<
250
251 # The initialization hook for profiling code is inherited from Cygwin,
252 # where it is built as gcrt0.$(OBJEXT); we build it, unmodified, as each
253 # of gcrt1.$(OBJEXT) and gcrt2.$(OBJEXT), to satisfy the differing GCC
254 # specs file dependencies for each of the (deprecated) CRTDLL build
255 # and (current) MSVCRT build cases, respectively.
256 #
257 vpath %.c ${mingwrt_srcdir}/profile
258 $(addsuffix .$(OBJEXT), gcrt0 gcrt1 gcrt2): %.$(OBJEXT): gcrt0.c
259         $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) -o $@ $<
260
261 # The primary runtime library is furnished by Microsoft, in the form
262 # of MSVCRT.DLL, as shipped with MS-Windows itself, or in any one of
263 # its versioned variants, as shipped with the MSVC compiler suite.
264 #
265 # We furnish the API for this runtime library, in the form of import
266 # libraries, for both release and debug DLL variants; furthermore,
267 # although we favour the freely available MSVCRT.DLL distributions,
268 # we also provide import libraries tailored to the non-free, and
269 # non-redistributable, MSVCRnn.DLL variants, corresponding to each
270 # of the following enumerated versions from the MSVC suite.
271 #
272 msvcrt_versions := 70 71 80 90 100
273 msvcrt_version_script = echo $1 | awk '\
274   { printf "0x%03d00000", gensub( "^[^1-9]*([0-9]*).*", "\\\\1", 1 ) \
275   }'
276
277 extra_objects_filter = $(filter %.$(OBJEXT),$1)
278 extra_objects_script = test -z "$(call extra_objects_filter,$2)" \
279   || { echo $(AR) $(ARFLAGS) $1 $(call extra_objects_filter,$2); \
280        $(AR) $(ARFLAGS) $1 $(call extra_objects_filter,$2); \
281      }
282
283 msvcrt_dllname_script = echo $1 | awk '\
284   /^c/{ print "crtdll.dll" } \
285   /^m/{ ext = gsub( "^.*d$$", "&" ) ? "d.dll" : ".dll"; \
286         printf "msvcr%s%s", gsub( "^[^1-9]*[0-9]+.*", "&" ) \
287           ? gensub( "^[^1-9]*([0-9]+).*", "\\\\1", 1 ) \
288           : "t", ext; \
289       }'
290
291 # We categorize our import libraries into "standard" (a.k.a. "release")
292 # versions, augmented by corresponding "debug" variants.
293 #
294 std_msvcrt := $(addprefix msvcr,t $(msvcrt_versions))
295 all_msvcrt := $(std_msvcrt) $(addsuffix d,$(std_msvcrt))
296
297 all-mingwrt-libs: $(call active_goals,all,libmsvcrt)
298 all-libmsvcrt install-mingwrt-libs: $(foreach name,$(all_msvcrt),lib$(name).a)
299 all-libcrtdll install-deprecated-mingwrt-libs: libcrtdll.a libcoldname.a
300 all-deprecated-mingwrt all-deprecated-libmsvcrt: all-libcrtdll
301
302 # For each import library to be built, we derive a tailored exports
303 # definition file, from a common source.
304 #
305 .SUFFIXES: .def.in .def
306 vpath %.def.in ${mingwrt_srcdir}/msvcrt-xref
307 $(addsuffix .def,$(all_msvcrt)): %.def: msvcrt.def.in
308         $(CC) -E -P -D__FILENAME__=$@ -D__DLLNAME__=$* \
309           -D__MSVCRT_VERSION__=`$(call msvcrt_version_script,$*)` \
310           -xc-header $< > $@
311
312 # To accommodate the __USE_MINGW_ANSI_STDIO feature, as specified
313 # in _mingw.h and stdio.h, while retaining a mechanism for accessing
314 # the MSVCRT.DLL functions which it replaces, we augment our import
315 # libraries with extra, alternatively named entry points, each of
316 # which implements a vectored jump to the regular entry point for
317 # the DLL implementation of its corresponding replaced function.
318 #
319 msvcrt_repl_prefix = __msvcrt
320 msvcrt_repl_funcs = printf fprintf sprintf vprintf vfprintf vsprintf
321
322 # This is kludgey, but dlltool lacks the selectivity to do the job
323 # well; (its --ext-prefix-alias option, which is what we would like
324 # to use, is rather like a chainsaw in the hands of a neurosurgeon,
325 # when he should have a scalpel).  We cannot selectively apply the
326 # prefix, to just the symbols of interest, so we end up by creating
327 # an initial copy of the import library, WITH the prefix applied to
328 # to EVERYTHING, (noting that, when we create this initial copy, we
329 # MUST specify the "--no-delete" option TWICE, to preserve temporary
330 # object files within the build tree); we then set this initial copy
331 # aside, and create a further copy WITHOUT the extra symbols, while
332 # duplicating the temporary object file name prefix retrieved from
333 # the initial copy, using this $(NM) lookup filter...
334 #
335 dlltool_temp_prefix = $(NM) $(1) | sed -n -e '/t.o:$$/{s///p;q' -e '}'
336
337 # ...after which, we apply the following $(NM) lookup filter to the
338 # initial copy of the import library file, to identify the specific
339 # temporary object files, defining the entry points to remap...
340 #
341 msvcrt_repl = $(call nmlookup,$1,$(msvcrt_repl_prefix)_,$(msvcrt_repl_funcs))
342 nmlookup = $(NM) $(1) | sed -n \
343   -e '/:$$/h;/^[0-7][0-7]*  *T  */{s///;H;g;s/\n//' \
344   $(foreach repl,$(3),-e 's/:_$(2)$(repl)$$//p') \
345   -e '}'
346
347 # ...and we add just that selection to the final copy of the import
348 # library, before explicitly deleting ALL temporary object files, and
349 # the (extended) initial copy of the import library.
350 #
351 vpath %.def ${mingwrt_srcdir}
352 $(foreach name,$(all_msvcrt) crtdll,lib$(name).a): lib%.a: %.def
353         $(DLLTOOL) --as $(AS) -k --input-def $< --no-delete --no-delete \
354           --dllname `$(call msvcrt_dllname_script,$*)` --output-lib $@  \
355           --ext-prefix-alias $(msvcrt_repl_prefix) && mv $@ lib$*-repl.a
356         $(DLLTOOL) --as $(AS) -k --input-def $< --output-lib $@ \
357           --temp-prefix `$(call dlltool_temp_prefix,lib$*-repl.a)` \
358           --dllname `$(DLLTOOL) --identify lib$*-repl.a`
359         $(AR) $(ARFLAGS) $@ `$(call msvcrt_repl,lib$*-repl.a)` \
360           $(filter %.$(OBJEXT),$^)
361         $(RM) lib$*-repl.a `$(call dlltool_temp_prefix,$@)`*
362
363 # Older versions of Microsoft's runtime libraries used a naming
364 # convention which is more consistent with POSIX, (and with other
365 # free software usage), than they currently employ; we support
366 # this earlier convention by mapping the old names to equivalent
367 # entry points in the current libraries, using libcoldname.a to
368 # map CRTDLL.DLL entries, and variants of libmoldname.a for each
369 # variant of MSVCRT.DLL
370 #
371 std_moldname := moldname $(addprefix moldname,$(msvcrt_versions))
372 all_moldname := $(std_moldname) $(addsuffix d,$(std_moldname))
373
374 all-mingwrt-libs: all-libmoldname
375 all-libmoldname install-mingwrt-libs: $(foreach name,$(all_moldname),lib$(name).a)
376 $(foreach name,coldname $(all_moldname),lib$(name).a): lib%.a: %.def
377         $(DLLTOOL) --as $(AS) -k -U --input-def $< --output-lib $@ \
378           --dllname `$(call msvcrt_dllname_script,$*)`
379         $(AR) $(ARFLAGS) $@ $(call extra_objects_filter,$^)
380
381 # The oldname libraries are also a convenient place to provide a
382 # few additional functions, with no direct implementation in the
383 # Microsoft DLLs, but which nevertheless are easily emulated.
384 #
385 $(foreach name,coldname $(all_moldname),lib$(name).a): $(addsuffix .$(OBJEXT), \
386   isascii iscsym iscsymf toascii)
387
388 # Selected versions of the oldname libraries also provide a
389 # convenient vehicle for delivery of stubs, emulating functions
390 # which appear in later MSVCRT versions, and which we also wish
391 # to support in conjunction with earlier versions.
392 #
393 $(foreach name,moldname $(addprefix moldname,70 71),lib$(name).a) \
394 $(foreach name,moldname $(addprefix moldname,70 71),lib$(name)d.a): \
395   strnlen.jmpstub.$(OBJEXT) wcsnlen.jmpstub.$(OBJEXT)
396
397 coldname.def: %.def: ${mingwrt_srcdir}/moldname.def.in
398         $(CC) -C -E -P -D__FILENAME__=$@ -D__CRTDLL__ -xc-header $< > $@
399
400 $(addsuffix .def,$(all_moldname)): %.def: ${mingwrt_srcdir}/moldname.def.in
401         $(CC) -C -E -P -D__FILENAME__=$@ -xc-header $< > $@
402
403 all-mingwrt-libs install-mingwrt-libs: libmingw32.a libmingwex.a
404 libmingw32.a: $(addsuffix .$(OBJEXT), CRTinit CRTglob setargv \
405   CRTfmode cpu_features CRT_fp10 txtmode main dllmain gccmain crtst \
406   tlsmcrt tlsmthread tlssup tlsthrd pseudo-reloc pseudo-reloc-list)
407
408 libmingw32.a libmingwex.a libm.a libmingwthrd.a libgmon.a:
409         $(AR) $(ARFLAGS) $@ $?
410
411 # Complex math objects, to be included in libmingwex.a
412 # (FIXME: consider whether these might be more suitably
413 # delivered in libm.a; ISO-C99 says they belong in the
414 # math library, which by POSIX convention, is libm.a)
415 #
416 vpath %.c ${mingwrt_srcdir}/mingwex
417 vpath %.c ${mingwrt_srcdir}/mingwex/complex
418 libmingwex.a: $(addsuffix .$(OBJEXT), cabs cabsf cabsl cacos cacosf \
419   cacosh cacoshf cacoshl cacosl casin casinf casinh casinhf casinhl casinl \
420   catan catanf catanh catanhf catanhl catanl ccos ccosf ccosh ccoshf ccoshl \
421   ccosl cexp cexpf cexpl clog clogf clogl cpow cpowf cpowl cproj cprojf \
422   cprojl csin csinf csinh csinhf csinhl csinl csqrt csqrtf csqrtl \
423   ctan ctanf ctanh ctanhf ctanhl ctanl)
424
425 libmingwex.a: $(addsuffix .$(OBJEXT), isblank iswblank)
426
427 # Floating point environment control, in libmingwex.a
428 # (FIXME: once again, maybe better delivered in libm.a)
429 #
430 libmingwex.a: $(addsuffix .$(OBJEXT), fegetenv fesetenv feupdateenv \
431   feclearexcept feraiseexcept fetestexcept feholdexcept fegetexceptflag \
432   fesetexceptflag fegetround fesetround)
433
434 # David Gay's "gdtoa" API, provided in libmingwex.a, and used
435 # by MinGW's ISO-C conforming printf() routines for formatting
436 # floating point output.
437 #
438 vpath %.c ${mingwrt_srcdir}/mingwex/gdtoa
439 libmingwex.a: $(addsuffix .$(OBJEXT), g__fmt gethex strtopx g_dfmt gdtoa \
440   gmisc smisc sum g_ffmt hd_init strtodg ulp dmisc g_xfmt hexnan strtodnrp \
441   dtoa misc strtof)
442
443 # "inttypes" conversion routines, provided in libmingwex.a
444 #
445 libmingwex.a: $(addsuffix .$(OBJEXT), \
446   imaxdiv strtoimax strtoumax wcstoimax wcstoumax)
447
448 # Additional math functions, augmenting Microsoft's paltry
449 # selection, also delivered in libmingwex.a, (FIXME: and yet
450 # again, perhaps libm.a would be a better fit)
451 #
452 vpath %.c ${mingwrt_srcdir}/mingwex/math
453 vpath %.s ${mingwrt_srcdir}/mingwex/math
454 libmingwex.a: $(addsuffix .$(OBJEXT), cosf cosl acosf acosl sinf sinl asinf \
455   asinl tanf tanl atanf atanl atan2f atan2l coshf coshl acosh acoshf acoshl \
456   sinhf sinhl asinh asinhf asinhl tanhf tanhl atanh atanhf atanhl cbrt cbrtf \
457   cbrtl ceilf ceill copysign copysignf copysignl erfl s_erf sf_erf expf expl \
458   exp2 exp2f exp2l expm1 expm1f expm1l fabs fabsf fabsl fdim fdimf fdiml \
459   floorf floorl fma fmaf fmal fmax fmaxf fmaxl fmin fminf fminl fmodf fmodl \
460   fp_consts fp_constsf fp_constsl fpclassify fpclassifyf fpclassifyl frexpf \
461   frexpl fucom hypotf hypotl ilogb ilogbf ilogbl isnan isnanf isnanl ldexpf \
462   ldexpl lgamma lgammaf lgammal llrint llrintf llrintl log10f log10l log1p \
463   log1pf log1pl log2 log2f log2l logb logbf logbl logf logl lrint lrintf \
464   lrintl llround llroundf llroundl lround lroundf lroundl modff modfl \
465   nearbyint nearbyintf nearbyintl nextafterf nextafterl nexttoward nexttowardf \
466   powf powl powi powif powil remainder remainderf remainderl remquo remquof \
467   remquol rint rintf rintl round roundf roundl scalbn scalbnf scalbnl signbit \
468   signbitf signbitl sqrtf sqrtl tgamma tgammaf tgammal trunc truncf truncl \
469   x87cvt x87cvtf x87log x87log1p x87pow)
470
471 # Replacement I/O functions in libmingwex.a, providing better POSIX
472 # compatibility than their Microsoft equivalents.
473 #
474 vpath %.c ${mingwrt_srcdir}/mingwex/stdio
475 libmingwex.a: $(addsuffix .$(OBJEXT), btowc fprintf fseeko64 ofmtctl pformat \
476   printf snprintf sprintf vfprintf vfscanf vfwscanf vprintf vscanf vsnprintf \
477   vsprintf vsscanf vswscanf vwscanf)
478
479 # pformat.$(OBJEXT) needs an explicit build rule, since we need to
480 # specify an additional header file path.
481 #
482 PFORMAT_CFLAGS = -I ${mingwrt_srcdir}/mingwex/gdtoa
483 pformat.$(OBJEXT): %.$(OBJEXT): %.c
484         $(CC) -c $(ALL_CFLAGS) $(PFORMAT_CFLAGS) $< -o $@
485
486 # To support Microsoft's DLL version specific exponent digits control,
487 # and "%n" format availability control APIs, in a DLL version agnostic
488 # manner, we also provide the following set of wrapper functions:
489 #
490 libmingwex.a: $(addsuffix fmt.$(OBJEXT),varo crto geto seto crtn getn setn)
491 $(addsuffix fmt.$(OBJEXT),varo crto geto seto crtn getn setn): %.$(OBJEXT): ofmt.c
492         $(CC) -c $(ALL_CFLAGS) -D__$*__ -fno-align-functions -o $@ $<
493
494 # Some additional miscellaneous functions, in libmingwex.a
495 #
496 libmingwex.a: $(addsuffix .$(OBJEXT), mingw-aligned-malloc mingw-fseek)
497 libmingwex.a: $(addsuffix .$(OBJEXT), glob getopt basename dirname nsleep)
498 libmingwex.a: $(addsuffix .$(OBJEXT), mkstemp mkdtemp cryptnam setenv)
499
500 libmingwex.a: $(addsuffix .$(OBJEXT), tdelete tfind tsearch twalk)
501 libmingwex.a: $(addsuffix .$(OBJEXT), dirent wdirent dlfcn strerror_r)
502 libmingwex.a: $(addsuffix .$(OBJEXT), getdelim gettimeofday)
503
504 vpath %.s ${mingwrt_srcdir}/mingwex
505 vpath %.sx ${mingwrt_srcdir}/mingwex
506 libmingwex.a: $(addsuffix .$(OBJEXT), fwide mbrtowc mbsinit strnlen wcrtomb \
507   wcsnlen wcstof wcstold wctob wctrans wctype wmemchr wmemcmp wmemcpy wmemmove \
508   wmemset)
509
510 # The wcsnlen() function, enumerated above, is an adaptation of strnlen();
511 # we need a specific rule to compile it, from shared source.
512 #
513 wcsnlen.$(OBJEXT): strnlen.sx
514         $(COMPILE.sx) -D_UNICODE $^ -o $@
515
516 # For the math sources, we support the convention that a single
517 # quux_generic.c source file will produce three objects: quux.o,
518 # quuxf.o, and quuxl.o; since a change in the common source file
519 # will require all three objects to be recompiled, we may handle
520 # this with a single, multiple target, pattern rule.
521 #
522 $(addsuffix .$(OBJEXT), % %f %l): %_generic.c
523         $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) -o $*.$(OBJEXT) $<
524         $(CC) -c -D FUNCTION=$*f $(CPPFLAGS) $(ALL_CFLAGS) -o $*f.$(OBJEXT) $<
525         $(CC) -c -D FUNCTION=$*l $(CPPFLAGS) $(ALL_CFLAGS) -o $*l.$(OBJEXT) $<
526
527 # The llround.o, llroundf.o, and llroundl.o variants are a special
528 # case of the preceding rule; (the source is lround_generic.c rather
529 # than llround_generic.c).  We can handle this using the following
530 # static pattern rule, (compiling each object individually).
531 #
532 $(addsuffix .$(OBJEXT), llround llroundf llroundl): %.$(OBJEXT): lround_generic.c
533         $(CC) -c -D FUNCTION=$* $(CPPFLAGS) $(ALL_CFLAGS) -o $@ $<
534
535 # Similarly, we may need to compile quux.o, quuxf.o, and quuxl.o
536 # variants from a common quux_generic.sx assembly language file.
537 #
538 vpath %.sx ${mingwrt_srcdir}/mingwex/math
539 $(addsuffix .$(OBJEXT), % %f %l): %_generic.sx
540         $(CC) -c -D_$*_source $(ALL_CPPFLAGS) $(ASFLAGS) -o $*.$(OBJEXT) $<
541         $(CC) -c -D_$*f_source $(ALL_CPPFLAGS) $(ASFLAGS) -o $*f.$(OBJEXT) $<
542         $(CC) -c -D_$*l_source $(ALL_CPPFLAGS) $(ASFLAGS) -o $*l.$(OBJEXT) $<
543
544 # Several generically implemented functions also require separate
545 # assembly of their generic back-end support routines.
546 #
547 x87%.$(OBJEXT): %_generic.sx
548         $(CC) -c $(ALL_CPPFLAGS) $(ASFLAGS) -o $@ $<
549
550 # Historically, MinGW.org's libm.a has been a dummy, delivering
551 # nothing of value; FIXME: IMO, this sucks; it should deliver the
552 # non-MSVCRT.DLL math functions, as noted above.
553 #
554 all-mingwrt-libs install-mingwrt-libs: libm.a
555 libm.a: libm_dummy.$(OBJEXT)
556 libm_dummy.c: Makefile
557         echo "static int __mingw_libm_dummy;" > $@
558
559 # The mingwrt headers define a number of functions which are normally
560 # expected to be compiled as inline code.  Each such function must also
561 # be provided with an externally visible entry point; we provide such
562 # entry points as stubs in libmingwex.a, via the following rules:
563 #
564 sinclude Makefile.stub
565 libstub_refnames = grep -lr '__$1.*FUNCTION *=' ${mingwrt_srcdir}
566 jmpstub_prerequisites := $(shell $(call libstub_refnames,JMPSTUB)/include)
567 libimpl_prerequisites := $(shell $(call libstub_refnames,LIBIMPL)/include)
568 Makefile.stub: Makefile $(jmpstub_prerequisites) $(libimpl_prerequisites)
569         echo "# $@: automatically generated file -- do not edit!" > $@
570         $(call jmpstub_awk_script,$(jmpstub_prerequisites)) >> $@
571         $(call libimpl_awk_script,$(libimpl_prerequisites)) >> $@
572         echo "# $@: end of file" >> $@
573
574 # Stubs are categorized into either of JMPSTUB or LIBIMPL classes;
575 # the rules for building the JMPSTUP inplementations are written to
576 # Makefile.stub, by processing each of their defining header files
577 # through the following awk script...
578 #
579 jmpstub_awk_script = test -z "$1" || awk '\
580   BEGIN { \
581     symbol = "([A-Z_a-z][A-Z_a-z0-9]*)"; \
582     fmt = "\nlib%s.a: %s\n%s: jmpstub.sx\n\t$$(COMPILE.sx) %s -o $$@ $$^\n"; \
583   } \
584   /__JMPSTUB(__)? *[(].*FUNCTION/ { \
585     FUNCTION = gensub( ".*[ ,(:]FUNCTION *= *"symbol".*", "\\1", 1 ); \
586     LIB = match( $$0, ".*[ ,(:]LIB *= *"symbol, altlib ) ? altlib[1] : "mingwex"; \
587     OBJNAME = gensub( "_*(.*)_*", "\\1", 1, FUNCTION )".jmpstub.$$(OBJEXT)"; \
588     OBJNAME_CFLAGS = "-D FUNCTION="FUNCTION; \
589     if( match( $$0, ".*[ ,(:]DLLENTRY *= *"symbol, alias ) ) \
590       OBJNAME_CFLAGS = OBJNAME_CFLAGS" -D DLLENTRY="alias[1]; \
591     else if( match( $$0, ".*[ ,(:]REMAPPED *= *"symbol, alias ) ) \
592       OBJNAME_CFLAGS = OBJNAME_CFLAGS" -D REMAPPED="alias[1]; \
593     printf fmt, LIB, OBJNAME, OBJNAME, OBJNAME_CFLAGS; \
594   } \
595   END { \
596     printf "\n"; \
597   }' $1
598
599 # ...while this establishes the dependencies which apply for each
600 # of those in the LIBIMPL class.
601 #
602 libimpl_awk_script = test -z "$1" || awk '\
603   BEGIN { \
604     symbol = "([A-Z_a-z][A-Z_a-z0-9]*)"; \
605     fmt = "\nlib%s.a: %s\n%s.libimpl: %s\n"; \
606   } \
607   /__LIBIMPL(__)? *[(].*FUNCTION/ { \
608     FUNCTION = gensub( ".*[ ,(:]FUNCTION *= *"symbol".*", "\\1", 1 ); \
609     LIB = match( $$0, ".*[ ,(:]LIB *= *"symbol, altlib ) ? altlib[1] : "mingwex"; \
610     OBJNAME = gensub( "_*(.*)_*", "\\1", 1, FUNCTION )".libimpl.$$(OBJEXT)"; \
611     printf fmt, LIB, OBJNAME, FUNCTION, FILENAME; \
612   } \
613   END { \
614     printf "\n"; \
615   }' $1
616
617 # In contrast to JMPSTUB implementations, which are best handled
618 # by individual compilation rules in Makefile.stub, generic rules
619 # are sufficient for all LIBIMPL implementations; in each case, we
620 # filter the static attribute from each defined implementation, in
621 # its defining header file, to create an intermediate C source for
622 # each individual function; (note that we also remove any pragma
623 # which identifies the originating file as a system header).
624 #
625 libimpl_sed_script = sed \
626   -e '/pragma .* system_header/d' \
627   -e '/__CRT_INLINE  *__LIBIMPL.*FUNCTION *= *$1[ ,)].*)/d' \
628   -e 's/__LIBIMPL.*ALIAS *= *$1[ ,)].*)/__attribute__((__alias__("$1")))/' \
629   -e '/__CRT_ALIAS  *__LIBIMPL.*FUNCTION *= *$1[ ,)].*)/d'
630
631 LIBIMPL_CFLAGS = $(CFLAGS) $(INCLUDES) $(LIBIMPL_EXTRA_CFLAGS)
632 LIBIMPL_EXTRA_CFLAGS = -fno-align-functions -Wno-deprecated-declarations
633
634 # LIBIMPL dependencies are tracked using zero sized name.libimpl
635 # files; the intermediate C files are generated as a side effect
636 # of resolving these dependencies...
637 #
638 %.libimpl:
639         $(call libimpl_sed_script,$*) $< > $@.c
640         > $@
641
642 # ...and ultimately discarded, after the requisite object file
643 # has been compiled; (note that this creates a vulnerability due
644 # to possible loss of the object file, while the tracking file is
645 # still in place; to circumvent this, we must be able to force a
646 # remake of the tracking file, so also regenerating the .c file,
647 # before it is compiled).
648 #
649 libimpl_remake = { $(RM) $1; $(MAKE) --no-print-directory $1; }
650 %.libimpl.$(OBJEXT): %.libimpl
651         test -f $<.c || $(call libimpl_remake,$<)
652         $(CC) -c $(CPPFLAGS) $(LIBIMPL_CFLAGS) -o $@ $<.c
653         $(RM) $<.c
654
655 # Thread support libraries.
656 #
657 all-mingwrt-libs install-mingwrt-libs: libmingwthrd.a libmingwthrd_old.a
658 libmingwthrd.a libmingwthrd_old.a: crtmt.$(OBJEXT)
659 mingwthrd_old.def mingwm10.dll: $(addsuffix .$(OBJEXT), mthr mthr_init)
660 mingwthrd_old.def:
661         $(DLLTOOL) --as $(AS) --output-def $@ $^
662
663 libmingwthrd_old.a: lib%.a: %.def
664         $(DLLTOOL) --as $(AS) --input-def $< --dllname mingwm10.dll --output-lib $@
665         $(AR) $(ARFLAGS) $@ $(call extra_objects_filter,$^)
666
667 all-mingwrt-dll install-mingwrt-dll-files: mingwm10.dll
668 mingwm10.dll: mingwthrd_old.def
669         $(CC) -shared -o $@ -Wl,--image-base,0x6FBC0000 \
670           -Wl,--entry,_DllMainCRTStartup@12 $^
671
672 # Code profiling support, using the GNU profiling library; (note
673 # that applications using this library MUST be licensed to comply
674 # with the GNU General Public License).
675 #
676 all-mingwrt-libs install-mingwrt-libs: libgmon.a
677 libgmon.a: $(addsuffix .$(OBJEXT), gmon mcount profil)
678
679
680 # Optional DLL Generation Rules
681 # -----------------------------
682 #
683 # The following rules are provided to accommodate optional delivery
684 # of certain of the static libraries, generated as components of this
685 # package, in the alternative form of DLLs, each with an accompanying
686 # import library.  Each such DLL should be versioned, ideally with an
687 # explicitly specified version number, but we provide this fall back
688 # as a catch-all default for any which is not so specified; (all such
689 # version specifications should be in the "current:revision:age" form,
690 # conforming to the GNU-libtool convention).
691 #
692 DLLVERSION = "0:0:0"
693
694 # Generally, we should prefer to have explicit version specifications,
695 # relating individually to each DLL; these are specified in VERSION.m4,
696 # and propagated here via configure time substitution.
697 #
698 @MAP_LIBMINGWEX_A_DLLVERSION@
699
700 # For convenience, we implement the DLL build rule in the form of a
701 # generic pattern rule, invoked in the form of a request to build any
702 # version-agnostic import library; the versioned DLL is then built as
703 # a side effect of building the import library.
704 #
705 # Note that, in addition to the obvious dependency on the originating
706 # static library, we also make this depend on configure; this ensures
707 # that DLL version changes, specified in VERSION.m4, are propagated.
708 #
709 # Further note that we use an alternatively named reference link to
710 # the originating static library, as code source for the DLL, rather
711 # than the original name; this is to work around a limitation of the
712 # handling of --whole-archive, by GNU-ld, which suppresses creation
713 # of an exports table, in the event that the same static library is
714 # named among GCC's implicit default libraries, after reverting to
715 # --no-whole-archive operation.
716 #
717 %.dll.a: %.a configure
718         $(LN_S) -f $< tmp$<
719         $(CC) $(call a2dll,tmp$<,$(call dllname,$*)) -L. -Wl,--out-implib=$@
720         $(RM) tmp$<
721
722 dllname = $1-$(dllsuffix).dll $(LIBGCC_LINK_OPTION)
723 a2dll = -shared -o $2 -Wl,--whole-archive $1 -Wl,--no-whole-archive
724 dllsuffix = `echo $(DLLVERSION) | awk -F: '{printf "%d",$$1-$$3}'`
725
726 all-optional-dlls: all-mingwrt-optional-dlls
727 all-mingwrt-optional-dlls: libmingwex.dll.a
728
729 # In most optional DLL build cases, we should avoid creating any
730 # unnecessary dependency on (known to be broken) -shared-libgcc
731 #
732 libmingwex.dll.a: LIBGCC_LINK_OPTION = -static-libgcc
733
734
735 # Installation Rules
736 # ------------------
737 #
738 # Users may expect to be able to specify DESTDIR, to stage the
739 # following stock installation directories outside of the regular
740 # "as configured" installation tree; unfortunately, this expectation
741 # MUST fail, when the stock path is in MS-Windows absolute format, so
742 # we provide an exception mechanism to forbid such usage, and we
743 # proceed to create the directories only when the exception is
744 # NOT triggered.
745 #
746 .PHONY: DESTDIR-UNSUPPORTED
747 bindir docdir includedir libdir mandir htmldir pdfdir:
748         @test -z "$(strip ${DESTDIR})" || case $($@) in ${DESTDIR}?:*) \
749           $(MAKE) --no-print-directory reject=$@ DESTDIR-UNSUPPORTED;; \
750           esac
751         $(call mkinstalldirs,,$($@))
752
753 # Note: we MUST use a recursive make invocation here, as the
754 # "error" function within the accompanying diagnostics would be
755 # triggered, irrespective of its placement in an unexecuted
756 # branch of the above exception trapping shell code.
757 #
758 DESTDIR-UNSUPPORTED:
759         $(call MSG_DESTDIR_FORBIDDEN,$(reject),$($(reject):${DESTDIR}%=%))
760
761 # The following macros, which rely heavily on GNU make's "call"
762 # function, define the diagnostics to be emitted, when the DESTDIR
763 # exception is triggered.
764 #
765 QUOTE = `$1'#'`
766 MSG_DESTDIR_FORBIDDEN = \
767   $(warning *** $(call MSG_DESTDIR_PATH_CONFLICT,$1,Win32,$2);) \
768   $(error try $(call QUOTE,$(call MSG_DESTDIR_ALTERNATIVE,$1,$2)) instead)
769 MSG_DESTDIR_BAD_PATH = DESTDIR is not supported when $1 contains $2 path $3
770 MSG_DESTDIR_PATH_CONFLICT = $(call MSG_DESTDIR_BAD_PATH,$1,$2,$(call QUOTE,$3))
771 MSG_DESTDIR_ALTERNATIVE = make install $1="$(call MSG_DESTDIR_TRANSFORM,$2)"
772 MSG_DESTDIR_TRANSFORM = ${DESTDIR}$(shell echo $1 | sed 's/^.://')
773
774 # Install everything.
775 #
776 install: inst@DEFAULT_MAKECMDGOALS@
777 install-stage-1-only: install-headers install-libdir-objects install-libs
778 install-stage-1-and-2: install-stage-1-only install-bin
779 install-gcc: install-stage-1-only
780
781 install-strip: install-strip-mingwrt
782 install-strip-%:
783         $(MAKE) --no-print-directory \
784           STRIP_DATA='cd ${libdir}; $(STRIP) --strip-unneeded $$1' \
785           STRIP_DLL='cd ${bindir}; $(STRIP) $$1' install-$*
786
787 # Install licence files.
788 #
789 install-license: install-mingwrt-license
790 install-licence install-mingwrt-licence: %-licence: %-license
791
792 vpath DISCLAIMER ${mingwrt_srcdir}
793 vpath COPYING ${mingwrt_srcdir}/profile
794 vpath CYGWIN_LICENSE ${mingwrt_srcdir}/profile
795 mingwrt-license-files: COPYING CYGWIN_LICENSE DISCLAIMER
796
797 # FIXME: The following rule is generalized, such that it may accommodate
798 # both mingwrt and w32api, (and other packages); thus, it should ideally
799 # be relocated into a common (shared) Makefile fragment.
800 #
801 install-mingwrt-license install-w32api-license: install-%: docdir %-files
802 %-license-files:
803         $(call mkinstalldirs,,${docdir}/$*/$(PACKAGE_VERSION))
804         $(call INSTALL_DATA,$^,${docdir}/$*/$(PACKAGE_VERSION))
805
806 # Install headers associated with the MinGW runtime libraries.
807 #
808 includedirs: mingwrt-includedirs
809 install-headers install-mingwrt: install-mingwrt-headers
810
811 mingwrt-includedirs: includedir $(eval mingwrt_include_subdirs=sys parts)
812         $(call mkinstalldirs,${includedir}/,$(mingwrt_include_subdirs))
813
814 SUB_HEADERS_PRESENT = echo $1/include/$2/*.h | grep -v '[*]' > /dev/null
815 INSTALL_SUB_HEADERS = $(call INSTALL_DATA,$1/include/$2/*.h,${includedir}/$2)
816
817 install-mingwrt-headers: _mingw.h mingwrt-includedirs
818         $(call INSTALL_DATA,_mingw.h,${includedir})
819         $(call INSTALL_DATA,${mingwrt_srcdir}/include/*.h,${includedir})
820         for dir in $(mingwrt_include_subdirs); do \
821           if $(call SUB_HEADERS_PRESENT,${mingwrt_srcdir},$$dir); then \
822             $(call INSTALL_SUB_HEADERS,${mingwrt_srcdir},$$dir); \
823             fi; \
824           done
825         $(call INSTALL_DATA,${mingwrt_srcdir}/profile/*.h,${includedir})
826
827 # Install libraries, and supporting free standing object files.
828 #
829 install-libs install-mingwrt: install-mingwrt-libdir-libs
830 install-libdir-objects install-mingwrt: install-mingwrt-libdir-objects
831
832 install-mingwrt-libdir-libs: libdir $(call active_goals,install,mingwrt-libs)
833 install-mingwrt-libdir-objects: libdir $(call active_goals,install,crt-objects)
834
835 install-crt-objects install-deprecated-crt-objects \
836 install-mingwrt-libs install-deprecated-mingwrt-libs:
837         $(call INSTALL_DATA,$^,${libdir})
838         $(if $(STRIP_DATA),$(call STRIP_DATA,$^))
839
840
841 # Install DLLs.
842 #
843 install-mingwrt: install-mingwrt-dll
844 install-bin install-dll: install-mingwrt-dll
845 install-mingwrt-bin install-w32api-bin: install-%-bin: install-%-dll
846 install-mingwrt-dll install-w32api-dll: install-%-dll: bindir install-%-dll-files
847 install-%-dll-files:
848         $(call INSTALL_DATA,$^,${bindir})
849         $(if $(STRIP_DLL),$(call STRIP_DLL,$^))
850
851 $(call optional_dll_version,libmingwex,@MAP_LIBMINGWEX_A_DLLVERSION@)
852 optional_dll_version = $(shell echo '$2' | sed s,^[^:]*,install-$1-optional-dll,)
853
854 install-optional-dlls: install-mingwrt-optional-dlls
855 install-mingwrt-optional-dlls: install-libmingwex-optional-dll
856 install-%-optional-dll: %.dll.a bindir libdir
857         $(call INSTALL_DATA,$<,${libdir})
858         $(call INSTALL_DATA,$(call dllname,$*),${bindir})
859         $(if $(STRIP_DLL),$(call STRIP_DLL,$(call dllname,$*)))
860         $(if $(STRIP_DATA),$(call STRIP_DATA,$<))
861
862
863 # Install manpages.
864 #
865 vpath %.man ${mingwrt_srcdir}/man
866 install-man install-manpages: install-mingwrt-manpages
867 mingwrt-man$(man3ext): $(addsuffix .$(man3ext),basename dirname getline getdelim)
868 install-mingwrt-manpages: mandir mingwrt-man3
869
870 mingwrt-man%:
871         $(call mkinstalldirs,,${man$*dir})
872         $(call INSTALL_DATA,$^,${man$*dir})
873         $(RM) $^
874
875 %: %.man
876         $(call format_manpage,$(basename $*),$(suffix $*),$<) $< > $@
877
878 format_manpage = sed \
879   -e "s/%PAGEREF%/`echo $1 | tr a-z A-Z` $(2:.%=%) `date -r $3 +%d-%b-%Y`/"
880
881 basename.$(man3ext): export reference_manpage = dirname.$(man3ext).man
882 basename.$(man3ext): %: %.mancopy-recursive
883
884 getdelim.$(man3ext): export reference_manpage = getline.$(man3ext).man
885 getdelim.$(man3ext): %: %.mancopy-recursive
886
887 %.mancopy-recursive:
888         $(MAKE) --no-print-directory $*.mancopy
889
890 %.mancopy: $(reference_manpage)
891         $(call format_manpage,$(basename $*),$(suffix $*),$<) $< > $*
892
893
894 # Undo Installation
895 # -----------------
896 #
897 uninstall: uninstall-mingwrt
898 uninstall-bin uninstall-dll uninstall-mingwrt: uninstall-mingwrt-dll
899 uninstall-optional-dlls uninstall-mingwrt: uninstall-mingwrt-optional-dlls
900 uninstall-mingwrt: uninstall-mingwrt-headers uninstall-mingwrt-libdir-libs
901 uninstall-mingwrt: uninstall-mingwrt-libdir-objects
902
903 REMOVE_HEADERS = cd $1 && $(RM) $(notdir $(wildcard $2))
904
905 uninstall-mingwrt-headers:
906         $(call REMOVE_HEADERS,${includedir},${mingwrt_srcdir}/include/*.h)
907         for dir in $(mingwrt_include_subdirs); do \
908           files=`cd ${mingwrt_srcdir}/include/$$dir && echo *.h`; \
909           (cd ${includedir}/$$dir && $(RM) $$files); \
910           done
911         $(call REMOVE_HEADERS,${includedir},${mingwrt_srcdir}/profile/*.h)
912
913 uninstall-mingwrt-dll uninstall-mingwrt-optional-dlls \
914 uninstall-mingwrt-libdir-objects uninstall-mingwrt-libdir-libs: un%:
915         $(MAKE) --no-print-directory mkinstalldirs= \
916           INSTALL_DATA='cd $$2 && $(RM) $$1' $*
917
918
919 # Test Suite
920 # ----------
921 #
922 .PHONY: check-recursive
923 check test tests: check-recursive
924 check-recursive:
925         $(MAKE) -C tests $@
926
927
928 # Distribution
929 # ------------
930 #
931 .PHONY: dist
932 dist: devdist dlldist licdist mandist optdist srcdist
933         $(RM) -r dist/mingwrt dist/w32api
934
935 mingwrt-dist-staged w32api-dist-staged: %-dist-staged:
936         $(RM) -r dist/$*
937         $(MAKE) --no-print-directory prefix=`pwd`/dist/$* install-strip-$*
938
939 devdist: mingwrt-devdist
940 mingwrt_devdist_objects = dist/mingwrt/lib/*.$(OBJEXT)
941 mingwrt-devdist w32api-devdist: %-devdist: %-dist-staged
942         cd dist/$* && tar chf - --hard-dereference include lib | \
943           xz -c > ../$*-$(PACKAGE_RELEASE_TAG)-dev.tar.xz
944
945 dlldist: mingwrt-dlldist
946 mingwrt-dlldist: %-dlldist: %-dist-staged
947         cd dist/$* && tar chf - --hard-dereference bin | \
948           xz -c > ../$*-$(PACKAGE_RELEASE_TAG)-dll.tar.xz
949
950 licdist: mingwrt-licdist
951 mingwrt-licdist w32api-licdist: %-licdist:
952         $(RM) -r tmp
953         $(MAKE) --no-print-directory prefix=`pwd`/tmp install-$*-licence
954         cd tmp && tar chf - --hard-dereference * | \
955           xz -c > ../dist/$*-$(PACKAGE_RELEASE_TAG)-lic.tar.xz
956         $(RM) -r tmp
957
958 mandist: mingwrt-mandist
959 mingwrt-mandist: %-mandist:
960         $(RM) -r tmp
961         $(MAKE) --no-print-directory prefix=`pwd`/tmp install-$*-manpages
962         cd tmp && tar chf - --hard-dereference share | \
963           xz -c > ../dist/$*-$(PACKAGE_RELEASE_TAG)-man.tar.xz
964         $(RM) -r tmp
965
966 optdist: mingwrt-optdist
967 mingwrt-optdist: mingwrt-libmingwex-optdist
968
969 $(call optional_dll_package,libmingwex,@MAP_LIBMINGWEX_A_DLLVERSION@)
970 optional_dll_package = $(shell echo '$2' | sed s,^[^:]*,mingwrt-$1-optdist)
971
972 mingwrt-%-optdist:
973         $(RM) -r tmp
974         $(MAKE) --no-print-directory prefix=`pwd`/tmp install-strip-$*-optional-dll
975         cd tmp && tar chf - --hard-dereference bin | \
976           xz -c > ../dist/$*-$(PACKAGE_RELEASE_TAG)-dll-$(dllsuffix).tar.xz
977         cd tmp && tar chf - --hard-dereference lib | \
978           xz -c > ../dist/$*-$(PACKAGE_RELEASE_TAG)-dev.tar.xz
979         $(RM) -r tmp
980
981 srcdist: mingwrt-srcdist
982 mingwrt-srcdist: mingwrt-srcdist-dir mingwrt-srcdist-files
983         cd dist && tar chf - $(PACKAGE_TARNAME)-$(PACKAGE_VERSION) | \
984           xz -c > $(PACKAGE_TARNAME)-$(PACKAGE_RELEASE_TAG)-src.tar.xz
985         $(RM) -r dist/$(PACKAGE_TARNAME)-$(PACKAGE_VERSION)
986
987 mingwrt-srcdist-dir:
988         $(RM) -r dist/$(PACKAGE_TARNAME)-$(PACKAGE_VERSION)
989         $(call mkinstalldirs,,dist/$(PACKAGE_TARNAME)-$(PACKAGE_VERSION))
990
991 mingwrt-srcdist-files: mingwrt-srcdist-config-files
992 mingwrt-srcdist-files: mingwrt-srcdist-testsuite-files
993 mingwrt-srcdist-files: mingwrt-srcdist-package-files
994
995 vpath install-sh ${top_srcdir}/.. ${top_srcdir}
996 mingwrt-srcdist-config-files: aclocal.m4 VERSION.m4 install-sh
997         cp -p $^ dist/$(PACKAGE_TARNAME)-$(PACKAGE_VERSION)
998
999 mingwrt-srcdist-package-files:
1000         (cd ${mingwrt_srcdir} && tar chf - --hard-dereference $(notdir $^)) | \
1001           (cd dist/$(PACKAGE_TARNAME)-$(PACKAGE_VERSION) && tar xf -)
1002
1003 mingwrt-srcdist-package-files: $(wildcard ${mingwrt_srcdir}/*.[chs]) \
1004   $(addprefix ${mingwrt_srcdir}/,ChangeLog CONTRIBUTORS DISCLAIMER README) \
1005   $(wildcard ${mingwrt_srcdir}/*.def.in) $(wildcard ${mingwrt_srcdir}/config*) \
1006   $(addprefix ${mingwrt_srcdir}/,include man mingwex msvcrt-xref profile) \
1007   $(addprefix ${mingwrt_srcdir}/,TODO Makefile.in crtdll.def) \
1008   $(wildcard ${mingwrt_srcdir}/*.txt)
1009
1010 mingwrt-srcdist-testsuite-files: $(wildcard ${mingwrt_srcdir}/tests/*.at)
1011 mingwrt-srcdist-testsuite-files: $(wildcard ${mingwrt_srcdir}/tests/*.in)
1012         (cd ${mingwrt_srcdir} && tar chf - $(addprefix tests/,$(notdir $^))) | \
1013           (cd dist/$(PACKAGE_TARNAME)-$(PACKAGE_VERSION) && tar xf -)
1014
1015 install-html install-pdf: install-%: %dir mingwrt-man$(man3ext)
1016         $(MAKE) --no-print-directory install-$*-files
1017
1018 install-html-files install-pdf-files: install-%-files: \
1019   $(addsuffix .%,$(wildcard ${man3dir}/*.$(man3ext)))
1020
1021 %.$(man3ext).html: %.$(man3ext)
1022         man2html $< | sed -e '1,/^<!DOCTYPE/{/^<!/p;d' -e '}' > ${htmldir}/$(notdir $@)
1023         chmod 644 ${htmldir}/$(notdir $@)
1024
1025 %.$(man3ext).pdf: %.$(man3ext)
1026         man -t $< | ps2pdf - > ${pdfdir}/$(notdir $@)
1027         chmod 644 ${pdfdir}/$(notdir $@)
1028
1029 html-docdist pdf-docdist: %-docdist:
1030         $(RM) -r tmp
1031         $(MAKE) --no-print-directory prefix=`pwd`/tmp install-$*
1032         $(RM) -r tmp/share/man
1033         cd tmp && tar chf - --hard-dereference share | \
1034           xz -c > ../dist/mingwrt-doc-$(PACKAGE_RELEASE_TAG)-$*.tar.xz
1035         $(RM) -r tmp
1036
1037
1038 # Clean-up Rules
1039 # --------------
1040 #
1041 clean-local: mostlyclean-local
1042         $(RM) msvcr*.def moldname*.def mingw*.def lib*.a *.dll
1043
1044 mostlyclean-local:
1045         $(RM) *.d *.$(OBJEXT) Makefile.stub *.libimpl
1046
1047 distclean-local: clean-local
1048         $(RM) config.log config.status libm_dummy.c
1049
1050 maintainer-clean-warning:
1051         $(warning $(MAKE) $(@:%-warning=%))
1052         $(warning This command should be used by package maintainers only;)
1053         $(warning it deletes files which may require special tools to rebuild.)
1054
1055 maintainer-clean-local: maintainer-clean-warning distclean-local
1056         $(RM) -r ${mingwrt_srcdir}/autom4te.cache
1057
1058 clean mostlyclean distclean maintainer-clean: %clean: %clean-local
1059
1060 # $RCSfile$: end of file