OSDN Git Service

Fix libmingwex-n.dll dependencies; cf. Issue #40438.
[mingw/mingw-org-wsl.git] / mingwrt / Makefile.in
index c0429e4..01bc0e3 100644 (file)
-# Makefile.in for the winsup/mingw directory.
-# Copyright (c) 1995-2008, 1996, 1997, 1998 Cygnus Solutions
+# @configure_input@
+# $Id$
+#
+# Makefile template for MinGW.org Runtime Library Package
+
+PACKAGE_TARNAME := @PACKAGE_TARNAME@
+PACKAGE_VERSION := @PACKAGE_VERSION@
 
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
+# Written by Keith Marshall <keithmarshall@users.sourceforge.net>
+# Copyright (C) 2014-2020, MinGW.org Project
+#
 #
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
 #
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+# The above copyright notice and this permission notice (including the next
+# paragraph) shall be included in all copies or substantial portions of the
+# Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+# DEALINGS IN THE SOFTWARE.
 
-# This makefile requires GNU make.
 
-PACKAGE = @PACKAGE_TARNAME@
-VERSION = @PACKAGE_VERSION@
-CYGRELEASE = 1
+# The default target is "all"; declare it early, to avoid any possible
+# inadvertent override from any included file.
+#
+all:
+PACKAGE_RELEASE :=
+PACKAGE_RELEASE_TAG := $(PACKAGE_VERSION)$(PACKAGE_RELEASE:%=-%)-mingw32
+
+# Establish the minimum version of Windows which this build is required
+# to support; note that we fix the default as WinNT4, but we define it in
+# a manner which will allow a command line override, and may be adapted,
+# ultimately, to support a configure time assignment.
+#
+NTDDI_VERSION := NTDDI_WINNT4
+NTDDI_VERSION_SPEC := $(NTDDI_VERSION:%=-D NTDDI_VERSION=%)
 
-VPATH = @srcdir@
+# Build paths and macros.
+#
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
-top_builddir = @top_builddir@
+mingwrt_srcdir = @srcdir@
+w32api_srcdir = @w32api_srcdir@
+abs_builddir = @abs_builddir@
+
+CC = @CC@
+CFLAGS = @CFLAGS@
+CPPFLAGS = @CPPFLAGS@
+
+OBJEXT = @OBJEXT@
 
-# FIXME: I see no reason to define `objdir';
-# it appears to be unused, and could be removed.
-objdir = .
+AR = @AR@
+ARFLAGS = @ARFLAGS@
+RANLIB = @RANLIB@
+
+AS = @AS@
+COMPILE.sx = @COMPILE_SX@
+DLLTOOL = @DLLTOOL@
+STRIP = @STRIP@
+NM = @NM@
+
+all: @DEFAULT_MAKECMDGOALS@
+all-mingwrt-stage-1-only: _mingw.h w32api.h
+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
+
+active_goals = $1-$2 $(if @include_deprecated@,$1-deprecated-$2)
+all-deprecated-mingwrt-stage-1-only: all-deprecated-mingwrt
 
-host_alias = @host_alias@
-build_alias = @build_alias@
-target_alias = @target_alias@
-with_cross_host = @with_cross_host@
+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.
+#
 prefix = @prefix@
-conf_prefix = @prefix@
-host_os = @host_os@
+exec_prefix = @exec_prefix@
+bindir = ${DESTDIR}@bindir@
 
 datarootdir = @datarootdir@
-program_transform_name = @program_transform_name@
-exec_prefix = @exec_prefix@
-bindir = @bindir@
-libdir = @libdir@
-
-ifneq (,$(findstring cygwin,$(target_alias)))
-#
-# FIXME: What is the purpose of such logic, testing `target_alias'?
-#
-# Firstly, there is no code generator being built here.  The concept
-# of `target' is meaningless, and there is no valid reason to expect
-# that `target_alias' would be anything other than an empty string.
-# Thus, the validity of such tests is extremely suspect.
-#
-# Secondly, the decisions being taken, on the basis of these tests,
-# rightfully belong in the configure script; all this logic should be
-# removed, and properly implemented in `configure.in'.
-#
-mandir = $(prefix)/share/man
-mansection = mingw
-else
-mandir = @mandir@
-mansection = 3
-endif
-manpage_transform = @mingw_manpage_transform@
-ifeq ($(target_alias),$(host_alias))
-ifeq ($(build_alias),$(host_alias))
-tooldir:=$(exec_prefix)
-else
-tooldir:=$(exec_prefix)/$(target_alias)
-endif
-else
-tooldir:=$(exec_prefix)/$(target_alias)
-endif
-datadir = @datadir@
-infodir = @infodir@
-includedir = @includedir@
-ifneq (,$(findstring cygwin,$(target_alias)))
-#
-# FIXME: Doubtful use of `target_alias', again.
-#
-# Here we not only have a dubious test, based on `target_alias',
-# but we also assign local alternatives for the standard autoconf
-# installation path macros.  This should not be necessary; the
-# configure script should simply assign appropriate values to
-# the standard macros, which should be used herein.
-#
-inst_bindir:=$(tooldir)/bin
-inst_includedir:=$(tooldir)/include/mingw
-inst_libdir:=$(tooldir)/lib/mingw
-inst_docdir:=$(tooldir)/share/doc/mingw-runtime
-need-DESTDIR-compatibility = prefix exec_prefix tooldir mandir
-else
-ifneq (,$(with_cross_host))
-#
-# FIXME: What is the intended purpose of `with_cross_host'?
-#
-# Notwithstanding that this conforms to no known standard, and
-# is completely undocumented, it does not belong here; every one
-# of these settings is the prerogative of the configure script,
-# and they should use standard names, as noted above.
-#
-inst_bindir:=$(tooldir)/bin
-inst_includedir:=$(tooldir)/include
-inst_libdir:=$(tooldir)/lib
-inst_docdir:=$(tooldir)/share/doc/mingw-runtime
-need-DESTDIR-compatibility = prefix exec_prefix tooldir mandir
-else
-inst_bindir:=$(bindir)
-inst_includedir:=$(includedir)
-inst_libdir:=$(libdir)
-inst_docdir:=$(prefix)/doc/runtime
-need-DESTDIR-compatibility = prefix bindir includedir libdir mandir
-endif
-endif
-
-# The Mingw headers are installed under a subdirectory of
-# $(tooldir)/include when configuring in Cygwin.
-HEADER_SUBDIR = @HEADER_SUBDIR@
-
-SHELL = /bin/sh
+docdir = ${DESTDIR}${datarootdir}/doc
+includedir = ${DESTDIR}@includedir@
+libdir = ${DESTDIR}@libdir@
+
+htmldir = @htmldir@
+pdfdir = @pdfdir@
+
+mandir = ${DESTDIR}@mandir@
+man3dir = ${mandir}/man$(man3ext)
+
+man3ext = 3
 
 INSTALL = @INSTALL@
-INSTALL_DATA = @INSTALL_DATA@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@
-mkinstalldirs = $(SHELL) @MKINSTALLDIRS@
+INSTALL_DATA = @INSTALL_DATA@ $1 $2
 
-CC := @CC@
-ifneq (,$(findstring cygwin,$(target_alias)))
+mkinstalldirs = @MKDIR_P@ $(addprefix $1,$2)
+LN_S = @LN_S@
+
+# Include the makefile content which is common to both the mingwrt,
+# and the w32api packages; this may be included within the top level
+# source directory for each package individually, but we must also
+# be prepared to find it in their common parent directory.
 #
-# FIXME: What is the purpose of this hideous kludge?
+shared_include_file = $1$(if $(wildcard $1/$2),,/..)/$2
+include $(call shared_include_file,${top_srcdir},Makefile.comm)
+
+# Capture dependencies conveyed within source files, ensuring that
+# header files are taken from our working source tree, and not from
+# the build-time compiler's installation path.  (Note: we use -MD,
+# and not -MMD in DEPFLAGS; since this package furnishes system
+# headers, we need changes therein to trigger a rebuild).
 #
-# Again, we have a dubious use of `target_alias'.  Worse, `CC'
-# should have been appropriately set by the configure script; to
-# mess with it, in this fashion, should neither be necessary,
-# nor accepted.
+sinclude *.d
+DEPFLAGS = -MD -MP
+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.
 #
-override CC := ${filter-out -L% -B%,${shell echo $(CC) | sed -e 's%\(-isystem\|-iwithprefixbefore\)  *[^ ]*\( \|$$\)% %g'}}
-endif
-# FIXME: Which is it, CC or CC_FOR_TARGET?
-CC_FOR_TARGET = $(CC)
-AS_FOR_TARGET = $(AS)
-CFLAGS = @CFLAGS@
-CXXFLAGS = @CXXFLAGS@
+%.$(OBJEXT): %.c
+       $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) -o $@ $<
 
-# compiling with Cygwin?
-NO_CYGWIN := @NO_CYGWIN@
-ifdef NO_CYGWIN
+# In some cases, both ANSI and UTF-16LE enabled variants of object
+# modules are compiled from a common source; the UTF-16LE variant is
+# to be identified by prefixing a "w" to the object file name.
+#
+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.
 #
-# FIXME: Again, this should have been resolved by `configure',
-# and this kludge should be unnecessary.
+%.$(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
+# two distinct groups, for support of the current MSVCRT.DLL build
+# case and the older CRTDLL build case, (noting that, ultimately,
+# we may wish to deprecate this latter case).
 #
-override CC := ${NO_CYGWIN} $(firstword ${CC})
-endif
+all-mingwrt-objects: $(call active_goals,all,crt-objects)
+all-deprecated-mingwrt-objects: all-deprecated-crt-objects
+
+# Further note that, in addition to specifying the build time
+# inventories for each of these object module categories, each
+# module should be allocated to an associated installation group,
+# whence it may be included in the eventual distribution, via a
+# staged installation.
+#
+all-crt-objects install-crt-objects: $(addsuffix .$(OBJEXT), crt2 crtmt \
+  crtst dllcrt2 gcrt2 CRT_fp8 CRT_fp10 CRT_noglob binmode txtmode)
 
-# Either crtdll (CRT_ID 1) or msvcrt (CRT_ID 2).
-RUNTIME = @RUNTIME@
-CRT_ID = @CRT_ID@
+all-deprecated-crt-objects install-deprecated-crt-objects: \
+  $(addsuffix .$(OBJEXT), crt1 dllcrt1 gcrt1)
 
-# Needed for threading dll.
-THREAD_DLL = @THREAD_DLL@
-THREAD_DLL_VERSION = 10
-THREAD_DLL_NAME = $(THREAD_DLL)$(THREAD_DLL_VERSION).dll
+# The crt1.$(OBJEXT) and crt2.$(OBJEXT) modules, for the (deprecated)
+# CRTDLL and the (current) MSVCRT build cases respectively, are built
+# from a common crt1.c source.  Similarly, the dllcrt1.$(OBJEXT) and
+# dllcrt2.$(OBJEXT) modules share the common dllcrt1.c source.
+#
+# Noting that the source files are named for the deprecated build
+# case, but that we need to specify this while compiling, we need
+# this explicit pattern rule...
+#
+vpath %.c ${mingwrt_srcdir}
+$(addsuffix .$(OBJEXT), crt1 dllcrt1): %.$(OBJEXT): %.c
+       $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) -D__CRTDLL__ -o $@ $<
 
-# Various libraries.
-LIBM_A=@LIBM_A@
+# ...while, for the current build case, we need an explicit mapping
+# to identify the disparately named source file...
+#
+$(addsuffix .$(OBJEXT), crt2 dllcrt2): %2.$(OBJEXT): %1.c
+       $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) -o $@ $<
 
-W32API_INCLUDE = @W32API_INCLUDE@
-INCLUDES = -I$(srcdir)/include \
-  -I$(srcdir)/../include \
-  -nostdinc \
-  -iwithprefixbefore include
-ALL_CFLAGS = $(CFLAGS) $(INCLUDES) $(W32API_INCLUDE)
-ALL_CXXFLAGS = $(CXXFLAGS) $(INCLUDES) -nostdinc++ $(W32API_INCLUDE)
+# ...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
+# specs file dependencies for each of the (deprecated) CRTDLL build
+# and (current) MSVCRT build cases, respectively.
+#
+vpath %.c ${mingwrt_srcdir}/profile
+$(addsuffix .$(OBJEXT), gcrt0 gcrt1 gcrt2): %.$(OBJEXT): gcrt0.c
+       $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) -o $@ $<
 
-AS = @AS@
-AR = @AR@
-LD = @LD@
-AR_FLAGS = rcv
-RANLIB = @RANLIB@
-DLLTOOL = @DLLTOOL@
-DLLTOOLFLAGS =
-DLLTOOL_FOR_TARGET = $(DLLTOOL)
-DLLTOOL_FLAGS = --as $(AS_FOR_TARGET)
-DLLWRAP = @DLLWRAP@
-DLLWRAP_FOR_TARGET = $(DLLWRAP)
-DLLWRAP_FLAGS = --dlltool $(DLLTOOL) --as $(AS) --driver-name $(CC)
-OBJCOPY = @OBJCOPY@
-NM = @NM@
+# The primary runtime library is furnished by Microsoft, in the form
+# of MSVCRT.DLL, as shipped with MS-Windows itself, or in any one of
+# its versioned variants, as shipped with the MSVC compiler suite.
+#
+# We furnish the API for this runtime library, in the form of import
+# libraries, for both release and debug DLL variants; furthermore,
+# although we favour the freely available MSVCRT.DLL distributions,
+# we also provide import libraries tailored to the non-free, and
+# non-redistributable, MSVCRnn.DLL variants, corresponding to each
+# of the following enumerated versions from the MSVC suite.
+#
+msvcrt_versions := 70 71 80 90 100
+msvcrt_version_script = echo $1 | awk '\
+  { printf "0x%03d00000", gensub( "^[^1-9]*([0-9]*).*", "\\\\1", 1 ) \
+  }'
+
+extra_objects_filter = $(filter %.$(OBJEXT),$1)
+extra_objects_script = test -z "$(call extra_objects_filter,$2)" \
+  || { echo $(AR) $(ARFLAGS) $1 $(call extra_objects_filter,$2); \
+       $(AR) $(ARFLAGS) $1 $(call extra_objects_filter,$2); \
+     }
+
+msvcrt_dllname_script = echo $1 | awk '\
+  /^c/{ print "crtdll.dll" } \
+  /^m/{ ext = gsub( "^.*d$$", "&" ) ? "d.dll" : ".dll"; \
+       printf "msvcr%s%s", gsub( "^[^1-9]*[0-9]+.*", "&" ) \
+         ? gensub( "^[^1-9]*([0-9]+).*", "\\\\1", 1 ) \
+         : "t", ext; \
+      }'
+
+# We categorize our import libraries into "standard" (a.k.a. "release")
+# versions, augmented by corresponding "debug" variants.
+#
+std_msvcrt := $(addprefix msvcr,t $(msvcrt_versions))
+all_msvcrt := $(std_msvcrt) $(addsuffix d,$(std_msvcrt))
+
+all-mingwrt-libs: $(call active_goals,all,libmsvcrt)
+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
+
+# For each import library to be built, we derive a tailored exports
+# definition file, from a common source.
+#
+.SUFFIXES: .def.in .def
+vpath %.def.in ${mingwrt_srcdir}/msvcrt-xref
+$(addsuffix .def,$(all_msvcrt)): %.def: msvcrt.def.in
+       $(CC) -E -P -D__FILENAME__=$@ -D__DLLNAME__=$* \
+         -D__MSVCRT_VERSION__=`$(call msvcrt_version_script,$*)` \
+         -xc-header $< > $@
+
+# To accommodate the __USE_MINGW_ANSI_STDIO feature, as specified
+# in _mingw.h and stdio.h, while retaining a mechanism for accessing
+# the MSVCRT.DLL functions which it replaces, we augment our import
+# libraries with extra, alternatively named entry points, each of
+# which implements a vectored jump to the regular entry point for
+# the DLL implementation of its corresponding replaced function.
+#
+msvcrt_repl_prefix := __msvcrt
+msvcrt_repl_funcs := printf fprintf sprintf vprintf vfprintf vsprintf
+msvcrt_repl_funcs += free realloc
+
+# This is kludgey, but dlltool lacks the selectivity to do the job
+# well; (its --ext-prefix-alias option, which is what we would like
+# to use, is rather like a chainsaw in the hands of a neurosurgeon,
+# when he should have a scalpel).  We cannot selectively apply the
+# prefix, to just the symbols of interest, so we end up by creating
+# an initial copy of the import library, WITH the prefix applied to
+# to EVERYTHING, (noting that, when we create this initial copy, we
+# MUST specify the "--no-delete" option TWICE, to preserve temporary
+# object files within the build tree); we then set this initial copy
+# aside, and create a further copy WITHOUT the extra symbols, while
+# duplicating the temporary object file name prefix retrieved from
+# the initial copy, using this $(NM) lookup filter...
+#
+dlltool_temp_prefix = $(NM) $(1) | sed -n -e '/t.o:$$/{s///p;q' -e '}'
+
+# ...after which, we apply the following $(NM) lookup filter to the
+# initial copy of the import library file, to identify the specific
+# temporary object files, defining the entry points to remap...
+#
+msvcrt_repl = $(call nmlookup,$1,$(msvcrt_repl_prefix)_,$(msvcrt_repl_funcs))
+nmlookup = $(NM) $(1) | sed -n \
+  -e '/:$$/h;/^[0-7][0-7]*  *T  */{s///;H;g;s/\n//' \
+  $(foreach repl,$(3),-e 's/:_$(2)$(repl)$$//p') \
+  -e '}'
+
+# ...and we add just that selection to the final copy of the import
+# library, before explicitly deleting ALL temporary object files, and
+# the (extended) initial copy of the import library.
+#
+vpath %.def ${mingwrt_srcdir}
+$(foreach name,$(all_msvcrt) crtdll,lib$(name).a): lib%.a: %.def
+       $(DLLTOOL) --as $(AS) -k --input-def $< --no-delete --no-delete \
+         --dllname `$(call msvcrt_dllname_script,$*)` --output-lib $@  \
+         --ext-prefix-alias $(msvcrt_repl_prefix) && mv $@ lib$*-repl.a
+       $(DLLTOOL) --as $(AS) -k --input-def $< --output-lib $@ \
+         --temp-prefix `$(call dlltool_temp_prefix,lib$*-repl.a)` \
+         --dllname `$(DLLTOOL) --identify lib$*-repl.a`
+       $(AR) $(ARFLAGS) $@ `$(call msvcrt_repl,lib$*-repl.a)` \
+         $(filter %.$(OBJEXT),$^)
+       $(RM) lib$*-repl.a `$(call dlltool_temp_prefix,$@)`*
+
+# Older versions of Microsoft's runtime libraries used a naming
+# convention which is more consistent with POSIX, (and with other
+# free software usage), than they currently employ; we support
+# this earlier convention by mapping the old names to equivalent
+# entry points in the current libraries, using libcoldname.a to
+# map CRTDLL.DLL entries, and variants of libmoldname.a for each
+# variant of MSVCRT.DLL
+#
+std_moldname := moldname $(addprefix moldname,$(msvcrt_versions))
+all_moldname := $(std_moldname) $(addsuffix d,$(std_moldname))
+
+all-mingwrt-libs: all-libmoldname
+all-libmoldname install-mingwrt-libs: $(foreach name,$(all_moldname),lib$(name).a)
+$(foreach name,coldname $(all_moldname),lib$(name).a): lib%.a: %.def
+       $(DLLTOOL) --as $(AS) -k -U --input-def $< --output-lib $@ \
+         --dllname `$(call msvcrt_dllname_script,$*)`
+       $(AR) $(ARFLAGS) $@ $(call extra_objects_filter,$^)
+
+# The oldname libraries are also a convenient place to provide a
+# few additional functions, with no direct implementation in the
+# Microsoft DLLs, but which nevertheless are easily emulated.
+#
+$(foreach name,coldname $(all_moldname),lib$(name).a): $(addsuffix .$(OBJEXT), \
+  isascii iscsym iscsymf toascii)
+
+# Selected versions of the oldname libraries also provide a
+# convenient vehicle for delivery of stubs, emulating functions
+# which appear in later MSVCRT versions, and which we also wish
+# to support in conjunction with earlier versions.
+#
+$(foreach name,moldname $(addprefix moldname,70 71),lib$(name).a) \
+$(foreach name,moldname $(addprefix moldname,70 71),lib$(name)d.a): \
+  strnlen.jmpstub.$(OBJEXT) wcsnlen.jmpstub.$(OBJEXT)
+
+coldname.def: %.def: ${mingwrt_srcdir}/moldname.def.in
+       $(CC) -C -E -P -D__FILENAME__=$@ -D__CRTDLL__ -xc-header $< > $@
+
+$(addsuffix .def,$(all_moldname)): %.def: ${mingwrt_srcdir}/moldname.def.in
+       $(CC) -C -E -P -D__FILENAME__=$@ -xc-header $< > $@
+
+vpath %.sx ${mingwrt_srcdir}
+all-mingwrt-libs install-mingwrt-libs: libmingw32.a libmingwex.a libmemalign.a
+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 libmemalign.a libm.a libmingwthrd.a libgmon.a:
+       $(AR) $(ARFLAGS) $@ $?
+
+# Complex math objects, to be included in libmingwex.a
+# (FIXME: consider whether these might be more suitably
+# delivered in libm.a; ISO-C99 says they belong in the
+# math library, which by POSIX convention, is libm.a)
+#
+vpath %.c ${mingwrt_srcdir}/mingwex
+vpath %.c ${mingwrt_srcdir}/mingwex/complex
+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)
+
+# Floating point environment control, in libmingwex.a
+# (FIXME: once again, maybe better delivered in libm.a)
+#
+libmingwex.a: $(addsuffix .$(OBJEXT), fegetenv fesetenv feupdateenv \
+  feclearexcept feraiseexcept fetestexcept feholdexcept fegetexceptflag \
+  fesetexceptflag fegetround fesetround)
+
+# David Gay's "gdtoa" API, provided in libmingwex.a, and used
+# by MinGW's ISO-C conforming printf() routines for formatting
+# floating point output.
+#
+vpath %.c ${mingwrt_srcdir}/mingwex/gdtoa
+libmingwex.a: $(addsuffix .$(OBJEXT), g__fmt gethex strtopx g_dfmt gdtoa \
+  gmisc smisc sum g_ffmt hd_init strtodg ulp dmisc g_xfmt hexnan strtodnrp \
+  dtoa misc strtof)
+
+# "inttypes" conversion routines, provided in libmingwex.a
+#
+libmingwex.a: $(addsuffix .$(OBJEXT), \
+  imaxdiv strtoimax strtoumax wcstoimax wcstoumax)
+
+# Additional math functions, augmenting Microsoft's paltry
+# selection, also delivered in libmingwex.a, (FIXME: and yet
+# again, perhaps libm.a would be a better fit)
+#
+vpath %.c ${mingwrt_srcdir}/mingwex/math
+vpath %.s ${mingwrt_srcdir}/mingwex/math
+libmingwex.a: $(addsuffix .$(OBJEXT), cosf cosl acosf acosl sinf sinl asinf \
+  asinl tanf tanl atanf atanl atan2f atan2l coshf coshl acosh acoshf acoshl \
+  sinhf sinhl asinh asinhf asinhl tanhf tanhl atanh atanhf atanhl cbrt cbrtf \
+  cbrtl ceilf ceill copysign copysignf copysignl erfl s_erf sf_erf expf expl \
+  exp2 exp2f exp2l expm1 expm1f expm1l fabs fabsf fabsl fdim fdimf fdiml \
+  floorf floorl fma fmaf fmal fmax fmaxf fmaxl fmin fminf fminl fmodf fmodl \
+  fp_consts fp_constsf fp_constsl fpclassify fpclassifyf fpclassifyl frexpf \
+  frexpl fucom hypotf hypotl ilogb ilogbf ilogbl isnan isnanf isnanl ldexpf \
+  ldexpl lgamma lgammaf lgammal llrint llrintf llrintl log10f log10l log1p \
+  log1pf log1pl log2 log2f log2l logb logbf logbl logf logl lrint lrintf \
+  lrintl llround llroundf llroundl lround lroundf lroundl modff modfl \
+  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 \
+  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 fseeki64 ftelli64 \
+  fwrite ofmtctl pformat 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.
+#
+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 $@ $<
+
+# Functions comprising the MinGW aligned heap management API:
+#
+LIBMINGWEX_MEMALIGN := memalign-lwm memalign-base aligned-malloc
+LIBMINGWEX_MEMALIGN += aligned-realloc memalign-realloc realloc free
+
+LIBMINGWEX_MEMALIGN_OBJECTS = $(addsuffix .$(OBJEXT),$(LIBMINGWEX_MEMALIGN))
+
+$(LIBMINGWEX_MEMALIGN_OBJECTS): %.$(OBJEXT): memalign.c
+       $(CC) -c $(CFLAGS) -D__mingw_$(subst -,_,$*)_case $< -o $@
+
+libmingwex.a: $(LIBMINGWEX_MEMALIGN_OBJECTS)
+
+# Some additional miscellaneous functions, in libmingwex.a
+#
+libmingwex.a: $(addsuffix .$(OBJEXT), ftruncate getdelim gettimeofday)
+libmingwex.a: $(addsuffix .$(OBJEXT), glob getopt basename dirname nsleep)
+libmingwex.a: $(addsuffix .$(OBJEXT), clockapi clockres clockset clocktime)
+libmingwex.a: $(addsuffix .$(OBJEXT), insque remque tdelete tfind tsearch twalk)
+libmingwex.a: $(addsuffix .$(OBJEXT), dirent wdirent dlfcn strerror_r strtok_r)
+libmingwex.a: $(addsuffix .$(OBJEXT), mkstemp mkdtemp cryptnam setenv)
+
+vpath %.s ${mingwrt_srcdir}/mingwex
+vpath %.sx ${mingwrt_srcdir}/mingwex
+libmingw32.a: $(addsuffix .$(OBJEXT), mbrscan wcharmap)
+libmingwex.a: $(addsuffix .$(OBJEXT), codeset mbrconv mbrlen)
+libmingwex.a: $(addsuffix .$(OBJEXT), mbrtowc mbsrtowcs strnlen)
+libmingwex.a: $(addsuffix .$(OBJEXT), wcrtomb wcsrtombs wcsnlen wcstod wcstof)
+libmingwex.a: $(addsuffix .$(OBJEXT), wcstofp wcstold wctob wctrans wctype)
+libmingwex.a: $(addsuffix .$(OBJEXT), wmemchr wmemcmp wmemcpy wmemmove wmemset)
+
+# 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 $@
+
+# Similarly, the wcstod(), wcstof(), and wcstold() functions are
+# compiled from the common wcstofp.c source file.
+#
+$(addsuffix .$(OBJEXT), wcstod wcstof wcstold): %.$(OBJEXT): wcstofp.c
+       $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) -D FUNCTION=$* -o $@ $<
+
+# For the math sources, we support the convention that a single
+# quux_generic.c source file will produce three objects: quux.o,
+# quuxf.o, and quuxl.o; since a change in the common source file
+# will require all three objects to be recompiled, we may handle
+# this with a single, multiple target, pattern rule.
+#
+$(addsuffix .$(OBJEXT), % %f %l): %_generic.c
+       $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) -o $*.$(OBJEXT) $<
+       $(CC) -c -D FUNCTION=$*f $(CPPFLAGS) $(ALL_CFLAGS) -o $*f.$(OBJEXT) $<
+       $(CC) -c -D FUNCTION=$*l $(CPPFLAGS) $(ALL_CFLAGS) -o $*l.$(OBJEXT) $<
+
+# The llround.o, llroundf.o, and llroundl.o variants are a special
+# case of the preceding rule; (the source is lround_generic.c rather
+# than llround_generic.c).  We can handle this using the following
+# static pattern rule, (compiling each object individually).
+#
+$(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
+       $(COMPILE.sx) -D_$*_source -o $*.$(OBJEXT) $<
+       $(COMPILE.sx) -D_$*f_source -o $*f.$(OBJEXT) $<
+       $(COMPILE.sx) -D_$*l_source -o $*l.$(OBJEXT) $<
+
+# Several generically implemented functions also require separate
+# assembly of their generic back-end support routines.
+#
+x87%.$(OBJEXT): %_generic.sx
+       $(COMPILE.sx) -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 "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
+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/ { \
+    FUNCTION = gensub( ".*[ ,(:]FUNCTION *= *"symbol".*", "\\1", 1 ); \
+    LIB = match( $$0, ".*[ ,(:]LIB *= *"symbol, altlib ) ? altlib[1] : "mingwex"; \
+    OBJNAME = gensub( "_*(.*)_*", "\\1", 1, FUNCTION )".jmpstub.$$(OBJEXT)"; \
+    OBJNAME_CFLAGS = "-D FUNCTION="FUNCTION; \
+    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; \
+  } \
+  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/ { \
+    FUNCTION = gensub( ".*[ ,(:]FUNCTION *= *"symbol".*", "\\1", 1 ); \
+    LIB = match( $$0, ".*[ ,(:]LIB *= *"symbol, altlib ) ? altlib[1] : "mingwex"; \
+    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
+libmingwthrd.a libmingwthrd_old.a: crtmt.$(OBJEXT)
+mingwthrd_old.def mingwm10.dll: $(addsuffix .$(OBJEXT), mthr mthr_init)
+mingwthrd_old.def:
+       $(DLLTOOL) --as $(AS) --output-def $@ $^
+
+libmingwthrd_old.a: lib%.a: %.def
+       $(DLLTOOL) --as $(AS) --input-def $< --dllname mingwm10.dll --output-lib $@
+       $(AR) $(ARFLAGS) $@ $(call extra_objects_filter,$^)
+
+all-mingwrt-dll install-mingwrt-dll-files: mingwm10.dll
+mingwm10.dll: mingwthrd_old.def
+       $(CC) -shared -o $@ -Wl,--image-base,0x6FBC0000 \
+         -Wl,--entry,_DllMainCRTStartup@12 $^
+
+# Code profiling support, using the GNU profiling library; (note
+# that applications using this library MUST be licensed to comply
+# with the GNU General Public License).
+#
+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"
+
+# DLLVERSION must be specified for each DLL file itself, and also for
+# the associated installation and distribution rules; the appropriate
+# dependencies may be specified by use of this function macro:
+#
+optional_dll = mingwrt-$1-optdist install-$1-optional-dll $2
+
+# 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.
+#
+$(call optional_dll,libmingwex,@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
+# ------------------
+#
+# Users may expect to be able to specify DESTDIR, to stage the
+# following stock installation directories outside of the regular
+# "as configured" installation tree; unfortunately, this expectation
+# MUST fail, when the stock path is in MS-Windows absolute format, so
+# we provide an exception mechanism to forbid such usage, and we
+# proceed to create the directories only when the exception is
+# NOT triggered.
+#
+.PHONY: DESTDIR-UNSUPPORTED
+bindir docdir includedir libdir mandir htmldir pdfdir:
+       @test -z "$(strip ${DESTDIR})" || case $($@) in ${DESTDIR}?:*) \
+         $(MAKE) --no-print-directory reject=$@ DESTDIR-UNSUPPORTED;; \
+         esac
+       $(call mkinstalldirs,,$($@))
+
+# Note: we MUST use a recursive make invocation here, as the
+# "error" function within the accompanying diagnostics would be
+# triggered, irrespective of its placement in an unexecuted
+# branch of the above exception trapping shell code.
+#
+DESTDIR-UNSUPPORTED:
+       $(call MSG_DESTDIR_FORBIDDEN,$(reject),$($(reject):${DESTDIR}%=%))
+
+# The following macros, which rely heavily on GNU make's "call"
+# function, define the diagnostics to be emitted, when the DESTDIR
+# exception is triggered.
+#
+QUOTE = `$1'#'`
+MSG_DESTDIR_FORBIDDEN = \
+  $(warning *** $(call MSG_DESTDIR_PATH_CONFLICT,$1,Win32,$2);) \
+  $(error try $(call QUOTE,$(call MSG_DESTDIR_ALTERNATIVE,$1,$2)) instead)
+MSG_DESTDIR_BAD_PATH = DESTDIR is not supported when $1 contains $2 path $3
+MSG_DESTDIR_PATH_CONFLICT = $(call MSG_DESTDIR_BAD_PATH,$1,$2,$(call QUOTE,$3))
+MSG_DESTDIR_ALTERNATIVE = make install $1="$(call MSG_DESTDIR_TRANSFORM,$2)"
+MSG_DESTDIR_TRANSFORM = ${DESTDIR}$(shell echo $1 | sed 's/^.://')
+
+# Install everything.
+#
+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
+
+install-strip: install-strip-mingwrt
+install-strip-%:
+       $(MAKE) --no-print-directory \
+         STRIP_DATA='cd ${libdir}; $(STRIP) --strip-unneeded $$1' \
+         STRIP_DLL='cd ${bindir}; $(STRIP) $$1' install-$*
+
+# Install licence files.
+#
+install-license: install-mingwrt-license
+install-licence install-mingwrt-licence: %-licence: %-license
+
+vpath DISCLAIMER ${mingwrt_srcdir}
+vpath COPYING ${mingwrt_srcdir}/profile
+vpath CYGWIN_LICENSE ${mingwrt_srcdir}/profile
+mingwrt-license-files: COPYING CYGWIN_LICENSE DISCLAIMER
+
+# FIXME: The following rule is generalized, such that it may accommodate
+# both mingwrt and w32api, (and other packages); thus, it should ideally
+# be relocated into a common (shared) Makefile fragment.
+#
+install-mingwrt-license install-w32api-license: install-%: docdir %-files
+%-license-files:
+       $(call mkinstalldirs,,${docdir}/$*/$(PACKAGE_VERSION))
+       $(call INSTALL_DATA,$^,${docdir}/$*/$(PACKAGE_VERSION))
+
+# Install headers associated with the MinGW runtime libraries.
+#
+includedirs: mingwrt-includedirs
+install-headers install-mingwrt: install-mingwrt-headers
+
+mingwrt-includedirs: includedir $(eval mingwrt_include_subdirs=sys parts)
+       $(call mkinstalldirs,${includedir}/,$(mingwrt_include_subdirs))
+
+SUB_HEADERS_PRESENT = echo $1/include/$2/*.h | grep -v '[*]' > /dev/null
+INSTALL_SUB_HEADERS = $(call INSTALL_DATA,$1/include/$2/*.h,${includedir}/$2)
+
+install-mingwrt-headers: _mingw.h mingwrt-includedirs
+       $(call INSTALL_DATA,_mingw.h,${includedir})
+       $(call INSTALL_DATA,${mingwrt_srcdir}/include/*.h,${includedir})
+       for dir in $(mingwrt_include_subdirs); do \
+         if $(call SUB_HEADERS_PRESENT,${mingwrt_srcdir},$$dir); then \
+           $(call INSTALL_SUB_HEADERS,${mingwrt_srcdir},$$dir); \
+           fi; \
+         done
+       $(call INSTALL_DATA,${mingwrt_srcdir}/profile/*.h,${includedir})
+
+# Install libraries, and supporting free standing object files.
+#
+install-libs install-mingwrt: install-mingwrt-libdir-libs
+install-libdir-objects install-mingwrt: install-mingwrt-libdir-objects
+
+install-mingwrt-libdir-libs: libdir $(call active_goals,install,mingwrt-libs)
+install-mingwrt-libdir-objects: libdir $(call active_goals,install,crt-objects)
+
+install-crt-objects install-deprecated-crt-objects \
+install-mingwrt-libs install-deprecated-mingwrt-libs:
+       $(call INSTALL_DATA,$^,${libdir})
+       $(if $(STRIP_DATA),$(call STRIP_DATA,$^))
+
+
+# Install DLLs.
+#
+install-mingwrt: install-mingwrt-dll
+install-bin install-dll: install-mingwrt-dll
+install-mingwrt-bin install-w32api-bin: install-%-bin: install-%-dll
+install-mingwrt-dll install-w32api-dll: install-%-dll: bindir install-%-dll-files
+install-%-dll-files:
+       $(call INSTALL_DATA,$^,${bindir})
+       $(if $(STRIP_DLL),$(call STRIP_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
+manpages = $(basename $(notdir $(wildcard $1/man/*.$2.man)))
+mancopy = $(call manpage_ref,$1,$2.man)$(eval $1: %: %.$0-recursive)
+manpage_ref = $(eval $1: export reference_manpage = $2)
+
+install-man install-manpages: install-mingwrt-manpages
+mingwrt-man$(man3ext): $(call manpages,${mingwrt_srcdir},$(man3ext))
+install-mingwrt-manpages: mandir mingwrt-man$(man3ext)
+
+mingwrt-man%:
+       $(call mkinstalldirs,,${man$*dir})
+       $(call INSTALL_DATA,$^,${man$*dir})
+       $(RM) $^
+
+%: %.man
+       $(call format_manpage,$(basename $*),$(suffix $*),$<) $< > $@
+
+format_manpage = sed \
+  -e "s/%PAGEREF%/`echo $1 | tr a-z A-Z` $(2:.%=%) `date -r $3 +%d-%b-%Y`/"
+
+manpage_copy = $(eval $1$3: $2.$3)$(call mancopy,$2.$3,$4)
+$(call manpage_copy,mingwrt-man,basename,$(man3ext),dirname.$(man3ext))
+$(call manpage_copy,mingwrt-man,getdelim,$(man3ext),getline.$(man3ext))
+
+%.mancopy-recursive:
+       $(MAKE) --no-print-directory $*.mancopy
+
+%.mancopy: $(reference_manpage)
+       $(call format_manpage,$(basename $*),$(suffix $*),$<) $< > $*
+
+
+# Undo Installation
+# -----------------
+#
+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
+
+REMOVE_HEADERS = cd $1 && $(RM) $(notdir $(wildcard $2))
+
+uninstall-mingwrt-headers:
+       $(call REMOVE_HEADERS,${includedir},${mingwrt_srcdir}/include/*.h)
+       for dir in $(mingwrt_include_subdirs); do \
+         files=`cd ${mingwrt_srcdir}/include/$$dir && echo *.h`; \
+         (cd ${includedir}/$$dir && $(RM) $$files); \
+         done
+       $(call REMOVE_HEADERS,${includedir},${mingwrt_srcdir}/profile/*.h)
+
+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' $*
+
+
+# Test Suite
+# ----------
+#
+.PHONY: check-recursive
+check test tests: check-recursive
+check-recursive:
+       $(MAKE) -C tests $@
+
+
+# Distribution
+# ------------
+#
+.PHONY: dist
+dist: devdist dlldist licdist mandist optdist srcdist
+       $(RM) -r dist/mingwrt dist/w32api
+
+mingwrt-dist-staged w32api-dist-staged: %-dist-staged:
+       $(RM) -r dist/$*
+       $(MAKE) --no-print-directory prefix=`pwd`/dist/$* install-strip-$*
+
+devdist: mingwrt-devdist
+mingwrt_devdist_objects = dist/mingwrt/lib/*.$(OBJEXT)
+mingwrt-devdist w32api-devdist: %-devdist: %-dist-staged
+       cd dist/$* && tar chf - --hard-dereference include lib | \
+         xz -c > ../$*-$(PACKAGE_RELEASE_TAG)-dev.tar.xz
+
+dlldist: mingwrt-dlldist
+mingwrt-dlldist: %-dlldist: %-dist-staged
+       cd dist/$* && tar chf - --hard-dereference bin | \
+         xz -c > ../$*-$(PACKAGE_RELEASE_TAG)-dll.tar.xz
+
+licdist: mingwrt-licdist
+mingwrt-licdist w32api-licdist: %-licdist:
+       $(RM) -r tmp
+       $(MAKE) --no-print-directory prefix=`pwd`/tmp install-$*-licence
+       cd tmp && tar chf - --hard-dereference * | \
+         xz -c > ../dist/$*-$(PACKAGE_RELEASE_TAG)-lic.tar.xz
+       $(RM) -r tmp
+
+mandist: mingwrt-mandist
+mingwrt-mandist: %-mandist:
+       $(RM) -r tmp
+       $(MAKE) --no-print-directory prefix=`pwd`/tmp install-$*-manpages
+       cd tmp && tar chf - --hard-dereference share | \
+         xz -c > ../dist/$*-$(PACKAGE_RELEASE_TAG)-man.tar.xz
+       $(RM) -r tmp
+
+optdist: mingwrt-optdist
+mingwrt-optdist: mingwrt-libmingwex-optdist
+
+mingwrt-%-optdist:
+       $(RM) -r tmp
+       $(MAKE) --no-print-directory prefix=`pwd`/tmp install-strip-$*-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) | \
+         xz -c > $(PACKAGE_TARNAME)-$(PACKAGE_RELEASE_TAG)-src.tar.xz
+       $(RM) -r dist/$(PACKAGE_TARNAME)-$(PACKAGE_VERSION)
+
+mingwrt-srcdist-dir:
+       $(RM) -r dist/$(PACKAGE_TARNAME)-$(PACKAGE_VERSION)
+       $(call mkinstalldirs,,dist/$(PACKAGE_TARNAME)-$(PACKAGE_VERSION))
+
+mingwrt-srcdist-files: mingwrt-srcdist-common-files
+mingwrt-srcdist-files: mingwrt-srcdist-testsuite-files
+mingwrt-srcdist-files: mingwrt-srcdist-package-files
+
+mingwrt-srcdist-package-files:
+       (cd ${mingwrt_srcdir} && tar chf - --hard-dereference $(notdir $^)) | \
+         (cd dist/$(PACKAGE_TARNAME)-$(PACKAGE_VERSION) && tar xf -)
+
+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}/,include man mingwex msvcrt-xref profile) \
+  $(addprefix ${mingwrt_srcdir}/,TODO Makefile.in crtdll.def) \
+  $(wildcard $(addprefix ${mingwrt_srcdir}/,*.sx *.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
+
+install-html-files install-pdf-files: install-%-files: \
+  $(addsuffix .%,$(wildcard ${man3dir}/*.$(man3ext)))
+
+%.$(man3ext).html: %.$(man3ext)
+       man2html $< | sed -e '1,/^<!DOCTYPE/{/^<!/p;d' -e '}' > ${htmldir}/$(notdir $@)
+       chmod 644 ${htmldir}/$(notdir $@)
+
+%.$(man3ext).pdf: %.$(man3ext)
+       man -t $(dir $<)$< | ps2pdf - > ${pdfdir}/$(notdir $@)
+       chmod 644 ${pdfdir}/$(notdir $@)
+
+html-docdist pdf-docdist: %-docdist:
+       $(RM) -r tmp
+       $(MAKE) --no-print-directory prefix=`pwd`/tmp install-$*
+       $(RM) -r tmp/share/man
+       cd tmp && tar chf - --hard-dereference share | \
+         xz -c > ../dist/mingwrt-doc-$(PACKAGE_RELEASE_TAG)-$*.tar.xz
+       $(RM) -r tmp
+
+
+# Clean-up Rules
+# --------------
+#
+clean-local: mostlyclean-local
+       $(RM) msvcr*.def moldname*.def mingw*.def lib*.a *.dll
+
+mostlyclean-local:
+       $(RM) *.d *.$(OBJEXT) Makefile.stub *.libimpl
+
+distclean-local: clean-local
+       $(RM) config.log config.status libm_dummy.c _mingw.h w32api.h
+
+maintainer-clean-warning:
+       $(warning $(MAKE) $(@:%-warning=%))
+       $(warning This command should be used by package maintainers only;)
+       $(warning it deletes files which may require special tools to rebuild.)
+
+maintainer-clean-local: maintainer-clean-warning distclean-local
+       $(RM) -r ${mingwrt_srcdir}/autom4te.cache
 
-TAR = tar
-TARFLAGS = z
-TARFILEEXT = .tar.gz
-
-SUBDIRS = mingwex profile
-
-# FIXME: Most of these are either redundant, or should be set
-# directly in the subdirectories' Makefiles, by `configure'.
-FLAGS_TO_PASS:=\
-       AS="$(AS)" \
-       CC="$(CC)" \
-       CFLAGS="$(CFLAGS) $(CFLAGS_COMMON) $(CFLAGS_CONFIG)" \
-       CXXFLAGS="$(CXXFLAGS) $(CFLAGS_COMMON) $(CFLAGS_CONFIG)" \
-       EXE_LDFLAGS="$(EXE_LDFLAGS)" \
-       AR="$(AR)" \
-       RANLIB="$(RANLIB)" \
-       LD="$(LD)" \
-       DLLTOOL="$(DLLTOOL)" \
-       exec_prefix="$(exec_prefix)" \
-       bindir="$(bindir)" \
-       libdir="$(libdir)" \
-       tooldir="$(tooldir)" \
-       datadir="$(datadir)" \
-       infodir="$(infodir)" \
-       includedir="$(includedir)" \
-       inst_bindir="$(inst_bindir)" \
-       inst_includedir="$(inst_includedir)" \
-       inst_libdir="$(inst_libdir)" \
-       inst_docdir="$(inst_docdir)" \
-       prefix="$(prefix)" \
-       target_alias="$(target_alias)" \
-       TAR="$(TAR)" \
-       TARFLAGS="$(TARFLAGS)" \
-       TARFILEEXT="$(TARFILEEXT)"
-
-CRT0S = crt1.o dllcrt1.o crt2.o dllcrt2.o CRT_noglob.o crtmt.o crtst.o \
-       CRT_fp8.o CRT_fp10.o txtmode.o binmode.o
-MINGW_OBJS = CRTglob.o CRTfmode.o CRTinit.o  dllmain.o gccmain.o \
-            main.o crtst.o CRT_fp10.o txtmode.o \
-            pseudo-reloc.o pseudo-reloc-list.o cpu_features.o \
-            tlsmcrt.o tlsmthread.o tlssup.o tlsthrd.o
-
-MOLD_OBJS = isascii.o iscsym.o iscsymf.o toascii.o \
-       strcasecmp.o strncasecmp.o wcscmpi.o
-
-LIBS = libcrtdll.a \
-       libmsvcrt.a  libmsvcrtd.a \
-       libmsvcr70.a libmsvcr70d.a \
-       libmsvcr71.a libmsvcr71d.a \
-       libmsvcr80.a libmsvcr80d.a \
-       libmsvcr90.a libmsvcr90d.a \
-       libmsvcr100.a libmsvcr100d.a \
-       libmingw32.a \
-       libcoldname.a \
-       libmoldname.a   libmoldnamed.a \
-       libmoldname70.a libmoldname70d.a \
-       libmoldname71.a libmoldname71d.a \
-       libmoldname80.a libmoldname80d.a \
-       libmoldname90.a libmoldname90d.a \
-       libmoldname100.a libmoldname100d.a \
-       $(LIBM_A) \
-       libmingwthrd_old.a \
-       libmingwthrd.a
-
-DLLS = $(THREAD_DLL_NAME)
-
-INSTDOCS = CONTRIBUTORS \
-          DISCLAIMER \
-          README
-
-SRCDIST_FILES = CRT_noglob.c CRTfmode.c CRTglob.c CRTinit.c ChangeLog \
-Makefile.in README TODO config.guess config.sub configure configure.in \
-aclocal.m4 crt1.c crtdll.def crtmt.c crtst.c  dllcrt1.c dllmain.c \
-gccmain.c init.c install-sh jamfile main.c mkinstalldirs \
-moldname.def.in msvcrt.def.in ofmt_stub.s \
-mthr.c mthr_init.c tlsmcrt.c tlsmthread.c tlssup.c tlsthrd.c readme.txt \
-isascii.c iscsym.c iscsymf.c toascii.c \
-strcasecmp.c strncasecmp.c wcscmpi.c \
-CRT_fp8.c CRT_fp10.c test_headers.c txtmode.c binmode.c pseudo-reloc.c \
-pseudo-reloc-list.c cpu_features.c cpu_features.h \
-DISCLAIMER CONTRIBUTORS
-
-
-all_dlls_host = @all_dlls_host@
-install_dlls_host = @install_dlls_host@
-
-all: $(CRT0S) $(LIBS) $(all_dlls_host)
-
-all_dlls_host: $(DLLS)
-
-install_dlls_host:
-       for i in $(DLLS); do \
-               $(INSTALL_PROGRAM) $$i $(DESTDIR)$(inst_bindir)/$$i ; \
-       done
-
-_libm_dummy.o:
-       rm -f _libm_dummy.c
-       echo "static int __mingw_libm_dummy;" > _libm_dummy.c
-       $(CC) -c $(ALL_CFLAGS) _libm_dummy.c
-       rm -f _libm_dummy.c
-
-libm.a: _libm_dummy.o
-       $(AR) rc $@ _libm_dummy.o
-       $(RANLIB) $@
-
-libmingwthrd.a: crtmt.o
-       $(AR) $(ARFLAGS) $@ crtmt.o
-       $(RANLIB) $@
-
-libmingwthrd_old.a: crtmt.o mingwthrd.def
-       $(DLLTOOL) $(DLLTOOL_FLAGS) --dllname $(THREAD_DLL_NAME) \
-         --def mingwthrd.def --output-lib $@
-       $(AR) $(ARFLAGS) $@ crtmt.o
-       $(RANLIB) $@
-
-DLL_OFILES        = mthr.o mthr_init.o
-DLL_CC_STUFF      = -B./ -shared $(MNO_CYGWIN) -Wl,--image-base,0x6FBC0000 \
-                   -Wl,--entry,_DllMainCRTStartup@12 \
-                    $(DLL_OFILES) mingwthrd.def \
-                   -Lmingwex
-
-$(THREAD_DLL_NAME) mingwthrd.def: $(DLL_OFILES) Makefile $(SUBDIRS)
-       $(DLLTOOL) --as $(AS) --output-def mingwthrd.def $(DLL_OFILES)
-       $(CC) $(DLL_CC_STUFF) -o $(THREAD_DLL_NAME)
-
-libmingw32.a: $(MINGW_OBJS)
-       $(AR) rc $@ $(MINGW_OBJS)
-       $(RANLIB) $@
-
-msvcrt.def  msvcrtd.def \
-msvcr70.def msvcr70d.def \
-msvcr71.def msvcr71d.def \
-msvcr80.def msvcr80d.def \
-msvcr90.def msvcr90d.def \
-msvcr100.def msvcr100d.def: msvcrt.def.in
-       V=`echo $@ | sed -e 's|[a-z]*\([0-9]*\).*|\1|'`; \
-       test -z "$$V" && V=60; \
-       V="0x0$${V}0"; \
-       $(CC) -DRUNTIME=$(basename $(notdir $@)) \
-               -D__MSVCRT_VERSION__=$$V \
-               -D__$(basename $(notdir $@))__=1 \
-               -D__MSVCRT__ -C -E -P \
-               -xc-header $? > $@
-
-moldname-crtdll.def: moldname.def.in
-       $(CC) -DRUNTIME=crtdll \
-               -D__FILENAME__=moldname-crtdll.def \
-               -D__CRTDLL__  -C -E -P \
-               -xc-header $? > $@
-
-moldname-msvcrt.def: moldname.def.in
-       $(CC) -DRUNTIME=msvcrt \
-               -D__FILENAME__=moldname-msvcrt.def \
-               -D__MSVCRT__  -C -E -P \
-               -xc-header $? > $@
-
-libcoldname.a: moldname-crtdll.def $(MOLD_OBJS)
-       $(DLLTOOL) --as $(AS) -k -U     \
-               --dllname crtdll.dll    \
-               --def moldname-crtdll.def       \
-               --output-lib $@
-       $(AR) rc $@ $(MOLD_OBJS)
-       $(RANLIB) $@
-
-libmoldname.a libmoldnamed.a: moldname-msvcrt.def $(MOLD_OBJS)
-       $(DLLTOOL) --as $(AS) -k -U     \
-               --dllname msvcrt$(@:libmoldname%a=%)dll \
-               --def moldname-msvcrt.def       \
-               --output-lib $@
-       $(AR) rc $@ $(MOLD_OBJS)
-       $(RANLIB) $@
-
-libmoldname70.a libmoldname70d.a \
-libmoldname71.a libmoldname71d.a \
-libmoldname80.a libmoldname80d.a \
-libmoldname90.a libmoldname90d.a \
-libmoldname100.a libmoldname100d.a: moldname-msvcrt.def $(MOLD_OBJS)
-       $(DLLTOOL) --as $(AS) -k -U     \
-               --dllname msvcr$(@:libmoldname%a=%)dll  \
-               --def moldname-msvcrt.def       \
-               --output-lib $@
-       $(AR) rc $@ $(MOLD_OBJS)
-       $(RANLIB) $@
-
-# These special rules are necessary...
-#
-crt1.o dllcrt1.o:
-       $(CC) -c -D__CRTDLL__ -U__MSVCRT__ $(ALL_CFLAGS) $< -o $@
-
-crt2.o dllcrt2.o:
-       $(CC) -c -D__MSVCRT__ -U__CRTDLL__ $(ALL_CFLAGS) $< -o $@
-
-check: check-headers
-
-TEST_H_OPTIONS = $(ALL_CFLAGS) -Wall -W -Wsystem-headers -c \
-       $(srcdir)/test_headers.c -o test_headers.o
-
-.PHONY: check-headers
-check-headers: force
-       @echo "Testing runtime headers..."
-       @for lang in c c++ objective-c ; do \
-               echo "$$lang ..."; \
-               $(CC) -x$$lang  $(TEST_H_OPTIONS) ; \
-               echo "$$lang -ansi"; \
-               $(CC) -x$$lang -ansi $(TEST_H_OPTIONS) ; \
-       done
-       @echo; echo "Testing runtime 8.0 headers..."
-       @for lang in c c++ objective-c ; do \
-               echo "$$lang ..."; \
-               $(CC) -x$$lang -Wall -D__MSVCRT_VERSION__=0x0800 $(TEST_H_OPTIONS) ; \
-               echo "$$lang -ansi"; \
-               $(CC) -x$$lang -Wall -D__MSVCRT_VERSION__=0x0800 -ansi $(TEST_H_OPTIONS) ; \
-       done
-       @echo; echo "Testing runtime 8.0(time32) headers..."
-       @for lang in c c++ objective-c ; do \
-               echo "$$lang ..."; \
-               $(CC) -x$$lang -Wall -D__MSVCRT_VERSION__=0x0800 -D_USE_32BIT_TIME_T $(TEST_H_OPTIONS) ; \
-               echo "$$lang -ansi"; \
-               $(CC) -x$$lang -Wall -D__MSVCRT_VERSION__=0x0800 -D_USE_32BIT_TIME_T -ansi $(TEST_H_OPTIONS) ; \
-       done
-       @echo; echo "Testing runtime 8.0(time32) headers..."
-# specify -std=xx only for C
-       @for std in gnu89 gnu99 c89 c99 ; do \
-               echo "std = $$std"; \
-               $(CC) -std=$$std  $(TEST_H_OPTIONS) ; \
-       done
-
-       @rm -f test_headers.o
-
-clean:
-       -rm -f *.o *.a *~ core a.out mingwthrd.def mingwthrd.base mingwthrd.exp
-       -rm -f $(THREAD_DLL_NAME) mingwthrd_dummy.exe
-       -rm -f msvcr*.def moldname-*.def
-       @$(MAKE) subdirs DO=$@ $(FLAGS_TO_PASS)
-
-distclean: clean
-       @$(MAKE) subdirs DO=$@ $(FLAGS_TO_PASS)
-       -rm -f config.cache config.status config.log
-       -rm -f Makefile
-
-ifdef SNAPDATE
-      distdir=$(PACKAGE)-$(VERSION)-$(SNAPDATE)
-else
-   ifneq (,$(findstring cygwin, $(target_alias)))
-      distdir=$(PACKAGE)-$(VERSION)-$(CYGRELEASE)
-   else
-      distdir=$(PACKAGE)-$(VERSION)-$(host_os)
-   endif
-endif
-
-ifneq (,$(findstring cygwin, $(target_alias)))
-#
-# FIXME: Dubious use of `target_alias', yet again.
-#
-# Once more, the default settings for these macros could be
-# more productively determined by `configure'.
-#
-  TARFLAGS = j
-  TARFILEEXT = .tar.bz2
-  dist_prefix = $(conf_prefix)
-endif
-
-dist: srcdist bindist
-
-srcdist:
-       rm -rf $(distdir)
-       mkdir $(distdir)
-       chmod 755 $(distdir)
-       for i in $(SRCDIST_FILES); do \
-               cp -p $(srcdir)/$$i $(distdir)/$$i ; \
-       done
-       for i in $(SUBDIRS); do \
-               (cd $$i; $(MAKE) distdir=../$(distdir) dist); \
-       done
-#FIXME this needs to be done with SUBDIRS and Makefiles.
-#
-#  Maybe, but this is simpler, and adequate for now!
-#  However, as more manpages are added, spanning multiple sections,
-#  we'll probably need a separate Makefile to organise them.
-#
-       mkdir $(distdir)/include
-       mkdir $(distdir)/include/sys
-       cp $(srcdir)/include/*.h $(distdir)/include/
-       cp $(srcdir)/include/sys/*.h $(distdir)/include/sys/
-       mkdir $(distdir)/man
-       cp $(srcdir)/man/*.man $(distdir)/man/
-#
-#end FIXME
-       rm -f $(distdir)-src.tar.gz
-       $(TAR) $(TARFLAGS)cf $(distdir)-src$(TARFILEEXT) $(distdir)
-
-# Binary package structure is determined according to the
-# preferred package name assigned at configure time...
-#
-bindist: bindist-$(PACKAGE)
-
-# The directory structure is common to both package styles...
-#
-bindist-common:
-       rm -rf $(distdir)
-       mkdir $(distdir)
-       chmod 755 $(distdir)
-       $(MAKE) install prefix=$(shell pwd)/$(distdir)$(dist_prefix)
-       rm -f $(distdir).tar.gz
-
-# Current MinGW distributions prefer separate `dev' and `dll' bundles,
-# and use the abbreviated `mingwrt' form for the package name...
-#
-DEVDIST_FILES = * --exclude=bin
-DLLDIST_FILES = bin/*.dll doc/*
-#
-bindist-mingwrt: bindist-common
-       cd $(distdir); \
-       $(TAR) $(TARFLAGS)cf ../$(distdir)-dev$(TARFILEEXT) $(DEVDIST_FILES); \
-       $(TAR) $(TARFLAGS)cf ../$(distdir)-dll$(TARFILEEXT) $(DLLDIST_FILES)
-       rm -rf $(distdir)
-
-# However, Cygwin maintainers continue to prefer a composite package,
-# retaining the older `mingw-runtime' naming convention...
-#
-BINDIST_FILES = *
-#
-bindist-mingw-runtime: bindist-common
-       cd $(distdir); \
-       $(TAR) $(TARFLAGS)cf ../$(distdir)$(TARFILEEXT) $(BINDIST_FILES)
-       rm -rf $(distdir)
-
-snapshot:
-       make dist SNAPDATE=$(shell date '+%Y%m%d')
-
-info:
-
-info-html:
-
-install-info: info
-
-.PHONY: $(need-DESTDIR-compatibility) fail-DESTDIR-compatibility
-
-$(need-DESTDIR-compatibility):
-       @test -z "$(DESTDIR)" || case "$($@)" in ?:*) \
-         $(MAKE) --no-print-directory reject="$@" fail-DESTDIR-compatibility ;; \
-       esac
-
-fail-DESTDIR-compatibility:
-       $(error DESTDIR is not supported when $(reject) contains Win32 path `$($(reject))'; \
-       try `make install $(reject)=$(shell echo '$($(reject))' | sed s,:,:$(DESTDIR),) ...' instead)
-
-install-dirs: $(need-DESTDIR-compatibility)
-       $(mkinstalldirs) $(DESTDIR)$(inst_bindir)
-       $(mkinstalldirs) $(DESTDIR)$(inst_includedir)
-       $(mkinstalldirs) $(DESTDIR)$(inst_libdir)
-       $(mkinstalldirs) $(DESTDIR)$(inst_docdir)
-       $(mkinstalldirs) $(DESTDIR)$(mandir)/man$(mansection)
-
-install: all install-dirs $(install_dlls_host)
-       for i in $(LIBS); do \
-               $(INSTALL_DATA) $$i $(DESTDIR)$(inst_libdir)/$$i ; \
-       done
-       for i in $(CRT0S); do \
-               $(INSTALL_DATA) $$i $(DESTDIR)$(inst_libdir)/$$i ; \
-       done
-       for i in $(INSTDOCS); do \
-               $(INSTALL_DATA) $(srcdir)/$$i $(DESTDIR)$(inst_docdir)/$$i ; \
-       done
-       for sub in . sys ; do \
-               dstdir=$(DESTDIR)$(inst_includedir)/$$sub ; \
-               $(mkinstalldirs) $$dstdir ; \
-               for i in $(srcdir)/include/$$sub/*.h ; do \
-                 $(INSTALL_DATA) $$i $$dstdir/`basename $$i` ; \
-               done ; \
-       done
-#
-# This provisional hack installs the only manpage we have at present...
-# It simply CANNOT suffice, when we have more manpages to ship.
-#
-       $(mkinstalldirs) $(DESTDIR)$(mandir)/man$(mansection)
-       $(INSTALL_DATA) $(srcdir)/man/dirname.man $(DESTDIR)$(mandir)/man$(mansection)/`\
-         echo dirname.man|sed '$(manpage_transform);s,man$$,$(mansection),'`
-       $(INSTALL_DATA) $(srcdir)/man/dirname.man $(DESTDIR)$(mandir)/man$(mansection)/`\
-         echo basename.man|sed '$(manpage_transform);s,man$$,$(mansection),'`
-#
-# End provisional hack.
-#
-       @$(MAKE) subdirs DO=$@ $(FLAGS_TO_PASS)
-
-subdirs: $(SUBDIRS)
-$(SUBDIRS): force
-       @test -n "$(DO)" && g="$(DO)" || g=all; echo "Making \`$$g' in \`$@'"
-       @cd $@; $(MAKE) $(FLAGS_TO_PASS) $(DO)
-
-force:
-
-#
-# Dependencies
-#
-libcrtdll.a: crtdll.def
-libmsvcrt.a: msvcrt.def
-libmsvcrtd.a: msvcrtd.def
-CRT_noglob.o: CRT_noglob.c
-CRTfmode.o: CRTfmode.c
-CRTglob.o: CRTglob.c
-CRTinit.o: CRTinit.c
-crt1.o: crt1.c init.c
-crt2.o: crt1.c init.c
-crtmt.o: crtmt.c
-crtst.o: crtst.c
-ctype_old.o: ctype_old.c
-dllcrt1.o: dllcrt1.c
-dllcrt2.o: dllcrt1.c
-dllmain.o: dllmain.c
-main.o: main.c
-oldnames.o: oldnames.c
-string_old.o: string_old.c
-CRT_fp8.o: CRT_fp8.c
-CRT_fp10.o: CRT_fp10.c
-
-
-Makefile: Makefile.in config.status configure
-       $(SHELL) config.status
-
-config.status: configure
-       $(SHELL) config.status --recheck
-
-.SUFFIXES: .y $(SUFFIXES) .cc .def .a
-
-sym_prefix = __msvcrt
-
-NM_LOOKUP = $(NM) $@ | sed -n \
-  -e '/:$$/h;/^[0-7][0-7]*  *T  */{s///;H;g;s/\n//p' \
-  -e '}' | sed -n 's/:_'"$$key"'$$//p'
-
-MINGW_REPL_FUNCS = printf fprintf sprintf vprintf vfprintf vsprintf
-
-lib%.a: %.def
-       $(DLLTOOL) --as=$(AS) -k --dllname $*.dll --output-lib $@ --def $<
-       for key in $(MINGW_REPL_FUNCS); do \
-         src=`$(NM_LOOKUP)`; \
-         if test -n "$$src"; then \
-           dst=`echo "$$src" | sed 's/0/4/'`; repl="$$repl $$dst"; \
-           tmpfiles="$$tmpfiles $$src $$dst"; \
-           $(AR) x $@ $$src; \
-           $(OBJCOPY) --redefine-sym _$$key=_$(sym_prefix)_$$key \
-             --redefine-sym __imp__$$key=__imp__$(sym_prefix)_$$key \
-             $$src $$dst; \
-         fi; done; \
-       test `key=_get_output_format; $(NM_LOOKUP)` || \
-         repl="$$repl ofmt_stub.o"; \
-       test -n "$$repl" && $(AR) rcs $@ $$repl; \
-       $(RM) $$tmpfiles
-
-libmsvcrt.a  libmsvcrtd.a:  ofmt_stub.o
-libmsvcr70.a libmsvcr70d.a: ofmt_stub.o
-libmsvcr71.a libmsvcr71d.a: ofmt_stub.o
-libcrtdll.a  libcrtdlld.a:  ofmt_stub.o
-
-.c.o:
-       $(CC) -c $(ALL_CFLAGS) $< -o $@
+clean mostlyclean distclean maintainer-clean: %clean: %clean-local
 
 # $RCSfile$: end of file