OSDN Git Service

Support optional DLL builds from static libraries.
authorKeith Marshall <keithmarshall@users.sourceforge.net>
Mon, 27 Feb 2017 17:59:26 +0000 (17:59 +0000)
committerKeith Marshall <keithmarshall@users.sourceforge.net>
Mon, 27 Feb 2017 17:59:26 +0000 (17:59 +0000)
VERSION.m4
aclocal.m4
mingwrt/ChangeLog
mingwrt/Makefile.in
mingwrt/configure.ac

index 872bc33..4e412b8 100644 (file)
@@ -5,7 +5,25 @@
 # Non-copyrightable material; adjust the following definition, to
 # assign a common version number to each of the mingwrt and w32api
 # MinGW System Library sub-packages.
-
+#
 m4_define([__VERSION__],[5.0])
 
+# This is also a convenient place to specify the import library
+# associations, and DLLVERSION information for each DLL which may
+# be delivered by this package; each specification record takes
+# the form of three data fields, comprising:
+#
+# 1) A tag field, which maps the assignment to a makefile variable
+#    substitution reference of the form @MAP_[TAG]_A_DLLVERSION@.
+#
+# 2) The name of the import library associated with the mapping.
+#
+# 3) The DLLVERSION for the corresponding DLL; this must be in the
+#    libtool current:revision:age notation, and should be updated,
+#    as required, in accordance with libtool conventions.
+#
+m4_define([MINGW_AC_ENUMERATE_DLLVERSION_SPECS],dnl
+[MINGW_AC_SET_DLLVERSION([LIBMINGWEX], [libmingwex.dll.a], [0:0:0])dnl
+])
+
 # $RCSfile$: end of file
index acdf9fa..caff4d4 100644 (file)
@@ -5,7 +5,7 @@
 ## $Id$
 ##
 ## Written by Keith Marshall <keithmarshall@users.sourceforge.net>
-## Copyright (C) 2014, 2016, MinGW.org Project
+## Copyright (C) 2014, 2016, 2017, MinGW.org Project
 ##
 ##
 m4_include([VERSION.m4])
@@ -166,4 +166,14 @@ AC_DEFUN([MINGW_AC_PROG_COMPILE_SX],
   }dnl
 ])
 
+# MINGW_AC_SET_DLLVERSION( TAG, IMPLIB, DLLVERSION )
+# --------------------------------------------------
+# Create a configuration time substitution for MAP_[TAG]_A_DLLVERSION,
+# such that it will define a target specific makefile variable assignment
+# for target IMPLIB, with specified value assigned to DLLVERSION.
+#
+AC_DEFUN([MINGW_AC_SET_DLLVERSION],dnl
+[AC_SUBST([MAP_][$1][_A_DLLVERSION],['$2: DLLVERSION = "$3"'])dnl
+])
+
 # $RCSfile$: end of file
index 5dfed08..ca0f260 100644 (file)
@@ -1,3 +1,30 @@
+2017-02-27  Keith Marshall  <keithmarshall@users.sourceforge.net>
+
+       Support optional DLL builds from static libraries.
+
+       * aclocal.m4 (MINGW_AC_SET_DLLVERSION): New macro; define it, and...
+       * VERSION.m4: ...use it here, to enumerate the specifcations for...
+       (MINGW_AC_ENUMERATE_DLLVERSION_SPECS): ...this collection of DLL
+       version identification records.
+
+       * Makefile.in (DLLVERSION): New macro; define default, and capture
+       library specific variants, as generated by AC_SUBST output from...
+       (MINGW_AC_ENUMERATE_DLLVERSION_SPECS): ...this configuration macro.
+       (a2dll, dllname, dllsuffix): New macros; define them, together with
+       new pattern rule using them, to create DLLs and import libraries from
+       existing static object libraries; augment these with...
+       (optional_dll_version): ...this further new macro, used by...
+       (install-optional-dlls, install-mingwrt-optional-dlls)
+       (install-libmingwex-optional-dll): ...these new installation rules...
+       (uninstall-optional-dlls, uninstall-mingwrt-optional-dlls): ...and
+       counterpart rules, to uninstall all such optional DLL files.
+       (optional_dll_package): Further new macro; it is required by...
+       (optdist, mingwrt-optdist, mingwrt-libmingwex-optdist): ...these new
+       distribution rules; they create packages for optional DLLs.
+       (dist): Add optdist.
+
+       * configure.ac (MINGW_AC_ENUMERATE_DLLVERSION_SPECS): Invoke it.
+
 2017-02-24  Keith Marshall  <keithmarshall@users.sourceforge.net>
 
        Make floating point environment more robust.
index 3eb6abd..1b379a1 100644 (file)
@@ -677,6 +677,56 @@ 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
+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
+
+
 # Installation Rules
 # ------------------
 #
@@ -793,6 +843,17 @@ 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.
 #
@@ -830,6 +891,7 @@ getdelim.$(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
 
@@ -843,7 +905,7 @@ 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 mkinstalldirs= \
          INSTALL_DATA='cd $$2 && $(RM) $$1' $*
@@ -862,7 +924,7 @@ check-recursive:
 # ------------
 #
 .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:
@@ -896,6 +958,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) | \
index 158465d..117b3e4 100644 (file)
@@ -6,7 +6,7 @@
 # $Id$
 #
 # 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
@@ -31,6 +31,8 @@
   AC_PREREQ([2.64])
   AC_INIT([MinGW C Runtime],[__VERSION__],[__BUG_REPORT_URL__],[mingwrt])
 
+  MINGW_AC_ENUMERATE_DLLVERSION_SPECS
+
   AC_PREFIX_DEFAULT([/mingw])
   AC_CONFIG_SRCDIR([include/_mingw.h.in])
   MINGW_AC_CONFIG_EXTRA_SRCDIR([w32api],[include/w32api.h.in])