OSDN Git Service

Extend basic test suite infrastructure to w32api.
[mingw/mingw-org-wsl.git] / w32api / Makefile.in
index 11dfb3a..b6d7b83 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, 2015, MinGW.org Project
+# Copyright (C) 2014-2017, MinGW.org Project
 #
 #
 # Permission is hereby granted, free of charge, to any person obtaining a
@@ -78,6 +78,7 @@ mkinstalldirs = @MKDIR_P@ $(addprefix $1,$2)
 
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@ $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
@@ -108,10 +109,30 @@ 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}
-configure: configure.ac aclocal.m4
-       cd ${top_srcdir}; autoconf
+vpath %.m4 ${top_srcdir}/.. ${top_srcdir}
+configure: configure.ac aclocal.m4 VERSION.m4
+       cd ${top_srcdir}; autoconf -I ..
+
+# Propagate package version, as configured, consistently throughout
+# the package build.
+#
+vpath %.h.in ${top_srcdir}/include ${mingwrt_srcdir}/include
+
+w32api.h _mingw.h: configure.ac
+
+PACKAGE_VERSION_SCRIPT = sed \
+  -e s"`$(call PACKAGE_VERSION_FORMAT,LONG,%d,$$3+1000*($$2+1000*$$1))`" \
+  -e s"`$(call PACKAGE_VERSION_FORMAT,MAJOR,%7d,$$1)`" \
+  -e s"`$(call PACKAGE_VERSION_FORMAT,MINOR,%7d,$$2)`" \
+  -e s"`$(call PACKAGE_VERSION_FORMAT,PATCH,%7d,$$3)`"
+
+PACKAGE_VERSION_FORMAT = echo $(PACKAGE_VERSION).0.0 | awk -F. '{ \
+  printf ",%%PACKAGE_VERSION_$1%%,$2,", $3; \
+}'
+
+w32api.h _mingw.h: %.h: %.h.in
+       $(PACKAGE_VERSION_SCRIPT) $< > $@
 
 # Capture dependencies conveyed within source files, ensuring that
 # header files are taken from our working source tree, and not from
@@ -136,6 +157,7 @@ deffiles = $(eval vpath %.def $1)$(notdir $(wildcard $1/*.def))
 implibfiles = $(addprefix lib,$(subst .def,.a,$(call deffiles,$1)))
 
 all: all-w32api-libs
+all-w32api-libs: w32api.h _mingw.h
 all-w32api-libs install-w32api-libs: $(call implibfiles,${srcdir}/lib)
 all-w32api-libs install-w32api-libs: $(call implibfiles,${srcdir}/lib/directx)
 all-w32api-libs install-w32api-libs: $(call implibfiles,${srcdir}/lib/ddk)
@@ -238,8 +260,28 @@ w32api-include-dirs: includedir
 w32api-lib-dirs: libdir
 
 install-headers: install-w32api-headers
-install-w32api-headers: w32api-include-dirs
-       $(call INSTALL_DATA,${srcdir}/include/*.h,${includedir})
+
+obsolete_headers := winable.h pbt.h
+winable.h pbt.h: replacement = winuser.h
+
+$(obsolete_headers): %.h: obsolete.h.in
+       $(if $(subst ./,,$(dir $@)),mkdir -p $(@D))
+       $(obsolete_header_script) $< > $@
+
+obsolete_header_script = sed -e 's,%HEADER%,$@,' \
+  -e "s,%PACKAGE%,$(call macro_name,$(PACKAGE_TARNAME))," \
+  -e 's,<REPLACEMENT>,$(call replace_header,$(replacement)),' \
+  -e "s,%GUARD_MACRO%,$(call macro_name,$@)," \
+  -e 's,%REPLACEMENT%,$(replacement),'
+
+replace_header = $(if $(subst ./,,$(dir $1)),<$1>,"$1")
+macro_name = `echo $1 | tr .a-z- _A-Z_`
+
+w32api_generated_headers := w32api.h $(obsolete_headers)
+w32api_dist_headers := $(w32api_generated_headers) ${srcdir}/include/*.h
+
+install-w32api-headers: $(w32api_dist_headers)  w32api-include-dirs
+       $(call INSTALL_DATA,$(w32api_dist_headers),${includedir})
        for dir in $(w32api_extra_include_dirs); do \
          $(call INSTALL_DATA,${srcdir}/include/$$dir/*.h,${includedir}); \
          done
@@ -254,7 +296,7 @@ install-w32api-libs: w32api-lib-reqs
        $(if $(STRIP_LIBS),$(call STRIP_LIBS,$(filter-out w32api-lib-reqs,$^)))
 
 install-strip-w32api-libs:
-       $(MAKE) --no-print-directory $(MAKEFLAGS) \
+       $(MAKE) --no-print-directory \
          STRIP_LIBS='cd ${libdir}; $(STRIP) --strip-unneeded $$1' \
          install-w32api-libs
 
@@ -272,9 +314,19 @@ uninstall-w32api-headers:
          done
 
 uninstall-w32api-libs: un%:
-       $(MAKE) --no-print-directory $(MAKEFLAGS) mkinstalldirs= \
+       $(MAKE) --no-print-directory mkinstalldirs= \
          INSTALL_DATA='cd $$2 && rm -f $$1' $*
 
+
+# Test Suite
+# ----------
+#
+.PHONY: check-recursive
+check test tests: check-recursive
+check-recursive:
+       $(MAKE) -C tests $@
+
+
 # Distribution
 # ------------
 #
@@ -303,11 +355,24 @@ mingwrt-srcdist w32api-srcdist: %-srcdist: %-srcdist-dir %-srcdist-files
          xz -c > $*-$(PACKAGE_RELEASE_TAG)-src.tar.xz
        $(RM) -r dist/$*-$(PACKAGE_VERSION)
 
+w32api-srcdist-testsuite-files: $(wildcard ${w32api_srcdir}/tests/*.at)
+w32api-srcdist-testsuite-files: $(wildcard ${w32api_srcdir}/tests/*.in)
+       (cd ${w32api_srcdir} && tar chf - $(addprefix tests/,$(notdir $^))) | \
+         (cd dist/$(PACKAGE_TARNAME)-$(PACKAGE_VERSION) && tar xf -)
+
 mingwrt-srcdist-dir w32api-srcdist-dir: %-srcdist-dir:
        $(RM) -r dist/$*-$(PACKAGE_VERSION)
        $(call mkinstalldirs,,dist/$*-$(PACKAGE_VERSION))
 
-mingwrt-srcdist-files w32api-srcdist-files: %-srcdist-files:
+w32api-srcdist-files: w32api-srcdist-config-files
+w32api-srcdist-files: w32api-srcdist-testsuite-files
+w32api-srcdist-files: w32api-srcdist-package-files
+
+vpath install-sh ${top_srcdir}/.. ${top_srcdir}
+%-srcdist-config-files: aclocal.m4 VERSION.m4 install-sh
+         cp -p $^ dist/$*-$(PACKAGE_VERSION)
+
+%-srcdist-package-files:
        (cd ${$*_srcdir} && tar chf - --hard-dereference $(notdir $^)) | \
          (cd dist/$*-$(PACKAGE_VERSION) && tar xf -)
 
@@ -315,13 +380,10 @@ mingwrt-devdist w32api-devdist: %-devdist: %-dist-staged
        cd dist/$* && tar chf - --hard-dereference include lib | \
          xz -c > ../$*-$(PACKAGE_RELEASE_TAG)-dev.tar.xz
 
-SRCDIST_ADD = $1-srcdist-files: $(addprefix ${$1_srcdir}/,$2)
+SRCDIST_ADD = $1-srcdist-package-files: $(addprefix ${$1_srcdir}/,$2)
 
 $(call SRCDIST_ADD,w32api,ChangeLog CONTRIBUTIONS README.w32api TODO)
-$(call SRCDIST_ADD,w32api,configure configure.ac aclocal.m4 Makefile.in)
-$(call SRCDIST_ADD,w32api,config.guess config.sub install-sh)
-$(call SRCDIST_ADD,w32api,include lib)
-
+$(call SRCDIST_ADD,w32api,configure configure.ac Makefile.in include lib)
 
 # Clean-up Rules
 # --------------