RANLIB = @RANLIB@
AS = @AS@
+COMPILE.sx = @COMPILE_SX@
DLLTOOL = @DLLTOOL@
STRIP = @STRIP@
NM = @NM@
all: @DEFAULT_MAKECMDGOALS@
-all-mingwrt-stage-1: all-mingwrt-objects all-mingwrt-libs
-all-mingwrt-stage-1-and-2: all-mingwrt-stage-1 all-mingwrt-dll
+all-mingwrt-stage-1-only: all-mingwrt-objects all-mingwrt-libs
+all-mingwrt-stage-1-and-2: all-mingwrt-stage-1-only all-mingwrt-dll
all-mingwrt: all-mingwrt-stage-1-and-2
+all-gcc: all-mingwrt-stage-1-only
-include_deprecated = @include_deprecated@
-active_goals = $1-$2 $(if $(include_deprecated),$1-deprecated-$2)
+active_goals = $1-$2 $(if @include_deprecated@,$1-deprecated-$2)
+all-deprecated-mingwrt-stage-1-only: all-deprecated-mingwrt
-all-stage-1: $(call active_goals,all,mingwrt-stage-1)
+all-stage-1-only: $(call active_goals,all,mingwrt-stage-1-only)
all-stage-1-and-2: $(call active_goals,all,mingwrt)
# Installation paths and macros.
requires_existing = $(if $(wildcard $1),$1,$1.missing)
Makefile: Makefile.in configure $(call requires_existing,config.status)
$(SHELL) config.status
+ $(RM) Makefile.stub
.PHONY: config.status.missing
# ... but, in the event that this may be missing, (e.g. because it
w%.$(OBJEXT): %.c
$(CC) -c -D UNICODE $(CPPFLAGS) $(ALL_CFLAGS) -o $@ $<
+# Compiling object files from *.sx sources: since GCC-4.3, these
+# have been supported as a case agnostic alternative to *.S sources,
+# for assembly language sources requiring initial interpretation by
+# the C preprocessor; owing to the case-insensitive nature of file
+# naming on MS-Windows, we should prefer these, but we must tell
+# make how to compile them.
+#
+%.$(OBJEXT): %.sx
+ $(COMPILE.sx) $($*_cflags) -o $@ $<
+
# Several components of the distributable object code base are to
# be provided as free-standing object modules, (rather than being
# encapsulated within object libraries); we classify these within
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)
# "inttypes" conversion routines, provided in libmingwex.a
#
libmingwex.a: $(addsuffix .$(OBJEXT), \
- imaxabs imaxdiv strtoimax strtoumax wcstoimax wcstoumax)
+ imaxdiv strtoimax strtoumax wcstoimax wcstoumax)
# Additional math functions, augmenting Microsoft's paltry
# selection, also delivered in libmingwex.a, (FIXME: and yet
# compatibility than their Microsoft equivalents.
#
vpath %.c ${mingwrt_srcdir}/mingwex/stdio
-libmingwex.a: $(addsuffix .$(OBJEXT), btowc fopen64 fprintf fseeko64 ftello64 \
- 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_CFLAGS = -I ${mingwrt_srcdir}/mingwex/gdtoa -D__MSVCRT_VERSION__=0x0800
+libmingwex.a: $(addsuffix .$(OBJEXT), btowc fprintf fseeko64 pformat \
+ printf snprintf snwprintf sprintf vfprintf vfscanf vfwscanf vprintf \
+ vscanf vsnprintf vsnwprintf vsprintf vsscanf vswscanf vwscanf)
+
+# pformat.$(OBJEXT) needs an explicit build rule, since we need to
+# specify an additional header file path.
+#
+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), getopt basename dirname ftruncate usleep)
+libmingwex.a: $(addsuffix .$(OBJEXT), glob getopt basename dirname nsleep)
+libmingwex.a: $(addsuffix .$(OBJEXT), mkstemp mkdtemp cryptnam)
libmingwex.a: $(addsuffix .$(OBJEXT), tdelete tfind tsearch twalk)
-libmingwex.a: $(addsuffix .$(OBJEXT), _Exit atoll lltoa lltow \
- 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 $@ $<
-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.
#
+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
+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!" > $@
+ $(call jmpstub_awk_script,$(jmpstub_prerequisites)) >> $@
+ $(call libimpl_awk_script,$(libimpl_prerequisites)) >> $@
+ echo "# $@: end of file" >> $@
+
+# 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 )".jmpstub.$$(OBJEXT)"; \
+ OBJNAME_CFLAGS = "-D FUNCTION="FUNCTION; \
+ if( match( $$0, ".*[ ,(:]REMAPPED *= *"symbol, alias ) ) \
+ OBJNAME_CFLAGS = OBJNAME_CFLAGS" -D REMAPPED="alias[1]; \
+ printf fmt, LIB, OBJNAME, OBJNAME, OBJNAME_CFLAGS; \
+ } \
+ END { \
+ printf "\n"; \
+ }' $1
+
+# ...while this establishes the dependencies which apply for each
+# of those in the LIBIMPL class.
+#
+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 '/pragma .* system_header/d' \
+ -e '/__CRT_INLINE *__LIBIMPL.*FUNCTION *= *$1[ ,)].*)/d' \
+ -e 's/__LIBIMPL.*ALIAS *= *$1[ ,)].*)/__attribute__((__alias__("$1")))/' \
+ -e '/__CRT_ALIAS *__LIBIMPL.*FUNCTION *= *$1[ ,)].*)/d'
+
+LIBIMPL_CFLAGS = $(CFLAGS) $(INCLUDES) $(LIBIMPL_EXTRA_CFLAGS)
+LIBIMPL_EXTRA_CFLAGS = -fno-align-functions -Wno-deprecated-declarations
+
+# 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.
#
all-mingwrt-libs install-mingwrt-libs: libmingwthrd.a libmingwthrd_old.a
# Install everything.
#
-install: install-mingwrt
+install: inst@DEFAULT_MAKECMDGOALS@
install-stage-1-only: install-headers install-libdir-objects install-libs
install-stage-1-and-2: install-stage-1-only install-bin
install-gcc: install-stage-1-only
includedirs: mingwrt-includedirs
install-headers install-mingwrt: install-mingwrt-headers
-${includedir}/sys: includedir
-mingwrt-includedirs: ${includedir}/sys
+${includedir}/sys ${includedir}/parts: includedir
+mingwrt-includedirs: ${includedir}/sys ${includedir}/parts
$(mkinstalldirs) $^
install-mingwrt-headers: mingwrt-includedirs
$(INSTALL_DATA) ${mingwrt_srcdir}/include/*.h ${includedir}
$(INSTALL_DATA) ${mingwrt_srcdir}/include/sys/*.h ${includedir}/sys
+ $(INSTALL_DATA) ${mingwrt_srcdir}/include/parts/*.h ${includedir}/parts
$(INSTALL_DATA) ${mingwrt_srcdir}/profile/*.h ${includedir}
# Install libraries, and supporting free standing object files.
$(RM) msvcr*.def moldname*.def mingw*.def lib*.a *.dll
mostlyclean-local:
- $(RM) *.d *.$(OBJEXT)
+ $(RM) *.d *.$(OBJEXT) Makefile.stub *.libimpl
distclean-local: clean-local
$(RM) config.log config.status libm_dummy.c