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@
64 all: @DEFAULT_MAKECMDGOALS@
65 all-mingwrt-stage-1: all-mingwrt-objects all-mingwrt-libs
66 all-mingwrt-stage-1-and-2: all-mingwrt-stage-1 all-mingwrt-dll
67 all-mingwrt: all-mingwrt-stage-1-and-2
69 include_deprecated = @include_deprecated@
70 active_goals = $1-$2 $(if $(include_deprecated),$1-deprecated-$2)
72 all-stage-1: $(call active_goals,all,mingwrt-stage-1)
73 all-stage-1-and-2: $(call active_goals,all,mingwrt)
75 # Installation paths and macros.
78 exec_prefix = @exec_prefix@
79 bindir = ${DESTDIR}@bindir@
81 datarootdir = @datarootdir@
82 docdir = ${DESTDIR}${datarootdir}/doc
83 includedir = ${DESTDIR}@includedir@
84 libdir = ${DESTDIR}@libdir@
89 mandir = ${DESTDIR}@mandir@
90 man3dir = ${mandir}/man$(man3ext)
95 INSTALL_DATA = @INSTALL_DATA@
97 mkinstalldirs = @MKDIR_P@
99 # Keep the configuration in a consistent state. Note that we assume
100 # that configure has been run initially, (otherwise we wouldn't have
101 # a Makefile to begin with); since this also creates config.status,
102 # we may normally assume that it is already available ...
104 vpath configure ${top_srcdir}
105 config.status: configure
106 $(SHELL) config.status --recheck
108 # ... in which case, updating Makefile should be a simple matter of
109 # running config.status ...
111 vpath Makefile.in ${top_srcdir}
112 requires_existing = $(if $(wildcard $1),$1,$1.missing)
113 Makefile: Makefile.in configure $(call requires_existing,config.status)
114 $(SHELL) config.status
116 .PHONY: config.status.missing
117 # ... but, in the event that this may be missing, (e.g. because it
118 # has been manually removed, or removed by "make distclean"), suggest
119 # running configure, and bail out.
121 config.status.missing:
122 $(warning *** cannot execute config.status)
123 $(error please run ${top_srcdir}/configure to regenerate it.)
125 # If configure itself needs to be updated, we must run autoconf in the
126 # top level source directory.
128 vpath %.m4 ${top_srcdir}
129 vpath configure.ac ${top_srcdir}
130 configure: configure.ac aclocal.m4
131 cd ${top_srcdir}; autoconf
133 # Capture dependencies conveyed within source files, ensuring that
134 # header files are taken from our working source tree, and not from
135 # the build-time compiler's installation path.
139 INCLUDES = -nostdinc -I . -I ${top_srcdir}/include -I ${w32api_srcdir}/include \
140 -I ${top_srcdir} -I ${top_srcdir}/profile -iwithprefixbefore include
142 ALL_CFLAGS = $(CFLAGS) $(DEPFLAGS) $(INCLUDES) $(NTDDI_VERSION_SPEC)
144 # The general case, for compiling object files from C source,
145 # requires a small adjustment to the default implicit rule.
148 $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) -o $@ $<
150 # In some cases, both ANSI and UTF-16LE enabled variants of object
151 # modules are compiled from a common source; the UTF-16LE variant is
152 # to be identified by prefixing a "w" to the object file name.
155 $(CC) -c -D UNICODE $(CPPFLAGS) $(ALL_CFLAGS) -o $@ $<
157 # Several components of the distributable object code base are to
158 # be provided as free-standing object modules, (rather than being
159 # encapsulated within object libraries); we classify these within
160 # two distinct groups, for support of the current MSVCRT.DLL build
161 # case and the older CRTDLL build case, (noting that, ultimately,
162 # we may wish to deprecate this latter case).
164 all-mingwrt-objects: $(call active_goals,all,crt-objects)
165 all-deprecated-mingwrt-objects: all-deprecated-crt-objects
167 # Further note that, in addition to specifying the build time
168 # inventories for each of these object module categories, each
169 # module should be allocated to an associated installation group,
170 # whence it may be included in the eventual distribution, via a
171 # staged installation.
173 all-crt-objects install-crt-objects: $(addsuffix .$(OBJEXT), crt2 crtmt \
174 crtst dllcrt2 gcrt2 CRT_fp8 CRT_fp10 CRT_noglob binmode txtmode)
176 all-deprecated-crt-objects install-deprecated-crt-objects: \
177 $(addsuffix .$(OBJEXT), crt1 dllcrt1 gcrt1)
179 # The crt1.$(OBJEXT) and crt2.$(OBJEXT) modules, for the (deprecated)
180 # CRTDLL and the (current) MSVCRT build cases respectively, are built
181 # from a common crt1.c source. Similarly, the dllcrt1.$(OBJEXT) and
182 # dllcrt2.$(OBJEXT) modules share the common dllcrt1.c source.
184 # Noting that the source files are named for the deprecated build
185 # case, but that we need to specify this while compiling, we need
186 # this explicit pattern rule...
188 vpath %.c ${mingwrt_srcdir}
189 $(addsuffix .$(OBJEXT), crt1 dllcrt1): %.$(OBJEXT): %.c
190 $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) -D__CRTDLL__ -o $@ $<
192 # ...while, for the current build case, we need an explicit mapping
193 # to identify the disparately named source file.
195 $(addsuffix .$(OBJEXT), crt2 dllcrt2): %2.$(OBJEXT): %1.c
196 $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) -o $@ $<
198 # The initialization hook for profiling code is inherited from Cygwin,
199 # where it is built as gcrt0.$(OBJEXT); we build it, unmodified, as each
200 # of gcrt1.$(OBJEXT) and gcrt2.$(OBJEXT), to satisfy the differing GCC
201 # specs file dependencies for each of the (deprecated) CRTDLL build
202 # and (current) MSVCRT build cases, respectively.
204 vpath %.c ${mingwrt_srcdir}/profile
205 $(addsuffix .$(OBJEXT), gcrt0 gcrt1 gcrt2): %.$(OBJEXT): gcrt0.c
206 $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) -o $@ $<
208 # The primary runtime library is furnished by Microsoft, in the form
209 # of MSVCRT.DLL, as shipped with MS-Windows itself, or in any one of
210 # its versioned variants, as shipped with the MSVC compiler suite.
212 # We furnish the API for this runtime library, in the form of import
213 # libraries, for both release and debug DLL variants; furthermore,
214 # although we favour the freely available MSVCRT.DLL distributions,
215 # we also provide import libraries tailored to the non-free, and
216 # non-redistributable, MSVCRnn.DLL variants, corresponding to each
217 # of the following enumerated versions from the MSVC suite.
219 msvcrt_versions := 70 71 80 90 100
220 msvcrt_version_script = echo $1 | awk '\
221 { printf "0x%03d0", gensub( "^[^1-9]*([0-9]*).*", "\\\\1", 1 ) \
224 extra_objects_filter = $(filter %.$(OBJEXT),$1)
225 extra_objects_script = test -z "$(call extra_objects_filter,$2)" \
226 || { echo $(AR) $(ARFLAGS) $1 $(call extra_objects_filter,$2); \
227 $(AR) $(ARFLAGS) $1 $(call extra_objects_filter,$2); \
230 msvcrt_dllname_script = echo $1 | awk '\
231 /^c/{ print "crtdll.dll" } \
232 /^m/{ ext = gsub( "^.*d$$", "&" ) ? "d.dll" : ".dll"; \
233 printf "msvcr%s%s", gsub( "^[^1-9]*[0-9]+.*", "&" ) \
234 ? gensub( "^[^1-9]*([0-9]+).*", "\\\\1", 1 ) \
238 # We categorize our import libraries into "standard" (a.k.a. "release")
239 # versions, augmented by corresponding "debug" variants.
241 std_msvcrt := $(addprefix msvcr,t $(msvcrt_versions))
242 all_msvcrt := $(std_msvcrt) $(addsuffix d,$(std_msvcrt))
244 all-mingwrt-libs: $(call active_goals,all,libmsvcrt)
245 all-libmsvcrt install-mingwrt-libs: $(foreach name,$(all_msvcrt),lib$(name).a)
246 all-libcrtdll install-deprecated-mingwrt-libs: libcrtdll.a libcoldname.a
247 all-deprecated-mingwrt all-deprecated-libmsvcrt: all-libcrtdll
249 # FIXME: We should aim to remove this interim work-around...
251 # MSVCRT.DLL, MSVCR70.DLL, and MSVCR71.DLL, (both regular and debug
252 # variants), lack the _get_output_format() function, which is required
253 # by the printf() module in libmingwex.a; add our own implementation.
254 # (Note that we also apply this for CRTDLL.DLL, via libcrtdll.a)
256 vpath ofmt_stub.s ${mingwrt_srcdir}
257 $(foreach ver,t 70 71,libmsvcr$(ver).a) libcrtdll.a \
258 $(foreach ver,t 70 71,libmsvcr$(ver)d.a): ofmt_stub.$(OBJEXT)
262 # For each import library to be built, we derive a tailored exports
263 # definition file, from a common source.
265 .SUFFIXES: .def.in .def
266 $(addsuffix .def,$(all_msvcrt)): %.def: ${mingwrt_srcdir}/msvcrt.def.in
267 $(CC) -C -E -P -D__FILENAME__=$@ -D__$*__=1 \
268 -D__MSVCRT_VERSION__=`$(call msvcrt_version_script,$*)` \
271 # To accommodate the __USE_MINGW_ANSI_STDIO feature, as specified
272 # in _mingw.h and stdio.h, while retaining a mechanism for accessing
273 # the MSVCRT.DLL functions which it replaces, we augment our import
274 # libraries with extra, alternatively named entry points, each of
275 # which implements a vectored jump to the regular entry point for
276 # the DLL implementation of its corresponding replaced function.
278 msvcrt_repl_prefix = __msvcrt
279 msvcrt_repl_funcs = printf fprintf sprintf vprintf vfprintf vsprintf
281 # This is kludgey, but dlltool lacks the selectivity to do the job
282 # well; (its --ext-prefix-alias option, which is what we would like
283 # to use, is rather like a chainsaw in the hands of a neurosurgeon,
284 # when he should have a scalpel). We cannot selectively apply the
285 # prefix, to just the symbols of interest, so we end up by creating
286 # an initial copy of the import library, WITH the prefix applied to
287 # to EVERYTHING, (noting that, when we create this initial copy, we
288 # MUST specify the "--no-delete" option TWICE, to preserve temporary
289 # object files within the build tree); we then set this initial copy
290 # aside, and create a further copy WITHOUT the extra symbols, while
291 # duplicating the temporary object file name prefix retrieved from
292 # the initial copy, using this $(NM) lookup filter...
294 dlltool_temp_prefix = $(NM) $(1) | sed -n -e '/t.o:$$/{s///p;q' -e '}'
296 # ...after which, we apply the following $(NM) lookup filter to the
297 # initial copy of the import library file, to identify the specific
298 # temporary object files, defining the entry points to remap...
300 msvcrt_repl = $(call nmlookup,$1,$(msvcrt_repl_prefix)_,$(msvcrt_repl_funcs))
301 nmlookup = $(NM) $(1) | sed -n \
302 -e '/:$$/h;/^[0-7][0-7]* *T */{s///;H;g;s/\n//' \
303 $(foreach repl,$(3),-e 's/:_$(2)$(repl)$$//p') \
306 # ...and we add just that selection to the final copy of the import
307 # library, before explicitly deleting ALL temporary object files, and
308 # the (extended) initial copy of the import library.
310 vpath %.def ${mingwrt_srcdir}
311 $(foreach name,$(all_msvcrt) crtdll,lib$(name).a): lib%.a: %.def
312 $(DLLTOOL) --as $(AS) -k --input-def $< --no-delete --no-delete \
313 --dllname `$(call msvcrt_dllname_script,$*)` --output-lib $@ \
314 --ext-prefix-alias $(msvcrt_repl_prefix) && mv $@ lib$*-repl.a
315 $(DLLTOOL) --as $(AS) -k --input-def $< --output-lib $@ \
316 --temp-prefix `$(call dlltool_temp_prefix,lib$*-repl.a)` \
317 --dllname `$(DLLTOOL) --identify lib$*-repl.a`
318 $(AR) $(ARFLAGS) $@ `$(call msvcrt_repl,lib$*-repl.a)` \
319 $(filter %.$(OBJEXT),$^)
320 $(RM) lib$*-repl.a `$(call dlltool_temp_prefix,$@)`*
322 # Older versions of Microsoft's runtime libraries used a naming
323 # convention which is more consistent with POSIX, (and with other
324 # free software usage), than they currently employ; we support
325 # this earlier convention by mapping the old names to equivalent
326 # entry points in the current libraries, using libcoldname.a to
327 # map CRTDLL.DLL entries, and variants of libmoldname.a for each
328 # variant of MSVCRT.DLL
330 std_moldname := moldname $(addprefix moldname,$(msvcrt_versions))
331 all_moldname := $(std_moldname) $(addsuffix d,$(std_moldname))
333 all-mingwrt-libs: all-libmoldname
334 all-libmoldname install-mingwrt-libs: $(foreach name,$(all_moldname),lib$(name).a)
335 $(foreach name,coldname $(all_moldname),lib$(name).a): lib%.a: %.def
336 $(DLLTOOL) --as $(AS) -k -U --input-def $< --output-lib $@ \
337 --dllname `$(call msvcrt_dllname_script,$*)`
338 $(AR) $(ARFLAGS) $@ $(call extra_objects_filter,$^)
340 # The oldname libraries are also a convenient place to provide a
341 # few additional functions, with no direct implementation in the
342 # Microsoft DLLs, but which nevertheless are easily emulated.
344 $(foreach name,coldname $(all_moldname),lib$(name).a): $(addsuffix .$(OBJEXT), \
345 isascii iscsym iscsymf strcasecmp strncasecmp toascii wcscmpi)
347 coldname.def: %.def: ${mingwrt_srcdir}/moldname.def.in
348 $(CC) -C -E -P -D__FILENAME__=$@ -D__CRTDLL__ -xc-header $< > $@
350 $(addsuffix .def,$(all_moldname)): %.def: ${mingwrt_srcdir}/moldname.def.in
351 $(CC) -C -E -P -D__FILENAME__=$@ -xc-header $< > $@
353 all-mingwrt-libs install-mingwrt-libs: libmingw32.a libmingwex.a
354 libmingw32.a: $(addsuffix .$(OBJEXT), CRTinit CRTfmode CRTglob \
355 cpu_features CRT_fp10 txtmode main dllmain gccmain crtst tlsmcrt \
356 tlsmthread tlssup tlsthrd pseudo-reloc pseudo-reloc-list)
358 libmingw32.a libmingwex.a libm.a libmingwthrd.a libgmon.a:
359 $(AR) $(ARFLAGS) $@ $?
361 # Complex math objects, to be included in libmingwex.a
362 # (FIXME: consider whether these might be more suitably
363 # delivered in libm.a; ISO-C99 says they belong in the
364 # math library, which by POSIX convention, is libm.a)
366 vpath %.c ${mingwrt_srcdir}/mingwex
367 vpath %.c ${mingwrt_srcdir}/mingwex/complex
368 libmingwex.a: $(addsuffix .$(OBJEXT), cabs carg catan ccoshf clog creal csqrt \
369 cabsf cargf catanf ccoshl clogf crealf csqrtf cabsl cargl catanh ccosl clogl \
370 creall csqrtl cacos casin catanhf cexp cpow csin ctan cacosf casinf catanhl \
371 cexpf cpowf csinf ctanf cacosh casinh catanl cexpl cpowl csinh ctanh cacoshf \
372 casinhf ccos cimag cproj csinhf ctanhf cacoshl casinhl ccosf cimagf cprojf \
373 csinhl ctanhl cacosl casinl ccosh cimagl cprojl csinl ctanl)
375 libmingwex.a: $(addsuffix .$(OBJEXT), isblank iswblank)
377 # Floating point environment control, in libmingwex.a
378 # (FIXME: once again, maybe better delivered in libm.a)
380 libmingwex.a: $(addsuffix .$(OBJEXT), fegetenv fesetenv feupdateenv \
381 feclearexcept feraiseexcept fetestexcept feholdexcept fegetexceptflag \
382 fesetexceptflag fegetround fesetround)
384 # David Gay's "gdtoa" API, provided in libmingwex.a, and used
385 # by MinGW's ISO-C conforming printf() routines for formatting
386 # floating point output.
388 vpath %.c ${mingwrt_srcdir}/mingwex/gdtoa
389 libmingwex.a: $(addsuffix .$(OBJEXT), g__fmt gethex strtopx g_dfmt gdtoa \
390 gmisc smisc sum g_ffmt hd_init strtodg ulp dmisc g_xfmt hexnan strtodnrp \
393 # "inttypes" conversion routines, provided in libmingwex.a
395 libmingwex.a: $(addsuffix .$(OBJEXT), \
396 imaxabs imaxdiv strtoimax strtoumax wcstoimax wcstoumax)
398 # Additional math functions, augmenting Microsoft's paltry
399 # selection, also delivered in libmingwex.a, (FIXME: and yet
400 # again, perhaps libm.a would be a better fit)
402 vpath %.c ${mingwrt_srcdir}/mingwex/math
403 vpath %.S ${mingwrt_srcdir}/mingwex/math
404 libmingwex.a: $(addsuffix .$(OBJEXT), cosf cosl acosf acosl sinf sinl asinf \
405 asinl tanf tanl atanf atanl atan2f atan2l coshf coshl acosh acoshf acoshl \
406 sinhf sinhl asinh asinhf asinhl tanhf tanhl atanh atanhf atanhl cbrt cbrtf \
407 cbrtl ceilf ceill copysign copysignf copysignl erfl s_erf sf_erf expf expl \
408 exp2 exp2f exp2l expm1 expm1f expm1l fabs fabsf fabsl fdim fdimf fdiml \
409 floorf floorl fma fmaf fmal fmax fmaxf fmaxl fmin fminf fminl fmodf fmodl \
410 fp_consts fp_constsf fp_constsl fpclassify fpclassifyf fpclassifyl frexpf \
411 frexpl fucom hypotf hypotl ilogb ilogbf ilogbl isnan isnanf isnanl ldexpf \
412 ldexpl lgamma lgammaf lgammal llrint llrintf llrintl log10f log10l log1p \
413 log1pf log1pl log2 log2f log2l logb logbf logbl logf logl lrint lrintf \
414 lrintl llround llroundf llroundl lround lroundf lroundl modff modfl \
415 nearbyint nearbyintf nearbyintl nextafterf nextafterl nexttoward nexttowardf \
416 powf powl powi powif powil remainder remainderf remainderl remquo remquof \
417 remquol rint rintf rintl round roundf roundl scalbn scalbnf scalbnl signbit \
418 signbitf signbitl sqrtf sqrtl tgamma tgammaf tgammal trunc truncf truncl)
420 # Replacement I/O functions in libmingwex.a, providing better POSIX
421 # compatibility than their Microsoft equivalents.
423 vpath %.c ${mingwrt_srcdir}/mingwex/stdio
424 libmingwex.a: $(addsuffix .$(OBJEXT), btowc fopen64 fprintf fseeko64 ftello64 \
425 lseek64 pformat printf snprintf snwprintf sprintf vfprintf vfscanf vfwscanf \
426 vprintf vscanf vsnprintf vsnwprintf vsprintf vsscanf vswscanf vwscanf)
428 # FIXME: We should adopt a semantic implementation similar to the
429 # dlsym( RTLD_DEFAULT, "_get_output_format" ) call in POSIX, to let
430 # us handle the following fall-back more effectively.
432 # pformat.$(OBJEXT) needs an explicit build rule; we always build it
433 # assuming that __MSVCRT_VERSION__ >= 0x0800, (and thus assuming that
434 # the Microsoft runtime provides the _get_output_format() function);
435 # we then rely on ofmt_stub.s, (in the top mingwrt source directory),
436 # to provide a fall-back implementation, so maintaining forward
437 # compatibility for earlier versions of MSVCRT.DLL
439 PFORMAT_CFLAGS = -I ${mingwrt_srcdir}/mingwex/gdtoa -D__MSVCRT_VERSION__=0x0800
440 pformat.$(OBJEXT): %.$(OBJEXT): %.c
441 $(CC) -c $(ALL_CFLAGS) $(PFORMAT_CFLAGS) $< -o $@
443 # Some additional miscellaneous functions, in libmingwex.a
445 #libmingwex.a: $(addsuffix .$(OBJEXT), glob membarrier)
446 libmingwex.a: $(addsuffix .$(OBJEXT), mingw-aligned-malloc mingw-fseek)
447 libmingwex.a: $(addsuffix .$(OBJEXT), getopt basename dirname ftruncate usleep)
449 libmingwex.a: $(addsuffix .$(OBJEXT), tdelete tfind tsearch twalk)
451 libmingwex.a: $(addsuffix .$(OBJEXT), _Exit atoll lltoa lltow \
454 libmingwex.a: gettimeofday.$(OBJEXT)
455 libmingwex.a: $(addsuffix .$(OBJEXT), dirent wdirent)
457 libmingwex.a: $(addsuffix .$(OBJEXT), fwide mbrtowc mbsinit wcrtomb wcstof \
458 wcstold wctob wmemchr wmemcmp wmemcpy wmemmove wmemset)
460 libmingwex.a: $(addsuffix .$(OBJEXT), wctrans wctype)
462 # For the math sources, we support the convention that a single
463 # quux_generic.c source file will produce three objects: quux.o,
464 # quuxf.o, and quuxl.o; since a change in the common source file
465 # will require all three objects to be recompiled, we may handle
466 # this with a single, multiple target, pattern rule.
468 $(addsuffix .$(OBJEXT), % %f %l): %_generic.c
469 $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) -o $*.$(OBJEXT) $<
470 $(CC) -c -D FUNCTION=$*f $(CPPFLAGS) $(ALL_CFLAGS) -o $*f.$(OBJEXT) $<
471 $(CC) -c -D FUNCTION=$*l $(CPPFLAGS) $(ALL_CFLAGS) -o $*l.$(OBJEXT) $<
473 # The llround.o, llroundf.o, and llroundl.o variants are a special
474 # case of the preceding rule; (the source is lround_generic.c rather
475 # than llround_generic.c). We can handle this using the following
476 # static pattern rule, (compiling each object individually).
478 $(addsuffix .$(OBJEXT), llround llroundf llroundl): %.$(OBJEXT): lround_generic.c
479 $(CC) -c -D FUNCTION=$* $(CPPFLAGS) $(ALL_CFLAGS) -o $@ $<
481 all-mingwrt-libs install-mingwrt-libs: libm.a
482 # Historically, MinGW.org's libm.a has been a dummy, delivering
483 # nothing of value; FIXME: IMO, this sucks; it should deliver the
484 # non-MSVCRT.DLL math functions, as noted above.
486 libm.a: libm_dummy.$(OBJEXT)
487 libm_dummy.c: Makefile
488 echo "static int __mingw_libm_dummy;" > $@
490 # Thread support libraries.
492 all-mingwrt-libs install-mingwrt-libs: libmingwthrd.a libmingwthrd_old.a
493 libmingwthrd.a libmingwthrd_old.a: crtmt.$(OBJEXT)
494 mingwthrd_old.def mingwm10.dll: $(addsuffix .$(OBJEXT), mthr mthr_init)
496 $(DLLTOOL) --as $(AS) --output-def $@ $^
498 libmingwthrd_old.a: lib%.a: %.def
499 $(DLLTOOL) --as $(AS) --input-def $< --dllname mingwm10.dll --output-lib $@
500 $(AR) $(ARFLAGS) $@ $(call extra_objects_filter,$^)
502 all-mingwrt-dll install-mingwrt-dll-files: mingwm10.dll
503 mingwm10.dll: mingwthrd_old.def
504 $(CC) -shared -o $@ -Wl,--image-base,0x6FBC0000 \
505 -Wl,--entry,_DllMainCRTStartup@12 $^
507 # Code profiling support, using the GNU profiling library; (note
508 # that applications using this library MUST be licensed to comply
509 # with the GNU General Public License).
511 all-mingwrt-libs install-mingwrt-libs: libgmon.a
512 libgmon.a: $(addsuffix .$(OBJEXT), gmon mcount profil)
518 # Users may expect to be able to specify DESTDIR, to stage the
519 # following stock installation directories outside of the regular
520 # "as configured" installation tree; unfortunately, this expectation
521 # MUST fail, when the stock path is in MS-Windows absolute format, so
522 # we provide an exception mechanism to forbid such usage, and we
523 # proceed to create the directories only when the exception is
526 .PHONY: DESTDIR-UNSUPPORTED
527 bindir docdir includedir libdir mandir htmldir pdfdir:
528 @test -z "$(strip ${DESTDIR})" || case $($@) in ${DESTDIR}?:*) \
529 $(MAKE) --no-print-directory reject=$@ DESTDIR-UNSUPPORTED;; \
531 $(mkinstalldirs) $($@)
533 # Note: we MUST use a recursive make invocation here, as the
534 # "error" function within the accompanying diagnostics would be
535 # triggered, irrespective of its placement in an unexecuted
536 # branch of the above exception trapping shell code.
539 $(call MSG_DESTDIR_FORBIDDEN,$(reject),$($(reject):${DESTDIR}%=%))
541 # The following macros, which rely heavily on GNU make's "call"
542 # function, define the diagnostics to be emitted, when the DESTDIR
543 # exception is triggered.
546 MSG_DESTDIR_FORBIDDEN = \
547 $(warning *** $(call MSG_DESTDIR_PATH_CONFLICT,$1,Win32,$2);) \
548 $(error try $(call QUOTE,$(call MSG_DESTDIR_ALTERNATIVE,$1,$2)) instead)
549 MSG_DESTDIR_BAD_PATH = DESTDIR is not supported when $1 contains $2 path $3
550 MSG_DESTDIR_PATH_CONFLICT = $(call MSG_DESTDIR_BAD_PATH,$1,$2,$(call QUOTE,$3))
551 MSG_DESTDIR_ALTERNATIVE = make install $1="$(call MSG_DESTDIR_TRANSFORM,$2)"
552 MSG_DESTDIR_TRANSFORM = ${DESTDIR}$(shell echo $1 | sed 's/^.://')
554 # Install everything.
556 install: install-mingwrt
557 install-stage-1-only: install-headers install-libdir-objects install-libs
558 install-stage-1-and-2: install-stage-1-only install-bin
559 install-gcc: install-stage-1-only
561 # Install licence files.
563 install-license: install-mingwrt-license
564 install-licence install-mingwrt-licence: %-licence: %-license
566 vpath DISCLAIMER ${mingwrt_srcdir}
567 vpath COPYING ${mingwrt_srcdir}/profile
568 vpath CYGWIN_LICENSE ${mingwrt_srcdir}/profile
569 mingwrt-license-files: COPYING CYGWIN_LICENSE DISCLAIMER
571 # FIXME: The following rule is generalized, such that it may accommodate
572 # both mingwrt and w32api, (and other packages); thus, it should ideally
573 # be relocated into a common (shared) Makefile fragment.
575 install-mingwrt-license install-w32api-license: install-%: docdir %-files
577 $(mkinstalldirs) ${docdir}/$*/$(PACKAGE_VERSION)
578 $(INSTALL_DATA) $^ ${docdir}/$*/$(PACKAGE_VERSION)
580 # Install headers associated with the MinGW runtime libraries.
582 includedirs: mingwrt-includedirs
583 install-headers install-mingwrt: install-mingwrt-headers
585 ${includedir}/sys: includedir
586 mingwrt-includedirs: ${includedir}/sys
589 install-mingwrt-headers: mingwrt-includedirs
590 $(INSTALL_DATA) ${mingwrt_srcdir}/include/*.h ${includedir}
591 $(INSTALL_DATA) ${mingwrt_srcdir}/include/sys/*.h ${includedir}/sys
592 $(INSTALL_DATA) ${mingwrt_srcdir}/profile/*.h ${includedir}
594 # Install libraries, and supporting free standing object files.
596 install-libs install-mingwrt: install-mingwrt-libdir-libs
597 install-libdir-objects install-mingwrt: install-mingwrt-libdir-objects
599 install-mingwrt-libdir-libs: libdir $(call active_goals,install,mingwrt-libs)
600 install-mingwrt-libdir-objects: libdir $(call active_goals,install,crt-objects)
602 install-crt-objects install-deprecated-crt-objects \
603 install-mingwrt-libs install-deprecated-mingwrt-libs:
604 $(INSTALL_DATA) $^ ${libdir}
608 install-mingwrt: install-mingwrt-dll
609 install-bin install-dll: install-mingwrt-dll
610 install-mingwrt-bin install-w32api-bin: install-%-bin: install-%-dll
611 install-mingwrt-dll install-w32api-dll: install-%-dll: bindir install-%-dll-files
613 $(INSTALL_DATA) $^ ${bindir}
617 install-man install-manpages: install-mingwrt-manpages
618 format_manpage = sed "s/%PAGEREF%/`echo $1 | tr a-z A-Z` $2/"
620 vpath %.man ${mingwrt_srcdir}/man
621 basename.$(man3ext) dirname.$(man3ext): %.$(man3ext): dirname.man
622 $(call format_manpage,$*,$(man3ext)) $< > $@
624 mingwrt-man$(man3ext): basename.$(man3ext) dirname.$(man3ext)
626 install-mingwrt-manpages: mandir mingwrt-man3
628 $(mkinstalldirs) ${man$*dir}
629 $(INSTALL_DATA) $^ ${man$*dir}
637 dist: devdist dlldist licdist mandist srcdist
638 $(RM) -r dist/mingwrt dist/w32api
640 mingwrt-dist-staged w32api-dist-staged: %-dist-staged:
642 $(MAKE) --no-print-directory prefix=`pwd`/dist/$* install-$*
644 devdist: mingwrt-devdist
645 mingwrt_devdist_objects = dist/mingwrt/lib/*.$(OBJEXT)
646 mingwrt-devdist w32api-devdist: %-devdist: %-dist-staged
647 $(STRIP) -g $($*_devdist_objects) dist/$*/lib/*.a
648 cd dist/$* && tar chf - --hard-dereference include lib | \
649 xz -c > ../$*-$(PACKAGE_RELEASE_TAG)-dev.tar.xz
651 dlldist: mingwrt-dlldist
652 mingwrt-dlldist: %-dlldist: %-dist-staged
653 $(STRIP) dist/$*/bin/*.dll
654 cd dist/$* && tar chf - --hard-dereference bin | \
655 xz -c > ../$*-$(PACKAGE_RELEASE_TAG)-dll.tar.xz
657 licdist: mingwrt-licdist
658 mingwrt-licdist w32api-licdist: %-licdist:
660 $(MAKE) --no-print-directory prefix=`pwd`/tmp install-$*-licence
661 cd tmp && tar chf - --hard-dereference * | \
662 xz -c > ../dist/$*-$(PACKAGE_RELEASE_TAG)-lic.tar.xz
665 mandist: mingwrt-mandist
666 mingwrt-mandist: %-mandist:
668 $(MAKE) --no-print-directory prefix=`pwd`/tmp install-$*-manpages
669 cd tmp && tar chf - --hard-dereference share | \
670 xz -c > ../dist/$*-$(PACKAGE_RELEASE_TAG)-man.tar.xz
673 srcdist: mingwrt-srcdist
674 mingwrt-srcdist: mingwrt-srcdist-dir mingwrt-srcdist-files
675 cd dist && tar chf - $(PACKAGE_TARNAME)-$(PACKAGE_VERSION) | \
676 xz -c > $(PACKAGE_TARNAME)-$(PACKAGE_RELEASE_TAG)-src.tar.xz
677 $(RM) -r dist/$(PACKAGE_TARNAME)-$(PACKAGE_VERSION)
680 $(RM) -r dist/$(PACKAGE_TARNAME)-$(PACKAGE_VERSION)
681 $(mkinstalldirs) dist/$(PACKAGE_TARNAME)-$(PACKAGE_VERSION)
683 mingwrt-srcdist-files:
684 (cd ${mingwrt_srcdir} && tar chf - --hard-dereference $(notdir $^)) | \
685 (cd dist/$(PACKAGE_TARNAME)-$(PACKAGE_VERSION) && tar xf -)
687 mingwrt-srcdist-files: $(wildcard ${mingwrt_srcdir}/*.[chs]) \
688 $(addprefix ${mingwrt_srcdir}/,ChangeLog CONTRIBUTORS DISCLAIMER README) \
689 $(wildcard ${mingwrt_srcdir}/*.def.in) $(wildcard ${mingwrt_srcdir}/config*) \
690 $(addprefix ${mingwrt_srcdir}/,aclocal.m4 install-sh Makefile.in TODO) \
691 $(addprefix ${mingwrt_srcdir}/,include man mingwex profile) \
692 $(addprefix ${mingwrt_srcdir}/,crtdll.def) \
693 $(wildcard ${mingwrt_srcdir}/*.txt)
695 install-html install-pdf: install-%: %dir mingwrt-man$(man3ext)
696 $(MAKE) --no-print-directory install-$*-files
698 install-html-files install-pdf-files: install-%-files: \
699 $(addsuffix .%,$(wildcard ${man3dir}/*.$(man3ext)))
701 %.$(man3ext).html: %.$(man3ext)
702 man2html $< | sed -e '1,/^<!DOCTYPE/{/^<!/p;d' -e '}' > ${htmldir}/$(notdir $@)
703 chmod 644 ${htmldir}/$(notdir $@)
705 %.$(man3ext).pdf: %.$(man3ext)
706 man -t $< | ps2pdf - > ${pdfdir}/$(notdir $@)
707 chmod 644 ${pdfdir}/$(notdir $@)
709 html-docdist pdf-docdist: %-docdist:
711 $(MAKE) --no-print-directory prefix=`pwd`/tmp install-$*
712 $(RM) -r tmp/share/man
713 cd tmp && tar chf - --hard-dereference share | \
714 xz -c > ../dist/mingwrt-doc-$(PACKAGE_RELEASE_TAG)-$*.tar.xz
721 clean-local: mostlyclean-local
722 $(RM) msvcr*.def moldname*.def mingw*.def lib*.a *.dll
725 $(RM) *.d *.$(OBJEXT)
727 distclean-local: clean-local
728 $(RM) config.log config.status libm_dummy.c
730 maintainer-clean-warning:
731 $(warning $(MAKE) $(@:%-warning=%))
732 $(warning This command should be used by package maintainers only;)
733 $(warning it deletes files which may require special tools to rebuild.)
735 maintainer-clean-local: maintainer-clean-warning distclean-local
736 $(RM) -r ${mingwrt_srcdir}/autom4te.cache
738 clean mostlyclean distclean maintainer-clean: %clean: %clean-local
740 # $RCSfile$: end of file