From 71992560f788ffb3c11a67ad92256a45d5ce09fe Mon Sep 17 00:00:00 2001 From: Keith Marshall Date: Sun, 15 Jan 2012 19:11:09 +0000 Subject: Add smart identification of auxiliary header file paths. --- winsup/w32api/ChangeLog | 19 +++++ winsup/w32api/Makefile.comm.in | 19 +---- winsup/w32api/Makefile.in | 2 +- winsup/w32api/aclocal.m4 | 174 +++++++++++++++++++++++++++++++++++++++++ winsup/w32api/configure.ac | 28 +------ 5 files changed, 199 insertions(+), 43 deletions(-) create mode 100644 winsup/w32api/aclocal.m4 (limited to 'winsup/w32api') diff --git a/winsup/w32api/ChangeLog b/winsup/w32api/ChangeLog index d4f0e5554..163c09929 100644 --- a/winsup/w32api/ChangeLog +++ b/winsup/w32api/ChangeLog @@ -1,3 +1,22 @@ +2012-01-15 Keith Marshall + + Add smart identification of auxiliary header file paths. + + * aclocal.m4: New file; replaces previously removed file of + same name, with entirely new content. + + * Makefile.in (DISTFILES): Reinstate aclocal.m4 + + * Makefile.comm.in (EXTRA_INCLUDES): Use AC_SUBST to assign it. + (BUILDENV): No longer required; remove all references to it. + + * configure.ac (BUILDENV): Redundant AC_SUBST variable; delete it. + (MINGW_AC_CONFIG_SRCDIR): Factor out; relocate it to aclocal.m4 + (EXTRA_INCLUDES): Define as AC_SUBST variable; assign value using... + (MINGW_AC_RUNTIME_SRCDIR): ...this new aclocal.m4 macro. + + * configure: Regenerated. + 2012-01-15 Keith Marshall More makefile code refactoring; fix top_srcdir references. diff --git a/winsup/w32api/Makefile.comm.in b/winsup/w32api/Makefile.comm.in index f1fa70c18..322de6fbc 100644 --- a/winsup/w32api/Makefile.comm.in +++ b/winsup/w32api/Makefile.comm.in @@ -35,6 +35,7 @@ LD = @LD@ CFLAGS = @CFLAGS@ ALL_CFLAGS = $(CFLAGS) $(INCLUDES) +EXTRA_INCLUDES = -nostdinc -iwithprefix include @EXTRA_INCLUDES@ DLLTOOL = @DLLTOOL@ DLLTOOL_FLAGS = --as=$(AS) -k @@ -43,24 +44,6 @@ WINDRES = @WINDRES@ RANLIB = @RANLIB@ AR = @AR@ -# Depending on if we build as part of winsup or mingw we need to -# add additional include paths in order to get the correct headers -# from the C library. -# -BUILDENV = @BUILDENV@ - -ifeq ($(BUILDENV), cygwin) - # winsup/include - # winsup/../newlib/libc/include - # winsup/../newlib/libc/sys/cygwin - EXTRA_INCLUDES = -I ${top_srcdir}/../include \ - -I ${top_srcdir}/../../newlib/libc/include \ - -I ${top_srcdir}/../../newlib/libc/sys/cygwin -endif -ifeq ($(BUILDENV), mingw) - EXTRA_INCLUDES = -I ${top_srcdir}/../mingw/include -endif - # In spite of its general unsuitability for use on MS-Windows hosts, # Cygwin is able to, and likes to support the $(DESTDIR) capability; # provide a graceful rejection mechanism, for any (non-Cygwin) cases diff --git a/winsup/w32api/Makefile.in b/winsup/w32api/Makefile.in index d863dda5c..c8d5ce969 100644 --- a/winsup/w32api/Makefile.in +++ b/winsup/w32api/Makefile.in @@ -30,7 +30,7 @@ TARFILEEXT = .tar.lzma SUBDIRS = lib DISTFILES = \ - ChangeLog configure.ac Makefile.in Makefile.comm.in configure \ + ChangeLog aclocal.m4 configure.ac Makefile.in Makefile.comm.in configure \ config.guess config.sub install-sh README.w32api TODO CONTRIBUTIONS all: $(SUBDIRS) diff --git a/winsup/w32api/aclocal.m4 b/winsup/w32api/aclocal.m4 new file mode 100644 index 000000000..4bff47f91 --- /dev/null +++ b/winsup/w32api/aclocal.m4 @@ -0,0 +1,174 @@ +# aclocal.m4 for MinGW/Cygwin w32api package. -*- Autoconf -*- +# +# Definitions of autoconf macros used to implement the configure +# script for the w32api package. +# +# $Id$ +# +# Written by Keith Marshall +# Copyright (C) 2011, 2012, MinGW Project +# +# ----------------------------------------------------------------------------- +# +# 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: +# +# The above copyright notice and this permission notice 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 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. +# +# ----------------------------------------------------------------------------- +# + +# MINGW_AC_CONFIG_SRCDIR( VERSION_TAG, UNIQUE_FILE ) +# -------------------------------------------------- +# Wrapper for AC_CONFIG_SRCDIR; in addition to checking for a +# unique file reference within the source tree, it resolves the +# definition for PACKAGE_VERSION, based on a tagged definition +# within that file. +# +AC_DEFUN([MINGW_AC_CONFIG_SRCDIR], +[AC_CONFIG_SRCDIR([$2]) + AC_MSG_CHECKING([package version]) + PACKAGE_VERSION=`awk '$[2] == "'"$1"'" { print $[3] }' ${srcdir}/$2` + AC_MSG_RESULT([$PACKAGE_VERSION])dnl +])# MINGW_AC_CONFIG_SRCDIR + +# MINGW_AC_RUNTIME_SRCDIR +# ----------------------- +# Attempt to identify the locations of the C runtime sources. +# Accept explicit locations specified by the user, as arguments +# to --with-host-srcdir and --with-libc-srcdir; if unspecified, +# fall back to standard locations relative to ${srcdir}. For a +# MinGW build, identification of an appropriate location will be +# determined by presence of include/_mingw.h in host-srcdir, and +# lib-srcdir is not required; for a Cygwin build, host-srcdir is +# identified by the presence of include/cygwin/cygwin_dll.h, and +# presence of include/newlib.h is also required to identify the +# libc-srcdir location. This is naive; however, AC_CHECK_HEADER +# cannot be used because the system's runtime headers may result +# in false identification of unsuitable locations. +# +AC_DEFUN([MINGW_AC_RUNTIME_SRCDIR], +[AC_REQUIRE([MINGW_AC_HOST_SRCDIR])dnl + AC_REQUIRE([MINGW_AC_LIBC_SRCDIR])dnl + AS_IF([(test "x${with_host_srcdir}" = xMISSING || test "x${with_libc_srcdir}" = xMISSING)], + [AC_MSG_WARN([the location of required runtime headers cannot be established]) + AC_MSG_WARN([please correct this omission before running configure again]) + AC_MSG_RESULT + AC_MSG_ERROR([unable to continue until this issue is resolved]) + ])dnl +])# MINGW_AC_RUNTIME_SRCDIR + +# MINGW_AC_HOST_SRCDIR +# -------------------- +# Helper macro, AC_REQUIREd by MINGW_AC_RUNTIME_SRCDIR. +# This establishes the --with-host-srcdir reference for identification +# of runtime header path; it is never called directly by configure.ac +# +AC_DEFUN([MINGW_AC_HOST_SRCDIR], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl + AC_ARG_WITH([host-srcdir], + [AS_HELP_STRING([--with-host-srcdir=DIR], + [locate host-specific runtime library sources in DIR [SRCDIR/../mingw*] + ([SRCDIR/../cygwin] when HOST == Cygwin) + ])dnl + ],[],[with_host_srcdir=NONE]) + AS_CASE([${host_os}], + [*cygwin*],[ac_dir="cygwin" ac_file="cygwin/cygwin_dll"], + [ac_dir="mingw" ac_file="_mingw"]) + MINGW_AC_CHECK_RUNTIME_SRCDIR([host],[host runtime]) + EXTRA_INCLUDES="-I ${with_host_srcdir}/include" +])# MINGW_AC_HOST_SRCDIR + +# MINGW_AC_LIBC_SRCDIR +# -------------------- +# Helper macro, AC_REQUIREd by MINGW_AC_RUNTIME_SRCDIR. +# This establishes the --with-libc-srcdir reference for identification +# of runtime header path; it is never called directly by configure.ac +# +AC_DEFUN([MINGW_AC_LIBC_SRCDIR], +[AC_ARG_WITH([libc-srcdir], + [AS_HELP_STRING([--with-libc-srcdir=DIR], + [locate additional libc sources in DIR [SRCDIR/../../newlib/libc] + (required only when HOST == Cygwin) + ])dnl + ],[],[with_libc_srcdir=NONE]) + AC_MSG_CHECKING([whether additional runtime headers are required]) + AS_CASE([${host_os}], + [*cygwin*], + [AC_MSG_RESULT([libc (newlib)]) + ac_dir="../newlib/libc" ac_file="newlib" + MINGW_AC_CHECK_RUNTIME_SRCDIR([libc],[libc runtime]) + AS_IF([test "x${with_libc_srcdir}" != xNONE], + [EXTRA_INCLUDES="-I ${with_libc_srcdir}/include ${EXTRA_INCLUDES}" + ])dnl + ],dnl + [AC_MSG_RESULT([no]) + ])dnl +])# MINGW_AC_LIBC_SRCDIR + +# MINGW_AC_CHECK_RUNTIME_SRCDIR( KEY, CATEGORY ) +# ---------------------------------------------- +# Helper macro, invoked by each of MINGW_AC_HOST_SRCDIR and +# MINGW_AC_LIBC_SRCDIR, with KEY passed as 'host' or as 'libc' +# respectively; it establishes and verifies the reference path +# for headers of the class described by CATEGORY, assigning +# the result to the shell variable 'with_KEY_srcdir'. +# +# As is the case for each of the preceding macros, which may +# call it, MINGW_AC_CHECK_RUNTIME_SRCDIR is never invoked +# directly by configure.ac +# +AC_DEFUN([MINGW_AC_CHECK_RUNTIME_SRCDIR], +[AS_IF([test "x${with_$1_srcdir}" = xNONE], + [AC_MSG_CHECKING([include path for $2 headers]) + for with_$1_srcdir in ${srcdir}/../${ac_dir}*; do + test -f "${with_$1_srcdir}/include/${ac_file}.h" && break + with_$1_srcdir=MISSING + done + AS_IF([test "x${with_$1_srcdir}" = xMISSING], + [AC_MSG_RESULT([none found]) + AC_MSG_RESULT + AC_MSG_WARN([source directory containing include/${ac_file}.h not found]) + AC_MSG_WARN([ensure $2 sources are installed at \${top_srcdir}/../${ac_dir}*]) + AC_MSG_WARN([or use --with-$1-srcdir=DIR to specify an alternative]) + AC_MSG_RESULT + ],dnl + [case "${with_$1_srcdir}" in + "${srcdir}/"*) with_$1_srcdir="`echo "${with_$1_srcdir}" \ + | sed s,"^${srcdir}/",'${top_srcdir}/',`" ;; + esac + AC_MSG_RESULT([${with_$1_srcdir}/include])dnl + ])dnl + ],dnl + [AC_MSG_CHECKING([for ${ac_file}.h in ${with_$1_srcdir}/include]) + AS_IF([test -f "${with_$1_srcdir}/include/${ac_file}.h"], + [AC_MSG_RESULT([yes]) + case "${with_$1_srcdir}" in /*) ;; + *) with_$1_srcdir='${top_builddir}/'"${with_$1_srcdir}" ;; + esac + ],dnl + [AC_MSG_RESULT([no]) + AC_MSG_RESULT + AC_MSG_WARN([the nominated directory, ${with_$1_srcdir}]) + AC_MSG_WARN([does not appear to contain valid $2 source code]) + AC_MSG_WARN([(file '${with_$1_srcdir}/include/${ac_file}.h' is not present)]) + AC_MSG_RESULT + with_$1_srcdir=MISSING + ])dnl + ])dnl +])# MINGW_AC_CHECK_RUNTIME_SRCDIR + +# $RCSfile$: end of file: vim: ft=config diff --git a/winsup/w32api/configure.ac b/winsup/w32api/configure.ac index e16a2ffba..ae05a70d5 100644 --- a/winsup/w32api/configure.ac +++ b/winsup/w32api/configure.ac @@ -9,20 +9,10 @@ AC_PREREQ([2.59]) # -# Extract current release version from include/w32api.h -# at autoconf time... +# Extract current release version from include/w32api.h at autoconf time. # m4_define([__ver__],dnl m4_esyscmd([awk '$2=="__W32API_VERSION"{printf "%s","v"$3}' include/w32api.h])) -# -# ...and confirm it at configure time. -# -AC_DEFUN([MINGW_AC_CONFIG_SRCDIR], -[AC_CONFIG_SRCDIR([$2]) - AC_MSG_CHECKING([package version]) - PACKAGE_VERSION=`awk '$[2] == "'"$1"'" { print $[3] }' ${srcdir}/$2` - AC_MSG_RESULT([$PACKAGE_VERSION])dnl -])# MINGW_AC_CONFIG_SRCDIR AC_INIT([MS-Windows API],[__ver__],[http://mingw.org/reporting_bugs],[w32api]) MINGW_AC_CONFIG_SRCDIR([__W32API_VERSION],[include/w32api.h]) @@ -50,6 +40,7 @@ AC_PROG_INSTALL # AC_CHECK_TOOL([CC], [gcc], [gcc]) AC_SUBST([CFLAGS], [${CFLAGS-"-O2 -g"}]) +AC_SUBST([EXTRA_INCLUDES], [MINGW_AC_RUNTIME_SRCDIR]) # FIXME: What is the purpose of this? I think it should go away. # @@ -64,19 +55,8 @@ AC_CHECK_TOOL([DLLTOOL], [dlltool], [dlltool]) AC_CHECK_TOOL([WINDRES], [windres], [windres]) AC_CHECK_TOOL([LD], [ld], [ld]) - -AC_MSG_CHECKING([for build environment]) -case "$build_alias" in -*-mingw*) BUILDENV=mingw;; -*-cygwin*) BUILDENV=cygwin;; -esac -if test -z "$BUILDENV"; then - AC_MSG_RESULT([standard]) -else - AC_MSG_RESULT([$BUILDENV]) -fi -AC_SUBST([BUILDENV]) - +# Create makefiles +# AC_CONFIG_FILES([Makefile Makefile.comm]) AC_CONFIG_FILES([lib/Makefile lib/ddk/Makefile lib/directx/Makefile]) AC_OUTPUT -- cgit v1.2.3