OSDN Git Service

More JMPSTUB rationalization of inline functions.
[mingw/mingw-org-wsl.git] / mingwrt / Makefile.in
index ed7c9f9..a711605 100644 (file)
@@ -258,19 +258,6 @@ all-libmsvcrt install-mingwrt-libs: $(foreach name,$(all_msvcrt),lib$(name).a)
 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.
 #
@@ -377,12 +364,12 @@ libmingw32.a libmingwex.a libm.a libmingwthrd.a libgmon.a:
 #
 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)
 
@@ -437,21 +424,21 @@ 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, since we need to
+# specify an additional header file path.
 #
-# 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
+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)
@@ -460,9 +447,6 @@ libmingwex.a: $(addsuffix .$(OBJEXT), getopt basename dirname ftruncate usleep)
 
 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 dlfcn)
 
@@ -530,6 +514,8 @@ jmpstub_awk_script = test -z "$1" || awk '\
     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 { \
@@ -564,6 +550,7 @@ libimpl_awk_script = test -z "$1" || awk '\
 #
 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
@@ -577,9 +564,15 @@ LIBIMPL_CFLAGS = $(CFLAGS) $(INCLUDES) -fno-align-functions
        > $@
 
 # ...and ultimately discarded, after the requisite object file
-# has been compiled.
+# 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
 
@@ -818,7 +811,7 @@ clean-local: mostlyclean-local
        $(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