OSDN Git Service

Correct omission of complex conjugate functions from libmingwex.a
[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, 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 NTDDI_VERSION_SPEC := -D NTDDI_VERSION=0x04000000
40
41 # Build paths and macros.
42 #
43 srcdir = @srcdir@
44 top_srcdir = @top_srcdir@
45 mingwrt_srcdir = @srcdir@
46 w32api_srcdir = @w32api_srcdir@
47 abs_builddir = @abs_builddir@
48
49 CC = @CC@
50 CFLAGS = @CFLAGS@
51 CPPFLAGS = @CPPFLAGS@
52
53 OBJEXT = @OBJEXT@
54
55 AR = @AR@
56 ARFLAGS = @ARFLAGS@
57 RANLIB = @RANLIB@
58
59 AS = @AS@
60 COMPILE.sx = @COMPILE_SX@
61 DLLTOOL = @DLLTOOL@
62 STRIP = @STRIP@
63 NM = @NM@
64
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
69
70 include_deprecated = @include_deprecated@
71 active_goals = $1-$2 $(if $(include_deprecated),$1-deprecated-$2)
72
73 all-stage-1: $(call active_goals,all,mingwrt-stage-1)
74 all-stage-1-and-2: $(call active_goals,all,mingwrt)
75
76 # Installation paths and macros.
77 #
78 prefix = @prefix@
79 exec_prefix = @exec_prefix@
80 bindir = ${DESTDIR}@bindir@
81
82 datarootdir = @datarootdir@
83 docdir = ${DESTDIR}${datarootdir}/doc
84 includedir = ${DESTDIR}@includedir@
85 libdir = ${DESTDIR}@libdir@
86
87 htmldir = @htmldir@
88 pdfdir = @pdfdir@
89
90 mandir = ${DESTDIR}@mandir@
91 man3dir = ${mandir}/man$(man3ext)
92
93 man3ext = 3
94
95 INSTALL = @INSTALL@
96 INSTALL_DATA = @INSTALL_DATA@
97
98 mkinstalldirs = @MKDIR_P@
99
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 ...
104 #
105 vpath configure ${top_srcdir}
106 config.status: configure
107         $(SHELL) config.status --recheck
108
109 # ... in which case, updating Makefile should be a simple matter of
110 # running config.status ...
111 #
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
116         $(RM) Makefile.stub
117
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.
122 #
123 config.status.missing:
124         $(warning *** cannot execute config.status)
125         $(error please run ${top_srcdir}/configure to regenerate it.)
126
127 # If configure itself needs to be updated, we must run autoconf in the
128 # top level source directory.
129 #
130 vpath %.m4 ${top_srcdir}
131 vpath configure.ac ${top_srcdir}
132 configure: configure.ac aclocal.m4
133         cd ${top_srcdir}; autoconf
134
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.
138 #
139 sinclude *.d
140 DEPFLAGS = -MMD -MP
141 INCLUDES = -nostdinc -I . -I ${top_srcdir}/include -I ${w32api_srcdir}/include \
142   -I ${top_srcdir} -I ${top_srcdir}/profile -iwithprefixbefore include
143
144 ALL_CFLAGS = $(CFLAGS) $(DEPFLAGS) $(INCLUDES) $(NTDDI_VERSION_SPEC)
145
146 # The general case, for compiling object files from C source,
147 # requires a small adjustment to the default implicit rule.
148 #
149 %.$(OBJEXT): %.c
150         $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) -o $@ $<
151
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.
155 #
156 w%.$(OBJEXT): %.c
157         $(CC) -c -D UNICODE $(CPPFLAGS) $(ALL_CFLAGS) -o $@ $<
158
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.
165 #
166 %.$(OBJEXT): %.sx
167         $(COMPILE.sx) $($*_cflags) -o $@ $<
168
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).
175 #
176 all-mingwrt-objects: $(call active_goals,all,crt-objects)
177 all-deprecated-mingwrt-objects: all-deprecated-crt-objects
178
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.
184 #
185 all-crt-objects install-crt-objects: $(addsuffix .$(OBJEXT), crt2 crtmt \
186   crtst dllcrt2 gcrt2 CRT_fp8 CRT_fp10 CRT_noglob binmode txtmode)
187
188 all-deprecated-crt-objects install-deprecated-crt-objects: \
189   $(addsuffix .$(OBJEXT), crt1 dllcrt1 gcrt1)
190
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.
195 #
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...
199 #
200 vpath %.c ${mingwrt_srcdir}
201 $(addsuffix .$(OBJEXT), crt1 dllcrt1): %.$(OBJEXT): %.c
202         $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) -D__CRTDLL__ -o $@ $<
203
204 # ...while, for the current build case, we need an explicit mapping
205 # to identify the disparately named source file.
206 #
207 $(addsuffix .$(OBJEXT), crt2 dllcrt2): %2.$(OBJEXT): %1.c
208         $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) -o $@ $<
209
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.
215 #
216 vpath %.c ${mingwrt_srcdir}/profile
217 $(addsuffix .$(OBJEXT), gcrt0 gcrt1 gcrt2): %.$(OBJEXT): gcrt0.c
218         $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) -o $@ $<
219
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.
223 #
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.
230 #
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 ) \
234   }'
235
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); \
240      }
241
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 ) \
247           : "t", ext; \
248       }'
249
250 # We categorize our import libraries into "standard" (a.k.a. "release")
251 # versions, augmented by corresponding "debug" variants.
252 #
253 std_msvcrt := $(addprefix msvcr,t $(msvcrt_versions))
254 all_msvcrt := $(std_msvcrt) $(addsuffix d,$(std_msvcrt))
255
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
260
261 # For each import library to be built, we derive a tailored exports
262 # definition file, from a common source.
263 #
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,$*)` \
268           -xc-header $< > $@
269
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.
276 #
277 msvcrt_repl_prefix = __msvcrt
278 msvcrt_repl_funcs = printf fprintf sprintf vprintf vfprintf vsprintf
279
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...
292 #
293 dlltool_temp_prefix = $(NM) $(1) | sed -n -e '/t.o:$$/{s///p;q' -e '}'
294
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...
298 #
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') \
303   -e '}'
304
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.
308 #
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,$@)`*
320
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
328 #
329 std_moldname := moldname $(addprefix moldname,$(msvcrt_versions))
330 all_moldname := $(std_moldname) $(addsuffix d,$(std_moldname))
331
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,$^)
338
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.
342 #
343 $(foreach name,coldname $(all_moldname),lib$(name).a): $(addsuffix .$(OBJEXT), \
344   isascii iscsym iscsymf strcasecmp strncasecmp toascii wcscmpi)
345
346 coldname.def: %.def: ${mingwrt_srcdir}/moldname.def.in
347         $(CC) -C -E -P -D__FILENAME__=$@ -D__CRTDLL__ -xc-header $< > $@
348
349 $(addsuffix .def,$(all_moldname)): %.def: ${mingwrt_srcdir}/moldname.def.in
350         $(CC) -C -E -P -D__FILENAME__=$@ -xc-header $< > $@
351
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)
356
357 libmingw32.a libmingwex.a libm.a libmingwthrd.a libgmon.a:
358         $(AR) $(ARFLAGS) $@ $?
359
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)
364 #
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)
373
374 libmingwex.a: $(addsuffix .$(OBJEXT), isblank iswblank)
375
376 # Floating point environment control, in libmingwex.a
377 # (FIXME: once again, maybe better delivered in libm.a)
378 #
379 libmingwex.a: $(addsuffix .$(OBJEXT), fegetenv fesetenv feupdateenv \
380   feclearexcept feraiseexcept fetestexcept feholdexcept fegetexceptflag \
381   fesetexceptflag fegetround fesetround)
382
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.
386 #
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 \
390   dtoa misc strtof)
391
392 # "inttypes" conversion routines, provided in libmingwex.a
393 #
394 libmingwex.a: $(addsuffix .$(OBJEXT), \
395   imaxabs imaxdiv strtoimax strtoumax wcstoimax wcstoumax)
396
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)
400 #
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)
418
419 # Replacement I/O functions in libmingwex.a, providing better POSIX
420 # compatibility than their Microsoft equivalents.
421 #
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)
426
427 # pformat.$(OBJEXT) needs an explicit build rule, since we need to
428 # specify an additional header file path.
429 #
430 PFORMAT_CFLAGS = -I ${mingwrt_srcdir}/mingwex/gdtoa
431 pformat.$(OBJEXT): %.$(OBJEXT): %.c
432         $(CC) -c $(ALL_CFLAGS) $(PFORMAT_CFLAGS) $< -o $@
433
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:
437 #
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 $@ $<
441
442 # Some additional miscellaneous functions, in libmingwex.a
443 #
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)
447
448 libmingwex.a: $(addsuffix .$(OBJEXT), tdelete tfind tsearch twalk)
449
450 libmingwex.a: $(addsuffix .$(OBJEXT), _Exit atoll lltoa lltow \
451   ulltoa ulltow wtoll)
452
453 libmingwex.a: gettimeofday.$(OBJEXT)
454 libmingwex.a: $(addsuffix .$(OBJEXT), dirent wdirent dlfcn)
455
456 libmingwex.a: $(addsuffix .$(OBJEXT), fwide mbrtowc mbsinit wcrtomb wcstof \
457   wcstold wctob wmemchr wmemcmp wmemcpy wmemmove wmemset)
458
459 libmingwex.a: $(addsuffix .$(OBJEXT), wctrans wctype)
460
461 # For the math sources, we support the convention that a single
462 # quux_generic.c source file will produce three objects: quux.o,
463 # quuxf.o, and quuxl.o; since a change in the common source file
464 # will require all three objects to be recompiled, we may handle
465 # this with a single, multiple target, pattern rule.
466 #
467 $(addsuffix .$(OBJEXT), % %f %l): %_generic.c
468         $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) -o $*.$(OBJEXT) $<
469         $(CC) -c -D FUNCTION=$*f $(CPPFLAGS) $(ALL_CFLAGS) -o $*f.$(OBJEXT) $<
470         $(CC) -c -D FUNCTION=$*l $(CPPFLAGS) $(ALL_CFLAGS) -o $*l.$(OBJEXT) $<
471
472 # The llround.o, llroundf.o, and llroundl.o variants are a special
473 # case of the preceding rule; (the source is lround_generic.c rather
474 # than llround_generic.c).  We can handle this using the following
475 # static pattern rule, (compiling each object individually).
476 #
477 $(addsuffix .$(OBJEXT), llround llroundf llroundl): %.$(OBJEXT): lround_generic.c
478         $(CC) -c -D FUNCTION=$* $(CPPFLAGS) $(ALL_CFLAGS) -o $@ $<
479
480 # Historically, MinGW.org's libm.a has been a dummy, delivering
481 # nothing of value; FIXME: IMO, this sucks; it should deliver the
482 # non-MSVCRT.DLL math functions, as noted above.
483 #
484 all-mingwrt-libs install-mingwrt-libs: libm.a
485 libm.a: libm_dummy.$(OBJEXT)
486 libm_dummy.c: Makefile
487         echo "static int __mingw_libm_dummy;" > $@
488
489 # The mingwrt headers define a number of functions which are normally
490 # expected to be compiled as inline code.  Each such function must also
491 # be provided with an externally visible entry point; we provide such
492 # entry points as stubs in libmingwex.a, via the following rules:
493 #
494 sinclude Makefile.stub
495 vpath jmpstub.sx ${mingwrt_srcdir}/mingwex
496 libstub_refnames = grep -lr '__$1.*FUNCTION *=' ${mingwrt_srcdir}
497 jmpstub_prerequisites := $(shell $(call libstub_refnames,JMPSTUB)/include)
498 libimpl_prerequisites := $(shell $(call libstub_refnames,LIBIMPL)/include)
499 Makefile.stub: Makefile $(jmpstub_prerequisites) $(libimpl_prerequisites)
500         echo "# $@: automatically generated file -- do not edit!" > $@
501         $(call jmpstub_awk_script,$(jmpstub_prerequisites)) >> $@
502         $(call libimpl_awk_script,$(libimpl_prerequisites)) >> $@
503         echo "# $@: end of file" >> $@
504
505 # Stubs are categorized into either of JMPSTUB or LIBIMPL classes;
506 # the rules for building the JMPSTUP inplementations are written to
507 # Makefile.stub, by processing each of their defining header files
508 # through the following awk script...
509 #
510 jmpstub_awk_script = test -z "$1" || awk '\
511   BEGIN { \
512     symbol = "([A-Z_a-z][A-Z_a-z0-9]*)"; \
513     fmt = "\nlib%s.a: %s\n%s: jmpstub.sx\n\t$$(COMPILE.sx) %s -o $$@ $$^\n"; \
514   } \
515   /__JMPSTUB(__)? *[(].*FUNCTION/ { \
516     LIB = "mingwex"; \
517     FUNCTION = gensub( ".*[ ,(:]FUNCTION *= *"symbol".*", "\\1", 1 ); \
518     OBJNAME = gensub( "_*(.*)_*", "\\1", 1, FUNCTION )".jmpstub.$$(OBJEXT)"; \
519     OBJNAME_CFLAGS = "-D FUNCTION="FUNCTION; \
520     printf fmt, LIB, OBJNAME, OBJNAME, OBJNAME_CFLAGS; \
521   } \
522   END { \
523     printf "\n"; \
524   }' $1
525
526 # ...while this establishes the dependencies which apply for each
527 # of those in the LIBIMPL class.
528 #
529 libimpl_awk_script = test -z "$1" || awk '\
530   BEGIN { \
531     symbol = "([A-Z_a-z][A-Z_a-z0-9]*)"; \
532     fmt = "\nlib%s.a: %s\n%s.libimpl: %s\n"; \
533   } \
534   /__LIBIMPL(__)? *[(].*FUNCTION/ { \
535     LIB = "mingwex"; \
536     FUNCTION = gensub( ".*[ ,(:]FUNCTION *= *"symbol".*", "\\1", 1 ); \
537     OBJNAME = gensub( "_*(.*)_*", "\\1", 1, FUNCTION )".libimpl.$$(OBJEXT)"; \
538     printf fmt, LIB, OBJNAME, FUNCTION, FILENAME; \
539   } \
540   END { \
541     printf "\n"; \
542   }' $1
543
544 # In contrast to JMPSTUB implementations, which are best handled
545 # by individual compilation rules in Makefile.stub, generic rules
546 # are sufficient for all LIBIMPL implementations; in each case, we
547 # filter the static attribute from each defined implementation, in
548 # its defining header file, to create an intermediate C source for
549 # each individual function; (note that we also remove any pragma
550 # which identifies the originating file as a system header).
551 #
552 libimpl_sed_script = sed \
553   -e '/__CRT_ALIAS  *__LIBIMPL.*FUNCTION *= *$1[ ,)].*)/d' \
554   -e '/__CRT_INLINE  *__LIBIMPL.*FUNCTION *= *$1[ ,)].*)/d' \
555   -e '/pragma .* system_header/d'
556
557 LIBIMPL_CFLAGS = $(CFLAGS) $(INCLUDES) -fno-align-functions
558
559 # LIBIMPL dependencies are tracked using zero sized name.libimpl
560 # files; the intermediate C files are generated as a side effect
561 # of resolving these dependencies...
562 #
563 %.libimpl:
564         $(call libimpl_sed_script,$*) $< > $@.c
565         > $@
566
567 # ...and ultimately discarded, after the requisite object file
568 # has been compiled; (note that this creates a vulnerability due
569 # to possible loss of the object file, while the tracking file is
570 # still in place; to circumvent this, we must be able to force a
571 # remake of the tracking file, so also regenerating the .c file,
572 # before it is compiled).
573 #
574 libimpl_remake = { $(RM) $1; $(MAKE) --no-print-directory $1; }
575 %.libimpl.$(OBJEXT): %.libimpl
576         test -f $<.c || $(call libimpl_remake,$<)
577         $(CC) -c $(CPPFLAGS) $(LIBIMPL_CFLAGS) -o $@ $<.c
578         $(RM) $<.c
579
580 # Thread support libraries.
581 #
582 all-mingwrt-libs install-mingwrt-libs: libmingwthrd.a libmingwthrd_old.a
583 libmingwthrd.a libmingwthrd_old.a: crtmt.$(OBJEXT)
584 mingwthrd_old.def mingwm10.dll: $(addsuffix .$(OBJEXT), mthr mthr_init)
585 mingwthrd_old.def:
586         $(DLLTOOL) --as $(AS) --output-def $@ $^
587
588 libmingwthrd_old.a: lib%.a: %.def
589         $(DLLTOOL) --as $(AS) --input-def $< --dllname mingwm10.dll --output-lib $@
590         $(AR) $(ARFLAGS) $@ $(call extra_objects_filter,$^)
591
592 all-mingwrt-dll install-mingwrt-dll-files: mingwm10.dll
593 mingwm10.dll: mingwthrd_old.def
594         $(CC) -shared -o $@ -Wl,--image-base,0x6FBC0000 \
595           -Wl,--entry,_DllMainCRTStartup@12 $^
596
597 # Code profiling support, using the GNU profiling library; (note
598 # that applications using this library MUST be licensed to comply
599 # with the GNU General Public License).
600 #
601 all-mingwrt-libs install-mingwrt-libs: libgmon.a
602 libgmon.a: $(addsuffix .$(OBJEXT), gmon mcount profil)
603
604
605 # Installation Rules
606 # ------------------
607 #
608 # Users may expect to be able to specify DESTDIR, to stage the
609 # following stock installation directories outside of the regular
610 # "as configured" installation tree; unfortunately, this expectation
611 # MUST fail, when the stock path is in MS-Windows absolute format, so
612 # we provide an exception mechanism to forbid such usage, and we
613 # proceed to create the directories only when the exception is
614 # NOT triggered.
615 #
616 .PHONY: DESTDIR-UNSUPPORTED
617 bindir docdir includedir libdir mandir htmldir pdfdir:
618         @test -z "$(strip ${DESTDIR})" || case $($@) in ${DESTDIR}?:*) \
619           $(MAKE) --no-print-directory reject=$@ DESTDIR-UNSUPPORTED;; \
620           esac
621         $(mkinstalldirs) $($@)
622
623 # Note: we MUST use a recursive make invocation here, as the
624 # "error" function within the accompanying diagnostics would be
625 # triggered, irrespective of its placement in an unexecuted
626 # branch of the above exception trapping shell code.
627 #
628 DESTDIR-UNSUPPORTED:
629         $(call MSG_DESTDIR_FORBIDDEN,$(reject),$($(reject):${DESTDIR}%=%))
630
631 # The following macros, which rely heavily on GNU make's "call"
632 # function, define the diagnostics to be emitted, when the DESTDIR
633 # exception is triggered.
634 #
635 QUOTE = `$1'#'`
636 MSG_DESTDIR_FORBIDDEN = \
637   $(warning *** $(call MSG_DESTDIR_PATH_CONFLICT,$1,Win32,$2);) \
638   $(error try $(call QUOTE,$(call MSG_DESTDIR_ALTERNATIVE,$1,$2)) instead)
639 MSG_DESTDIR_BAD_PATH = DESTDIR is not supported when $1 contains $2 path $3
640 MSG_DESTDIR_PATH_CONFLICT = $(call MSG_DESTDIR_BAD_PATH,$1,$2,$(call QUOTE,$3))
641 MSG_DESTDIR_ALTERNATIVE = make install $1="$(call MSG_DESTDIR_TRANSFORM,$2)"
642 MSG_DESTDIR_TRANSFORM = ${DESTDIR}$(shell echo $1 | sed 's/^.://')
643
644 # Install everything.
645 #
646 install: install-mingwrt
647 install-stage-1-only: install-headers install-libdir-objects install-libs
648 install-stage-1-and-2: install-stage-1-only install-bin
649 install-gcc: install-stage-1-only
650
651 # Install licence files.
652 #
653 install-license: install-mingwrt-license
654 install-licence install-mingwrt-licence: %-licence: %-license
655
656 vpath DISCLAIMER ${mingwrt_srcdir}
657 vpath COPYING ${mingwrt_srcdir}/profile
658 vpath CYGWIN_LICENSE ${mingwrt_srcdir}/profile
659 mingwrt-license-files: COPYING CYGWIN_LICENSE DISCLAIMER
660
661 # FIXME: The following rule is generalized, such that it may accommodate
662 # both mingwrt and w32api, (and other packages); thus, it should ideally
663 # be relocated into a common (shared) Makefile fragment.
664 #
665 install-mingwrt-license install-w32api-license: install-%: docdir %-files
666 %-license-files:
667         $(mkinstalldirs) ${docdir}/$*/$(PACKAGE_VERSION)
668         $(INSTALL_DATA) $^ ${docdir}/$*/$(PACKAGE_VERSION)
669
670 # Install headers associated with the MinGW runtime libraries.
671 #
672 includedirs: mingwrt-includedirs
673 install-headers install-mingwrt: install-mingwrt-headers
674
675 ${includedir}/sys: includedir
676 mingwrt-includedirs: ${includedir}/sys
677         $(mkinstalldirs) $^
678
679 install-mingwrt-headers: mingwrt-includedirs
680         $(INSTALL_DATA) ${mingwrt_srcdir}/include/*.h ${includedir}
681         $(INSTALL_DATA) ${mingwrt_srcdir}/include/sys/*.h ${includedir}/sys
682         $(INSTALL_DATA) ${mingwrt_srcdir}/profile/*.h ${includedir}
683
684 # Install libraries, and supporting free standing object files.
685 #
686 install-libs install-mingwrt: install-mingwrt-libdir-libs
687 install-libdir-objects install-mingwrt: install-mingwrt-libdir-objects
688
689 install-mingwrt-libdir-libs: libdir $(call active_goals,install,mingwrt-libs)
690 install-mingwrt-libdir-objects: libdir $(call active_goals,install,crt-objects)
691
692 install-crt-objects install-deprecated-crt-objects \
693 install-mingwrt-libs install-deprecated-mingwrt-libs:
694         $(INSTALL_DATA) $^ ${libdir}
695
696 # Install DLLs.
697 #
698 install-mingwrt: install-mingwrt-dll
699 install-bin install-dll: install-mingwrt-dll 
700 install-mingwrt-bin install-w32api-bin: install-%-bin: install-%-dll
701 install-mingwrt-dll install-w32api-dll: install-%-dll: bindir install-%-dll-files
702 install-%-dll-files:
703         $(INSTALL_DATA) $^ ${bindir}
704
705 # Install manpages.
706 #
707 install-man install-manpages: install-mingwrt-manpages
708 format_manpage = sed "s/%PAGEREF%/`echo $1 | tr a-z A-Z` $2/"
709
710 vpath %.man ${mingwrt_srcdir}/man
711 basename.$(man3ext) dirname.$(man3ext): %.$(man3ext): dirname.man
712         $(call format_manpage,$*,$(man3ext)) $< > $@
713
714 mingwrt-man$(man3ext): basename.$(man3ext) dirname.$(man3ext)
715
716 install-mingwrt-manpages: mandir mingwrt-man3
717 mingwrt-man%:
718         $(mkinstalldirs) ${man$*dir}
719         $(INSTALL_DATA) $^ ${man$*dir}
720         $(RM) $^
721
722
723 # Distribution
724 # ------------
725 #
726 .PHONY: dist
727 dist: devdist dlldist licdist mandist srcdist
728         $(RM) -r dist/mingwrt dist/w32api
729
730 mingwrt-dist-staged w32api-dist-staged: %-dist-staged:
731         $(RM) -r dist/$*
732         $(MAKE) --no-print-directory prefix=`pwd`/dist/$* install-$*
733
734 devdist: mingwrt-devdist
735 mingwrt_devdist_objects = dist/mingwrt/lib/*.$(OBJEXT)
736 mingwrt-devdist w32api-devdist: %-devdist: %-dist-staged
737         $(STRIP) -g $($*_devdist_objects) dist/$*/lib/*.a
738         cd dist/$* && tar chf - --hard-dereference include lib | \
739           xz -c > ../$*-$(PACKAGE_RELEASE_TAG)-dev.tar.xz
740
741 dlldist: mingwrt-dlldist
742 mingwrt-dlldist: %-dlldist: %-dist-staged
743         $(STRIP) dist/$*/bin/*.dll
744         cd dist/$* && tar chf - --hard-dereference bin | \
745           xz -c > ../$*-$(PACKAGE_RELEASE_TAG)-dll.tar.xz
746
747 licdist: mingwrt-licdist
748 mingwrt-licdist w32api-licdist: %-licdist:
749         $(RM) -r tmp
750         $(MAKE) --no-print-directory prefix=`pwd`/tmp install-$*-licence
751         cd tmp && tar chf - --hard-dereference * | \
752           xz -c > ../dist/$*-$(PACKAGE_RELEASE_TAG)-lic.tar.xz
753         $(RM) -r tmp
754
755 mandist: mingwrt-mandist
756 mingwrt-mandist: %-mandist:
757         $(RM) -r tmp
758         $(MAKE) --no-print-directory prefix=`pwd`/tmp install-$*-manpages
759         cd tmp && tar chf - --hard-dereference share | \
760           xz -c > ../dist/$*-$(PACKAGE_RELEASE_TAG)-man.tar.xz
761         $(RM) -r tmp
762
763 srcdist: mingwrt-srcdist
764 mingwrt-srcdist: mingwrt-srcdist-dir mingwrt-srcdist-files
765         cd dist && tar chf - $(PACKAGE_TARNAME)-$(PACKAGE_VERSION) | \
766           xz -c > $(PACKAGE_TARNAME)-$(PACKAGE_RELEASE_TAG)-src.tar.xz
767         $(RM) -r dist/$(PACKAGE_TARNAME)-$(PACKAGE_VERSION)
768
769 mingwrt-srcdist-dir:
770         $(RM) -r dist/$(PACKAGE_TARNAME)-$(PACKAGE_VERSION)
771         $(mkinstalldirs) dist/$(PACKAGE_TARNAME)-$(PACKAGE_VERSION)
772
773 mingwrt-srcdist-files:
774         (cd ${mingwrt_srcdir} && tar chf - --hard-dereference $(notdir $^)) | \
775           (cd dist/$(PACKAGE_TARNAME)-$(PACKAGE_VERSION) && tar xf -)
776
777 mingwrt-srcdist-files: $(wildcard ${mingwrt_srcdir}/*.[chs]) \
778   $(addprefix ${mingwrt_srcdir}/,ChangeLog CONTRIBUTORS DISCLAIMER README) \
779   $(wildcard ${mingwrt_srcdir}/*.def.in) $(wildcard ${mingwrt_srcdir}/config*) \
780   $(addprefix ${mingwrt_srcdir}/,aclocal.m4 install-sh Makefile.in TODO) \
781   $(addprefix ${mingwrt_srcdir}/,include man mingwex profile) \
782   $(addprefix ${mingwrt_srcdir}/,crtdll.def) \
783   $(wildcard ${mingwrt_srcdir}/*.txt)
784
785 install-html install-pdf: install-%: %dir mingwrt-man$(man3ext)
786         $(MAKE) --no-print-directory install-$*-files
787
788 install-html-files install-pdf-files: install-%-files: \
789   $(addsuffix .%,$(wildcard ${man3dir}/*.$(man3ext)))
790
791 %.$(man3ext).html: %.$(man3ext)
792         man2html $< | sed -e '1,/^<!DOCTYPE/{/^<!/p;d' -e '}' > ${htmldir}/$(notdir $@)
793         chmod 644 ${htmldir}/$(notdir $@)
794
795 %.$(man3ext).pdf: %.$(man3ext)
796         man -t $< | ps2pdf - > ${pdfdir}/$(notdir $@)
797         chmod 644 ${pdfdir}/$(notdir $@)
798
799 html-docdist pdf-docdist: %-docdist:
800         $(RM) -r tmp
801         $(MAKE) --no-print-directory prefix=`pwd`/tmp install-$*
802         $(RM) -r tmp/share/man
803         cd tmp && tar chf - --hard-dereference share | \
804           xz -c > ../dist/mingwrt-doc-$(PACKAGE_RELEASE_TAG)-$*.tar.xz
805         $(RM) -r tmp
806
807
808 # Clean-up Rules
809 # --------------
810 #
811 clean-local: mostlyclean-local
812         $(RM) msvcr*.def moldname*.def mingw*.def lib*.a *.dll
813
814 mostlyclean-local:
815         $(RM) *.d *.$(OBJEXT) Makefile.stub *.libimpl
816
817 distclean-local: clean-local
818         $(RM) config.log config.status libm_dummy.c
819
820 maintainer-clean-warning:
821         $(warning $(MAKE) $(@:%-warning=%))
822         $(warning This command should be used by package maintainers only;)
823         $(warning it deletes files which may require special tools to rebuild.)
824
825 maintainer-clean-local: maintainer-clean-warning distclean-local
826         $(RM) -r ${mingwrt_srcdir}/autom4te.cache
827
828 clean mostlyclean distclean maintainer-clean: %clean: %clean-local
829
830 # $RCSfile$: end of file