From 08e7b500f02098b25e3bed5e26cbc81933182911 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20=C3=81vila=20de=20Esp=C3=ADndola?= Date: Sat, 26 Nov 2011 16:05:17 -0500 Subject: [PATCH] Bug 705461 - Use MOZ_CHECK_HEADER(S) everywhere. r=neil. --- build/autoconf/mozheader.m4 | 9 ++-- configure.in | 4 +- js/src/aclocal.m4 | 1 + js/src/build/autoconf/mozheader.m4 | 66 ++++++++++++++++++++++++++++++ js/src/configure.in | 56 ++++++++++++------------- 5 files changed, 102 insertions(+), 34 deletions(-) create mode 100644 js/src/build/autoconf/mozheader.m4 diff --git a/build/autoconf/mozheader.m4 b/build/autoconf/mozheader.m4 index a1c2a3c740e84..50b3189944cbb 100644 --- a/build/autoconf/mozheader.m4 +++ b/build/autoconf/mozheader.m4 @@ -36,13 +36,14 @@ dnl the terms of any one of the MPL, the GPL or the LGPL. dnl dnl ***** END LICENSE BLOCK ***** -dnl MOZ_CHECK_HEADER(HEADER-FILE, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) +dnl MOZ_CHECK_HEADER(HEADER-FILE, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, INCLUDES]]]) AC_DEFUN([MOZ_CHECK_HEADER], [ dnl Do the transliteration at runtime so arg 1 can be a shell variable. ac_safe=`echo "$1" | sed 'y%./+-%__p_%'` AC_MSG_CHECKING([for $1]) AC_CACHE_VAL(ac_cv_header_$ac_safe, - [ AC_TRY_COMPILE([#include <$1>], , + [ AC_TRY_COMPILE([$4 +#include <$1>], , eval "ac_cv_header_$ac_safe=yes", eval "ac_cv_header_$ac_safe=no") ]) if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then @@ -54,12 +55,12 @@ AC_DEFUN([MOZ_CHECK_HEADER], fi ]) -dnl MOZ_CHECK_HEADERS(HEADER-FILE... [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) +dnl MOZ_CHECK_HEADERS(HEADER-FILE... [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, INCLUDES]]]) AC_DEFUN([MOZ_CHECK_HEADERS], [ for ac_hdr in $1 do MOZ_CHECK_HEADER($ac_hdr, [ ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` - AC_DEFINE_UNQUOTED($ac_tr_hdr) $2], $3) + AC_DEFINE_UNQUOTED($ac_tr_hdr) $2], $3, [$4]) done ]) diff --git a/configure.in b/configure.in index 0fe873a72a123..3c6c7a81b1dac 100644 --- a/configure.in +++ b/configure.in @@ -8760,8 +8760,8 @@ if test "$USE_FC_FREETYPE"; then if test "$COMPILE_ENVIRONMENT"; then _SAVE_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $FT2_CFLAGS $XCFLAGS" - AC_CHECK_HEADERS(fontconfig/fcfreetype.h, , - [AC_MSG_ERROR(Can't find header fontconfig/fcfreetype.h.)]) + MOZ_CHECK_HEADERS([fontconfig/fcfreetype.h], , + [AC_MSG_ERROR(Can't find header fontconfig/fcfreetype.h.)], [#include ]) CPPFLAGS="$_SAVE_CPPFLAGS" else AC_DEFINE(HAVE_FONTCONFIG_FCFREETYPE_H) diff --git a/js/src/aclocal.m4 b/js/src/aclocal.m4 index 144a8641298a6..e3ac8aa0d2e56 100644 --- a/js/src/aclocal.m4 +++ b/js/src/aclocal.m4 @@ -8,6 +8,7 @@ builtin(include, build/autoconf/nspr.m4)dnl builtin(include, build/autoconf/altoptions.m4)dnl builtin(include, build/autoconf/moznbytetype.m4)dnl builtin(include, build/autoconf/mozprog.m4)dnl +builtin(include, build/autoconf/mozheader.m4)dnl builtin(include, build/autoconf/acwinpaths.m4)dnl builtin(include, build/autoconf/lto.m4)dnl builtin(include, build/autoconf/gcc-pr49911.m4)dnl diff --git a/js/src/build/autoconf/mozheader.m4 b/js/src/build/autoconf/mozheader.m4 new file mode 100644 index 0000000000000..50b3189944cbb --- /dev/null +++ b/js/src/build/autoconf/mozheader.m4 @@ -0,0 +1,66 @@ +dnl ***** BEGIN LICENSE BLOCK ***** +dnl Version: MPL 1.1/GPL 2.0/LGPL 2.1 +dnl +dnl The contents of this file are subject to the Mozilla Public License Version +dnl 1.1 (the "License"); you may not use this file except in compliance with +dnl the License. You may obtain a copy of the License at +dnl http://www.mozilla.org/MPL/ +dnl +dnl Software distributed under the License is distributed on an "AS IS" basis, +dnl WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +dnl for the specific language governing rights and limitations under the +dnl License. +dnl +dnl The Original Code is mozilla.org code. +dnl +dnl The Initial Developer of the Original Code is the +dnl Mozilla Foundation +dnl +dnl Portions created by the Initial Developer are Copyright (C) 2009 +dnl the Initial Developer. All Rights Reserved. +dnl +dnl Contributor(s): +dnl Neil Rashbrook +dnl +dnl Alternatively, the contents of this file may be used under the terms of +dnl either of the GNU General Public License Version 2 or later (the "GPL"), +dnl or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +dnl in which case the provisions of the GPL or the LGPL are applicable instead +dnl of those above. If you wish to allow use of your version of this file only +dnl under the terms of either the GPL or the LGPL, and not to allow others to +dnl use your version of this file under the terms of the MPL, indicate your +dnl decision by deleting the provisions above and replace them with the notice +dnl and other provisions required by the GPL or the LGPL. If you do not delete +dnl the provisions above, a recipient may use your version of this file under +dnl the terms of any one of the MPL, the GPL or the LGPL. +dnl +dnl ***** END LICENSE BLOCK ***** + +dnl MOZ_CHECK_HEADER(HEADER-FILE, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, INCLUDES]]]) +AC_DEFUN([MOZ_CHECK_HEADER], +[ dnl Do the transliteration at runtime so arg 1 can be a shell variable. + ac_safe=`echo "$1" | sed 'y%./+-%__p_%'` + AC_MSG_CHECKING([for $1]) + AC_CACHE_VAL(ac_cv_header_$ac_safe, + [ AC_TRY_COMPILE([$4 +#include <$1>], , + eval "ac_cv_header_$ac_safe=yes", + eval "ac_cv_header_$ac_safe=no") ]) + if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + AC_MSG_RESULT(yes) + ifelse([$2], , :, [$2]) + else + AC_MSG_RESULT(no) + ifelse([$3], , , [$3]) + fi +]) + +dnl MOZ_CHECK_HEADERS(HEADER-FILE... [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, INCLUDES]]]) +AC_DEFUN([MOZ_CHECK_HEADERS], +[ for ac_hdr in $1 + do + MOZ_CHECK_HEADER($ac_hdr, + [ ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + AC_DEFINE_UNQUOTED($ac_tr_hdr) $2], $3, [$4]) + done +]) diff --git a/js/src/configure.in b/js/src/configure.in index cfefdda9497f1..35ef358c55a8c 100644 --- a/js/src/configure.in +++ b/js/src/configure.in @@ -803,7 +803,7 @@ case "$target" in # Identify which version of the SDK we're building with # Windows Server 2008 and newer SDKs have WinSDKVer.h, get the version # from there - AC_CHECK_HEADERS([winsdkver.h]) + MOZ_CHECK_HEADERS([winsdkver.h]) if test "$ac_cv_header_winsdkver_h" = "yes"; then # Get the highest _WIN32_WINNT and NTDDI versions supported # Take the higher of the two @@ -830,7 +830,7 @@ EOF else # The Vista SDK is the only one to have sdkddkver.h but not # WinSDKVer.h - AC_CHECK_HEADERS([sdkddkver.h]) + MOZ_CHECK_HEADERS([sdkddkver.h]) if test "$ac_cv_header_sdkddkver_h" = "yes"; then MOZ_WINSDK_MAXVER=0x06000000 else @@ -1190,7 +1190,7 @@ tools are selected during the Xcode/Developer Tools installation.]) CFLAGS="$CFLAGS -isysroot ${MACOS_SDK_DIR}" CXXFLAGS="$CXXFLAGS -isysroot ${MACOS_SDK_DIR}" - dnl CPP/CXXCPP needs to be set for AC_CHECK_HEADER. + dnl CPP/CXXCPP needs to be set for MOZ_CHECK_HEADER. CPP="$CPP -isysroot ${MACOS_SDK_DIR}" CXXCPP="$CXXCPP -isysroot ${MACOS_SDK_DIR}" @@ -2164,7 +2164,7 @@ case "$target" in ;; esac if test "$COMPILE_ENVIRONMENT"; then - AC_CHECK_HEADERS(sys/inttypes.h) + MOZ_CHECK_HEADERS(sys/inttypes.h) fi AC_DEFINE(JS_SYS_TYPES_H_DEFINES_EXACT_SIZE_TYPES) AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES) @@ -2501,7 +2501,7 @@ ia64*-hpux*) CXXFLAGS="$CXXFLAGS -mstackrealign" fi - AC_CHECK_HEADERS(mmintrin.h) + MOZ_CHECK_HEADERS(mmintrin.h) AC_DEFINE(_X86_) ;; x86_64-*) @@ -2926,7 +2926,7 @@ dnl ======================================================== dnl Once this is working, we can delete the code for int16_t, dnl etc. below. -AC_CHECK_HEADER(stdint.h) +MOZ_CHECK_HEADER(stdint.h) if test "$ac_cv_header_stdint_h" = yes; then AC_DEFINE(JS_HAVE_STDINT_H) else @@ -2954,12 +2954,12 @@ fi MOZ_ALIGN_OF_TYPE(JS_ALIGN_OF_POINTER, void*, 2 4 8 16) MOZ_SIZE_OF_TYPE(JS_BYTES_PER_DOUBLE, double, 6 8 10 12 14) -AC_CHECK_HEADERS(endian.h) +MOZ_CHECK_HEADERS(endian.h) if test "$ac_cv_header_endian_h" = yes; then AC_DEFINE(JS_HAVE_ENDIAN_H) fi -AC_CHECK_HEADERS(sys/isa_defs.h) +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 @@ -3248,30 +3248,30 @@ freebsd*) CPPFLAGS="${CPPFLAGS} ${X_CFLAGS}" ;; esac -AC_CHECK_HEADERS(sys/byteorder.h compat.h getopt.h) -AC_CHECK_HEADERS(sys/bitypes.h memory.h unistd.h) -AC_CHECK_HEADERS(gnu/libc-version.h nl_types.h) -AC_CHECK_HEADERS(malloc.h) -AC_CHECK_HEADERS(X11/XKBlib.h) -AC_CHECK_HEADERS(io.h) +MOZ_CHECK_HEADERS(sys/byteorder.h compat.h getopt.h) +MOZ_CHECK_HEADERS(sys/bitypes.h memory.h unistd.h) +MOZ_CHECK_HEADERS(gnu/libc-version.h nl_types.h) +MOZ_CHECK_HEADERS(malloc.h) +MOZ_CHECK_HEADERS(X11/XKBlib.h) +MOZ_CHECK_HEADERS(io.h) dnl These are all the places some variant of statfs can be hiding. -AC_CHECK_HEADERS(sys/statvfs.h sys/statfs.h sys/vfs.h sys/mount.h) +MOZ_CHECK_HEADERS(sys/statvfs.h sys/statfs.h sys/vfs.h sys/mount.h) dnl Quota support -AC_CHECK_HEADERS(sys/quota.h) -AC_CHECK_HEADERS(linux/quota.h) +MOZ_CHECK_HEADERS(sys/quota.h) +MOZ_CHECK_HEADERS(linux/quota.h) dnl Try for MMX support dnl NB - later gcc versions require -mmmx for this header to be successfully dnl included (or another option which implies it, such as -march=pentium-mmx) -AC_CHECK_HEADERS(mmintrin.h) +MOZ_CHECK_HEADERS(mmintrin.h) dnl Check whether the compiler supports the new-style C++ standard dnl library headers (i.e. ) or needs the old "new.h" AC_LANG_CPLUSPLUS NEW_H=new.h -AC_CHECK_HEADER(new, [NEW_H=new]) +MOZ_CHECK_HEADER(new, [NEW_H=new]) AC_DEFINE_UNQUOTED(NEW_H, <$NEW_H>) AC_LANG_C @@ -3279,7 +3279,7 @@ AC_ARG_ENABLE(dtrace, [ --enable-dtrace build with dtrace support if available (default=no)], [enable_dtrace="yes"],) if test "x$enable_dtrace" = "xyes"; then - AC_CHECK_HEADER(sys/sdt.h, HAVE_DTRACE=1) + MOZ_CHECK_HEADER(sys/sdt.h, HAVE_DTRACE=1) if test -n "$HAVE_DTRACE"; then AC_DEFINE(INCLUDE_MOZILLA_DTRACE) else @@ -3292,12 +3292,12 @@ case $target in *-aix4.3*|*-aix5*) ;; *) - AC_CHECK_HEADERS(sys/cdefs.h) + MOZ_CHECK_HEADERS(sys/cdefs.h) ;; esac dnl Performance measurement headers. -AC_CHECK_HEADER(linux/perf_event.h, +MOZ_CHECK_HEADER(linux/perf_event.h, [AC_CACHE_CHECK(for perf_event_open system call,ac_cv_perf_event_open, [AC_TRY_COMPILE([#include ],[return sizeof(__NR_perf_event_open);], ac_cv_perf_event_open=yes, @@ -3332,7 +3332,7 @@ case $target in ;; *) AC_SEARCH_LIBS(dlopen, dl, - AC_CHECK_HEADER(dlfcn.h, + MOZ_CHECK_HEADER(dlfcn.h, AC_DEFINE(HAVE_DLOPEN))) ;; esac @@ -3905,11 +3905,11 @@ fi dnl Check for the existence of various allocation headers/functions MALLOC_H= -AC_CHECK_HEADER(malloc.h, [MALLOC_H=malloc.h]) +MOZ_CHECK_HEADER(malloc.h, [MALLOC_H=malloc.h]) if test "$MALLOC_H" = ""; then - AC_CHECK_HEADER(malloc/malloc.h, [MALLOC_H=malloc/malloc.h]) + MOZ_CHECK_HEADER(malloc/malloc.h, [MALLOC_H=malloc/malloc.h]) if test "$MALLOC_H" = ""; then - AC_CHECK_HEADER(sys/malloc.h, [MALLOC_H=sys/malloc.h]) + MOZ_CHECK_HEADER(sys/malloc.h, [MALLOC_H=sys/malloc.h]) fi fi if test "$MALLOC_H" != ""; then @@ -4462,7 +4462,7 @@ MOZ_ARG_ENABLE_BOOL(valgrind, MOZ_VALGRIND=1, MOZ_VALGRIND= ) if test -n "$MOZ_VALGRIND"; then - AC_CHECK_HEADER([valgrind/valgrind.h], [], + MOZ_CHECK_HEADER([valgrind/valgrind.h], [], AC_MSG_ERROR( [--enable-valgrind specified but Valgrind is not installed])) AC_DEFINE(MOZ_VALGRIND) @@ -4667,7 +4667,7 @@ dnl ======================================================== dnl = Support for gcc stack unwinding (from gcc 3.3) dnl ======================================================== if test -z "$SKIP_LIBRARY_CHECKS"; then - AC_CHECK_HEADER(unwind.h, AC_CHECK_FUNCS(_Unwind_Backtrace)) + MOZ_CHECK_HEADER(unwind.h, AC_CHECK_FUNCS(_Unwind_Backtrace)) fi dnl ========================================================