4 # Makefile template for MinGW.org Runtime Library Package
6 PACKAGE_TARNAME := @PACKAGE_TARNAME@
7 PACKAGE_VERSION := @PACKAGE_VERSION@
9 # Written by Keith Marshall <keithmarshall@users.sourceforge.net>
10 # Copyright (C) 2014, MinGW.org Project
13 # Permission is hereby granted, free of charge, to any person obtaining a
14 # copy of this software and associated documentation files (the "Software"),
15 # to deal in the Software without restriction, including without limitation
16 # the rights to use, copy, modify, merge, publish, distribute, sublicense,
17 # and/or sell copies of the Software, and to permit persons to whom the
18 # Software is furnished to do so, subject to the following conditions:
20 # The above copyright notice and this permission notice (including the next
21 # paragraph) shall be included in all copies or substantial portions of the
24 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27 # AUTHORS OR THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30 # DEALINGS IN THE SOFTWARE.
33 # The default target is "all"; declare it early, to avoid any possible
34 # inadvertent override from any included file.
38 PACKAGE_RELEASE_TAG := $(PACKAGE_VERSION)$(PACKAGE_RELEASE:%=-%)-mingw32
39 NTDDI_VERSION_SPEC := -D NTDDI_VERSION=0x04000000
41 # Build paths and macros.
44 top_srcdir = @top_srcdir@
45 mingwrt_srcdir = @srcdir@
46 w32api_srcdir = @w32api_srcdir@
47 abs_builddir = @abs_builddir@
60 COMPILE.sx = @COMPILE_SX@
65 all: @DEFAULT_MAKECMDGOALS@
66 all-mingwrt-stage-1: all-mingwrt-objects all-mingwrt-libs
67 all-mingwrt-stage-1-and-2: all-mingwrt-stage-1 all-mingwrt-dll
68 all-mingwrt: all-mingwrt-stage-1-and-2
70 include_deprecated = @include_deprecated@
71 active_goals = $1-$2 $(if $(include_deprecated),$1-deprecated-$2)
73 all-stage-1: $(call active_goals,all,mingwrt-stage-1)
74 all-stage-1-and-2: $(call active_goals,all,mingwrt)
76 # Installation paths and macros.
79 exec_prefix = @exec_prefix@
80 bindir = ${DESTDIR}@bindir@
82 datarootdir = @datarootdir@
83 docdir = ${DESTDIR}${datarootdir}/doc
84 includedir = ${DESTDIR}@includedir@
85 libdir = ${DESTDIR}@libdir@
90 mandir = ${DESTDIR}@mandir@
91 man3dir = ${mandir}/man$(man3ext)
96 INSTALL_DATA = @INSTALL_DATA@
98 mkinstalldirs = @MKDIR_P@
100 # Keep the configuration in a consistent state. Note that we assume
101 # that configure has been run initially, (otherwise we wouldn't have
102 # a Makefile to begin with); since this also creates config.status,
103 # we may normally assume that it is already available ...
105 vpath configure ${top_srcdir}
106 config.status: configure
107 $(SHELL) config.status --recheck
109 # ... in which case, updating Makefile should be a simple matter of
110 # running config.status ...
112 vpath Makefile.in ${top_srcdir}
113 requires_existing = $(if $(wildcard $1),$1,$1.missing)
114 Makefile: Makefile.in configure $(call requires_existing,config.status)
115 $(SHELL) config.status
118 .PHONY: config.status.missing
119 # ... but, in the event that this may be missing, (e.g. because it
120 # has been manually removed, or removed by "make distclean"), suggest
121 # running configure, and bail out.
123 config.status.missing:
124 $(warning *** cannot execute config.status)
125 $(error please run ${top_srcdir}/configure to regenerate it.)
127 # If configure itself needs to be updated, we must run autoconf in the
128 # top level source directory.
130 vpath %.m4 ${top_srcdir}
131 vpath configure.ac ${top_srcdir}
132 configure: configure.ac aclocal.m4
133 cd ${top_srcdir}; autoconf
135 # Capture dependencies conveyed within source files, ensuring that
136 # header files are taken from our working source tree, and not from
137 # the build-time compiler's installation path.
141 INCLUDES = -nostdinc -I . -I ${top_srcdir}/include -I ${w32api_srcdir}/include \
142 -I ${top_srcdir} -I ${top_srcdir}/profile -iwithprefixbefore include
144 ALL_CFLAGS = $(CFLAGS) $(DEPFLAGS) $(INCLUDES) $(NTDDI_VERSION_SPEC)
146 # The general case, for compiling object files from C source,
147 # requires a small adjustment to the default implicit rule.
150 $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) -o $@ $<
152 # In some cases, both ANSI and UTF-16LE enabled variants of object
153 # modules are compiled from a common source; the UTF-16LE variant is
154 # to be identified by prefixing a "w" to the object file name.
157 $(CC) -c -D UNICODE $(CPPFLAGS) $(ALL_CFLAGS) -o $@ $<
159 # Compiling object files from *.sx sources: since GCC-4.3, these
160 # have been supported as a case agnostic alternative to *.S sources,
161 # for assembly language sources requiring initial interpretation by
162 # the C preprocessor; owing to the case-insensitive nature of file
163 # naming on MS-Windows, we should prefer these, but we must tell
164 # make how to compile them.
167 $(COMPILE.sx) $($*_cflags) -o $@ $<
169 # Several components of the distributable object code base are to
170 # be provided as free-standing object modules, (rather than being
171 # encapsulated within object libraries); we classify these within
172 # two distinct groups, for support of the current MSVCRT.DLL build
173 # case and the older CRTDLL build case, (noting that, ultimately,
174 # we may wish to deprecate this latter case).
176 all-mingwrt-objects: $(call active_goals,all,crt-objects)
177 all-deprecated-mingwrt-objects: all-deprecated-crt-objects
179 # Further note that, in addition to specifying the build time
180 # inventories for each of these object module categories, each
181 # module should be allocated to an associated installation group,
182 # whence it may be included in the eventual distribution, via a
183 # staged installation.
185 all-crt-objects install-crt-objects: $(addsuffix .$(OBJEXT), crt2 crtmt \
186 crtst dllcrt2 gcrt2 CRT_fp8 CRT_fp10 CRT_noglob binmode txtmode)
188 all-deprecated-crt-objects install-deprecated-crt-objects: \
189 $(addsuffix .$(OBJEXT), crt1 dllcrt1 gcrt1)
191 # The crt1.$(OBJEXT) and crt2.$(OBJEXT) modules, for the (deprecated)
192 # CRTDLL and the (current) MSVCRT build cases respectively, are built
193 # from a common crt1.c source. Similarly, the dllcrt1.$(OBJEXT) and
194 # dllcrt2.$(OBJEXT) modules share the common dllcrt1.c source.
196 # Noting that the source files are named for the deprecated build
197 # case, but that we need to specify this while compiling, we need
198 # this explicit pattern rule...
200 vpath %.c ${mingwrt_srcdir}
201 $(addsuffix .$(OBJEXT), crt1 dllcrt1): %.$(OBJEXT): %.c
202 $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) -D__CRTDLL__ -o $@ $<
204 # ...while, for the current build case, we need an explicit mapping
205 # to identify the disparately named source file.
207 $(addsuffix .$(OBJEXT), crt2 dllcrt2): %2.$(OBJEXT): %1.c
208 $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) -o $@ $<
210 # The initialization hook for profiling code is inherited from Cygwin,
211 # where it is built as gcrt0.$(OBJEXT); we build it, unmodified, as each
212 # of gcrt1.$(OBJEXT) and gcrt2.$(OBJEXT), to satisfy the differing GCC
213 # specs file dependencies for each of the (deprecated) CRTDLL build
214 # and (current) MSVCRT build cases, respectively.
216 vpath %.c ${mingwrt_srcdir}/profile
217 $(addsuffix .$(OBJEXT), gcrt0 gcrt1 gcrt2): %.$(OBJEXT): gcrt0.c
218 $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) -o $@ $<
220 # The primary runtime library is furnished by Microsoft, in the form
221 # of MSVCRT.DLL, as shipped with MS-Windows itself, or in any one of
222 # its versioned variants, as shipped with the MSVC compiler suite.
224 # We furnish the API for this runtime library, in the form of import
225 # libraries, for both release and debug DLL variants; furthermore,
226 # although we favour the freely available MSVCRT.DLL distributions,
227 # we also provide import libraries tailored to the non-free, and
228 # non-redistributable, MSVCRnn.DLL variants, corresponding to each
229 # of the following enumerated versions from the MSVC suite.
231 msvcrt_versions := 70 71 80 90 100
232 msvcrt_version_script = echo $1 | awk '\
233 { printf "0x%03d0", gensub( "^[^1-9]*([0-9]*).*", "\\\\1", 1 ) \
236 extra_objects_filter = $(filter %.$(OBJEXT),$1)
237 extra_objects_script = test -z "$(call extra_objects_filter,$2)" \
238 || { echo $(AR) $(ARFLAGS) $1 $(call extra_objects_filter,$2); \
239 $(AR) $(ARFLAGS) $1 $(call extra_objects_filter,$2); \
242 msvcrt_dllname_script = echo $1 | awk '\
243 /^c/{ print "crtdll.dll" } \
244 /^m/{ ext = gsub( "^.*d$$", "&" ) ? "d.dll" : ".dll"; \
245 printf "msvcr%s%s", gsub( "^[^1-9]*[0-9]+.*", "&" ) \
246 ? gensub( "^[^1-9]*([0-9]+).*", "\\\\1", 1 ) \
250 # We categorize our import libraries into "standard" (a.k.a. "release")
251 # versions, augmented by corresponding "debug" variants.
253 std_msvcrt := $(addprefix msvcr,t $(msvcrt_versions))
254 all_msvcrt := $(std_msvcrt) $(addsuffix d,$(std_msvcrt))
256 all-mingwrt-libs: $(call active_goals,all,libmsvcrt)
257 all-libmsvcrt install-mingwrt-libs: $(foreach name,$(all_msvcrt),lib$(name).a)
258 all-libcrtdll install-deprecated-mingwrt-libs: libcrtdll.a libcoldname.a
259 all-deprecated-mingwrt all-deprecated-libmsvcrt: all-libcrtdll
261 # For each import library to be built, we derive a tailored exports
262 # definition file, from a common source.
264 .SUFFIXES: .def.in .def
265 $(addsuffix .def,$(all_msvcrt)): %.def: ${mingwrt_srcdir}/msvcrt.def.in
266 $(CC) -C -E -P -D__FILENAME__=$@ -D__$*__=1 \
267 -D__MSVCRT_VERSION__=`$(call msvcrt_version_script,$*)` \
270 # To accommodate the __USE_MINGW_ANSI_STDIO feature, as specified
271 # in _mingw.h and stdio.h, while retaining a mechanism for accessing
272 # the MSVCRT.DLL functions which it replaces, we augment our import
273 # libraries with extra, alternatively named entry points, each of
274 # which implements a vectored jump to the regular entry point for
275 # the DLL implementation of its corresponding replaced function.
277 msvcrt_repl_prefix = __msvcrt
278 msvcrt_repl_funcs = printf fprintf sprintf vprintf vfprintf vsprintf
280 # This is kludgey, but dlltool lacks the selectivity to do the job
281 # well; (its --ext-prefix-alias option, which is what we would like
282 # to use, is rather like a chainsaw in the hands of a neurosurgeon,
283 # when he should have a scalpel). We cannot selectively apply the
284 # prefix, to just the symbols of interest, so we end up by creating
285 # an initial copy of the import library, WITH the prefix applied to
286 # to EVERYTHING, (noting that, when we create this initial copy, we
287 # MUST specify the "--no-delete" option TWICE, to preserve temporary
288 # object files within the build tree); we then set this initial copy
289 # aside, and create a further copy WITHOUT the extra symbols, while
290 # duplicating the temporary object file name prefix retrieved from
291 # the initial copy, using this $(NM) lookup filter...
293 dlltool_temp_prefix = $(NM) $(1) | sed -n -e '/t.o:$$/{s///p;q' -e '}'
295 # ...after which, we apply the following $(NM) lookup filter to the
296 # initial copy of the import library file, to identify the specific
297 # temporary object files, defining the entry points to remap...
299 msvcrt_repl = $(call nmlookup,$1,$(msvcrt_repl_prefix)_,$(msvcrt_repl_funcs))
300 nmlookup = $(NM) $(1) | sed -n \
301 -e '/:$$/h;/^[0-7][0-7]* *T */{s///;H;g;s/\n//' \
302 $(foreach repl,$(3),-e 's/:_$(2)$(repl)$$//p') \
305 # ...and we add just that selection to the final copy of the import
306 # library, before explicitly deleting ALL temporary object files, and
307 # the (extended) initial copy of the import library.
309 vpath %.def ${mingwrt_srcdir}
310 $(foreach name,$(all_msvcrt) crtdll,lib$(name).a): lib%.a: %.def
311 $(DLLTOOL) --as $(AS) -k --input-def $< --no-delete --no-delete \
312 --dllname `$(call msvcrt_dllname_script,$*)` --output-lib $@ \
313 --ext-prefix-alias $(msvcrt_repl_prefix) && mv $@ lib$*-repl.a
314 $(DLLTOOL) --as $(AS) -k --input-def $< --output-lib $@ \
315 --temp-prefix `$(call dlltool_temp_prefix,lib$*-repl.a)` \
316 --dllname `$(DLLTOOL) --identify lib$*-repl.a`
317 $(AR) $(ARFLAGS) $@ `$(call msvcrt_repl,lib$*-repl.a)` \
318 $(filter %.$(OBJEXT),$^)
319 $(RM) lib$*-repl.a `$(call dlltool_temp_prefix,$@)`*
321 # Older versions of Microsoft's runtime libraries used a naming
322 # convention which is more consistent with POSIX, (and with other
323 # free software usage), than they currently employ; we support
324 # this earlier convention by mapping the old names to equivalent
325 # entry points in the current libraries, using libcoldname.a to
326 # map CRTDLL.DLL entries, and variants of libmoldname.a for each
327 # variant of MSVCRT.DLL
329 std_moldname := moldname $(addprefix moldname,$(msvcrt_versions))
330 all_moldname := $(std_moldname) $(addsuffix d,$(std_moldname))
332 all-mingwrt-libs: all-libmoldname
333 all-libmoldname install-mingwrt-libs: $(foreach name,$(all_moldname),lib$(name).a)
334 $(foreach name,coldname $(all_moldname),lib$(name).a): lib%.a: %.def
335 $(DLLTOOL) --as $(AS) -k -U --input-def $< --output-lib $@ \
336 --dllname `$(call msvcrt_dllname_script,$*)`
337 $(AR) $(ARFLAGS) $@ $(call extra_objects_filter,$^)
339 # The oldname libraries are also a convenient place to provide a
340 # few additional functions, with no direct implementation in the
341 # Microsoft DLLs, but which nevertheless are easily emulated.
343 $(foreach name,coldname $(all_moldname),lib$(name).a): $(addsuffix .$(OBJEXT), \
344 isascii iscsym iscsymf strcasecmp strncasecmp toascii wcscmpi)
346 coldname.def: %.def: ${mingwrt_srcdir}/moldname.def.in
347 $(CC) -C -E -P -D__FILENAME__=$@ -D__CRTDLL__ -xc-header $< > $@
349 $(addsuffix .def,$(all_moldname)): %.def: ${mingwrt_srcdir}/moldname.def.in
350 $(CC) -C -E -P -D__FILENAME__=$@ -xc-header $< > $@
352 all-mingwrt-libs install-mingwrt-libs: libmingw32.a libmingwex.a
353 libmingw32.a: $(addsuffix .$(OBJEXT), CRTinit CRTglob setargv \
354 CRTfmode cpu_features CRT_fp10 txtmode main dllmain gccmain crtst \
355 tlsmcrt tlsmthread tlssup tlsthrd pseudo-reloc pseudo-reloc-list)
357 libmingw32.a libmingwex.a libm.a libmingwthrd.a libgmon.a:
358 $(AR) $(ARFLAGS) $@ $?
360 # Complex math objects, to be included in libmingwex.a
361 # (FIXME: consider whether these might be more suitably
362 # delivered in libm.a; ISO-C99 says they belong in the
363 # math library, which by POSIX convention, is libm.a)
365 vpath %.c ${mingwrt_srcdir}/mingwex
366 vpath %.c ${mingwrt_srcdir}/mingwex/complex
367 libmingwex.a: $(addsuffix .$(OBJEXT), cabs cabsf cabsl cacos cacosf \
368 cacosh cacoshf cacoshl cacosl casin casinf casinh casinhf casinhl casinl \
369 catan catanf catanh catanhf catanhl catanl ccos ccosf ccosh ccoshf ccoshl \
370 ccosl cexp cexpf cexpl clog clogf clogl cpow cpowf cpowl cproj cprojf \
371 cprojl csin csinf csinh csinhf csinhl csinl csqrt csqrtf csqrtl \
372 ctan ctanf ctanh ctanhf ctanhl ctanl)
374 libmingwex.a: $(addsuffix .$(OBJEXT), isblank iswblank)
376 # Floating point environment control, in libmingwex.a
377 # (FIXME: once again, maybe better delivered in libm.a)
379 libmingwex.a: $(addsuffix .$(OBJEXT), fegetenv fesetenv feupdateenv \
380 feclearexcept feraiseexcept fetestexcept feholdexcept fegetexceptflag \
381 fesetexceptflag fegetround fesetround)
383 # David Gay's "gdtoa" API, provided in libmingwex.a, and used
384 # by MinGW's ISO-C conforming printf() routines for formatting
385 # floating point output.
387 vpath %.c ${mingwrt_srcdir}/mingwex/gdtoa
388 libmingwex.a: $(addsuffix .$(OBJEXT), g__fmt gethex strtopx g_dfmt gdtoa \
389 gmisc smisc sum g_ffmt hd_init strtodg ulp dmisc g_xfmt hexnan strtodnrp \
392 # "inttypes" conversion routines, provided in libmingwex.a
394 libmingwex.a: $(addsuffix .$(OBJEXT), \
395 imaxabs imaxdiv strtoimax strtoumax wcstoimax wcstoumax)
397 # Additional math functions, augmenting Microsoft's paltry
398 # selection, also delivered in libmingwex.a, (FIXME: and yet
399 # again, perhaps libm.a would be a better fit)
401 vpath %.c ${mingwrt_srcdir}/mingwex/math
402 vpath %.s ${mingwrt_srcdir}/mingwex/math
403 libmingwex.a: $(addsuffix .$(OBJEXT), cosf cosl acosf acosl sinf sinl asinf \
404 asinl tanf tanl atanf atanl atan2f atan2l coshf coshl acosh acoshf acoshl \
405 sinhf sinhl asinh asinhf asinhl tanhf tanhl atanh atanhf atanhl cbrt cbrtf \
406 cbrtl ceilf ceill copysign copysignf copysignl erfl s_erf sf_erf expf expl \
407 exp2 exp2f exp2l expm1 expm1f expm1l fabs fabsf fabsl fdim fdimf fdiml \
408 floorf floorl fma fmaf fmal fmax fmaxf fmaxl fmin fminf fminl fmodf fmodl \
409 fp_consts fp_constsf fp_constsl fpclassify fpclassifyf fpclassifyl frexpf \
410 frexpl fucom hypotf hypotl ilogb ilogbf ilogbl isnan isnanf isnanl ldexpf \
411 ldexpl lgamma lgammaf lgammal llrint llrintf llrintl log10f log10l log1p \
412 log1pf log1pl log2 log2f log2l logb logbf logbl logf logl lrint lrintf \
413 lrintl llround llroundf llroundl lround lroundf lroundl modff modfl \
414 nearbyint nearbyintf nearbyintl nextafterf nextafterl nexttoward nexttowardf \
415 powf powl powi powif powil remainder remainderf remainderl remquo remquof \
416 remquol rint rintf rintl round roundf roundl scalbn scalbnf scalbnl signbit \
417 signbitf signbitl sqrtf sqrtl tgamma tgammaf tgammal trunc truncf truncl)
419 # Replacement I/O functions in libmingwex.a, providing better POSIX
420 # compatibility than their Microsoft equivalents.
422 vpath %.c ${mingwrt_srcdir}/mingwex/stdio
423 libmingwex.a: $(addsuffix .$(OBJEXT), btowc fopen64 fprintf fseeko64 ftello64 \
424 lseek64 pformat printf snprintf snwprintf sprintf vfprintf vfscanf vfwscanf \
425 vprintf vscanf vsnprintf vsnwprintf vsprintf vsscanf vswscanf vwscanf)
427 # pformat.$(OBJEXT) needs an explicit build rule, since we need to
428 # specify an additional header file path.
430 PFORMAT_CFLAGS = -I ${mingwrt_srcdir}/mingwex/gdtoa
431 pformat.$(OBJEXT): %.$(OBJEXT): %.c
432 $(CC) -c $(ALL_CFLAGS) $(PFORMAT_CFLAGS) $< -o $@
434 # To support Microsoft's DLL version specific exponent digits control,
435 # and "%n" format availability control APIs, in a DLL version agnostic
436 # manner, we also provide the following set of wrapper functions:
438 libmingwex.a: $(addsuffix fmt.$(OBJEXT),varo crto geto seto crtn getn setn)
439 $(addsuffix fmt.$(OBJEXT),varo crto geto seto crtn getn setn): %.$(OBJEXT): ofmt.c
440 $(CC) -c $(ALL_CFLAGS) -D__$*__ -fno-align-functions -o $@ $<
442 # Some additional miscellaneous functions, in libmingwex.a
444 #libmingwex.a: $(addsuffix .$(OBJEXT), glob membarrier)
445 libmingwex.a: $(addsuffix .$(OBJEXT), mingw-aligned-malloc mingw-fseek glob)
446 libmingwex.a: $(addsuffix .$(OBJEXT), getopt basename dirname ftruncate usleep)
448 libmingwex.a: $(addsuffix .$(OBJEXT), tdelete tfind tsearch twalk)
450 libmingwex.a: gettimeofday.$(OBJEXT)
451 libmingwex.a: $(addsuffix .$(OBJEXT), dirent wdirent dlfcn)
453 libmingwex.a: $(addsuffix .$(OBJEXT), fwide mbrtowc mbsinit wcrtomb wcstof \
454 wcstold wctob wmemchr wmemcmp wmemcpy wmemmove wmemset)
456 libmingwex.a: $(addsuffix .$(OBJEXT), wctrans wctype)
458 # For the math sources, we support the convention that a single
459 # quux_generic.c source file will produce three objects: quux.o,
460 # quuxf.o, and quuxl.o; since a change in the common source file
461 # will require all three objects to be recompiled, we may handle
462 # this with a single, multiple target, pattern rule.
464 $(addsuffix .$(OBJEXT), % %f %l): %_generic.c
465 $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) -o $*.$(OBJEXT) $<
466 $(CC) -c -D FUNCTION=$*f $(CPPFLAGS) $(ALL_CFLAGS) -o $*f.$(OBJEXT) $<
467 $(CC) -c -D FUNCTION=$*l $(CPPFLAGS) $(ALL_CFLAGS) -o $*l.$(OBJEXT) $<
469 # The llround.o, llroundf.o, and llroundl.o variants are a special
470 # case of the preceding rule; (the source is lround_generic.c rather
471 # than llround_generic.c). We can handle this using the following
472 # static pattern rule, (compiling each object individually).
474 $(addsuffix .$(OBJEXT), llround llroundf llroundl): %.$(OBJEXT): lround_generic.c
475 $(CC) -c -D FUNCTION=$* $(CPPFLAGS) $(ALL_CFLAGS) -o $@ $<
477 # Historically, MinGW.org's libm.a has been a dummy, delivering
478 # nothing of value; FIXME: IMO, this sucks; it should deliver the
479 # non-MSVCRT.DLL math functions, as noted above.
481 all-mingwrt-libs install-mingwrt-libs: libm.a
482 libm.a: libm_dummy.$(OBJEXT)
483 libm_dummy.c: Makefile
484 echo "static int __mingw_libm_dummy;" > $@
486 # The mingwrt headers define a number of functions which are normally
487 # expected to be compiled as inline code. Each such function must also
488 # be provided with an externally visible entry point; we provide such
489 # entry points as stubs in libmingwex.a, via the following rules:
491 sinclude Makefile.stub
492 vpath jmpstub.sx ${mingwrt_srcdir}/mingwex
493 libstub_refnames = grep -lr '__$1.*FUNCTION *=' ${mingwrt_srcdir}
494 jmpstub_prerequisites := $(shell $(call libstub_refnames,JMPSTUB)/include)
495 libimpl_prerequisites := $(shell $(call libstub_refnames,LIBIMPL)/include)
496 Makefile.stub: Makefile $(jmpstub_prerequisites) $(libimpl_prerequisites)
497 echo "# $@: automatically generated file -- do not edit!" > $@
498 $(call jmpstub_awk_script,$(jmpstub_prerequisites)) >> $@
499 $(call libimpl_awk_script,$(libimpl_prerequisites)) >> $@
500 echo "# $@: end of file" >> $@
502 # Stubs are categorized into either of JMPSTUB or LIBIMPL classes;
503 # the rules for building the JMPSTUP inplementations are written to
504 # Makefile.stub, by processing each of their defining header files
505 # through the following awk script...
507 jmpstub_awk_script = test -z "$1" || awk '\
509 symbol = "([A-Z_a-z][A-Z_a-z0-9]*)"; \
510 fmt = "\nlib%s.a: %s\n%s: jmpstub.sx\n\t$$(COMPILE.sx) %s -o $$@ $$^\n"; \
512 /__JMPSTUB(__)? *[(].*FUNCTION/ { \
514 FUNCTION = gensub( ".*[ ,(:]FUNCTION *= *"symbol".*", "\\1", 1 ); \
515 OBJNAME = gensub( "_*(.*)_*", "\\1", 1, FUNCTION )".jmpstub.$$(OBJEXT)"; \
516 OBJNAME_CFLAGS = "-D FUNCTION="FUNCTION; \
517 if( match( $$0, ".*[ ,(:]REMAPPED *= *"symbol, alias ) ) \
518 OBJNAME_CFLAGS = OBJNAME_CFLAGS" -D REMAPPED="alias[1]; \
519 printf fmt, LIB, OBJNAME, OBJNAME, OBJNAME_CFLAGS; \
525 # ...while this establishes the dependencies which apply for each
526 # of those in the LIBIMPL class.
528 libimpl_awk_script = test -z "$1" || awk '\
530 symbol = "([A-Z_a-z][A-Z_a-z0-9]*)"; \
531 fmt = "\nlib%s.a: %s\n%s.libimpl: %s\n"; \
533 /__LIBIMPL(__)? *[(].*FUNCTION/ { \
535 FUNCTION = gensub( ".*[ ,(:]FUNCTION *= *"symbol".*", "\\1", 1 ); \
536 OBJNAME = gensub( "_*(.*)_*", "\\1", 1, FUNCTION )".libimpl.$$(OBJEXT)"; \
537 printf fmt, LIB, OBJNAME, FUNCTION, FILENAME; \
543 # In contrast to JMPSTUB implementations, which are best handled
544 # by individual compilation rules in Makefile.stub, generic rules
545 # are sufficient for all LIBIMPL implementations; in each case, we
546 # filter the static attribute from each defined implementation, in
547 # its defining header file, to create an intermediate C source for
548 # each individual function; (note that we also remove any pragma
549 # which identifies the originating file as a system header).
551 libimpl_sed_script = sed \
552 -e '/__CRT_ALIAS *__LIBIMPL.*FUNCTION *= *$1[ ,)].*)/d' \
553 -e '/__CRT_INLINE *__LIBIMPL.*FUNCTION *= *$1[ ,)].*)/d' \
554 -e '/pragma .* system_header/d'
556 LIBIMPL_CFLAGS = $(CFLAGS) $(INCLUDES) -fno-align-functions
558 # LIBIMPL dependencies are tracked using zero sized name.libimpl
559 # files; the intermediate C files are generated as a side effect
560 # of resolving these dependencies...
563 $(call libimpl_sed_script,$*) $< > $@.c
566 # ...and ultimately discarded, after the requisite object file
567 # has been compiled; (note that this creates a vulnerability due
568 # to possible loss of the object file, while the tracking file is
569 # still in place; to circumvent this, we must be able to force a
570 # remake of the tracking file, so also regenerating the .c file,
571 # before it is compiled).
573 libimpl_remake = { $(RM) $1; $(MAKE) --no-print-directory $1; }
574 %.libimpl.$(OBJEXT): %.libimpl
575 test -f $<.c || $(call libimpl_remake,$<)
576 $(CC) -c $(CPPFLAGS) $(LIBIMPL_CFLAGS) -o $@ $<.c
579 # Thread support libraries.
581 all-mingwrt-libs install-mingwrt-libs: libmingwthrd.a libmingwthrd_old.a
582 libmingwthrd.a libmingwthrd_old.a: crtmt.$(OBJEXT)
583 mingwthrd_old.def mingwm10.dll: $(addsuffix .$(OBJEXT), mthr mthr_init)
585 $(DLLTOOL) --as $(AS) --output-def $@ $^
587 libmingwthrd_old.a: lib%.a: %.def
588 $(DLLTOOL) --as $(AS) --input-def $< --dllname mingwm10.dll --output-lib $@
589 $(AR) $(ARFLAGS) $@ $(call extra_objects_filter,$^)
591 all-mingwrt-dll install-mingwrt-dll-files: mingwm10.dll
592 mingwm10.dll: mingwthrd_old.def
593 $(CC) -shared -o $@ -Wl,--image-base,0x6FBC0000 \
594 -Wl,--entry,_DllMainCRTStartup@12 $^
596 # Code profiling support, using the GNU profiling library; (note
597 # that applications using this library MUST be licensed to comply
598 # with the GNU General Public License).
600 all-mingwrt-libs install-mingwrt-libs: libgmon.a
601 libgmon.a: $(addsuffix .$(OBJEXT), gmon mcount profil)
607 # Users may expect to be able to specify DESTDIR, to stage the
608 # following stock installation directories outside of the regular
609 # "as configured" installation tree; unfortunately, this expectation
610 # MUST fail, when the stock path is in MS-Windows absolute format, so
611 # we provide an exception mechanism to forbid such usage, and we
612 # proceed to create the directories only when the exception is
615 .PHONY: DESTDIR-UNSUPPORTED
616 bindir docdir includedir libdir mandir htmldir pdfdir:
617 @test -z "$(strip ${DESTDIR})" || case $($@) in ${DESTDIR}?:*) \
618 $(MAKE) --no-print-directory reject=$@ DESTDIR-UNSUPPORTED;; \
620 $(mkinstalldirs) $($@)
622 # Note: we MUST use a recursive make invocation here, as the
623 # "error" function within the accompanying diagnostics would be
624 # triggered, irrespective of its placement in an unexecuted
625 # branch of the above exception trapping shell code.
628 $(call MSG_DESTDIR_FORBIDDEN,$(reject),$($(reject):${DESTDIR}%=%))
630 # The following macros, which rely heavily on GNU make's "call"
631 # function, define the diagnostics to be emitted, when the DESTDIR
632 # exception is triggered.
635 MSG_DESTDIR_FORBIDDEN = \
636 $(warning *** $(call MSG_DESTDIR_PATH_CONFLICT,$1,Win32,$2);) \
637 $(error try $(call QUOTE,$(call MSG_DESTDIR_ALTERNATIVE,$1,$2)) instead)
638 MSG_DESTDIR_BAD_PATH = DESTDIR is not supported when $1 contains $2 path $3
639 MSG_DESTDIR_PATH_CONFLICT = $(call MSG_DESTDIR_BAD_PATH,$1,$2,$(call QUOTE,$3))
640 MSG_DESTDIR_ALTERNATIVE = make install $1="$(call MSG_DESTDIR_TRANSFORM,$2)"
641 MSG_DESTDIR_TRANSFORM = ${DESTDIR}$(shell echo $1 | sed 's/^.://')
643 # Install everything.
645 install: install-mingwrt
646 install-stage-1-only: install-headers install-libdir-objects install-libs
647 install-stage-1-and-2: install-stage-1-only install-bin
648 install-gcc: install-stage-1-only
650 # Install licence files.
652 install-license: install-mingwrt-license
653 install-licence install-mingwrt-licence: %-licence: %-license
655 vpath DISCLAIMER ${mingwrt_srcdir}
656 vpath COPYING ${mingwrt_srcdir}/profile
657 vpath CYGWIN_LICENSE ${mingwrt_srcdir}/profile
658 mingwrt-license-files: COPYING CYGWIN_LICENSE DISCLAIMER
660 # FIXME: The following rule is generalized, such that it may accommodate
661 # both mingwrt and w32api, (and other packages); thus, it should ideally
662 # be relocated into a common (shared) Makefile fragment.
664 install-mingwrt-license install-w32api-license: install-%: docdir %-files
666 $(mkinstalldirs) ${docdir}/$*/$(PACKAGE_VERSION)
667 $(INSTALL_DATA) $^ ${docdir}/$*/$(PACKAGE_VERSION)
669 # Install headers associated with the MinGW runtime libraries.
671 includedirs: mingwrt-includedirs
672 install-headers install-mingwrt: install-mingwrt-headers
674 ${includedir}/sys: includedir
675 mingwrt-includedirs: ${includedir}/sys
678 install-mingwrt-headers: mingwrt-includedirs
679 $(INSTALL_DATA) ${mingwrt_srcdir}/include/*.h ${includedir}
680 $(INSTALL_DATA) ${mingwrt_srcdir}/include/sys/*.h ${includedir}/sys
681 $(INSTALL_DATA) ${mingwrt_srcdir}/profile/*.h ${includedir}
683 # Install libraries, and supporting free standing object files.
685 install-libs install-mingwrt: install-mingwrt-libdir-libs
686 install-libdir-objects install-mingwrt: install-mingwrt-libdir-objects
688 install-mingwrt-libdir-libs: libdir $(call active_goals,install,mingwrt-libs)
689 install-mingwrt-libdir-objects: libdir $(call active_goals,install,crt-objects)
691 install-crt-objects install-deprecated-crt-objects \
692 install-mingwrt-libs install-deprecated-mingwrt-libs:
693 $(INSTALL_DATA) $^ ${libdir}
697 install-mingwrt: install-mingwrt-dll
698 install-bin install-dll: install-mingwrt-dll
699 install-mingwrt-bin install-w32api-bin: install-%-bin: install-%-dll
700 install-mingwrt-dll install-w32api-dll: install-%-dll: bindir install-%-dll-files
702 $(INSTALL_DATA) $^ ${bindir}
706 install-man install-manpages: install-mingwrt-manpages
707 format_manpage = sed "s/%PAGEREF%/`echo $1 | tr a-z A-Z` $2/"
709 vpath %.man ${mingwrt_srcdir}/man
710 basename.$(man3ext) dirname.$(man3ext): %.$(man3ext): dirname.man
711 $(call format_manpage,$*,$(man3ext)) $< > $@
713 mingwrt-man$(man3ext): basename.$(man3ext) dirname.$(man3ext)
715 install-mingwrt-manpages: mandir mingwrt-man3
717 $(mkinstalldirs) ${man$*dir}
718 $(INSTALL_DATA) $^ ${man$*dir}
726 dist: devdist dlldist licdist mandist srcdist
727 $(RM) -r dist/mingwrt dist/w32api
729 mingwrt-dist-staged w32api-dist-staged: %-dist-staged:
731 $(MAKE) --no-print-directory prefix=`pwd`/dist/$* install-$*
733 devdist: mingwrt-devdist
734 mingwrt_devdist_objects = dist/mingwrt/lib/*.$(OBJEXT)
735 mingwrt-devdist w32api-devdist: %-devdist: %-dist-staged
736 $(STRIP) -g $($*_devdist_objects) dist/$*/lib/*.a
737 cd dist/$* && tar chf - --hard-dereference include lib | \
738 xz -c > ../$*-$(PACKAGE_RELEASE_TAG)-dev.tar.xz
740 dlldist: mingwrt-dlldist
741 mingwrt-dlldist: %-dlldist: %-dist-staged
742 $(STRIP) dist/$*/bin/*.dll
743 cd dist/$* && tar chf - --hard-dereference bin | \
744 xz -c > ../$*-$(PACKAGE_RELEASE_TAG)-dll.tar.xz
746 licdist: mingwrt-licdist
747 mingwrt-licdist w32api-licdist: %-licdist:
749 $(MAKE) --no-print-directory prefix=`pwd`/tmp install-$*-licence
750 cd tmp && tar chf - --hard-dereference * | \
751 xz -c > ../dist/$*-$(PACKAGE_RELEASE_TAG)-lic.tar.xz
754 mandist: mingwrt-mandist
755 mingwrt-mandist: %-mandist:
757 $(MAKE) --no-print-directory prefix=`pwd`/tmp install-$*-manpages
758 cd tmp && tar chf - --hard-dereference share | \
759 xz -c > ../dist/$*-$(PACKAGE_RELEASE_TAG)-man.tar.xz
762 srcdist: mingwrt-srcdist
763 mingwrt-srcdist: mingwrt-srcdist-dir mingwrt-srcdist-files
764 cd dist && tar chf - $(PACKAGE_TARNAME)-$(PACKAGE_VERSION) | \
765 xz -c > $(PACKAGE_TARNAME)-$(PACKAGE_RELEASE_TAG)-src.tar.xz
766 $(RM) -r dist/$(PACKAGE_TARNAME)-$(PACKAGE_VERSION)
769 $(RM) -r dist/$(PACKAGE_TARNAME)-$(PACKAGE_VERSION)
770 $(mkinstalldirs) dist/$(PACKAGE_TARNAME)-$(PACKAGE_VERSION)
772 mingwrt-srcdist-files:
773 (cd ${mingwrt_srcdir} && tar chf - --hard-dereference $(notdir $^)) | \
774 (cd dist/$(PACKAGE_TARNAME)-$(PACKAGE_VERSION) && tar xf -)
776 mingwrt-srcdist-files: $(wildcard ${mingwrt_srcdir}/*.[chs]) \
777 $(addprefix ${mingwrt_srcdir}/,ChangeLog CONTRIBUTORS DISCLAIMER README) \
778 $(wildcard ${mingwrt_srcdir}/*.def.in) $(wildcard ${mingwrt_srcdir}/config*) \
779 $(addprefix ${mingwrt_srcdir}/,aclocal.m4 install-sh Makefile.in TODO) \
780 $(addprefix ${mingwrt_srcdir}/,include man mingwex profile) \
781 $(addprefix ${mingwrt_srcdir}/,crtdll.def) \
782 $(wildcard ${mingwrt_srcdir}/*.txt)
784 install-html install-pdf: install-%: %dir mingwrt-man$(man3ext)
785 $(MAKE) --no-print-directory install-$*-files
787 install-html-files install-pdf-files: install-%-files: \
788 $(addsuffix .%,$(wildcard ${man3dir}/*.$(man3ext)))
790 %.$(man3ext).html: %.$(man3ext)
791 man2html $< | sed -e '1,/^<!DOCTYPE/{/^<!/p;d' -e '}' > ${htmldir}/$(notdir $@)
792 chmod 644 ${htmldir}/$(notdir $@)
794 %.$(man3ext).pdf: %.$(man3ext)
795 man -t $< | ps2pdf - > ${pdfdir}/$(notdir $@)
796 chmod 644 ${pdfdir}/$(notdir $@)
798 html-docdist pdf-docdist: %-docdist:
800 $(MAKE) --no-print-directory prefix=`pwd`/tmp install-$*
801 $(RM) -r tmp/share/man
802 cd tmp && tar chf - --hard-dereference share | \
803 xz -c > ../dist/mingwrt-doc-$(PACKAGE_RELEASE_TAG)-$*.tar.xz
810 clean-local: mostlyclean-local
811 $(RM) msvcr*.def moldname*.def mingw*.def lib*.a *.dll
814 $(RM) *.d *.$(OBJEXT) Makefile.stub *.libimpl
816 distclean-local: clean-local
817 $(RM) config.log config.status libm_dummy.c
819 maintainer-clean-warning:
820 $(warning $(MAKE) $(@:%-warning=%))
821 $(warning This command should be used by package maintainers only;)
822 $(warning it deletes files which may require special tools to rebuild.)
824 maintainer-clean-local: maintainer-clean-warning distclean-local
825 $(RM) -r ${mingwrt_srcdir}/autom4te.cache
827 clean mostlyclean distclean maintainer-clean: %clean: %clean-local
829 # $RCSfile$: end of file