OSDN Git Service

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