OSDN Git Service

Avoid -shared-libgcc dependencies in optional DLLs.
[mingw/mingw-org-wsl.git] / mingwrt / Makefile.in
index bbb0d51..c6ad956 100644 (file)
@@ -7,7 +7,7 @@ PACKAGE_TARNAME := @PACKAGE_TARNAME@
 PACKAGE_VERSION := @PACKAGE_VERSION@
 
 # Written by Keith Marshall <keithmarshall@users.sourceforge.net>
-# Copyright (C) 2014-2016, MinGW.org Project
+# Copyright (C) 2014-2017, MinGW.org Project
 #
 #
 # Permission is hereby granted, free of charge, to any person obtaining a
@@ -105,6 +105,7 @@ INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@ $1 $2
 
 mkinstalldirs = @MKDIR_P@ $(addprefix $1,$2)
+LN_S = @LN_S@
 
 # Keep the configuration in a consistent state.  Note that we assume
 # that configure has been run initially, (otherwise we wouldn't have
@@ -136,10 +137,10 @@ config.status.missing:
 # If configure itself needs to be updated, we must run autoconf in the
 # top level source directory.
 #
-vpath %.m4 ${top_srcdir}
 vpath configure.ac ${top_srcdir}
+vpath %.m4 ${top_srcdir}/.. ${top_srcdir}
 configure: configure.ac aclocal.m4 VERSION.m4
-       cd ${top_srcdir}; autoconf
+       cd ${top_srcdir}; autoconf -I ..
 
 # Propagate package version, as configured, consistently throughout
 # the package build.
@@ -174,6 +175,7 @@ INCLUDES = -nostdinc -I . -I ${top_srcdir}/include -I ${w32api_srcdir}/include \
   -I ${top_srcdir} -I ${top_srcdir}/profile -iwithprefixbefore include
 
 ALL_CFLAGS = $(CFLAGS) $(DEPFLAGS) $(INCLUDES) $(NTDDI_VERSION_SPEC)
+ALL_CPPFLAGS = $(CPPFLAGS) $(DEPFLAGS) $(INCLUDES) $(NTDDI_VERSION_SPEC)
 
 # The general case, for compiling object files from C source,
 # requires a small adjustment to the default implicit rule.
@@ -234,11 +236,18 @@ $(addsuffix .$(OBJEXT), crt1 dllcrt1): %.$(OBJEXT): %.c
        $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) -D__CRTDLL__ -o $@ $<
 
 # ...while, for the current build case, we need an explicit mapping
-# to identify the disparately named source file.
+# to identify the disparately named source file...
 #
 $(addsuffix .$(OBJEXT), crt2 dllcrt2): %2.$(OBJEXT): %1.c
        $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) -o $@ $<
 
+# ...and for the pair of default FPU configuration selectors, we
+# need to pass the configuration specification to the compiler, when
+# compiling the common source for each of the two cases.
+#
+CRT_fp8.$(OBJEXT) CRT_fp10.$(OBJEXT): CRT_fp%.$(OBJEXT): CRT_fenv.c
+       $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) -D_CRT_FE_DFL_ENV=$* -o $@ $<
+
 # The initialization hook for profiling code is inherited from Cygwin,
 # where it is built as gcrt0.$(OBJEXT); we build it, unmodified, as each
 # of gcrt1.$(OBJEXT) and gcrt2.$(OBJEXT), to satisfy the differing GCC
@@ -383,7 +392,7 @@ $(foreach name,coldname $(all_moldname),lib$(name).a): $(addsuffix .$(OBJEXT), \
 #
 $(foreach name,moldname $(addprefix moldname,70 71),lib$(name).a) \
 $(foreach name,moldname $(addprefix moldname,70 71),lib$(name)d.a): \
-  strnlen.jmpstub.$(OBJEXT)
+  strnlen.jmpstub.$(OBJEXT) wcsnlen.jmpstub.$(OBJEXT)
 
 coldname.def: %.def: ${mingwrt_srcdir}/moldname.def.in
        $(CC) -C -E -P -D__FILENAME__=$@ -D__CRTDLL__ -xc-header $< > $@
@@ -456,15 +465,16 @@ libmingwex.a: $(addsuffix .$(OBJEXT), cosf cosl acosf acosl sinf sinl asinf \
   nearbyint nearbyintf nearbyintl nextafterf nextafterl nexttoward nexttowardf \
   powf powl powi powif powil remainder remainderf remainderl remquo remquof \
   remquol rint rintf rintl round roundf roundl scalbn scalbnf scalbnl signbit \
-  signbitf signbitl sqrtf sqrtl tgamma tgammaf tgammal trunc truncf truncl)
+  signbitf signbitl sqrtf sqrtl tgamma tgammaf tgammal trunc truncf truncl \
+  x87cvt x87cvtf x87log x87log1p x87pow)
 
 # Replacement I/O functions in libmingwex.a, providing better POSIX
 # compatibility than their Microsoft equivalents.
 #
 vpath %.c ${mingwrt_srcdir}/mingwex/stdio
 libmingwex.a: $(addsuffix .$(OBJEXT), btowc fprintf fseeko64 ofmtctl pformat \
-  printf snprintf snwprintf sprintf vfprintf vfscanf vfwscanf vprintf vscanf \
-  vsnprintf vsnwprintf vsprintf vsscanf vswscanf vwscanf)
+  printf snprintf sprintf vfprintf vfscanf vfwscanf vprintf vscanf vsnprintf \
+  vsprintf vsscanf vswscanf vwscanf)
 
 # pformat.$(OBJEXT) needs an explicit build rule, since we need to
 # specify an additional header file path.
@@ -483,21 +493,25 @@ $(addsuffix fmt.$(OBJEXT),varo crto geto seto crtn getn setn): %.$(OBJEXT): ofmt
 
 # 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), glob getopt basename dirname nsleep)
-libmingwex.a: $(addsuffix .$(OBJEXT), mkstemp mkdtemp cryptnam)
+libmingwex.a: $(addsuffix .$(OBJEXT), mkstemp mkdtemp cryptnam setenv)
 
 libmingwex.a: $(addsuffix .$(OBJEXT), tdelete tfind tsearch twalk)
-
-libmingwex.a: gettimeofday.$(OBJEXT)
-libmingwex.a: $(addsuffix .$(OBJEXT), dirent wdirent dlfcn)
+libmingwex.a: $(addsuffix .$(OBJEXT), dirent wdirent dlfcn strerror_r)
+libmingwex.a: $(addsuffix .$(OBJEXT), getdelim gettimeofday)
 
 vpath %.s ${mingwrt_srcdir}/mingwex
+vpath %.sx ${mingwrt_srcdir}/mingwex
 libmingwex.a: $(addsuffix .$(OBJEXT), fwide mbrtowc mbsinit strnlen wcrtomb \
-  wcstof wcstold wctob wmemchr wmemcmp wmemcpy wmemmove wmemset)
+  wcsnlen wcstof wcstold wctob wctrans wctype wmemchr wmemcmp wmemcpy wmemmove \
+  wmemset)
 
-libmingwex.a: $(addsuffix .$(OBJEXT), wctrans wctype)
+# The wcsnlen() function, enumerated above, is an adaptation of strnlen();
+# we need a specific rule to compile it, from shared source.
+#
+wcsnlen.$(OBJEXT): strnlen.sx
+       $(COMPILE.sx) -D_UNICODE $^ -o $@
 
 # For the math sources, we support the convention that a single
 # quux_generic.c source file will produce three objects: quux.o,
@@ -518,6 +532,21 @@ $(addsuffix .$(OBJEXT), % %f %l): %_generic.c
 $(addsuffix .$(OBJEXT), llround llroundf llroundl): %.$(OBJEXT): lround_generic.c
        $(CC) -c -D FUNCTION=$* $(CPPFLAGS) $(ALL_CFLAGS) -o $@ $<
 
+# Similarly, we may need to compile quux.o, quuxf.o, and quuxl.o
+# variants from a common quux_generic.sx assembly language file.
+#
+vpath %.sx ${mingwrt_srcdir}/mingwex/math
+$(addsuffix .$(OBJEXT), % %f %l): %_generic.sx
+       $(CC) -c -D_$*_source $(ALL_CPPFLAGS) $(ASFLAGS) -o $*.$(OBJEXT) $<
+       $(CC) -c -D_$*f_source $(ALL_CPPFLAGS) $(ASFLAGS) -o $*f.$(OBJEXT) $<
+       $(CC) -c -D_$*l_source $(ALL_CPPFLAGS) $(ASFLAGS) -o $*l.$(OBJEXT) $<
+
+# Several generically implemented functions also require separate
+# assembly of their generic back-end support routines.
+#
+x87%.$(OBJEXT): %_generic.sx
+       $(CC) -c $(ALL_CPPFLAGS) $(ASFLAGS) -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.
@@ -533,7 +562,6 @@ libm_dummy.c: Makefile
 # 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)
@@ -558,7 +586,9 @@ jmpstub_awk_script = test -z "$1" || awk '\
     LIB = match( $$0, ".*[ ,(:]LIB *= *"symbol, altlib ) ? altlib[1] : "mingwex"; \
     OBJNAME = gensub( "_*(.*)_*", "\\1", 1, FUNCTION )".jmpstub.$$(OBJEXT)"; \
     OBJNAME_CFLAGS = "-D FUNCTION="FUNCTION; \
-    if( match( $$0, ".*[ ,(:]REMAPPED *= *"symbol, alias ) ) \
+    if( match( $$0, ".*[ ,(:]DLLENTRY *= *"symbol, alias ) ) \
+      OBJNAME_CFLAGS = OBJNAME_CFLAGS" -D DLLENTRY="alias[1]; \
+    else if( match( $$0, ".*[ ,(:]REMAPPED *= *"symbol, alias ) ) \
       OBJNAME_CFLAGS = OBJNAME_CFLAGS" -D REMAPPED="alias[1]; \
     printf fmt, LIB, OBJNAME, OBJNAME, OBJNAME_CFLAGS; \
   } \
@@ -647,6 +677,61 @@ all-mingwrt-libs install-mingwrt-libs: libgmon.a
 libgmon.a: $(addsuffix .$(OBJEXT), gmon mcount profil)
 
 
+# Optional DLL Generation Rules
+# -----------------------------
+#
+# The following rules are provided to accommodate optional delivery
+# of certain of the static libraries, generated as components of this
+# package, in the alternative form of DLLs, each with an accompanying
+# import library.  Each such DLL should be versioned, ideally with an
+# explicitly specified version number, but we provide this fall back
+# as a catch-all default for any which is not so specified; (all such
+# version specifications should be in the "current:revision:age" form,
+# conforming to the GNU-libtool convention).
+#
+DLLVERSION = "0:0:0"
+
+# Generally, we should prefer to have explicit version specifications,
+# relating individually to each DLL; these are specified in VERSION.m4,
+# and propagated here via configure time substitution.
+#
+@MAP_LIBMINGWEX_A_DLLVERSION@
+
+# For convenience, we implement the DLL build rule in the form of a
+# generic pattern rule, invoked in the form of a request to build any
+# version-agnostic import library; the versioned DLL is then built as
+# a side effect of building the import library.
+#
+# Note that, in addition to the obvious dependency on the originating
+# static library, we also make this depend on configure; this ensures
+# that DLL version changes, specified in VERSION.m4, are propagated.
+#
+# Further note that we use an alternatively named reference link to
+# the originating static library, as code source for the DLL, rather
+# than the original name; this is to work around a limitation of the
+# handling of --whole-archive, by GNU-ld, which suppresses creation
+# of an exports table, in the event that the same static library is
+# named among GCC's implicit default libraries, after reverting to
+# --no-whole-archive operation.
+#
+%.dll.a: %.a configure
+       $(LN_S) -f $< tmp$<
+       $(CC) $(call a2dll,tmp$<,$(call dllname,$*)) -L. -Wl,--out-implib=$@
+       $(RM) tmp$<
+
+dllname = $1-$(dllsuffix).dll $(LIBGCC_LINK_OPTION)
+a2dll = -shared -o $2 -Wl,--whole-archive $1 -Wl,--no-whole-archive
+dllsuffix = `echo $(DLLVERSION) | awk -F: '{printf "%d",$$1-$$3}'`
+
+all-optional-dlls: all-mingwrt-optional-dlls
+all-mingwrt-optional-dlls: libmingwex.dll.a
+
+# In most optional DLL build cases, we should avoid creating any
+# unnecessary dependency on (known to be broken) -shared-libgcc
+#
+libmingwex.dll.a: LIBGCC_LINK_OPTION = -static-libgcc
+
+
 # Installation Rules
 # ------------------
 #
@@ -695,7 +780,7 @@ install-gcc: install-stage-1-only
 
 install-strip: install-strip-mingwrt
 install-strip-%:
-       $(MAKE) --no-print-directory $(MAKEFLAGS) \
+       $(MAKE) --no-print-directory \
          STRIP_DATA='cd ${libdir}; $(STRIP) --strip-unneeded $$1' \
          STRIP_DLL='cd ${bindir}; $(STRIP) $$1' install-$*
 
@@ -763,12 +848,23 @@ install-%-dll-files:
        $(call INSTALL_DATA,$^,${bindir})
        $(if $(STRIP_DLL),$(call STRIP_DLL,$^))
 
+$(call optional_dll_version,libmingwex,@MAP_LIBMINGWEX_A_DLLVERSION@)
+optional_dll_version = $(shell echo '$2' | sed s,^[^:]*,install-$1-optional-dll,)
+
+install-optional-dlls: install-mingwrt-optional-dlls
+install-mingwrt-optional-dlls: install-libmingwex-optional-dll
+install-%-optional-dll: %.dll.a bindir libdir
+       $(call INSTALL_DATA,$<,${libdir})
+       $(call INSTALL_DATA,$(call dllname,$*),${bindir})
+       $(if $(STRIP_DLL),$(call STRIP_DLL,$(call dllname,$*)))
+       $(if $(STRIP_DATA),$(call STRIP_DATA,$<))
+
 
 # Install manpages.
 #
 vpath %.man ${mingwrt_srcdir}/man
 install-man install-manpages: install-mingwrt-manpages
-mingwrt-man$(man3ext): $(addsuffix .$(man3ext),basename dirname)
+mingwrt-man$(man3ext): $(addsuffix .$(man3ext),basename dirname getline getdelim)
 install-mingwrt-manpages: mandir mingwrt-man3
 
 mingwrt-man%:
@@ -785,6 +881,9 @@ format_manpage = sed \
 basename.$(man3ext): export reference_manpage = dirname.$(man3ext).man
 basename.$(man3ext): %: %.mancopy-recursive
 
+getdelim.$(man3ext): export reference_manpage = getline.$(man3ext).man
+getdelim.$(man3ext): %: %.mancopy-recursive
+
 %.mancopy-recursive:
        $(MAKE) --no-print-directory $*.mancopy
 
@@ -797,6 +896,7 @@ basename.$(man3ext): %: %.mancopy-recursive
 #
 uninstall: uninstall-mingwrt
 uninstall-bin uninstall-dll uninstall-mingwrt: uninstall-mingwrt-dll
+uninstall-optional-dlls uninstall-mingwrt: uninstall-mingwrt-optional-dlls
 uninstall-mingwrt: uninstall-mingwrt-headers uninstall-mingwrt-libdir-libs
 uninstall-mingwrt: uninstall-mingwrt-libdir-objects
 
@@ -810,17 +910,26 @@ uninstall-mingwrt-headers:
          done
        $(call REMOVE_HEADERS,${includedir},${mingwrt_srcdir}/profile/*.h)
 
-uninstall-mingwrt-dll \
+uninstall-mingwrt-dll uninstall-mingwrt-optional-dlls \
 uninstall-mingwrt-libdir-objects uninstall-mingwrt-libdir-libs: un%:
-       $(MAKE) --no-print-directory $(MAKEFLAGS) mkinstalldirs= \
+       $(MAKE) --no-print-directory mkinstalldirs= \
          INSTALL_DATA='cd $$2 && $(RM) $$1' $*
 
 
+# Test Suite
+# ----------
+#
+.PHONY: check-recursive
+check test tests: check-recursive
+check-recursive:
+       $(MAKE) -C tests $@
+
+
 # Distribution
 # ------------
 #
 .PHONY: dist
-dist: devdist dlldist licdist mandist srcdist
+dist: devdist dlldist licdist mandist optdist srcdist
        $(RM) -r dist/mingwrt dist/w32api
 
 mingwrt-dist-staged w32api-dist-staged: %-dist-staged:
@@ -854,6 +963,21 @@ mingwrt-mandist: %-mandist:
          xz -c > ../dist/$*-$(PACKAGE_RELEASE_TAG)-man.tar.xz
        $(RM) -r tmp
 
+optdist: mingwrt-optdist
+mingwrt-optdist: mingwrt-libmingwex-optdist
+
+$(call optional_dll_package,libmingwex,@MAP_LIBMINGWEX_A_DLLVERSION@)
+optional_dll_package = $(shell echo '$2' | sed s,^[^:]*,mingwrt-$1-optdist)
+
+mingwrt-%-optdist:
+       $(RM) -r tmp
+       $(MAKE) --no-print-directory prefix=`pwd`/tmp install-$*-optional-dll
+       cd tmp && tar chf - --hard-dereference bin | \
+         xz -c > ../dist/$*-$(PACKAGE_RELEASE_TAG)-dll-$(dllsuffix).tar.xz
+       cd tmp && tar chf - --hard-dereference lib | \
+         xz -c > ../dist/$*-$(PACKAGE_RELEASE_TAG)-dev.tar.xz
+       $(RM) -r tmp
+
 srcdist: mingwrt-srcdist
 mingwrt-srcdist: mingwrt-srcdist-dir mingwrt-srcdist-files
        cd dist && tar chf - $(PACKAGE_TARNAME)-$(PACKAGE_VERSION) | \
@@ -864,18 +988,30 @@ mingwrt-srcdist-dir:
        $(RM) -r dist/$(PACKAGE_TARNAME)-$(PACKAGE_VERSION)
        $(call mkinstalldirs,,dist/$(PACKAGE_TARNAME)-$(PACKAGE_VERSION))
 
-mingwrt-srcdist-files:
+mingwrt-srcdist-files: mingwrt-srcdist-config-files
+mingwrt-srcdist-files: mingwrt-srcdist-testsuite-files
+mingwrt-srcdist-files: mingwrt-srcdist-package-files
+
+vpath install-sh ${top_srcdir}/.. ${top_srcdir}
+mingwrt-srcdist-config-files: aclocal.m4 VERSION.m4 install-sh
+       cp -p $^ dist/$(PACKAGE_TARNAME)-$(PACKAGE_VERSION)
+
+mingwrt-srcdist-package-files:
        (cd ${mingwrt_srcdir} && tar chf - --hard-dereference $(notdir $^)) | \
          (cd dist/$(PACKAGE_TARNAME)-$(PACKAGE_VERSION) && tar xf -)
 
-mingwrt-srcdist-files: $(wildcard ${mingwrt_srcdir}/*.[chs]) \
+mingwrt-srcdist-package-files: $(wildcard ${mingwrt_srcdir}/*.[chs]) \
   $(addprefix ${mingwrt_srcdir}/,ChangeLog CONTRIBUTORS DISCLAIMER README) \
   $(wildcard ${mingwrt_srcdir}/*.def.in) $(wildcard ${mingwrt_srcdir}/config*) \
-  $(addprefix ${mingwrt_srcdir}/,aclocal.m4 install-sh Makefile.in TODO) \
-  $(addprefix ${mingwrt_srcdir}/,include man mingwex profile) \
-  $(addprefix ${mingwrt_srcdir}/,crtdll.def) \
+  $(addprefix ${mingwrt_srcdir}/,include man mingwex msvcrt-xref profile) \
+  $(addprefix ${mingwrt_srcdir}/,TODO Makefile.in crtdll.def) \
   $(wildcard ${mingwrt_srcdir}/*.txt)
 
+mingwrt-srcdist-testsuite-files: $(wildcard ${mingwrt_srcdir}/tests/*.at)
+mingwrt-srcdist-testsuite-files: $(wildcard ${mingwrt_srcdir}/tests/*.in)
+       (cd ${mingwrt_srcdir} && tar chf - $(addprefix tests/,$(notdir $^))) | \
+         (cd dist/$(PACKAGE_TARNAME)-$(PACKAGE_VERSION) && tar xf -)
+
 install-html install-pdf: install-%: %dir mingwrt-man$(man3ext)
        $(MAKE) --no-print-directory install-$*-files