Bug 1269517 - Move various header checks to Python configure. draft
authorChris Manchester <cmanchester@mozilla.com>
Fri, 15 Jul 2016 15:33:21 -0700
changeset 388450 ad7e0c3093f4855a284ed19fffb7332f40abed05
parent 388449 f6e038c6d09b34954723f2a9160fccdf89543268
child 525556 d18a601cf22a32ab1c8354c61be6803f37a02ae2
push id23183
push usercmanchester@mozilla.com
push dateFri, 15 Jul 2016 22:34:36 +0000
bugs1269517
milestone50.0a1
Bug 1269517 - Move various header checks to Python configure. MozReview-Commit-ID: CLn3PQUh4gG
aclocal.m4
build/autoconf/alloc.m4
build/autoconf/mozcommonheader.m4
build/moz.configure/headers.configure
js/src/aclocal.m4
js/src/old-configure.in
moz.configure
old-configure.in
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -11,17 +11,16 @@ builtin(include, build/autoconf/toolchai
 builtin(include, build/autoconf/nspr.m4)dnl
 builtin(include, build/autoconf/nspr-build.m4)dnl
 builtin(include, build/autoconf/nss.m4)dnl
 builtin(include, build/autoconf/pkg.m4)dnl
 builtin(include, build/autoconf/codeset.m4)dnl
 builtin(include, build/autoconf/altoptions.m4)dnl
 builtin(include, build/autoconf/mozprog.m4)dnl
 builtin(include, build/autoconf/mozheader.m4)dnl
-builtin(include, build/autoconf/mozcommonheader.m4)dnl
 builtin(include, build/autoconf/lto.m4)dnl
 builtin(include, build/autoconf/frameptr.m4)dnl
 builtin(include, build/autoconf/compiler-opts.m4)dnl
 builtin(include, build/autoconf/expandlibs.m4)dnl
 builtin(include, build/autoconf/arch.m4)dnl
 builtin(include, build/autoconf/android.m4)dnl
 builtin(include, build/autoconf/zlib.m4)dnl
 builtin(include, build/autoconf/linux.m4)dnl
--- a/build/autoconf/alloc.m4
+++ b/build/autoconf/alloc.m4
@@ -17,26 +17,26 @@ for file in $MALLOC_HEADERS; do
 done
 
 MOZ_CHECK_HEADERS(alloca.h)
 
 AC_CHECK_FUNCS(strndup posix_memalign memalign)
 
 AC_CHECK_FUNCS(malloc_usable_size)
 MALLOC_USABLE_SIZE_CONST_PTR=const
-MOZ_CHECK_HEADERS([malloc.h], [
+if test -n "$HAVE_MALLOC_H"; then
   AC_MSG_CHECKING([whether malloc_usable_size definition can use const argument])
   AC_TRY_COMPILE([#include <malloc.h>
                   #include <stddef.h>
                   size_t malloc_usable_size(const void *ptr);],
                   [return malloc_usable_size(0);],
                   AC_MSG_RESULT([yes]),
                   AC_MSG_RESULT([no])
                   MALLOC_USABLE_SIZE_CONST_PTR=)
-])
+fi
 AC_DEFINE_UNQUOTED([MALLOC_USABLE_SIZE_CONST_PTR],[$MALLOC_USABLE_SIZE_CONST_PTR])
 
 
 dnl In newer bionic headers, valloc is built but not defined,
 dnl so we check more carefully here.
 AC_MSG_CHECKING([for valloc in malloc.h])
 AC_EGREP_HEADER(valloc, malloc.h,
                 AC_DEFINE(HAVE_VALLOC)
deleted file mode 100644
--- a/build/autoconf/mozcommonheader.m4
+++ /dev/null
@@ -1,9 +0,0 @@
-dnl This Source Code Form is subject to the terms of the Mozilla Public
-dnl License, v. 2.0. If a copy of the MPL was not distributed with this
-dnl file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-AC_DEFUN(MOZ_CHECK_COMMON_HEADERS,
-	MOZ_CHECK_HEADERS(sys/byteorder.h compat.h getopt.h sys/bitypes.h \
-        memory.h unistd.h gnu/libc-version.h nl_types.h malloc.h \
-        X11/XKBlib.h io.h cpuid.h)
-)
new file mode 100644
--- /dev/null
+++ b/build/moz.configure/headers.configure
@@ -0,0 +1,95 @@
+# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+# Check for headers defining standard int types.
+have_stdint, have_inttypes = check_headers('stdint.h', 'inttypes.h')
+
+set_config('HAVE_INTTYPES_H', have_inttypes)
+
+# Checks for headers relevant to non-windows systems.
+non_msvc_compiler = depends(c_compiler)(lambda info: info.type != 'msvc')
+
+@depends(non_msvc_compiler, building_js)
+def building_js_non_msvc(non_msvc, js):
+    return js and non_msvc
+
+(have_malloc,) = check_headers('malloc.h')
+
+add_old_configure_assignment('HAVE_MALLOC_H', have_malloc)
+
+check_headers(
+    'sys/byteorder.h',
+    'compat.h',
+    'getopt.h',
+    'sys/bitypes.h',
+    'memory.h',
+    'unistd.h',
+    'gnu/libc-version.h',
+    'nl_types.h',
+    'X11/XKBlib.h',
+    'io.h',
+    'cpuid.h',
+    when=non_msvc_compiler,
+)
+
+# These are all the places some variant of statfs can be hiding.
+check_headers(
+    'sys/statvfs.h',
+    'sys/statfs.h',
+    'sys/vfs.h',
+    'sys/mount.h',
+    when=non_msvc_compiler,
+)
+
+# Quota support
+check_headers(
+    'sys/quota.h',
+    'sys/sysmacros.h',
+    when=non_msvc_compiler,
+)
+
+check_headers('linux/quota.h',
+              includes=['sys/socket.h'],
+              when=non_msvc_compiler)
+
+# SCTP support - needs various network include headers
+check_headers(
+    'linux/if_addr.h',
+    'linux/rtnetlink.h',
+    includes=['sys/socket.h'],
+    when=non_msvc_compiler,
+)
+
+check_headers('sys/queue.h',
+              when=non_msvc_compiler)
+
+check_headers(
+    'sys/types.h',
+    'netinet/in.h',
+    'byteswap.h',
+    when=non_msvc_compiler,
+)
+
+
+# Checks for headers relevant when building js.
+
+endian_h, sys_isa_defs_h, sys_cdefs_h = check_headers(
+    'endian.h',
+    'sys/isa_defs.h',
+    'sys/cdefs.h',
+    when=building_js_non_msvc,
+)
+
+set_define('JS_HAVE_ENDIAN_H', endian_h)
+set_define('JS_HAVE_SYS_ISA_DEFS_H', sys_isa_defs_h)
+
+(machine_endian_h,) = check_headers(
+    'machine/endian.h',
+    includes=['sys/types.h'],
+    when=building_js_non_msvc,
+)
+
+set_define('JS_HAVE_MACHINE_ENDIAN_H', machine_endian_h)
--- a/js/src/aclocal.m4
+++ b/js/src/aclocal.m4
@@ -10,17 +10,16 @@ builtin(include, ../../build/autoconf/co
 builtin(include, ../../build/autoconf/toolchain.m4)dnl
 builtin(include, ../../build/autoconf/pkg.m4)dnl
 builtin(include, ../../build/autoconf/nspr.m4)dnl
 builtin(include, ../../build/autoconf/nspr-build.m4)dnl
 builtin(include, ../../build/autoconf/codeset.m4)dnl
 builtin(include, ../../build/autoconf/altoptions.m4)dnl
 builtin(include, ../../build/autoconf/mozprog.m4)dnl
 builtin(include, ../../build/autoconf/mozheader.m4)dnl
-builtin(include, ../../build/autoconf/mozcommonheader.m4)dnl
 builtin(include, ../../build/autoconf/lto.m4)dnl
 builtin(include, ../../build/autoconf/frameptr.m4)dnl
 builtin(include, ../../build/autoconf/compiler-opts.m4)dnl
 builtin(include, ../../build/autoconf/expandlibs.m4)dnl
 builtin(include, ../../build/autoconf/arch.m4)dnl
 builtin(include, ../../build/autoconf/android.m4)dnl
 builtin(include, ../../build/autoconf/zlib.m4)dnl
 builtin(include, ../../build/autoconf/linux.m4)dnl
--- a/js/src/old-configure.in
+++ b/js/src/old-configure.in
@@ -1217,31 +1217,16 @@ AC_CACHE_VAL(ac_cv_type_ssize_t,
                  [ac_cv_type_ssize_t=false])])
 if test "$ac_cv_type_ssize_t" = true ; then
   AC_DEFINE(HAVE_SSIZE_T)
   AC_MSG_RESULT(yes)
 else
   AC_MSG_RESULT(no)
 fi
 
-MOZ_CHECK_HEADERS(endian.h)
-if test "$ac_cv_header_endian_h" = yes; then
-    AC_DEFINE(JS_HAVE_ENDIAN_H)
-fi
-
-MOZ_CHECK_HEADERS([machine/endian.h],[],[],[#include <sys/types.h>])
-if test "$ac_cv_header_machine_endian_h" = yes; then
-    AC_DEFINE(JS_HAVE_MACHINE_ENDIAN_H)
-fi
-
-MOZ_CHECK_HEADERS(sys/isa_defs.h)
-if test "$ac_cv_header_sys_isa_defs_h" = yes; then
-    AC_DEFINE(JS_HAVE_SYS_ISA_DEFS_H)
-fi
-
 AC_LANG_CPLUSPLUS
 
 MOZ_CXX11
 
 dnl Check for .hidden assembler directive and visibility attribute.
 dnl Borrowed from glibc configure.in
 dnl ===============================================================
 if test "$GNU_CC" -a "$OS_TARGET" != WINNT; then
@@ -1274,40 +1259,30 @@ dnl Checks for header files.
 dnl ========================================================
 AC_HEADER_DIRENT
 case "$target_os" in
 freebsd*)
 # for stuff like -lXshm
     CPPFLAGS="${CPPFLAGS} ${X_CFLAGS}"
     ;;
 esac
-MOZ_CHECK_COMMON_HEADERS
-
-dnl These are all the places some variant of statfs can be hiding.
-MOZ_CHECK_HEADERS(sys/statvfs.h sys/statfs.h sys/vfs.h sys/mount.h)
-
-dnl Quota support
-MOZ_CHECK_HEADERS(sys/quota.h)
-MOZ_CHECK_HEADERS(linux/quota.h)
 
 MOZ_ARG_ENABLE_BOOL(dtrace,
               [  --enable-dtrace         build with dtrace support if available (default=no)],
               [enable_dtrace="yes"],)
 if test "x$enable_dtrace" = "xyes"; then
   MOZ_CHECK_HEADER(sys/sdt.h, HAVE_DTRACE=1)
   if test -n "$HAVE_DTRACE"; then
       AC_DEFINE(INCLUDE_MOZILLA_DTRACE)
   else
       AC_MSG_ERROR([dtrace enabled but sys/sdt.h not found]);
   fi
 fi
 AC_SUBST(HAVE_DTRACE)
 
-MOZ_CHECK_HEADERS(sys/cdefs.h)
-
 MOZ_LINUX_PERF_EVENT
 
 dnl Checks for libraries.
 dnl ========================================================
 AC_CHECK_LIB(c_r, gethostbyname_r)
 
 dnl We don't want to link with libdl even if it's present on OS X, since
 dnl it's not used and not part of the default installation. OS/2 has dlfcn
--- a/moz.configure
+++ b/moz.configure
@@ -102,16 +102,22 @@ include(toolchain_include)
 
 @depends('--disable-compile-environment', '--help')
 def memory_include(compile_env, help):
     if compile_env:
         return 'build/moz.configure/memory.configure'
 
 include(memory_include)
 
+@depends('--disable-compile-environment', '--help')
+def headers_check_include(compile_env, help):
+    if compile_env:
+        return 'build/moz.configure/headers.configure'
+
+include(headers_check_include)
 
 @depends('--help')
 @imports(_from='mozbuild.backend', _import='backends')
 def build_backends_choices(help):
     return tuple(backends)
 
 
 @deprecated_option('--enable-build-backend', nargs='+',
--- a/old-configure.in
+++ b/old-configure.in
@@ -1631,30 +1631,16 @@ dnl Checks for header files.
 dnl ========================================================
 AC_HEADER_DIRENT
 case "$target_os" in
 freebsd*|openbsd*)
 # for stuff like -lXshm
     CPPFLAGS="${CPPFLAGS} ${X_CFLAGS}"
     ;;
 esac
-MOZ_CHECK_COMMON_HEADERS
-
-dnl These are all the places some variant of statfs can be hiding.
-MOZ_CHECK_HEADERS(sys/statvfs.h sys/statfs.h sys/vfs.h sys/mount.h)
-
-dnl Quota support
-MOZ_CHECK_HEADERS(sys/quota.h sys/sysmacros.h)
-MOZ_CHECK_HEADERS([linux/quota.h],,,[#include <sys/socket.h>])
-
-dnl SCTP support - needs various network include headers
-MOZ_CHECK_HEADERS([linux/if_addr.h linux/rtnetlink.h],,,[#include <sys/socket.h>])
-MOZ_CHECK_HEADERS(sys/queue.h)
-
-MOZ_CHECK_HEADERS(sys/types.h netinet/in.h byteswap.h)
 
 dnl Check for sin_len and sin6_len - used by SCTP; only appears in Mac/*BSD generally
 AC_CACHE_CHECK(for sockaddr_in.sin_len,
                    ac_cv_sockaddr_in_sin_len,
                    [AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H
                                     #include <sys/types.h>
                                     #endif
                                     #include <netinet/in.h>
@@ -5913,27 +5899,16 @@ elif test -z "$MOZ_TREE_CAIRO"; then
 fi
 
 if test "$MOZ_TREE_PIXMAN"; then
     AC_DEFINE(MOZ_TREE_PIXMAN)
 else
     PKG_CHECK_MODULES(MOZ_PIXMAN, pixman-1 >= 0.19.2)
 fi
 
-# Check for headers defining standard int types.
-if test -n "$COMPILE_ENVIRONMENT"; then
-    MOZ_CHECK_HEADERS(stdint.h inttypes.h)
-
-    if test "${ac_cv_header_inttypes_h}" = "yes"; then
-        HAVE_INTTYPES_H=1
-    fi
-fi
-
-AC_SUBST(HAVE_INTTYPES_H)
-
 if test "$MOZ_TREE_CAIRO"; then
     MOZ_CAIRO_CFLAGS="-I${DIST}/include/cairo"
     AC_DEFINE(MOZ_TREE_CAIRO)
 
     if test "$OS_ARCH" = "WINNT"; then
         # For now we assume that we will have a uint64_t available through
         # one of the above headers or mozstdint.h.
         AC_DEFINE(HAVE_UINT64_T)