all-libcrtdll install-deprecated-mingwrt-libs: libcrtdll.a libcoldname.a
all-deprecated-mingwrt all-deprecated-libmsvcrt: all-libcrtdll
-# FIXME: We should aim to remove this interim work-around...
-#
-# MSVCRT.DLL, MSVCR70.DLL, and MSVCR71.DLL, (both regular and debug
-# variants), lack the _get_output_format() function, which is required
-# by the printf() module in libmingwex.a; add our own implementation.
-# (Note that we also apply this for CRTDLL.DLL, via libcrtdll.a)
-#
-vpath ofmt_stub.s ${mingwrt_srcdir}
-$(foreach ver,t 70 71,libmsvcr$(ver).a) libcrtdll.a \
-$(foreach ver,t 70 71,libmsvcr$(ver)d.a): ofmt_stub.$(OBJEXT)
-#
-# End of work-around
-
# For each import library to be built, we derive a tailored exports
# definition file, from a common source.
#
$(CC) -C -E -P -D__FILENAME__=$@ -xc-header $< > $@
all-mingwrt-libs install-mingwrt-libs: libmingw32.a libmingwex.a
-libmingw32.a: $(addsuffix .$(OBJEXT), CRTinit CRTfmode CRTglob \
- cpu_features CRT_fp10 txtmode main dllmain gccmain crtst tlsmcrt \
- tlsmthread tlssup tlsthrd pseudo-reloc pseudo-reloc-list)
+libmingw32.a: $(addsuffix .$(OBJEXT), CRTinit CRTglob setargv \
+ CRTfmode cpu_features CRT_fp10 txtmode main dllmain gccmain crtst \
+ tlsmcrt tlsmthread tlssup tlsthrd pseudo-reloc pseudo-reloc-list)
libmingw32.a libmingwex.a libm.a libmingwthrd.a libgmon.a:
$(AR) $(ARFLAGS) $@ $?
#
vpath %.c ${mingwrt_srcdir}/mingwex
vpath %.c ${mingwrt_srcdir}/mingwex/complex
-libmingwex.a: $(addsuffix .$(OBJEXT), cabs carg catan ccoshf clog creal csqrt \
- cabsf cargf catanf ccoshl clogf crealf csqrtf cabsl cargl catanh ccosl clogl \
- creall csqrtl cacos casin catanhf cexp cpow csin ctan cacosf casinf catanhl \
- cexpf cpowf csinf ctanf cacosh casinh catanl cexpl cpowl csinh ctanh cacoshf \
- casinhf ccos cimag cproj csinhf ctanhf cacoshl casinhl ccosf cimagf cprojf \
- csinhl ctanhl cacosl casinl ccosh cimagl cprojl csinl ctanl)
+libmingwex.a: $(addsuffix .$(OBJEXT), cabs cabsf cabsl cacos cacosf \
+ cacosh cacoshf cacoshl cacosl casin casinf casinh casinhf casinhl casinl \
+ catan catanf catanh catanhf catanhl catanl ccos ccosf ccosh ccoshf ccoshl \
+ ccosl cexp cexpf cexpl clog clogf clogl cpow cpowf cpowl cproj cprojf \
+ cprojl csin csinf csinh csinhf csinhl csinl csqrt csqrtf csqrtl \
+ ctan ctanf ctanh ctanhf ctanhl ctanl)
libmingwex.a: $(addsuffix .$(OBJEXT), isblank iswblank)
lseek64 pformat printf snprintf snwprintf sprintf vfprintf vfscanf vfwscanf \
vprintf vscanf vsnprintf vsnwprintf vsprintf vsscanf vswscanf vwscanf)
-# FIXME: We should adopt a semantic implementation similar to the
-# dlsym( RTLD_DEFAULT, "_get_output_format" ) call in POSIX, to let
-# us handle the following fall-back more effectively.
-#
-# pformat.$(OBJEXT) needs an explicit build rule; we always build it
-# assuming that __MSVCRT_VERSION__ >= 0x0800, (and thus assuming that
-# the Microsoft runtime provides the _get_output_format() function);
-# we then rely on ofmt_stub.s, (in the top mingwrt source directory),
-# to provide a fall-back implementation, so maintaining forward
-# compatibility for earlier versions of MSVCRT.DLL
+# pformat.$(OBJEXT) needs an explicit build rule, since we need to
+# specify an additional header file path.
#
-PFORMAT_CFLAGS = -I ${mingwrt_srcdir}/mingwex/gdtoa -D__MSVCRT_VERSION__=0x0800
+PFORMAT_CFLAGS = -I ${mingwrt_srcdir}/mingwex/gdtoa
pformat.$(OBJEXT): %.$(OBJEXT): %.c
$(CC) -c $(ALL_CFLAGS) $(PFORMAT_CFLAGS) $< -o $@
+# To support Microsoft's DLL version specific exponent digits control,
+# and "%n" format availability control APIs, in a DLL version agnostic
+# manner, we also provide the following set of wrapper functions:
+#
+libmingwex.a: $(addsuffix fmt.$(OBJEXT),varo crto geto seto crtn getn setn)
+$(addsuffix fmt.$(OBJEXT),varo crto geto seto crtn getn setn): %.$(OBJEXT): ofmt.c
+ $(CC) -c $(ALL_CFLAGS) -D__$*__ -fno-align-functions -o $@ $<
+
# Some additional miscellaneous functions, in libmingwex.a
#
#libmingwex.a: $(addsuffix .$(OBJEXT), glob membarrier)
-libmingwex.a: $(addsuffix .$(OBJEXT), mingw-aligned-malloc mingw-fseek)
+libmingwex.a: $(addsuffix .$(OBJEXT), mingw-aligned-malloc mingw-fseek glob)
libmingwex.a: $(addsuffix .$(OBJEXT), getopt basename dirname ftruncate usleep)
libmingwex.a: $(addsuffix .$(OBJEXT), tdelete tfind tsearch twalk)
ulltoa ulltow wtoll)
libmingwex.a: gettimeofday.$(OBJEXT)
-libmingwex.a: $(addsuffix .$(OBJEXT), dirent wdirent)
+libmingwex.a: $(addsuffix .$(OBJEXT), dirent wdirent dlfcn)
libmingwex.a: $(addsuffix .$(OBJEXT), fwide mbrtowc mbsinit wcrtomb wcstof \
wcstold wctob wmemchr wmemcmp wmemcpy wmemmove wmemset)
$(addsuffix .$(OBJEXT), llround llroundf llroundl): %.$(OBJEXT): lround_generic.c
$(CC) -c -D FUNCTION=$* $(CPPFLAGS) $(ALL_CFLAGS) -o $@ $<
+# Historically, MinGW.org's libm.a has been a dummy, delivering
+# nothing of value; FIXME: IMO, this sucks; it should deliver the
+# non-MSVCRT.DLL math functions, as noted above.
+#
+all-mingwrt-libs install-mingwrt-libs: libm.a
+libm.a: libm_dummy.$(OBJEXT)
+libm_dummy.c: Makefile
+ echo "static int __mingw_libm_dummy;" > $@
+
# The mingwrt headers define a number of functions which are normally
# expected to be compiled as inline code. Each such function must also
# be provided with an externally visible entry point; we provide such
# entry points as stubs in libmingwex.a, via the following rules:
#
sinclude Makefile.stub
-jmpstub_refs = grep -lr '__JMPSTUB.*FUNCTION'
-jmpstub_prerequisites := $(shell $(jmpstub_refs) ${mingwrt_srcdir}/include)
-Makefile.stub: Makefile $(jmpstub_prerequisites)
+vpath jmpstub.sx ${mingwrt_srcdir}/mingwex
+libstub_refnames = grep -lr '__$1.*FUNCTION *=' ${mingwrt_srcdir}
+jmpstub_prerequisites := $(shell $(call libstub_refnames,JMPSTUB)/include)
+libimpl_prerequisites := $(shell $(call libstub_refnames,LIBIMPL)/include)
+Makefile.stub: Makefile $(jmpstub_prerequisites) $(libimpl_prerequisites)
echo "# $@: automatically generated file -- do not edit!" > $@
- $(jmpstub_awk_script) $(jmpstub_prerequisites) >> $@
+ $(call jmpstub_awk_script,$(jmpstub_prerequisites)) >> $@
+ $(call libimpl_awk_script,$(libimpl_prerequisites)) >> $@
echo "# $@: end of file" >> $@
-vpath jmpstub.sx ${mingwrt_srcdir}/mingwex
-jmpstub_awk_script = test "$^" = Makefile || awk '\
+# Stubs are categorized into either of JMPSTUB or LIBIMPL classes;
+# the rules for building the JMPSTUP inplementations are written to
+# Makefile.stub, by processing each of their defining header files
+# through the following awk script...
+#
+jmpstub_awk_script = test -z "$1" || awk '\
BEGIN { \
symbol = "([A-Z_a-z][A-Z_a-z0-9]*)"; \
fmt = "\nlib%s.a: %s\n%s: jmpstub.sx\n\t$$(COMPILE.sx) %s -o $$@ $$^\n"; \
/__JMPSTUB(__)? *[(].*FUNCTION/ { \
LIB = "mingwex"; \
FUNCTION = gensub( ".*[ ,(:]FUNCTION *= *"symbol".*", "\\1", 1 ); \
- OBJNAME = gensub( "_*(.*)_*", "\\1", 1, FUNCTION )".stub.$$(OBJEXT)"; \
+ OBJNAME = gensub( "_*(.*)_*", "\\1", 1, FUNCTION )".jmpstub.$$(OBJEXT)"; \
OBJNAME_CFLAGS = "-D FUNCTION="FUNCTION; \
printf fmt, LIB, OBJNAME, OBJNAME, OBJNAME_CFLAGS; \
} \
END { \
printf "\n"; \
- }'
+ }' $1
-all-mingwrt-libs install-mingwrt-libs: libm.a
-# Historically, MinGW.org's libm.a has been a dummy, delivering
-# nothing of value; FIXME: IMO, this sucks; it should deliver the
-# non-MSVCRT.DLL math functions, as noted above.
+# ...while this establishes the dependencies which apply for each
+# of those in the LIBIMPL class.
#
-libm.a: libm_dummy.$(OBJEXT)
-libm_dummy.c: Makefile
- echo "static int __mingw_libm_dummy;" > $@
+libimpl_awk_script = test -z "$1" || awk '\
+ BEGIN { \
+ symbol = "([A-Z_a-z][A-Z_a-z0-9]*)"; \
+ fmt = "\nlib%s.a: %s\n%s.libimpl: %s\n"; \
+ } \
+ /__LIBIMPL(__)? *[(].*FUNCTION/ { \
+ LIB = "mingwex"; \
+ FUNCTION = gensub( ".*[ ,(:]FUNCTION *= *"symbol".*", "\\1", 1 ); \
+ OBJNAME = gensub( "_*(.*)_*", "\\1", 1, FUNCTION )".libimpl.$$(OBJEXT)"; \
+ printf fmt, LIB, OBJNAME, FUNCTION, FILENAME; \
+ } \
+ END { \
+ printf "\n"; \
+ }' $1
+
+# In contrast to JMPSTUB implementations, which are best handled
+# by individual compilation rules in Makefile.stub, generic rules
+# are sufficient for all LIBIMPL implementations; in each case, we
+# filter the static attribute from each defined implementation, in
+# its defining header file, to create an intermediate C source for
+# each individual function; (note that we also remove any pragma
+# which identifies the originating file as a system header).
+#
+libimpl_sed_script = sed \
+ -e '/__CRT_ALIAS *__LIBIMPL.*FUNCTION *= *$1[ ,)].*)/d' \
+ -e '/__CRT_INLINE *__LIBIMPL.*FUNCTION *= *$1[ ,)].*)/d' \
+ -e '/pragma .* system_header/d'
+
+LIBIMPL_CFLAGS = $(CFLAGS) $(INCLUDES) -fno-align-functions
+
+# LIBIMPL dependencies are tracked using zero sized name.libimpl
+# files; the intermediate C files are generated as a side effect
+# of resolving these dependencies...
+#
+%.libimpl:
+ $(call libimpl_sed_script,$*) $< > $@.c
+ > $@
+
+# ...and ultimately discarded, after the requisite object file
+# has been compiled; (note that this creates a vulnerability due
+# to possible loss of the object file, while the tracking file is
+# still in place; to circumvent this, we must be able to force a
+# remake of the tracking file, so also regenerating the .c file,
+# before it is compiled).
+#
+libimpl_remake = { $(RM) $1; $(MAKE) --no-print-directory $1; }
+%.libimpl.$(OBJEXT): %.libimpl
+ test -f $<.c || $(call libimpl_remake,$<)
+ $(CC) -c $(CPPFLAGS) $(LIBIMPL_CFLAGS) -o $@ $<.c
+ $(RM) $<.c
# Thread support libraries.
#
$(RM) msvcr*.def moldname*.def mingw*.def lib*.a *.dll
mostlyclean-local:
- $(RM) *.d *.$(OBJEXT) Makefile.stub
+ $(RM) *.d *.$(OBJEXT) Makefile.stub *.libimpl
distclean-local: clean-local
$(RM) config.log config.status libm_dummy.c