PageRenderTime 94ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 1ms

/js/src/configure.in

http://github.com/zpao/v8monkey
Autoconf | 5430 lines | 4042 code | 569 blank | 819 comment | 503 complexity | 6dc810d30993e3187ef7be0a50c2697c MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, LGPL-3.0, AGPL-1.0, LGPL-2.1, BSD-3-Clause, GPL-2.0, JSON, Apache-2.0, 0BSD
  1. dnl -*- Mode: Autoconf; tab-width: 4; indent-tabs-mode: nil; -*-
  2. dnl vi: set tabstop=4 shiftwidth=4 expandtab syntax=m4:
  3. dnl ***** BEGIN LICENSE BLOCK *****
  4. dnl Version: MPL 1.1/GPL 2.0/LGPL 2.1
  5. dnl
  6. dnl The contents of this file are subject to the Mozilla Public License Version
  7. dnl 1.1 (the "License"); you may not use this file except in compliance with
  8. dnl the License. You may obtain a copy of the License at
  9. dnl http://www.mozilla.org/MPL/
  10. dnl
  11. dnl Software distributed under the License is distributed on an "AS IS" basis,
  12. dnl WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  13. dnl for the specific language governing rights and limitations under the
  14. dnl License.
  15. dnl
  16. dnl The Original Code is this file as it was released upon August 6, 1998.
  17. dnl
  18. dnl The Initial Developer of the Original Code is
  19. dnl Christopher Seawood.
  20. dnl Portions created by the Initial Developer are Copyright (C) 1998-2001
  21. dnl the Initial Developer. All Rights Reserved.
  22. dnl
  23. dnl Contributor(s):
  24. dnl Jamie Zawinski <jwz@jwz.org>
  25. dnl gettimeofday args check
  26. dnl Christopher Blizzard <blizzard@appliedtheory.com>
  27. dnl gnomefe update & enable-pthreads
  28. dnl Ramiro Estrugo <ramiro@netscape.com>
  29. dnl X11 makedepend support
  30. dnl Insure support.
  31. dnl Henry Sobotka <sobotka@axess.com>
  32. dnl OS/2 support
  33. dnl Dan Mosedale <dmose@mozilla.org>
  34. dnl LDAP support
  35. dnl Seth Spitzer <sspitzer@netscape.com>
  36. dnl xpctools support
  37. dnl Benjamin Smedberg <benjamin@smedbergs.us>
  38. dnl Howard Chu <hyc@symas.com>
  39. dnl MSYS support
  40. dnl Mark Mentovai <mark@moxienet.com>:
  41. dnl Mac OS X 10.4 support
  42. dnl Giorgio Maone <g.maone@informaction.com>
  43. dnl MSVC l10n compatible version check
  44. dnl Ben Turner <mozilla@songbirdnest.com>
  45. dnl Windows x64 support
  46. dnl Makoto Kato <m_kato@ga2.so-net.ne.jp>
  47. dnl
  48. dnl Alternatively, the contents of this file may be used under the terms of
  49. dnl either the GNU General Public License Version 2 or later (the "GPL"), or
  50. dnl the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  51. dnl in which case the provisions of the GPL or the LGPL are applicable instead
  52. dnl of those above. If you wish to allow use of your version of this file only
  53. dnl under the terms of either the GPL or the LGPL, and not to allow others to
  54. dnl use your version of this file under the terms of the MPL, indicate your
  55. dnl decision by deleting the provisions above and replace them with the notice
  56. dnl and other provisions required by the GPL or the LGPL. If you do not delete
  57. dnl the provisions above, a recipient may use your version of this file under
  58. dnl the terms of any one of the MPL, the GPL or the LGPL.
  59. dnl
  60. dnl ***** END LICENSE BLOCK *****
  61. dnl Process this file with autoconf to produce a configure script.
  62. dnl ========================================================
  63. AC_PREREQ(2.13)
  64. AC_INIT(jsapi.h)
  65. AC_CONFIG_AUX_DIR(${srcdir}/build/autoconf)
  66. AC_CONFIG_HEADER(js-config.h)
  67. AC_CANONICAL_SYSTEM
  68. TARGET_CPU="${target_cpu}"
  69. TARGET_VENDOR="${target_vendor}"
  70. TARGET_OS="${target_os}"
  71. dnl ========================================================
  72. dnl =
  73. dnl = Don't change the following two lines. Doing so breaks:
  74. dnl =
  75. dnl = CFLAGS="-foo" ./configure
  76. dnl =
  77. dnl ========================================================
  78. CFLAGS="${CFLAGS=}"
  79. CPPFLAGS="${CPPFLAGS=}"
  80. CXXFLAGS="${CXXFLAGS=}"
  81. LDFLAGS="${LDFLAGS=}"
  82. HOST_CFLAGS="${HOST_CFLAGS=}"
  83. HOST_CXXFLAGS="${HOST_CXXFLAGS=}"
  84. HOST_LDFLAGS="${HOST_LDFLAGS=}"
  85. dnl ========================================================
  86. dnl = Preserve certain environment flags passed to configure
  87. dnl = We want sub projects to receive the same flags
  88. dnl = untainted by this configure script
  89. dnl ========================================================
  90. _SUBDIR_CC="$CC"
  91. _SUBDIR_CXX="$CXX"
  92. _SUBDIR_CFLAGS="$CFLAGS"
  93. _SUBDIR_CPPFLAGS="$CPPFLAGS"
  94. _SUBDIR_CXXFLAGS="$CXXFLAGS"
  95. _SUBDIR_LDFLAGS="$LDFLAGS"
  96. _SUBDIR_HOST_CC="$HOST_CC"
  97. _SUBDIR_HOST_CFLAGS="$HOST_CFLAGS"
  98. _SUBDIR_HOST_CXXFLAGS="$HOST_CXXFLAGS"
  99. _SUBDIR_HOST_LDFLAGS="$HOST_LDFLAGS"
  100. _SUBDIR_CONFIG_ARGS="$ac_configure_args"
  101. dnl Set the version number of the libs included with mozilla
  102. dnl ========================================================
  103. NSPR_VERSION=4
  104. dnl Set the minimum version of toolkit libs used by mozilla
  105. dnl ========================================================
  106. PERL_VERSION=5.006
  107. PYTHON_VERSION=2.5
  108. WINDRES_VERSION=2.14.90
  109. W32API_VERSION=3.14
  110. MSMANIFEST_TOOL=
  111. dnl Set various checks
  112. dnl ========================================================
  113. MISSING_X=
  114. AC_PROG_AWK
  115. dnl Initialize the Pthread test variables early so they can be
  116. dnl overridden by each platform.
  117. dnl ========================================================
  118. USE_PTHREADS=
  119. _PTHREAD_LDFLAGS=""
  120. dnl Do not allow a separate objdir build if a srcdir build exists.
  121. dnl ==============================================================
  122. _topsrcdir=`cd \`dirname $0\`; pwd`
  123. _objdir=`pwd`
  124. if test "$_topsrcdir" != "$_objdir"
  125. then
  126. # Check for a couple representative files in the source tree
  127. _conflict_files=
  128. for file in $_topsrcdir/Makefile $_topsrcdir/config/autoconf.mk; do
  129. if test -f $file; then
  130. _conflict_files="$_conflict_files $file"
  131. fi
  132. done
  133. if test "$_conflict_files"; then
  134. echo "***"
  135. echo "* Your source tree contains these files:"
  136. for file in $_conflict_files; do
  137. echo "* $file"
  138. done
  139. cat 1>&2 <<-EOF
  140. * This indicates that you previously built in the source tree.
  141. * A source tree build can confuse the separate objdir build.
  142. *
  143. * To clean up the source tree:
  144. * 1. cd $_topsrcdir
  145. * 2. gmake distclean
  146. ***
  147. EOF
  148. exit 1
  149. break
  150. fi
  151. fi
  152. MOZ_BUILD_ROOT=`pwd`
  153. dnl Choose where to put the 'dist' directory.
  154. dnl ==============================================================
  155. MOZ_ARG_WITH_STRING(dist-dir,
  156. [ --with-dist-dir=DIR Use DIR as 'dist' staging area. DIR may be
  157. relative to the top of SpiderMonkey build tree,
  158. or absolute.],
  159. TOP_DIST=$withval,
  160. TOP_DIST=dist)
  161. AC_SUBST(TOP_DIST)
  162. dnl Default to MSVC for win32
  163. dnl ==============================================================
  164. if test -z "$CROSS_COMPILE"; then
  165. case "$target" in
  166. *-mingw*)
  167. if test -z "$CC"; then CC=cl; fi
  168. if test -z "$CXX"; then CXX=cl; fi
  169. if test -z "$CPP"; then CPP="cl -E -nologo"; fi
  170. if test -z "$CXXCPP"; then CXXCPP="cl -TP -E -nologo"; ac_cv_prog_CXXCPP="$CXXCPP"; fi
  171. if test -z "$LD"; then LD=link; fi
  172. if test -z "$AS"; then
  173. case "${target_cpu}" in
  174. i*86)
  175. AS=ml;
  176. ;;
  177. x86_64)
  178. AS=ml64;
  179. ;;
  180. esac
  181. fi
  182. if test -z "$MIDL"; then MIDL=midl; fi
  183. ;;
  184. *-darwin*)
  185. # prefer gcc-4.2 to default cc on older xcode
  186. MOZ_PATH_PROGS(CC, $CC gcc-4.2 gcc)
  187. MOZ_PATH_PROGS(CXX, $CXX g++-4.2 g++)
  188. ;;
  189. esac
  190. fi
  191. COMPILE_ENVIRONMENT=1
  192. MOZ_ARG_DISABLE_BOOL(compile-environment,
  193. [ --disable-compile-environment
  194. Disable compiler/library checks.],
  195. COMPILE_ENVIRONMENT= )
  196. AC_SUBST(COMPILE_ENVIRONMENT)
  197. dnl Check for Perl first -- needed for win32 SDK checks
  198. MOZ_PATH_PROGS(PERL, $PERL perl5 perl )
  199. if test -z "$PERL" -o "$PERL" = ":"; then
  200. AC_MSG_ERROR([perl not found in \$PATH])
  201. fi
  202. MOZ_ARG_ENABLE_BOOL(shared-js,
  203. [ --disable-shared-js
  204. Do not create a shared library.],
  205. DISABLE_SHARED_JS=0,
  206. DISABLE_SHARED_JS=1)
  207. if test "$DISABLE_SHARED_JS" = "1" ; then
  208. AC_DEFINE(STATIC_EXPORTABLE_JS_API)
  209. else
  210. JS_SHARED_LIBRARY=1
  211. fi
  212. AC_SUBST(JS_SHARED_LIBRARY)
  213. dnl ========================================================
  214. dnl = Android uses a very custom (hacky) toolchain; we need to do this
  215. dnl = here, so that the compiler checks can succeed
  216. dnl ========================================================
  217. MOZ_ARG_WITH_STRING(android-ndk,
  218. [ --with-android-ndk=DIR
  219. location where the Android NDK can be found],
  220. android_ndk=$withval)
  221. MOZ_ARG_WITH_STRING(android-toolchain,
  222. [ --with-android-toolchain=DIR
  223. location of the android toolchain, default NDK/build/prebuilt/HOST/arm-eabi-4.4.0],
  224. android_toolchain=$withval)
  225. MOZ_ARG_WITH_STRING(android-version,
  226. [ --with-android-version=VER
  227. android platform version, default 5],
  228. android_version=$withval,
  229. android_version=5)
  230. MOZ_ARG_WITH_STRING(android-sdk,
  231. [ --with-android-sdk=DIR
  232. location where the Android SDK can be found (base directory, e.g. .../android/platforms/android-6)],
  233. android_sdk=$withval)
  234. MOZ_ARG_WITH_STRING(android-platform,
  235. [ --with-android-platform=DIR
  236. location of platform dir, default NDK/build/platforms/android-5/arch-arm],
  237. android_platform=$withval)
  238. MOZ_ARG_ENABLE_BOOL(android-libstdcxx,
  239. [ --enable-android-libstdcxx
  240. use GNU libstdc++ instead of STLPort for NDK >= 5],
  241. MOZ_ANDROID_LIBSTDCXX=1,
  242. MOZ_ANDROID_LIBSTDCXX= )
  243. case "$target" in
  244. arm-linux*-android*|*-linuxandroid*)
  245. android_tool_prefix="arm-linux-androideabi"
  246. ;;
  247. arm-android-eabi)
  248. android_tool_prefix="arm-eabi"
  249. ;;
  250. i?86-*android*)
  251. android_tool_prefix="i686-android-linux"
  252. ;;
  253. *)
  254. android_tool_prefix="$target_os"
  255. ;;
  256. esac
  257. MOZ_ARG_WITH_STRING(gonk,
  258. [ --with-gonk=DIR
  259. location of gonk dir],
  260. gonkdir=$withval)
  261. if test -n "$gonkdir" ; then
  262. kernel_name=`uname -s | tr "[[:upper:]]" "[[:lower:]]"`
  263. gonk_toolchain="$gonkdir"/prebuilt/$kernel_name-x86/toolchain/arm-eabi-4.4.3
  264. dnl set up compilers
  265. AS="$gonk_toolchain"/bin/"$android_tool_prefix"-as
  266. CC="$gonk_toolchain"/bin/"$android_tool_prefix"-gcc
  267. CXX="$gonk_toolchain"/bin/"$android_tool_prefix"-g++
  268. CPP="$gonk_toolchain"/bin/"$android_tool_prefix"-cpp
  269. LD="$gonk_toolchain"/bin/"$android_tool_prefix"-ld
  270. AR="$gonk_toolchain"/bin/"$android_tool_prefix"-ar
  271. RANLIB="$gonk_toolchain"/bin/"$android_tool_prefix"-ranlib
  272. STRIP="$gonk_toolchain"/bin/"$android_tool_prefix"-strip
  273. STLPORT_CPPFLAGS="-I$gonkdir/external/stlport/stlport"
  274. STLPORT_LIBS="-lstlport"
  275. CPPFLAGS="-DANDROID -I$gonkdir/bionic/libc/include/ -I$gonkdir/bionic/libc/kernel/common -I$gonkdir/bionic/libc/arch-arm/include -I$gonkdir/bionic/libc/kernel/arch-arm -I$gonkdir/bionic/libm/include -I$gonkdir/frameworks/base/native/include -I$gonkdir/system/core/include -I$gonkdir/bionic $STLPORT_CPPFLAGS $CPPFLAGS"
  276. CFLAGS="-mandroid -fno-short-enums -fno-exceptions $CFLAGS"
  277. CXXFLAGS="-mandroid -fno-short-enums -fno-exceptions $CXXFLAGS"
  278. LIBS="$LIBS $STLPORT_LIBS"
  279. dnl Add -llog by default, since we use it all over the place.
  280. LDFLAGS="-mandroid -L$gonkdir/out/target/product/$GONK_PRODUCT/obj/lib -Wl,-rpath-link=$gonkdir/out/target/product/$GONK_PRODUCT/obj/lib --sysroot=$gonkdir/out/target/product/$GONK_PRODUCT/obj/ -llog $LDFLAGS"
  281. dnl prevent cross compile section from using these flags as host flags
  282. if test -z "$HOST_CPPFLAGS" ; then
  283. HOST_CPPFLAGS=" "
  284. fi
  285. if test -z "$HOST_CFLAGS" ; then
  286. HOST_CFLAGS=" "
  287. fi
  288. if test -z "$HOST_CXXFLAGS" ; then
  289. HOST_CXXFLAGS=" "
  290. fi
  291. if test -z "$HOST_LDFLAGS" ; then
  292. HOST_LDFLAGS=" "
  293. fi
  294. # save these for libffi's subconfigure,
  295. # which doesn't know how to figure this stuff out on its own
  296. ANDROID_CFLAGS="$CFLAGS"
  297. ANDROID_CPPFLAGS="$CPPFLAGS"
  298. ANDROID_LDFLAGS="$LDFLAGS"
  299. AC_DEFINE(ANDROID)
  300. AC_DEFINE(GONK)
  301. CROSS_COMPILE=1
  302. else
  303. case "$target" in
  304. *-android*|*-linuxandroid*)
  305. if test -z "$android_ndk" ; then
  306. AC_MSG_ERROR([You must specify --with-android-ndk=/path/to/ndk when targeting Android.])
  307. fi
  308. if test -z "$android_sdk" ; then
  309. AC_MSG_ERROR([You must specify --with-android-sdk=/path/to/sdk when targeting Android.])
  310. fi
  311. android_platform_tools="$android_sdk"/../../platform-tools
  312. if test ! -d "$android_platform_tools" ; then
  313. android_platform_tools="$android_sdk"/tools # SDK Tools < r8
  314. else
  315. if ! test -e "$android_sdk"/source.properties ; then
  316. AC_MSG_ERROR([The path in --with-android-sdk isn't valid (source.properties hasn't been found).])
  317. fi
  318. # Minimum Android SDK API Level we require.
  319. android_min_api_level=13
  320. # Get the api level from "$android_sdk"/source.properties.
  321. android_api_level=`$AWK -F = '$1 == "AndroidVersion.ApiLevel" {print $2}' "$android_sdk"/source.properties`
  322. if test -z "$android_api_level" ; then
  323. AC_MSG_ERROR([Unexpected error: no AndroidVersion.ApiLevel field has been found in source.properties.])
  324. fi
  325. if ! test "$android_api_level" -eq "$android_api_level" ; then
  326. AC_MSG_ERROR([Unexpected error: the found android api value isn't a number! (found $android_api_level)])
  327. fi
  328. if test $android_api_level -lt $android_min_api_level ; then
  329. AC_MSG_ERROR([The given Android SDK provides API level $android_api_level ($android_min_api_level or higher required).])
  330. fi
  331. fi
  332. if test -z "$android_toolchain" ; then
  333. AC_MSG_CHECKING([for android toolchain directory])
  334. kernel_name=`uname -s | tr "[[:upper:]]" "[[:lower:]]"`
  335. android_toolchain="$android_ndk"/build/prebuilt/$kernel_name-x86/arm-eabi-4.4.0
  336. # With newer NDK, the toolchain path has changed.
  337. if ! test -d "$android_toolchain" ; then
  338. android_toolchain="$android_ndk"/toolchains/arm-$kernel_name-androideabi-4.4.3/prebuilt/$kernel_name-x86
  339. fi
  340. if test -d "$android_toolchain" ; then
  341. AC_MSG_RESULT([$android_toolchain])
  342. else
  343. AC_MSG_ERROR([not found. You have to specify --with-android-toolchain=/path/to/ndk/toolchain.])
  344. fi
  345. fi
  346. if test -z "$android_platform" ; then
  347. AC_MSG_CHECKING([for android platform directory])
  348. android_platform="$android_ndk"/build/platforms/android-"$android_version"/arch-"$target_cpu"
  349. # With newer NDK, the platform path has changed.
  350. if ! test -d "$android_platform" ; then
  351. android_platform="$android_ndk"/platforms/android-"$android_version"/arch-"$target_cpu"
  352. fi
  353. if test -d "$android_platform" ; then
  354. AC_MSG_RESULT([$android_platform])
  355. else
  356. AC_MSG_ERROR([not found. You have to specify --with-android-platform=/path/to/ndk/platform.])
  357. fi
  358. fi
  359. dnl set up compilers
  360. AS="$android_toolchain"/bin/"$android_tool_prefix"-as
  361. CC="$android_toolchain"/bin/"$android_tool_prefix"-gcc
  362. CXX="$android_toolchain"/bin/"$android_tool_prefix"-g++
  363. CPP="$android_toolchain"/bin/"$android_tool_prefix"-cpp
  364. LD="$android_toolchain"/bin/"$android_tool_prefix"-ld
  365. AR="$android_toolchain"/bin/"$android_tool_prefix"-ar
  366. RANLIB="$android_toolchain"/bin/"$android_tool_prefix"-ranlib
  367. STRIP="$android_toolchain"/bin/"$android_tool_prefix"-strip
  368. CPPFLAGS="-I$android_platform/usr/include $CPPFLAGS"
  369. CFLAGS="-mandroid -I$android_platform/usr/include -fno-short-enums -fno-exceptions $CFLAGS"
  370. CXXFLAGS="-mandroid -I$android_platform/usr/include -fno-short-enums -fno-exceptions $CXXFLAGS"
  371. dnl Add -llog by default, since we use it all over the place.
  372. dnl Add --allow-shlib-undefined, because libGLESv2 links to an
  373. dnl undefined symbol (present on the hardware, just not in the
  374. dnl NDK.)
  375. LDFLAGS="-mandroid -L$android_platform/usr/lib -Wl,-rpath-link=$android_platform/usr/lib --sysroot=$android_platform -llog -Wl,--allow-shlib-undefined $LDFLAGS"
  376. dnl prevent cross compile section from using these flags as host flags
  377. if test -z "$HOST_CPPFLAGS" ; then
  378. HOST_CPPFLAGS=" "
  379. fi
  380. if test -z "$HOST_CFLAGS" ; then
  381. HOST_CFLAGS=" "
  382. fi
  383. if test -z "$HOST_CXXFLAGS" ; then
  384. HOST_CXXFLAGS=" "
  385. fi
  386. if test -z "$HOST_LDFLAGS" ; then
  387. HOST_LDFLAGS=" "
  388. fi
  389. ANDROID_NDK="${android_ndk}"
  390. ANDROID_TOOLCHAIN="${android_toolchain}"
  391. ANDROID_PLATFORM="${android_platform}"
  392. ANDROID_SDK="${android_sdk}"
  393. ANDROID_PLATFORM_TOOLS="${android_platform_tools}"
  394. ANDROID_VERSION="${android_version}"
  395. AC_DEFINE(ANDROID)
  396. AC_DEFINE_UNQUOTED(ANDROID_VERSION, $android_version)
  397. AC_SUBST(ANDROID_VERSION)
  398. CROSS_COMPILE=1
  399. MOZ_CHROME_FILE_FORMAT=omni
  400. ;;
  401. esac
  402. fi
  403. AC_SUBST(ANDROID_NDK)
  404. AC_SUBST(ANDROID_TOOLCHAIN)
  405. AC_SUBST(ANDROID_PLATFORM)
  406. AC_SUBST(ANDROID_SDK)
  407. AC_SUBST(ANDROID_PLATFORM_TOOLS)
  408. dnl ========================================================
  409. dnl Checks for compilers.
  410. dnl ========================================================
  411. dnl Set CROSS_COMPILE in the environment when running configure
  412. dnl to use the cross-compile setup for now
  413. dnl ========================================================
  414. dnl AR_FLAGS set here so HOST_AR_FLAGS can be set correctly (see bug 538269)
  415. AR_FLAGS='cr $@'
  416. if test "$COMPILE_ENVIRONMENT"; then
  417. # Note:
  418. # In Mozilla, we use the names $target, $host and $build incorrectly, but are
  419. # too far gone to back out now. See Bug 475488:
  420. # - When we say $target, we mean $host, that is, the system on which
  421. # Mozilla will be run.
  422. # - When we say $host, we mean $build, that is, the system on which Mozilla
  423. # is built.
  424. # - $target (in its correct usage) is for compilers who generate code for a
  425. # different platform than $host, so it would not be used by Mozilla.
  426. if test "$target" != "$host"; then
  427. echo "cross compiling from $host to $target"
  428. _SAVE_CC="$CC"
  429. _SAVE_CFLAGS="$CFLAGS"
  430. _SAVE_LDFLAGS="$LDFLAGS"
  431. AC_MSG_CHECKING([for host c compiler])
  432. AC_CHECK_PROGS(HOST_CC, $HOST_CC gcc cc /usr/ucb/cc cl icc, "")
  433. if test -z "$HOST_CC"; then
  434. AC_MSG_ERROR([no acceptable c compiler found in \$PATH])
  435. fi
  436. AC_MSG_RESULT([$HOST_CC])
  437. AC_MSG_CHECKING([for host c++ compiler])
  438. AC_CHECK_PROGS(HOST_CXX, $HOST_CXX $CCC c++ g++ gcc CC cxx cc++ cl icc, "")
  439. if test -z "$HOST_CXX"; then
  440. AC_MSG_ERROR([no acceptable c++ compiler found in \$PATH])
  441. fi
  442. AC_MSG_RESULT([$HOST_CXX])
  443. if test -z "$HOST_CFLAGS"; then
  444. HOST_CFLAGS="$CFLAGS"
  445. fi
  446. if test -z "$HOST_CXXFLAGS"; then
  447. HOST_CXXFLAGS="$CXXFLAGS"
  448. fi
  449. if test -z "$HOST_LDFLAGS"; then
  450. HOST_LDFLAGS="$LDFLAGS"
  451. fi
  452. if test -z "$HOST_AR_FLAGS"; then
  453. HOST_AR_FLAGS="$AR_FLAGS"
  454. fi
  455. AC_CHECK_PROGS(HOST_RANLIB, $HOST_RANLIB ranlib, ranlib, :)
  456. AC_CHECK_PROGS(HOST_AR, $HOST_AR ar, ar, :)
  457. CC="$HOST_CC"
  458. CFLAGS="$HOST_CFLAGS"
  459. LDFLAGS="$HOST_LDFLAGS"
  460. AC_MSG_CHECKING([whether the host c compiler ($HOST_CC $HOST_CFLAGS $HOST_LDFLAGS) works])
  461. AC_TRY_COMPILE([], [return(0);],
  462. [ac_cv_prog_hostcc_works=1 AC_MSG_RESULT([yes])],
  463. AC_MSG_ERROR([installation or configuration problem: host compiler $HOST_CC cannot create executables.]) )
  464. CC="$HOST_CXX"
  465. CFLAGS="$HOST_CXXFLAGS"
  466. AC_MSG_CHECKING([whether the host c++ compiler ($HOST_CXX $HOST_CXXFLAGS $HOST_LDFLAGS) works])
  467. AC_TRY_COMPILE([], [return(0);],
  468. [ac_cv_prog_hostcxx_works=1 AC_MSG_RESULT([yes])],
  469. AC_MSG_ERROR([installation or configuration problem: host compiler $HOST_CXX cannot create executables.]) )
  470. CC=$_SAVE_CC
  471. CFLAGS=$_SAVE_CFLAGS
  472. LDFLAGS=$_SAVE_LDFLAGS
  473. AC_CHECK_PROGS(CC, $CC "${target_alias}-gcc" "${target}-gcc", :)
  474. unset ac_cv_prog_CC
  475. AC_PROG_CC
  476. AC_CHECK_PROGS(CXX, $CXX "${target_alias}-g++" "${target}-g++", :)
  477. unset ac_cv_prog_CXX
  478. AC_PROG_CXX
  479. AC_CHECK_PROGS(RANLIB, $RANLIB "${target_alias}-ranlib" "${target}-ranlib", :)
  480. AC_CHECK_PROGS(AR, $AR "${target_alias}-ar" "${target}-ar", :)
  481. MOZ_PATH_PROGS(AS, $AS "${target_alias}-as" "${target}-as", :)
  482. AC_CHECK_PROGS(LD, $LD "${target_alias}-ld" "${target}-ld", :)
  483. AC_CHECK_PROGS(STRIP, $STRIP "${target_alias}-strip" "${target}-strip", :)
  484. AC_CHECK_PROGS(WINDRES, $WINDRES "${target_alias}-windres" "${target}-windres", :)
  485. AC_DEFINE(CROSS_COMPILE)
  486. dnl If we cross compile for ppc on Mac OS X x86, cross_compiling will
  487. dnl have erroneously been set to "no", because the x86 build host is
  488. dnl able to run ppc code in a translated environment, making a cross
  489. dnl compiler appear native. So we override that here.
  490. cross_compiling=yes
  491. else
  492. AC_PROG_CC
  493. AC_PROG_CXX
  494. AC_PROG_RANLIB
  495. MOZ_PATH_PROGS(AS, $AS as, $CC)
  496. AC_CHECK_PROGS(AR, ar, :)
  497. AC_CHECK_PROGS(LD, ld, :)
  498. AC_CHECK_PROGS(STRIP, strip, :)
  499. AC_CHECK_PROGS(WINDRES, windres, :)
  500. if test -z "$HOST_CC"; then
  501. HOST_CC='$(CC)'
  502. fi
  503. if test -z "$HOST_CFLAGS"; then
  504. HOST_CFLAGS='$(CFLAGS)'
  505. fi
  506. if test -z "$HOST_CXX"; then
  507. HOST_CXX='$(CXX)'
  508. fi
  509. if test -z "$HOST_CXXFLAGS"; then
  510. HOST_CXXFLAGS='$(CXXFLAGS)'
  511. fi
  512. if test -z "$HOST_LDFLAGS"; then
  513. HOST_LDFLAGS='$(LDFLAGS)'
  514. fi
  515. if test -z "$HOST_RANLIB"; then
  516. HOST_RANLIB='$(RANLIB)'
  517. fi
  518. if test -z "$HOST_AR"; then
  519. HOST_AR='$(AR)'
  520. fi
  521. if test -z "$HOST_AR_FLAGS"; then
  522. HOST_AR_FLAGS='$(AR_FLAGS)'
  523. fi
  524. fi
  525. GNU_AS=
  526. GNU_LD=
  527. GNU_CC=
  528. GNU_CXX=
  529. CC_VERSION='N/A'
  530. CXX_VERSION='N/A'
  531. if test "$GCC" = "yes"; then
  532. GNU_CC=1
  533. CC_VERSION=`$CC -v 2>&1 | grep 'gcc version'`
  534. fi
  535. if test "$GXX" = "yes"; then
  536. GNU_CXX=1
  537. CXX_VERSION=`$CXX -v 2>&1 | grep 'gcc version'`
  538. fi
  539. if test "`echo | $AS -v 2>&1 | grep -c GNU`" != "0"; then
  540. GNU_AS=1
  541. fi
  542. if test "`echo | $LD -v 2>&1 | grep -c GNU`" != "0"; then
  543. GNU_LD=1
  544. fi
  545. if test "$GNU_CC"; then
  546. if `$CC -print-prog-name=ld` -v 2>&1 | grep -c GNU >/dev/null; then
  547. GCC_USE_GNU_LD=1
  548. fi
  549. fi
  550. INTEL_CC=
  551. INTEL_CXX=
  552. if test "$GCC" = yes; then
  553. if test "`$CC -help 2>&1 | grep -c 'Intel(R) C++ Compiler'`" != "0"; then
  554. INTEL_CC=1
  555. fi
  556. fi
  557. if test "$GXX" = yes; then
  558. if test "`$CXX -help 2>&1 | grep -c 'Intel(R) C++ Compiler'`" != "0"; then
  559. INTEL_CXX=1
  560. fi
  561. fi
  562. CLANG_CC=
  563. CLANG_CXX=
  564. if test "$GCC" = yes; then
  565. if test "`$CC -v 2>&1 | grep -c 'clang version'`" != "0"; then
  566. CLANG_CC=1
  567. fi
  568. fi
  569. if test "$GXX" = yes; then
  570. if test "`$CXX -v 2>&1 | grep -c 'clang version'`" != "0"; then
  571. CLANG_CXX=1
  572. fi
  573. fi
  574. dnl Special win32 checks
  575. dnl ========================================================
  576. WINVER=502
  577. dnl Target the Windows 7 SDK by default
  578. WINSDK_TARGETVER=601
  579. MOZ_ARG_WITH_STRING(windows-version,
  580. [ --with-windows-version=WINSDK_TARGETVER
  581. Highest Windows version to target using this SDK
  582. 601: Windows 7],
  583. WINSDK_TARGETVER=$withval)
  584. case "$WINSDK_TARGETVER" in
  585. 601)
  586. MOZ_WINSDK_TARGETVER=0${WINSDK_TARGETVER}0000
  587. ;;
  588. *)
  589. AC_MSG_ERROR([Invalid value for --with-windows-version ($WINSDK_TARGETVER), must be 601]);
  590. ;;
  591. esac
  592. case "$target" in
  593. *-mingw*)
  594. if test "$GCC" != "yes"; then
  595. # Check to see if we are really running in a msvc environemnt
  596. _WIN32_MSVC=1
  597. # Make sure compilers are valid
  598. CFLAGS="$CFLAGS -TC -nologo"
  599. CXXFLAGS="$CXXFLAGS -TP -nologo"
  600. # MSVC warning C4345 warns of newly conformant behavior as of VS2003.
  601. # _CRT_SECURE_NO_WARNINGS disables warnings about using MSVC-specific
  602. # secure CRT functions.
  603. CXXFLAGS="$CXXFLAGS -wd4345 -D_CRT_SECURE_NO_WARNINGS"
  604. AC_LANG_SAVE
  605. AC_LANG_C
  606. AC_TRY_COMPILE([#include <stdio.h>],
  607. [ printf("Hello World\n"); ],,
  608. AC_MSG_ERROR([\$(CC) test failed. You must have MS VC++ in your path to build.]) )
  609. AC_LANG_CPLUSPLUS
  610. AC_TRY_COMPILE([#include <new.h>],
  611. [ unsigned *test = new unsigned(42); ],,
  612. AC_MSG_ERROR([\$(CXX) test failed. You must have MS VC++ in your path to build.]) )
  613. AC_LANG_RESTORE
  614. changequote(,)
  615. _MSVC_VER_FILTER='s|.* ([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?).*|\1|p'
  616. changequote([,])
  617. # Determine compiler version
  618. CC_VERSION=`"${CC}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
  619. _CC_MAJOR_VERSION=`echo ${CC_VERSION} | $AWK -F\. '{ print $1 }'`
  620. _CC_MINOR_VERSION=`echo ${CC_VERSION} | $AWK -F\. '{ print $2 }'`
  621. _CC_RELEASE=`echo ${CC_VERSION} | $AWK -F\. '{ print $3 }'`
  622. _CC_BUILD=`echo ${CC_VERSION} | $AWK -F\. '{ print $4 }'`
  623. _MSC_VER=${_CC_MAJOR_VERSION}${_CC_MINOR_VERSION}
  624. CXX_VERSION=`"${CXX}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
  625. _CXX_MAJOR_VERSION=`echo ${CXX_VERSION} | $AWK -F\. '{ print $1 }'`
  626. if test "$_CC_MAJOR_VERSION" != "$_CXX_MAJOR_VERSION"; then
  627. AC_MSG_ERROR([The major versions of \$CC and \$CXX do not match.])
  628. fi
  629. if test "$_CC_MAJOR_VERSION" = "14"; then
  630. dnl Require VC8SP1 or newer.
  631. dnl VC8 is 14.00.50727.42, VC8SP1 is 14.00.50727.762.
  632. if test "$_CC_RELEASE" -lt 50727 -o \
  633. \( "$_CC_RELEASE" -eq 50727 -a "$_CC_BUILD" -lt 762 \); then
  634. AC_MSG_ERROR([This version ($CC_VERSION) of the MSVC compiler is unsupported. You probably need to install Service Pack 1 of Visual Studio 2005. See https://developer.mozilla.org/en/Windows_Build_Prerequisites.])
  635. fi
  636. _CC_SUITE=8
  637. AC_DEFINE(_CRT_SECURE_NO_DEPRECATE)
  638. AC_DEFINE(_CRT_NONSTDC_NO_DEPRECATE)
  639. elif test "$_CC_MAJOR_VERSION" = "15"; then
  640. _CC_SUITE=9
  641. AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
  642. AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
  643. elif test "$_CC_MAJOR_VERSION" = "16"; then
  644. _CC_SUITE=10
  645. AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
  646. AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
  647. elif test "$_CC_MAJOR_VERSION" = "17"; then
  648. _CC_SUITE=11
  649. AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
  650. AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
  651. else
  652. AC_MSG_ERROR([This version ($CC_VERSION) of the MSVC compiler is unsupported. See https://developer.mozilla.org/en/Windows_Build_Prerequisites.])
  653. fi
  654. _MOZ_RTTI_FLAGS_ON='-GR'
  655. _MOZ_RTTI_FLAGS_OFF='-GR-'
  656. dnl Ensure that mt.exe is 'Microsoft (R) Manifest Tool',
  657. dnl not something else like "magnetic tape manipulation utility".
  658. MSMT_TOOL=`mt 2>&1|grep 'Microsoft (R) Manifest Tool'`
  659. if test -z "$MSMT_TOOL"; then
  660. AC_MSG_ERROR([Microsoft (R) Manifest Tool must be in your \$PATH.])
  661. fi
  662. changequote(,)
  663. _MSMT_VER_FILTER='s|.* \([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*|\1|p'
  664. changequote([,])
  665. MSMANIFEST_TOOL_VERSION=`echo ${MSMT_TOOL}|sed -ne "$_MSMT_VER_FILTER"`
  666. if test -z "$MSMANIFEST_TOOL_VERSION"; then
  667. AC_MSG_WARN([Unknown version of the Microsoft (R) Manifest Tool.])
  668. fi
  669. MSMANIFEST_TOOL=1
  670. unset MSMT_TOOL
  671. # Check linker version
  672. _LD_FULL_VERSION=`"${LD}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
  673. _LD_MAJOR_VERSION=`echo ${_LD_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
  674. if test "$_LD_MAJOR_VERSION" != "$_CC_SUITE"; then
  675. AC_MSG_ERROR([The linker major version, $_LD_FULL_VERSION, does not match the compiler suite version, $_CC_SUITE.])
  676. fi
  677. INCREMENTAL_LINKER=1
  678. # Identify which version of the SDK we're building with
  679. # Windows Server 2008 and newer SDKs have WinSDKVer.h, get the version
  680. # from there
  681. MOZ_CHECK_HEADERS([winsdkver.h])
  682. if test "$ac_cv_header_winsdkver_h" = "yes"; then
  683. # Get the highest _WIN32_WINNT and NTDDI versions supported
  684. # Take the higher of the two
  685. # This is done because the Windows 7 beta SDK reports its
  686. # NTDDI_MAXVER to be 0x06000100 instead of 0x06010000, as it should
  687. AC_CACHE_CHECK(for highest Windows version supported by this SDK,
  688. ac_cv_winsdk_maxver,
  689. [cat > conftest.h <<EOF
  690. #include <winsdkver.h>
  691. #include <sdkddkver.h>
  692. #if (NTDDI_VERSION_FROM_WIN32_WINNT(_WIN32_WINNT_MAXVER) > NTDDI_MAXVER)
  693. #define WINSDK_MAXVER NTDDI_VERSION_FROM_WIN32_WINNT(_WIN32_WINNT_MAXVER)
  694. #else
  695. #define WINSDK_MAXVER NTDDI_MAXVER
  696. #endif
  697. WINSDK_MAXVER
  698. EOF
  699. ac_cv_winsdk_maxver=`$CPP conftest.h 2>/dev/null | tail -n1`
  700. rm -f conftest.h
  701. ])
  702. MOZ_WINSDK_MAXVER=${ac_cv_winsdk_maxver}
  703. else
  704. # Any SDK which doesn't have WinSDKVer.h is too old.
  705. AC_MSG_ERROR([Your SDK does not have WinSDKVer.h. It is probably too old. Please upgrade to a newer SDK or try running the Windows SDK Configuration Tool and selecting a newer SDK. See https://developer.mozilla.org/En/Windows_SDK_versions for more details on fixing this.])
  706. fi
  707. unset _MSVC_VER_FILTER
  708. AC_CACHE_CHECK(for std::_Throw, ac_cv_have_std__Throw,
  709. [
  710. AC_LANG_SAVE
  711. AC_LANG_CPLUSPLUS
  712. _SAVE_CXXFLAGS="$CXXFLAGS"
  713. CXXFLAGS="${CXXFLAGS} -D_HAS_EXCEPTIONS=0"
  714. AC_TRY_COMPILE([#include <exception>],
  715. [std::_Throw(std::exception()); return 0;],
  716. ac_cv_have_std__Throw="yes",
  717. ac_cv_have_std__Throw="no")
  718. CXXFLAGS="$_SAVE_CXXFLAGS"
  719. AC_LANG_RESTORE
  720. ])
  721. if test "$ac_cv_have_std__Throw" == "yes"; then
  722. AC_CACHE_CHECK(for |class __declspec(dllimport) exception| bug,
  723. ac_cv_have_dllimport_exception_bug,
  724. [
  725. AC_LANG_SAVE
  726. AC_LANG_CPLUSPLUS
  727. _SAVE_CXXFLAGS="$CXXFLAGS"
  728. CXXFLAGS="${CXXFLAGS} -D_HAS_EXCEPTIONS=0"
  729. AC_TRY_LINK([#include <vector>],
  730. [std::vector<int> v; return v.at(1);],
  731. ac_cv_have_dllimport_exception_bug="no",
  732. ac_cv_have_dllimport_exception_bug="yes")
  733. CXXFLAGS="$_SAVE_CXXFLAGS"
  734. AC_LANG_RESTORE
  735. ])
  736. if test "$ac_cv_have_dllimport_exception_bug" = "no"; then
  737. WRAP_STL_INCLUDES=1
  738. MOZ_MSVC_STL_WRAP__Throw=1
  739. AC_DEFINE(MOZ_MSVC_STL_WRAP__Throw)
  740. fi
  741. else
  742. AC_CACHE_CHECK(for overridable _RAISE,
  743. ac_cv_have__RAISE,
  744. [
  745. AC_LANG_SAVE
  746. AC_LANG_CPLUSPLUS
  747. _SAVE_CXXFLAGS="$CXXFLAGS"
  748. CXXFLAGS="${CXXFLAGS} -D_HAS_EXCEPTIONS=0"
  749. AC_TRY_COMPILE([#include <xstddef>
  750. #undef _RAISE
  751. #define _RAISE(x) externallyDefinedFunction((x).what())
  752. #include <vector>
  753. ],
  754. [std::vector<int> v; return v.at(1);],
  755. ac_cv_have__RAISE="no",
  756. ac_cv_have__RAISE="yes")
  757. CXXFLAGS="$_SAVE_CXXFLAGS"
  758. AC_LANG_RESTORE
  759. ])
  760. if test "$ac_cv_have__RAISE" = "yes"; then
  761. WRAP_STL_INCLUDES=1
  762. MOZ_MSVC_STL_WRAP__RAISE=1
  763. AC_DEFINE(MOZ_MSVC_STL_WRAP__RAISE)
  764. else
  765. AC_MSG_ERROR([Gecko exception wrapping doesn't understand your your MSVC/SDK. Please file a bug describing this error and your build configuration.])
  766. fi
  767. fi
  768. if test "$WRAP_STL_INCLUDES" = "1"; then
  769. STL_FLAGS='-D_HAS_EXCEPTIONS=0 -I$(DIST)/stl_wrappers'
  770. fi
  771. else
  772. # Check w32api version
  773. _W32API_MAJOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $1 }'`
  774. _W32API_MINOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $2 }'`
  775. AC_MSG_CHECKING([for w32api version >= $W32API_VERSION])
  776. AC_TRY_COMPILE([#include <w32api.h>],
  777. #if (__W32API_MAJOR_VERSION < $_W32API_MAJOR_VERSION) || \
  778. (__W32API_MAJOR_VERSION == $_W32API_MAJOR_VERSION && \
  779. __W32API_MINOR_VERSION < $_W32API_MINOR_VERSION)
  780. #error "test failed."
  781. #endif
  782. , [ res=yes ], [ res=no ])
  783. AC_MSG_RESULT([$res])
  784. if test "$res" != "yes"; then
  785. AC_MSG_ERROR([w32api version $W32API_VERSION or higher required.])
  786. fi
  787. # Check windres version
  788. AC_MSG_CHECKING([for windres version >= $WINDRES_VERSION])
  789. _WINDRES_VERSION=`${WINDRES} --version 2>&1 | grep -i windres 2>/dev/null | $AWK '{ print $3 }'`
  790. AC_MSG_RESULT([$_WINDRES_VERSION])
  791. _WINDRES_MAJOR_VERSION=`echo $_WINDRES_VERSION | $AWK -F\. '{ print $1 }'`
  792. _WINDRES_MINOR_VERSION=`echo $_WINDRES_VERSION | $AWK -F\. '{ print $2 }'`
  793. _WINDRES_RELEASE_VERSION=`echo $_WINDRES_VERSION | $AWK -F\. '{ print $3 }'`
  794. WINDRES_MAJOR_VERSION=`echo $WINDRES_VERSION | $AWK -F\. '{ print $1 }'`
  795. WINDRES_MINOR_VERSION=`echo $WINDRES_VERSION | $AWK -F\. '{ print $2 }'`
  796. WINDRES_RELEASE_VERSION=`echo $WINDRES_VERSION | $AWK -F\. '{ print $3 }'`
  797. if test "$_WINDRES_MAJOR_VERSION" -lt "$WINDRES_MAJOR_VERSION" -o \
  798. "$_WINDRES_MAJOR_VERSION" -eq "$WINDRES_MAJOR_VERSION" -a \
  799. "$_WINDRES_MINOR_VERSION" -lt "$WINDRES_MINOR_VERSION" -o \
  800. "$_WINDRES_MAJOR_VERSION" -eq "$WINDRES_MAJOR_VERSION" -a \
  801. "$_WINDRES_MINOR_VERSION" -eq "$WINDRES_MINOR_VERSION" -a \
  802. "$_WINDRES_RELEASE_VERSION" -lt "$WINDRES_RELEASE_VERSION"
  803. then
  804. AC_MSG_ERROR([windres version $WINDRES_VERSION or higher is required to build.])
  805. fi
  806. MOZ_WINSDK_MAXVER=0x06010000
  807. fi # !GNU_CC
  808. AC_DEFINE_UNQUOTED(WINVER,0x$WINVER)
  809. AC_DEFINE_UNQUOTED(_WIN32_WINNT,0x$WINVER)
  810. # Require OS features provided by IE 5.0
  811. AC_DEFINE_UNQUOTED(_WIN32_IE,0x0500)
  812. # If the maximum version supported by this SDK is lower than the target
  813. # version, error out
  814. AC_MSG_CHECKING([for Windows SDK being recent enough])
  815. if $PERL -e "exit(0x$MOZ_WINSDK_TARGETVER > $MOZ_WINSDK_MAXVER)"; then
  816. AC_MSG_RESULT("yes")
  817. else
  818. AC_MSG_RESULT("no")
  819. AC_MSG_ERROR([You are targeting Windows version 0x$MOZ_WINSDK_TARGETVER, but your SDK only supports up to version $MOZ_WINSDK_MAXVER. Install and use an updated SDK, or target a lower version using --with-windows-version. Alternatively, try running the Windows SDK Configuration Tool and selecting a newer SDK. See https://developer.mozilla.org/En/Windows_SDK_versions for more details on fixing this.])
  820. fi
  821. AC_DEFINE_UNQUOTED(MOZ_WINSDK_TARGETVER,0x$MOZ_WINSDK_TARGETVER)
  822. # Definitions matching sdkddkver.h
  823. AC_DEFINE_UNQUOTED(MOZ_NTDDI_WS03, 0x05020000)
  824. AC_DEFINE_UNQUOTED(MOZ_NTDDI_LONGHORN, 0x06000000)
  825. AC_DEFINE_UNQUOTED(MOZ_NTDDI_WIN7, 0x06010000)
  826. ;;
  827. esac
  828. AC_PROG_CPP
  829. AC_PROG_CXXCPP
  830. if test -n "$_WIN32_MSVC"; then
  831. SKIP_PATH_CHECKS=1
  832. SKIP_COMPILER_CHECKS=1
  833. SKIP_LIBRARY_CHECKS=1
  834. # Since we're skipping compiler and library checks, hard-code
  835. # some facts here.
  836. # Common to all MSVC environments:
  837. # Windows lacks <stdint.h>, but has __int8, and so on.
  838. AC_DEFINE(JS_HAVE___INTN)
  839. AC_DEFINE(HAVE_LOCALECONV)
  840. AC_DEFINE(HAVE_SYSTEMTIMETOFILETIME)
  841. AC_DEFINE(HAVE_GETSYSTEMTIMEASFILETIME)
  842. # Windows <stddef.h> defines intptr_t and uintptr_t.
  843. # VS2005: http://msdn.microsoft.com/en-us/library/323b6b3k(VS.80).aspx
  844. # VS2008: http://msdn.microsoft.com/en-us/library/323b6b3k.aspx
  845. AC_DEFINE(JS_STDDEF_H_HAS_INTPTR_T)
  846. fi
  847. fi # COMPILE_ENVIRONMENT
  848. if test "$cross_compiling" = "yes"; then
  849. CROSS_COMPILE=1
  850. else
  851. CROSS_COMPILE=
  852. fi
  853. # Check to see if we are running in a broken QEMU scratchbox.
  854. # We know that anything below 1.0.16 is broken.
  855. AC_CHECK_PROGS(SBCONF, sb-conf ve, "")
  856. if test -n "$SBCONF"; then
  857. _sb_version=`$SBCONF ve`
  858. _sb_version_major=`echo $_sb_version | cut -f1 -d.`
  859. _sb_version_minor=`echo $_sb_version | cut -f2 -d.`
  860. _sb_version_point=`echo $_sb_version | cut -f3 -d.`
  861. if test $_sb_version_major -eq 1 -a $_sb_version_minor -eq 0 -a $_sb_version_point -le 16; then
  862. QEMU_CANT_RUN_JS_SHELL=1
  863. fi
  864. fi
  865. AC_SUBST(QEMU_CANT_RUN_JS_SHELL)
  866. AC_SUBST(_MSC_VER)
  867. AC_SUBST(GNU_AS)
  868. AC_SUBST(GNU_LD)
  869. AC_SUBST(GNU_CC)
  870. AC_SUBST(GNU_CXX)
  871. AC_SUBST(INTEL_CC)
  872. AC_SUBST(INTEL_CXX)
  873. AC_SUBST(STL_FLAGS)
  874. AC_SUBST(WRAP_STL_INCLUDES)
  875. AC_SUBST(MOZ_MSVC_STL_WRAP__Throw)
  876. AC_SUBST(MOZ_MSVC_STL_WRAP__RAISE)
  877. dnl ========================================================
  878. dnl Checks for programs.
  879. dnl ========================================================
  880. AC_PROG_INSTALL
  881. AC_PROG_LN_S
  882. if test -z "$TINDERBOX_SKIP_PERL_VERSION_CHECK"; then
  883. AC_MSG_CHECKING([for minimum required perl version >= $PERL_VERSION])
  884. _perl_version=`PERL_VERSION=$PERL_VERSION $PERL -e 'print "$]"; if ($] >= $ENV{PERL_VERSION}) { exit(0); } else { exit(1); }' 2>&5`
  885. _perl_res=$?
  886. AC_MSG_RESULT([$_perl_version])
  887. if test "$_perl_res" != 0; then
  888. AC_MSG_ERROR([Perl $PERL_VERSION or higher is required.])
  889. fi
  890. fi
  891. AC_MSG_CHECKING([for full perl installation])
  892. _perl_archlib=`$PERL -e 'use Config; if ( -d $Config{archlib} ) { exit(0); } else { exit(1); }' 2>&5`
  893. _perl_res=$?
  894. if test "$_perl_res" != 0; then
  895. AC_MSG_RESULT([no])
  896. AC_MSG_ERROR([Cannot find Config.pm or \$Config{archlib}. A full perl installation is required.])
  897. else
  898. AC_MSG_RESULT([yes])
  899. fi
  900. MOZ_PATH_PROGS(PYTHON, $PYTHON python2.7 python2.6 python2.5 python)
  901. if test -z "$PYTHON"; then
  902. AC_MSG_ERROR([python was not found in \$PATH])
  903. fi
  904. if test -z "$COMPILE_ENVIRONMENT"; then
  905. NSINSTALL_BIN='$(PYTHON) $(topsrcdir)/config/nsinstall.py'
  906. fi
  907. AC_SUBST(NSINSTALL_BIN)
  908. MOZ_PATH_PROG(DOXYGEN, doxygen, :)
  909. MOZ_PATH_PROG(AUTOCONF, autoconf, :)
  910. MOZ_PATH_PROG(SYSTEM_MAKEDEPEND, makedepend)
  911. MOZ_PATH_PROG(XARGS, xargs)
  912. if test -z "$XARGS" -o "$XARGS" = ":"; then
  913. AC_MSG_ERROR([xargs not found in \$PATH .])
  914. fi
  915. if test "$COMPILE_ENVIRONMENT"; then
  916. dnl ========================================================
  917. dnl = Mac OS X toolchain support
  918. dnl ========================================================
  919. case "$target_os" in
  920. darwin*)
  921. dnl Current known valid versions for GCC_VERSION are 2.95.2 3.1 3.3 4.0.
  922. dnl 4.0 identifies itself as 4.0.x, so strip the decidecimal for
  923. dnl the environment and includedir purposes (when using an SDK, below),
  924. dnl but remember the full version number for the libdir (SDK).
  925. changequote(,)
  926. GCC_VERSION_FULL=`echo $CXX_VERSION | $PERL -pe 's/^.*gcc version ([^ ]*).*/$1/'`
  927. GCC_VERSION=`echo $GCC_VERSION_FULL | $PERL -pe '(split(/\./))[0]>=4&&s/(^\d*\.\d*).*/$1/;'`
  928. changequote([,])
  929. if test "$GCC_VERSION_FULL" = "4.0.0" ; then
  930. dnl Bug 280479, but this keeps popping up in bug 292530 too because
  931. dnl 4.0.0/4061 is the default compiler in Tiger.
  932. changequote(,)
  933. GCC_BUILD=`echo $CXX_VERSION | $PERL -pe 's/^.*build ([^ )]*).*/$1/'`
  934. changequote([,])
  935. if test "$GCC_BUILD" = "4061" ; then
  936. AC_MSG_ERROR([You are attempting to use Apple gcc 4.0 build 4061.
  937. This compiler was supplied with Xcode 2.0, and contains bugs that prevent it
  938. from building Mozilla. Upgrade to Xcode 2.1 or later.])
  939. fi
  940. fi
  941. dnl xcodebuild needs GCC_VERSION defined in the environment, since it
  942. dnl doesn't respect the CC/CXX setting. With GCC_VERSION set, it will use
  943. dnl /usr/bin/g(cc|++)-$GCC_VERSION.
  944. MOZ_PATH_PROGS(PBBUILD, pbbuild xcodebuild pbxbuild)
  945. dnl sdp was formerly in /Developer/Tools. As of Mac OS X 10.4 (Darwin 8),
  946. dnl it has moved into /usr/bin.
  947. MOZ_PATH_PROG(SDP, sdp, :, [$PATH:/usr/bin:/Developer/Tools])
  948. ;;
  949. esac
  950. AC_SUBST(GCC_VERSION)
  951. dnl The universal machinery sets UNIVERSAL_BINARY to inform packager.mk
  952. dnl that a universal binary is being produced and MOZ_CAN_RUN_PROGRAMS
  953. dnl when we can run target binaries.
  954. AC_SUBST(UNIVERSAL_BINARY)
  955. AC_SUBST(MOZ_CAN_RUN_PROGRAMS)
  956. dnl ========================================================
  957. dnl Check for MacOS deployment target version
  958. dnl ========================================================
  959. MOZ_ARG_ENABLE_STRING(macos-target,
  960. [ --enable-macos-target=VER (default=10.5)
  961. Set the minimum MacOS version needed at runtime],
  962. [_MACOSX_DEPLOYMENT_TARGET=$enableval])
  963. if test "$target_cpu" != "arm"; then
  964. case "$target" in
  965. *-darwin*)
  966. if test -n "$_MACOSX_DEPLOYMENT_TARGET" ; then
  967. dnl Use the specified value
  968. export MACOSX_DEPLOYMENT_TARGET=$_MACOSX_DEPLOYMENT_TARGET
  969. else
  970. dnl No value specified on the command line or in the environment,
  971. dnl use architecture minimum.
  972. case "${target_cpu}" in
  973. i*86)
  974. export MACOSX_DEPLOYMENT_TARGET=10.5
  975. ;;
  976. x86_64)
  977. export MACOSX_DEPLOYMENT_TARGET=10.6
  978. ;;
  979. esac
  980. fi
  981. ;;
  982. esac
  983. fi
  984. AC_SUBST(MACOSX_DEPLOYMENT_TARGET)
  985. dnl ========================================================
  986. dnl = Mac OS X SDK support
  987. dnl ========================================================
  988. MACOS_SDK_DIR=
  989. NEXT_ROOT=
  990. MOZ_ARG_WITH_STRING(macos-sdk,
  991. [ --with-macos-sdk=dir Location of platform SDK to use (Mac OS X only)],
  992. MACOS_SDK_DIR=$withval)
  993. dnl MACOS_SDK_DIR will be set to the SDK location whenever one is in use.
  994. dnl NEXT_ROOT will be set and exported only if it's needed.
  995. AC_SUBST(MACOS_SDK_DIR)
  996. AC_SUBST(NEXT_ROOT)
  997. if test "$MACOS_SDK_DIR"; then
  998. dnl Sync this section with the ones in NSPR and NSS.
  999. dnl Changes to the cross environment here need to be accounted for in
  1000. dnl the libIDL checks (below) and xpidl build.
  1001. if test ! -d "$MACOS_SDK_DIR"; then
  1002. AC_MSG_ERROR([SDK not found. When using --with-macos-sdk, you must
  1003. specify a valid SDK. SDKs are installed when the optional cross-development
  1004. tools are selected during the Xcode/Developer Tools installation.])
  1005. fi
  1006. GCC_VERSION_MAJOR=`echo $GCC_VERSION_FULL | $PERL -pe 's/(^\d*).*/$1/;'`
  1007. if test "$GCC_VERSION_MAJOR" -lt "4" ; then
  1008. AC_MSG_ERROR([You need to upgrade the compiler version to 4.x])
  1009. else
  1010. CFLAGS="$CFLAGS -isysroot ${MACOS_SDK_DIR}"
  1011. CXXFLAGS="$CXXFLAGS -isysroot ${MACOS_SDK_DIR}"
  1012. dnl CPP/CXXCPP needs to be set for MOZ_CHECK_HEADER.
  1013. CPP="$CPP -isysroot ${MACOS_SDK_DIR}"
  1014. CXXCPP="$CXXCPP -isysroot ${MACOS_SDK_DIR}"
  1015. if test "$GCC_VERSION_FULL" = "4.0.0" ; then
  1016. dnl If gcc >= 4.0, we're guaranteed to be on Tiger, which has an ld
  1017. dnl that supports -syslibroot. Don't set NEXT_ROOT because it will
  1018. dnl be ignored and cause warnings when -syslibroot is specified.
  1019. dnl gcc 4.0.1 will pass -syslibroot to ld automatically based on
  1020. dnl the -isysroot it receives, so this is only needed with 4.0.0.
  1021. LDFLAGS="$LDFLAGS -Wl,-syslibroot,${MACOS_SDK_DIR}"
  1022. fi
  1023. fi
  1024. AC_LANG_SAVE
  1025. AC_MSG_CHECKING([for valid compiler/Mac OS X SDK combination])
  1026. AC_LANG_CPLUSPLUS
  1027. AC_TRY_COMPILE([#include <new>
  1028. int main() { return 0; }],
  1029. result=yes,
  1030. result=no)
  1031. AC_LANG_RESTORE
  1032. AC_MSG_RESULT($result)
  1033. if test "$result" = "no" ; then
  1034. AC_MSG_ERROR([The selected compiler and Mac OS X SDK are incompatible.])
  1035. fi
  1036. fi
  1037. fi # COMPILE_ENVIRONMENT
  1038. if test -n "$MAKE"; then
  1039. if test `echo $MAKE | grep -c make.py` != 1; then
  1040. NOT_PYMAKE=$MAKE
  1041. fi
  1042. fi
  1043. case "$host_os" in
  1044. mingw*)
  1045. MOZ_PATH_PROGS(GMAKE, $GMAKE $NOT_PYMAKE make gmake, :)
  1046. ;;
  1047. *)
  1048. MOZ_PATH_PROGS(GMAKE, $GMAKE $NOT_PYMAKE gmake make, :)
  1049. ;;
  1050. esac
  1051. if test "$GMAKE" = ":"; then
  1052. AC_MSG_ERROR([GNU make not found])
  1053. fi
  1054. AC_SUBST(GMAKE)
  1055. # MAKE will be set by client.mk, but still need this for standalone js builds
  1056. if test -z "$MAKE"; then
  1057. MAKE=$GMAKE
  1058. fi
  1059. if test "$COMPILE_ENVIRONMENT"; then
  1060. AC_PATH_XTRA
  1061. XCFLAGS="$X_CFLAGS"
  1062. fi # COMPILE_ENVIRONMENT
  1063. dnl ========================================================
  1064. dnl set the defaults first
  1065. dnl ========================================================
  1066. AS_BIN=$AS
  1067. AR_LIST='$(AR) t'
  1068. AR_EXTRACT='$(AR) x'
  1069. AR_DELETE='$(AR) d'
  1070. AS='$(CC)'
  1071. AS_DASH_C_FLAG='-c'
  1072. DLL_PREFIX=lib
  1073. LIB_PREFIX=lib
  1074. DLL_SUFFIX=.so
  1075. OBJ_SUFFIX=o
  1076. LIB_SUFFIX=a
  1077. ASM_SUFFIX=s
  1078. IMPORT_LIB_SUFFIX=
  1079. TARGET_MD_ARCH=unix
  1080. DIRENT_INO=d_ino
  1081. WIN_TOP_SRC=
  1082. MOZ_USER_DIR=".mozilla"
  1083. MOZ_JS_LIBS='-L$(libdir) -lmozjs'
  1084. MOZ_FIX_LINK_PATHS='-Wl,-rpath-link,$(LIBXUL_DIST)/bin -Wl,-rpath-link,$(prefix)/lib'
  1085. MOZ_COMPONENT_NSPR_LIBS='-L$(LIBXUL_DIST)/bin $(NSPR_LIBS)'
  1086. USE_DEPENDENT_LIBS=1
  1087. _PLATFORM_DEFAULT_TOOLKIT=cairo-gtk2
  1088. if test -n "$CROSS_COMPILE"; then
  1089. OS_TARGET="${target_os}"
  1090. OS_ARCH=`echo $target_os | sed -e 's|/|_|g'`
  1091. OS_RELEASE=
  1092. case "${target_os}" in
  1093. linux*) OS_ARCH=Linux OS_TARGET=Linux ;;
  1094. kfreebsd*-gnu) OS_ARCH=GNU_kFreeBSD OS_TARGET=GNU_kFreeBSD ;;
  1095. gnu*) OS_ARCH=GNU ;;
  1096. solaris*) OS_ARCH=SunOS OS_RELEASE=5 ;;
  1097. mingw*) OS_ARCH=WINNT OS_TARGET=WINNT ;;
  1098. darwin*) OS_ARCH=Darwin OS_TARGET=Darwin ;;
  1099. esac
  1100. case "${target}" in
  1101. *-android*|*-linuxandroid*) OS_ARCH=Linux OS_TARGET=Android ;;
  1102. esac
  1103. else
  1104. OS_TARGET=`uname -s`
  1105. OS_ARCH=`uname -s | sed -e 's|/|_|g'`
  1106. OS_RELEASE=`uname -r`
  1107. fi
  1108. # Before this used `uname -m` when not cross compiling
  1109. # but that breaks when you have a 64 bit kernel with a 32 bit userland.
  1110. OS_TEST="${target_cpu}"
  1111. HOST_OS_ARCH=`echo $host_os | sed -e 's|/|_|g'`
  1112. #######################################################################
  1113. # Master "Core Components" macros for getting the OS target #
  1114. #######################################################################
  1115. #
  1116. # If OS_TARGET is not specified, it defaults to $(OS_ARCH), i.e., no
  1117. # cross-compilation.
  1118. #
  1119. #
  1120. # Define and override various archtecture-specific variables, including
  1121. # HOST_OS_ARCH
  1122. # OS_ARCH
  1123. # OS_TEST
  1124. # OS_TARGET
  1125. # OS_RELEASE
  1126. # OS_MINOR_RELEASE
  1127. #
  1128. case "$HOST_OS_ARCH" in
  1129. mingw*)
  1130. HOST_OS_ARCH=WINNT
  1131. ;;
  1132. darwin*)
  1133. HOST_OS_ARCH=Darwin
  1134. ;;
  1135. linux*)
  1136. HOST_OS_ARCH=Linux
  1137. ;;
  1138. solaris*)
  1139. HOST_OS_ARCH=SunOS
  1140. SOLARIS_SUNPRO_CC=
  1141. SOLARIS_SUNPRO_CXX=
  1142. if test -z "$GNU_CC"; then
  1143. if test "`$CC -V 2>&1 | egrep -c 'Sun.*C '`" != "0"; then
  1144. SOLARIS_SUNPRO_CC=1
  1145. fi
  1146. fi
  1147. if test -z "$GNU_CXX"; then
  1148. if test "`$CXX -V 2>&1 | egrep -c 'Sun.*C\+\+ '`" != "0"; then
  1149. SOLARIS_SUNPRO_CXX=1
  1150. fi
  1151. fi
  1152. AC_SUBST(SOLARIS_SUNPRO_CC)
  1153. AC_SUBST(SOLARIS_SUNPRO_CXX)
  1154. ;;
  1155. BSD_386)
  1156. HOST_OS_ARCH=BSD
  1157. ;;
  1158. OS_2)
  1159. HOST_OS_ARCH=OS2
  1160. ;;
  1161. esac
  1162. case "$OS_ARCH" in
  1163. WINNT)
  1164. if test -z "$CROSS_COMPILE" ; then
  1165. OS_TEST=`uname -p`
  1166. fi
  1167. ;;
  1168. Windows_NT)
  1169. #
  1170. # If uname -s returns "Windows_NT", we assume that we are using
  1171. # the uname.exe in MKS toolkit.
  1172. #
  1173. # The -r option of MKS uname only returns the major version number.
  1174. # So we need to use its -v option to get the minor version number.
  1175. # Moreover, it doesn't have the -p option, so we need to use uname -m.
  1176. #
  1177. OS_ARCH=WINNT
  1178. OS_TARGET=WINNT
  1179. OS_MINOR_RELEASE=`uname -v`
  1180. if test "$OS_MINOR_RELEASE" = "00"; then
  1181. OS_MINOR_RELEASE=0
  1182. fi
  1183. OS_RELEASE="${OS_RELEASE}.${OS_MINOR_RELEASE}"
  1184. ;;
  1185. MINGW*_NT*)
  1186. #
  1187. # If uname -s returns MINGW32_NT-5.1, we assume that we are using
  1188. # the uname.exe in the MSYS tools.
  1189. #
  1190. OS_RELEASE=`expr $OS_ARCH : '.*NT-\(.*\)'`
  1191. OS_ARCH=WINNT
  1192. OS_TARGET=WINNT
  1193. ;;
  1194. AIX)
  1195. OS_RELEASE=`uname -v`.`uname -r`
  1196. OS_TEST=${target_cpu}
  1197. if test -z "$GNU_CC"; then
  1198. if test "`$CC -qversion 2>&1 | egrep -c 'IBM XL'`" != "0"; then
  1199. AIX_IBM_XLC=1
  1200. fi
  1201. fi
  1202. ;;
  1203. BSD_386)
  1204. OS_ARCH=BSD
  1205. ;;
  1206. OS_2)
  1207. OS_ARCH=OS2
  1208. OS_TARGET=OS2
  1209. OS_RELEASE=`uname -v`
  1210. ;;
  1211. Darwin)
  1212. case "${target_cpu}" in
  1213. powerpc*)
  1214. OS_TEST=ppc
  1215. ;;
  1216. i*86*)
  1217. OS_TEST=i386
  1218. ;;
  1219. x86_64)
  1220. OS_TEST=x86_64
  1221. ;;
  1222. *)
  1223. if test -z "$CROSS_COMPILE" ; then
  1224. OS_TEST=`uname -p`
  1225. fi
  1226. ;;
  1227. esac
  1228. ;;
  1229. esac
  1230. # Only set CPU_ARCH if we recognize the value of OS_TEST
  1231. case "$OS_TEST" in
  1232. *86 | i86pc)
  1233. CPU_ARCH=x86
  1234. ;;
  1235. powerpc64 | ppc64)
  1236. CPU_ARCH=ppc64
  1237. ;;
  1238. powerpc | ppc | rs6000)
  1239. CPU_ARCH=ppc
  1240. ;;
  1241. Alpha | alpha | ALPHA)
  1242. CPU_ARCH=Alpha
  1243. ;;
  1244. s390)
  1245. CPU_ARCH=s390
  1246. ;;
  1247. s390x)
  1248. CPU_ARCH=s390x
  1249. ;;
  1250. hppa* | parisc)
  1251. CPU_ARCH=hppa
  1252. ;;
  1253. sun4u | sparc*)
  1254. CPU_ARCH=sparc
  1255. ;;
  1256. x86_64 | ia64)
  1257. CPU_ARCH="$OS_TEST"
  1258. ;;
  1259. arm*)
  1260. CPU_ARCH=arm
  1261. ;;
  1262. mips|mipsel)
  1263. CPU_ARCH="mips"
  1264. ;;
  1265. esac
  1266. if test -z "$OS_TARGET"; then
  1267. OS_TARGET=$OS_ARCH
  1268. fi
  1269. OS_CONFIG="${OS_TARGET}${OS_RELEASE}"
  1270. dnl Set INTEL_ARCHITECTURE if we're compiling for x86-32 or x86-64.
  1271. dnl ===============================================================
  1272. INTEL_ARCHITECTURE=
  1273. case "$OS_TEST" in
  1274. x86_64|i?86)
  1275. INTEL_ARCHITECTURE=1
  1276. esac
  1277. dnl ========================================================
  1278. dnl = ARM toolchain tweaks
  1279. dnl ========================================================
  1280. dnl Defaults
  1281. case "${CPU_ARCH}-${OS_TARGET}" in
  1282. arm-Android)
  1283. MOZ_THUMB=yes
  1284. MOZ_ARCH=armv7-a
  1285. MOZ_FPU=vfp
  1286. MOZ_FLOAT_ABI=softfp
  1287. ;;
  1288. arm-Darwin)
  1289. MOZ_THUMB=yes
  1290. ;;
  1291. arm-*)
  1292. if test -n "$MOZ_PLATFORM_MAEMO"; then
  1293. MOZ_THUMB=no
  1294. MOZ_ARCH=armv7-a
  1295. MOZ_FLOAT_ABI=softfp
  1296. fi
  1297. if test "$MOZ_PLATFORM_MAEMO" = 6; then
  1298. MOZ_THUMB=yes
  1299. fi
  1300. ;;
  1301. esac
  1302. dnl Kept for compatibility with some buildbot mozconfig
  1303. MOZ_ARG_DISABLE_BOOL(thumb2, [], MOZ_THUMB=no, MOZ_THUMB=yes)
  1304. MOZ_ARG_WITH_STRING(thumb,
  1305. [ --with-thumb[[=yes|no|toolchain-default]]]
  1306. [ Use Thumb instruction set (-mthumb)],
  1307. if test -z "$GNU_CC"; then
  1308. AC_MSG_ERROR([--with-thumb is not supported on non-GNU toolchain-defaults])
  1309. fi
  1310. MOZ_THUMB=$withval)
  1311. MOZ_ARG_WITH_STRING(thumb-interwork,
  1312. [ --with-thumb-interwork[[=yes|no|toolchain-default]]
  1313. Use Thumb/ARM instuctions interwork (-mthumb-interwork)],
  1314. if test -z "$GNU_CC"; then
  1315. AC_MSG_ERROR([--with-thumb-interwork is not supported on non-GNU toolchain-defaults])
  1316. fi
  1317. MOZ_THUMB_INTERWORK=$withval)
  1318. MOZ_ARG_WITH_STRING(arch,
  1319. [ --with-arch=[[type|toolchain-default]]
  1320. Use specific CPU features (-march=type)],
  1321. if test -z "$GNU_CC"; then
  1322. AC_MSG_ERROR([--with-arch is not supported on non-GNU toolchain-defaults])
  1323. fi
  1324. MOZ_ARCH=$withval)
  1325. MOZ_ARG_WITH_STRING(fpu,
  1326. [ --with-fpu=[[type|toolchain-default]]
  1327. Use specific FPU type (-mfpu=type)],
  1328. if test -z "$GNU_CC"; then
  1329. AC_MSG_ERROR([--with-fpu is not supported on non-GNU toolchain-defaults])
  1330. fi
  1331. MOZ_FPU=$withval)
  1332. MOZ_ARG_WITH_STRING(float-abi,
  1333. [ --with-float-abi=[[type|toolchain-default]]
  1334. Use specific arm float ABI (-mfloat-abi=type)],
  1335. if test -z "$GNU_CC"; then
  1336. AC_MSG_ERROR([--with-float-abi is not supported on non-GNU toolchain-defaults])
  1337. fi
  1338. MOZ_FLOAT_ABI=$withval)
  1339. MOZ_ARG_WITH_STRING(soft-float,
  1340. [ --with-soft-float[[=yes|no|toolchain-default]]
  1341. Use soft float library (-msoft-float)],
  1342. if test -z "$GNU_CC"; then
  1343. AC_MSG_ERROR([--with-soft-float is not supported on non-GNU toolchain-defaults])
  1344. fi
  1345. MOZ_SOFT_FLOAT=$withval)
  1346. case "$MOZ_ARCH" in
  1347. toolchain-default|"")
  1348. arch_flag=""
  1349. ;;
  1350. *)
  1351. arch_flag="-march=$MOZ_ARCH"
  1352. ;;
  1353. esac
  1354. case "$MOZ_THUMB" in
  1355. yes)
  1356. MOZ_THUMB2=1
  1357. thumb_flag="-mthumb"
  1358. ;;
  1359. no)
  1360. MOZ_THUMB2=
  1361. thumb_flag="-marm"
  1362. ;;
  1363. *)
  1364. _SAVE_CFLAGS="$CFLAGS"
  1365. CFLAGS="$arch_flag"
  1366. AC_TRY_COMPILE([],[return sizeof(__thumb2__);],
  1367. MOZ_THUMB2=1,
  1368. MOZ_THUMB2=)
  1369. CFLAGS="$_SAVE_CFLAGS"
  1370. thumb_flag=""
  1371. ;;
  1372. esac
  1373. if test "$MOZ_THUMB2" = 1; then
  1374. AC_DEFINE(MOZ_THUMB2)
  1375. fi
  1376. case "$MOZ_THUMB_INTERWORK" in
  1377. yes)
  1378. thumb_interwork_flag="-mthumb-interwork"
  1379. ;;
  1380. no)
  1381. thumb_interwork_flag="-mno-thumb-interwork"
  1382. ;;
  1383. *) # toolchain-default
  1384. thumb_interwork_flag=""
  1385. ;;
  1386. esac
  1387. case "$MOZ_FPU" in
  1388. toolchain-default|"")
  1389. fpu_flag=""
  1390. ;;
  1391. *)
  1392. fpu_flag="-mfpu=$MOZ_FPU"
  1393. ;;
  1394. esac
  1395. case "$MOZ_FLOAT_ABI" in
  1396. toolchain-default|"")
  1397. float_abi_flag=""
  1398. ;;
  1399. *)
  1400. float_abi_flag="-mfloat-abi=$MOZ_FLOAT_ABI"
  1401. ;;
  1402. esac
  1403. case "$MOZ_SOFT_FLOAT" in
  1404. yes)
  1405. soft_float_flag="-msoft-float"
  1406. ;;
  1407. no)
  1408. soft_float_flag="-mno-soft-float"
  1409. ;;
  1410. *) # toolchain-default
  1411. soft_float_flag=""
  1412. ;;
  1413. esac
  1414. dnl Use echo to avoid accumulating space characters
  1415. all_flags=`echo $arch_flag $thumb_flag $thumb_interwork_flag $fpu_flag $float_abi_flag $soft_float_flag`
  1416. if test -n "$all_flags"; then
  1417. _SAVE_CFLAGS="$CFLAGS"
  1418. CFLAGS="$all_flags"
  1419. AC_MSG_CHECKING(whether the chosen combination of compiler flags ($all_flags) works)
  1420. AC_TRY_COMPILE([],[return 0;],
  1421. AC_MSG_RESULT([yes]),
  1422. AC_MSG_ERROR([no]))
  1423. CFLAGS="$_SAVE_CFLAGS $all_flags"
  1424. CXXFLAGS="$CXXFLAGS $all_flags"
  1425. ASFLAGS="$ASFLAGS $all_flags"
  1426. if test -n "$thumb_flag"; then
  1427. LDFLAGS="$LDFLAGS $thumb_flag"
  1428. fi
  1429. fi
  1430. AC_SUBST(MOZ_THUMB2)
  1431. if test "$CPU_ARCH" = "arm"; then
  1432. AC_MSG_CHECKING(for ARM SIMD support in compiler)
  1433. # We try to link so that this also fails when
  1434. # building with LTO.
  1435. AC_TRY_LINK([],
  1436. [asm("uqadd8 r1, r1, r2");],
  1437. result="yes", result="no")
  1438. AC_MSG_RESULT("$result")
  1439. if test "$result" = "yes"; then
  1440. AC_DEFINE(HAVE_ARM_SIMD)
  1441. HAVE_ARM_SIMD=1
  1442. fi
  1443. AC_MSG_CHECKING(for ARM NEON support in compiler)
  1444. # We try to link so that this also fails when
  1445. # building with LTO.
  1446. AC_TRY_LINK([],
  1447. [asm(".fpu neon\n vadd.i8 d0, d0, d0");],
  1448. result="yes", result="no")
  1449. AC_MSG_RESULT("$result")
  1450. if test "$result" = "yes"; then
  1451. AC_DEFINE(HAVE_ARM_NEON)
  1452. HAVE_ARM_NEON=1
  1453. fi
  1454. fi # CPU_ARCH = arm
  1455. AC_SUBST(HAVE_ARM_SIMD)
  1456. AC_SUBST(HAVE_ARM_NEON)
  1457. dnl =================================================================
  1458. dnl Set up and test static assertion macros used to avoid AC_TRY_RUN,
  1459. dnl which is bad when cross compiling.
  1460. dnl =================================================================
  1461. if test "$COMPILE_ENVIRONMENT"; then
  1462. configure_static_assert_macros='
  1463. #define CONFIGURE_STATIC_ASSERT(condition) CONFIGURE_STATIC_ASSERT_IMPL(condition, __LINE__)
  1464. #define CONFIGURE_STATIC_ASSERT_IMPL(condition, line) CONFIGURE_STATIC_ASSERT_IMPL2(condition, line)
  1465. #define CONFIGURE_STATIC_ASSERT_IMPL2(condition, line) typedef int static_assert_line_##line[(condition) ? 1 : -1]
  1466. '
  1467. dnl test that the macros actually work:
  1468. AC_MSG_CHECKING(that static assertion macros used in autoconf tests work)
  1469. AC_CACHE_VAL(ac_cv_static_assertion_macros_work,
  1470. [AC_LANG_SAVE
  1471. AC_LANG_C
  1472. ac_cv_static_assertion_macros_work="yes"
  1473. AC_TRY_COMPILE([$configure_static_assert_macros],
  1474. [CONFIGURE_STATIC_ASSERT(1)],
  1475. ,
  1476. ac_cv_static_assertion_macros_work="no")
  1477. AC_TRY_COMPILE([$configure_static_assert_macros],
  1478. [CONFIGURE_STATIC_ASSERT(0)],
  1479. ac_cv_static_assertion_macros_work="no",
  1480. )
  1481. AC_LANG_CPLUSPLUS
  1482. AC_TRY_COMPILE([$configure_static_assert_macros],
  1483. [CONFIGURE_STATIC_ASSERT(1)],
  1484. ,
  1485. ac_cv_static_assertion_macros_work="no")
  1486. AC_TRY_COMPILE([$configure_static_assert_macros],
  1487. [CONFIGURE_STATIC_ASSERT(0)],
  1488. ac_cv_static_assertion_macros_work="no",
  1489. )
  1490. AC_LANG_RESTORE
  1491. ])
  1492. AC_MSG_RESULT("$ac_cv_static_assertion_macros_work")
  1493. if test "$ac_cv_static_assertion_macros_work" = "no"; then
  1494. AC_MSG_ERROR([Compiler cannot compile macros used in autoconf tests.])
  1495. fi
  1496. fi # COMPILE_ENVIRONMENT
  1497. dnl ========================================================
  1498. dnl Android libstdc++, placed here so it can use MOZ_ARCH
  1499. dnl computed above.
  1500. dnl ========================================================
  1501. if test "$OS_TARGET" = "Android"; then
  1502. case "${CPU_ARCH}-${MOZ_ARCH}" in
  1503. arm-armv7*)
  1504. ANDROID_CPU_ARCH=armeabi-v7a
  1505. ;;
  1506. arm-*)
  1507. ANDROID_CPU_ARCH=armeabi
  1508. ;;
  1509. x86-*)
  1510. ANDROID_CPU_ARCH=x86
  1511. ;;
  1512. esac
  1513. if test -n "$MOZ_ANDROID_LIBSTDCXX" ; then
  1514. if test ! -e "$android_ndk/sources/cxx-stl/gnu-libstdc++/libs/$ANDROID_CPU_ARCH/libstdc++.a" ; then
  1515. AC_MSG_ERROR([Cannot find path to libstdc++ (NDK version >= 5?)])
  1516. fi
  1517. STLPORT_CPPFLAGS="-I$android_ndk/sources/cxx-stl/gnu-libstdc++/include -I$android_ndk/sources/cxx-stl/gnu-libstdc++/libs/$ANDROID_CPU_ARCH/include -D_GLIBCXX_PERMIT_BACKWARD_HASH"
  1518. STLPORT_LDFLAGS="-L$android_ndk/sources/cxx-stl/gnu-libstdc++/libs/$ANDROID_CPU_ARCH"
  1519. STLPORT_LIBS="-lstdc++"
  1520. elif test -e "$android_ndk/sources/cxx-stl/stlport/libs/$ANDROID_CPU_ARCH/libstlport_static.a" ; then
  1521. STLPORT_CPPFLAGS="-I$android_ndk/sources/cxx-stl/stlport/stlport"
  1522. STLPORT_LDFLAGS="-L$android_ndk/sources/cxx-stl/stlport/libs/$ANDROID_CPU_ARCH/"
  1523. STLPORT_LIBS="-lstlport_static"
  1524. elif test -e "$android_ndk/tmp/ndk-digit/build/install/sources/cxx-stl/stlport/libs/$ANDROID_CPU_ARCH/libstlport_static.a" ; then
  1525. STLPORT_CPPFLAGS="-I$android_ndk/sources/cxx-stl/stlport/stlport"
  1526. STLPORT_LDFLAGS="-L$android_ndk/tmp/ndk-digit/build/install/sources/cxx-stl/stlport/libs/$ANDROID_CPU_ARCH"
  1527. STLPORT_LIBS="-lstlport_static"
  1528. elif test "$target" != "arm-android-eabi"; then
  1529. dnl fail if we're not building with NDKr4
  1530. AC_MSG_ERROR([Couldn't find path to stlport in the android ndk])
  1531. fi
  1532. CPPFLAGS="$CPPFLAGS $STLPORT_CPPFLAGS"
  1533. LDFLAGS="$LDFLAGS $STLPORT_LDFLAGS"
  1534. LIBS="$LIBS $STLPORT_LIBS"
  1535. # save these for libffi's subconfigure,
  1536. # which doesn't know how to figure this stuff out on its own
  1537. ANDROID_CFLAGS="$CFLAGS"
  1538. ANDROID_CPPFLAGS="$CPPFLAGS"
  1539. ANDROID_LDFLAGS="$LDFLAGS"
  1540. fi
  1541. dnl ========================================================
  1542. dnl Suppress Clang Argument Warnings
  1543. dnl ========================================================
  1544. if test -n "$CLANG_CC"; then
  1545. _WARNINGS_CFLAGS="-Qunused-arguments ${_WARNINGS_CFLAGS}"
  1546. CPPFLAGS="-Qunused-arguments ${CPPFLAGS}"
  1547. fi
  1548. if test -n "$CLANG_CXX"; then
  1549. _WARNINGS_CXXFLAGS="-Qunused-arguments ${_WARNINGS_CXXFLAGS}"
  1550. fi
  1551. dnl ========================================================
  1552. dnl GNU specific defaults
  1553. dnl ========================================================
  1554. if test "$GNU_CC"; then
  1555. MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$@ -o $@'
  1556. MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$@ -o $@'
  1557. DSO_LDOPTS='-shared'
  1558. if test "$GCC_USE_GNU_LD"; then
  1559. # Don't allow undefined symbols in libraries
  1560. DSO_LDOPTS="$DSO_LDOPTS -Wl,-z,defs"
  1561. fi
  1562. WARNINGS_AS_ERRORS='-Werror -Wno-error=uninitialized'
  1563. DSO_CFLAGS=''
  1564. DSO_PIC_CFLAGS='-fPIC'
  1565. ASFLAGS="$ASFLAGS -fPIC"
  1566. _MOZ_RTTI_FLAGS_ON=-frtti
  1567. _MOZ_RTTI_FLAGS_OFF=-fno-rtti
  1568. # Turn on GNU specific features
  1569. # -Wall - turn on all warnings
  1570. # -pedantic - make compiler warn about non-ANSI stuff, and
  1571. # be a little bit stricter
  1572. # Warnings slamm took out for now (these were giving more noise than help):
  1573. # -Wbad-function-cast - warns when casting a function to a new return type
  1574. # -Wshadow - removed because it generates more noise than help --pete
  1575. _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wall -W -Wno-unused -Wpointer-arith"
  1576. if test -z "$INTEL_CC" -a -z "$CLANG_CC"; then
  1577. # Don't use -Wcast-align with ICC or clang
  1578. case "$CPU_ARCH" in
  1579. # And don't use it on hppa, ia64, sparc, arm, since it's noisy there
  1580. hppa | ia64 | sparc | arm)
  1581. ;;
  1582. *)
  1583. _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wcast-align"
  1584. ;;
  1585. esac
  1586. fi
  1587. dnl Turn pedantic on but disable the warnings for long long
  1588. _PEDANTIC=1
  1589. if test -z "$INTEL_CC"; then
  1590. _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -W"
  1591. fi
  1592. _DEFINES_CFLAGS='-include $(DEPTH)/js-confdefs.h -DMOZILLA_CLIENT'
  1593. _USE_CPP_INCLUDE_FLAG=1
  1594. elif test "$SOLARIS_SUNPRO_CC"; then
  1595. DSO_CFLAGS=''
  1596. if test "$CPU_ARCH" = "sparc"; then
  1597. # for Sun Studio on Solaris/SPARC
  1598. DSO_PIC_CFLAGS='-xcode=pic32'
  1599. else
  1600. DSO_PIC_CFLAGS='-KPIC'
  1601. fi
  1602. _DEFINES_CFLAGS='$(ACDEFINES) -D_JS_CONFDEFS_H_ -DMOZILLA_CLIENT'
  1603. else
  1604. MKSHLIB='$(LD) $(DSO_LDOPTS) -h $@ -o $@'
  1605. MKCSHLIB='$(LD) $(DSO_LDOPTS) -h $@ -o $@'
  1606. DSO_LDOPTS='-shared'
  1607. if test "$GNU_LD"; then
  1608. # Don't allow undefined symbols in libraries
  1609. DSO_LDOPTS="$DSO_LDOPTS -z defs"
  1610. fi
  1611. DSO_CFLAGS=''
  1612. DSO_PIC_CFLAGS='-KPIC'
  1613. _DEFINES_CFLAGS='$(ACDEFINES) -D_JS_CONFDEFS_H_ -DMOZILLA_CLIENT'
  1614. fi
  1615. if test "$GNU_CXX"; then
  1616. # Turn on GNU specific features
  1617. _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wall -Wpointer-arith -Woverloaded-virtual -Wsynth -Wno-ctor-dtor-privacy -Wno-non-virtual-dtor"
  1618. if test -z "$INTEL_CXX" -a -z "$CLANG_CXX"; then
  1619. # Don't use -Wcast-align with ICC or clang
  1620. case "$CPU_ARCH" in
  1621. # And don't use it on hppa, ia64, sparc, arm, since it's noisy there
  1622. hppa | ia64 | sparc | arm)
  1623. ;;
  1624. *)
  1625. _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wcast-align"
  1626. ;;
  1627. esac
  1628. fi
  1629. _DEFINES_CXXFLAGS='-DMOZILLA_CLIENT -include $(DEPTH)/js-confdefs.h'
  1630. _USE_CPP_INCLUDE_FLAG=1
  1631. # Recent clang and gcc support C++11 deleted functions without warnings if
  1632. # compiling with -std=c++0x or -std=gnu++0x (or c++11 or gnu++11 in very new
  1633. # versions). We can't use -std=c++0x yet, so gcc's support must remain
  1634. # unused. But clang's warning can be disabled, so when compiling with clang
  1635. # we use it to opt out of the warning, enabling (macro-encapsulated) use of
  1636. # deleted function syntax.
  1637. if test "$CLANG_CXX"; then
  1638. _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wno-c++0x-extensions"
  1639. fi
  1640. AC_CACHE_CHECK(whether the compiler supports -Wno-extended-offsetof,
  1641. ac_has_wno_extended_offsetof,
  1642. [
  1643. AC_LANG_SAVE
  1644. AC_LANG_CPLUSPLUS
  1645. _SAVE_CXXFLAGS="$CXXFLAGS"
  1646. CXXFLAGS="$CXXFLAGS -Wno-extended-offsetof"
  1647. AC_TRY_COMPILE([$configure_static_assert_macros
  1648. #ifndef __has_warning
  1649. #define __has_warning(x) 0
  1650. #endif],
  1651. [CONFIGURE_STATIC_ASSERT(__has_warning("-Wextended-offsetof"))],
  1652. ac_has_wno_extended_offsetof="yes",
  1653. ac_has_wno_extended_offsetof="no")
  1654. CXXFLAGS="$_SAVE_CXXFLAGS"
  1655. AC_LANG_RESTORE
  1656. ])
  1657. if test "$ac_has_wno_extended_offsetof" = "yes"; then
  1658. _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wno-extended-offsetof"
  1659. fi
  1660. AC_CACHE_CHECK(whether the compiler supports -Wno-invalid-offsetof,
  1661. ac_has_wno_invalid_offsetof,
  1662. [
  1663. AC_LANG_SAVE
  1664. AC_LANG_CPLUSPLUS
  1665. _SAVE_CXXFLAGS="$CXXFLAGS"
  1666. CXXFLAGS="$CXXFLAGS -Wno-invalid-offsetof"
  1667. AC_TRY_COMPILE([],
  1668. [return(0);],
  1669. ac_has_wno_invalid_offsetof="yes",
  1670. ac_has_wno_invalid_offsetof="no")
  1671. CXXFLAGS="$_SAVE_CXXFLAGS"
  1672. AC_LANG_RESTORE
  1673. ])
  1674. if test "$ac_has_wno_invalid_offsetof" = "yes"; then
  1675. _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wno-invalid-offsetof"
  1676. fi
  1677. AC_CACHE_CHECK(whether the compiler supports -Wno-variadic-macros,
  1678. ac_has_wno_variadic_macros,
  1679. [
  1680. AC_LANG_SAVE
  1681. AC_LANG_CPLUSPLUS
  1682. _SAVE_CXXFLAGS="$CXXFLAGS"
  1683. CXXFLAGS="$CXXFLAGS -Wno-variadic-macros"
  1684. AC_TRY_COMPILE([],
  1685. [return(0);],
  1686. ac_has_wno_variadic_macros="yes",
  1687. ac_has_wno_variadic_macros="no")
  1688. CXXFLAGS="$_SAVE_CXXFLAGS"
  1689. AC_LANG_RESTORE
  1690. ])
  1691. if test "$ac_has_wno_variadic_macros" = "yes"; then
  1692. _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wno-variadic-macros"
  1693. fi
  1694. AC_CACHE_CHECK(whether the compiler supports -Werror=return-type,
  1695. ac_has_werror_return_type,
  1696. [
  1697. AC_LANG_SAVE
  1698. AC_LANG_CPLUSPLUS
  1699. _SAVE_CXXFLAGS="$CXXFLAGS"
  1700. CXXFLAGS="$CXXFLAGS -Werror=return-type"
  1701. AC_TRY_COMPILE([],
  1702. [return(0);],
  1703. ac_has_werror_return_type="yes",
  1704. ac_has_werror_return_type="no")
  1705. CXXFLAGS="$_SAVE_CXXFLAGS"
  1706. AC_LANG_RESTORE
  1707. ])
  1708. if test "$ac_has_werror_return_type" = "yes"; then
  1709. _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=return-type"
  1710. fi
  1711. else
  1712. _DEFINES_CXXFLAGS='-DMOZILLA_CLIENT -D_JS_CONFDEFS_H_ $(ACDEFINES)'
  1713. fi
  1714. dnl gcc can come with its own linker so it is better to use the pass-thru calls
  1715. dnl MKSHLIB_FORCE_ALL is used to force the linker to include all object
  1716. dnl files present in an archive. MKSHLIB_UNFORCE_ALL reverts the linker to
  1717. dnl normal behavior.
  1718. dnl ========================================================
  1719. MKSHLIB_FORCE_ALL=
  1720. MKSHLIB_UNFORCE_ALL=
  1721. if test "$COMPILE_ENVIRONMENT"; then
  1722. if test "$GNU_CC"; then
  1723. AC_MSG_CHECKING(whether ld has archive extraction flags)
  1724. AC_CACHE_VAL(ac_cv_mkshlib_force_and_unforce,
  1725. [_SAVE_LDFLAGS=$LDFLAGS; _SAVE_LIBS=$LIBS
  1726. ac_cv_mkshlib_force_and_unforce="no"
  1727. exec 3<&0 <<LOOP_INPUT
  1728. force="-Wl,--whole-archive"; unforce="-Wl,--no-whole-archive"
  1729. force="-Wl,-z -Wl,allextract"; unforce="-Wl,-z -Wl,defaultextract"
  1730. force="-Wl,-all"; unforce="-Wl,-none"
  1731. LOOP_INPUT
  1732. while read line
  1733. do
  1734. eval $line
  1735. LDFLAGS=$force
  1736. LIBS=$unforce
  1737. AC_TRY_LINK(,, ac_cv_mkshlib_force_and_unforce=$line; break)
  1738. done
  1739. exec 0<&3 3<&-
  1740. LDFLAGS=$_SAVE_LDFLAGS; LIBS=$_SAVE_LIBS
  1741. ])
  1742. if test "$ac_cv_mkshlib_force_and_unforce" = "no"; then
  1743. AC_MSG_RESULT(no)
  1744. else
  1745. AC_MSG_RESULT(yes)
  1746. eval $ac_cv_mkshlib_force_and_unforce
  1747. MKSHLIB_FORCE_ALL=$force
  1748. MKSHLIB_UNFORCE_ALL=$unforce
  1749. fi
  1750. fi # GNU_CC
  1751. fi # COMPILE_ENVIRONMENT
  1752. dnl ========================================================
  1753. dnl Checking for 64-bit OS
  1754. dnl ========================================================
  1755. if test "$COMPILE_ENVIRONMENT"; then
  1756. AC_LANG_SAVE
  1757. AC_LANG_C
  1758. AC_MSG_CHECKING(for 64-bit OS)
  1759. AC_TRY_COMPILE([$configure_static_assert_macros],
  1760. [CONFIGURE_STATIC_ASSERT(sizeof(void*) == 8)],
  1761. result="yes", result="no")
  1762. AC_MSG_RESULT("$result")
  1763. if test "$result" = "yes"; then
  1764. AC_DEFINE(HAVE_64BIT_OS)
  1765. HAVE_64BIT_OS=1
  1766. fi
  1767. AC_SUBST(HAVE_64BIT_OS)
  1768. AC_LANG_RESTORE
  1769. fi # COMPILE_ENVIRONMENT
  1770. dnl ========================================================
  1771. dnl Enable high-memory support on OS/2 by default.
  1772. dnl ========================================================
  1773. MOZ_OS2_HIGH_MEMORY=1
  1774. MOZ_ARG_DISABLE_BOOL(os2-high-mem,
  1775. [ --disable-os2-high-mem Disable high-memory support on OS/2],
  1776. MOZ_OS2_HIGH_MEMORY=,
  1777. MOZ_OS2_HIGH_MEMORY=1 )
  1778. AC_SUBST(MOZ_OS2_HIGH_MEMORY)
  1779. dnl ========================================================
  1780. dnl = Use profiling compile flags
  1781. dnl ========================================================
  1782. MOZ_ARG_ENABLE_BOOL(profiling,
  1783. [ --enable-profiling Set compile flags necessary for using sampling profilers (e.g. shark, perf)],
  1784. MOZ_PROFILING=1,
  1785. MOZ_PROFILING= )
  1786. dnl ========================================================
  1787. dnl System overrides of the defaults for host
  1788. dnl ========================================================
  1789. case "$host" in
  1790. *mingw*)
  1791. # we need Python 2.5 on Windows
  1792. PYTHON_VERSION=2.5
  1793. if test -n "$_WIN32_MSVC"; then
  1794. HOST_AR=lib
  1795. HOST_AR_FLAGS='-NOLOGO -OUT:"$@"'
  1796. HOST_CFLAGS="$HOST_CFLAGS -TC -nologo -Fd\$(HOST_PDBFILE)"
  1797. HOST_RANLIB='echo ranlib'
  1798. else
  1799. HOST_CFLAGS="$HOST_CFLAGS -mwindows"
  1800. fi
  1801. HOST_CFLAGS="$HOST_CFLAGS -DXP_WIN32 -DXP_WIN -DWIN32 -D_WIN32 -DNO_X11 -D_CRT_SECURE_NO_WARNINGS"
  1802. HOST_NSPR_MDCPUCFG='\"md/_winnt.cfg\"'
  1803. HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
  1804. HOST_BIN_SUFFIX=.exe
  1805. case "$host" in
  1806. *mingw*)
  1807. PERL="/bin/sh ${_topsrcdir}/build/msys-perl-wrapper"
  1808. ;;
  1809. esac
  1810. case "${host_cpu}" in
  1811. x86_64)
  1812. HOST_CFLAGS="$HOST_CFLAGS -D_AMD64_"
  1813. ;;
  1814. esac
  1815. ;;
  1816. *-darwin*)
  1817. HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX -DXP_MACOSX -DNO_X11"
  1818. HOST_NSPR_MDCPUCFG='\"md/_darwin.cfg\"'
  1819. HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
  1820. ;;
  1821. *-linux*|*-kfreebsd*-gnu|*-gnu*)
  1822. HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
  1823. HOST_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
  1824. HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
  1825. ;;
  1826. *os2*)
  1827. HOST_CFLAGS="$HOST_CFLAGS -DXP_OS2 -DNO_X11 -Zomf"
  1828. HOST_NSPR_MDCPUCFG='\"md/_os2.cfg\"'
  1829. HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
  1830. HOST_BIN_SUFFIX=.exe
  1831. MOZ_FIX_LINK_PATHS=
  1832. ;;
  1833. *)
  1834. HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
  1835. HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
  1836. ;;
  1837. esac
  1838. dnl We require version 2.4 or newer of Python to build,
  1839. dnl and 2.5 or newer on Windows.
  1840. AC_MSG_CHECKING([for Python version >= $PYTHON_VERSION but not 3.x])
  1841. changequote(,)
  1842. $PYTHON -c "import sys; sys.exit(sys.version[:3] < sys.argv[1] or sys.version[:2] != '2.')" $PYTHON_VERSION
  1843. _python_res=$?
  1844. changequote([,])
  1845. if test "$_python_res" != 0; then
  1846. AC_MSG_ERROR([Python $PYTHON_VERSION or higher (but not Python 3.x) is required.])
  1847. fi
  1848. AC_MSG_RESULT([yes])
  1849. dnl Check for using a custom <stdint.h> implementation
  1850. dnl ========================================================
  1851. AC_MSG_CHECKING(for custom <stdint.h> implementation)
  1852. if test "$MOZ_CUSTOM_STDINT_H"; then
  1853. AC_DEFINE_UNQUOTED(MOZ_CUSTOM_STDINT_H, "$MOZ_CUSTOM_STDINT_H")
  1854. AC_SUBST(MOZ_CUSTOM_STDINT_H)
  1855. AC_MSG_RESULT(using $MOZ_CUSTOM_STDINT_H)
  1856. else
  1857. AC_MSG_RESULT(none specified)
  1858. fi
  1859. MOZ_DOING_LTO(lto_is_enabled)
  1860. dnl ========================================================
  1861. dnl System overrides of the defaults for target
  1862. dnl ========================================================
  1863. case "$target" in
  1864. *-aix*)
  1865. AC_DEFINE(AIX)
  1866. if test ! "$GNU_CC"; then
  1867. if test ! "$HAVE_64BIT_OS"; then
  1868. # Compiling with Visual Age C++ object model compat is the
  1869. # default. To compile with object model ibm, add
  1870. # AIX_OBJMODEL=ibm to .mozconfig.
  1871. if test "$AIX_OBJMODEL" = "ibm"; then
  1872. CXXFLAGS="$CXXFLAGS -qobjmodel=ibm"
  1873. else
  1874. AIX_OBJMODEL=compat
  1875. fi
  1876. else
  1877. AIX_OBJMODEL=compat
  1878. fi
  1879. AC_SUBST(AIX_OBJMODEL)
  1880. DSO_LDOPTS='-qmkshrobj=1'
  1881. DSO_CFLAGS='-qflag=w:w'
  1882. DSO_PIC_CFLAGS=
  1883. LDFLAGS="$LDFLAGS -Wl,-brtl -blibpath:/usr/lib:/lib"
  1884. MOZ_FIX_LINK_PATHS=
  1885. MKSHLIB='$(CXX) $(DSO_LDOPTS) -o $@'
  1886. MKCSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
  1887. if test "$COMPILE_ENVIRONMENT"; then
  1888. AC_LANG_SAVE
  1889. AC_LANG_CPLUSPLUS
  1890. AC_MSG_CHECKING([for IBM XLC/C++ compiler version >= 9.0.0.7])
  1891. AC_TRY_COMPILE([],
  1892. [#if (__IBMCPP__ < 900)
  1893. #error "Bad compiler"
  1894. #endif],
  1895. _BAD_COMPILER=,_BAD_COMPILER=1)
  1896. if test -n "$_BAD_COMPILER"; then
  1897. AC_MSG_RESULT([no])
  1898. AC_MSG_ERROR([IBM XLC/C++ 9.0.0.7 or higher is required to build.])
  1899. else
  1900. AC_MSG_RESULT([yes])
  1901. fi
  1902. AC_LANG_RESTORE
  1903. TARGET_COMPILER_ABI="ibmc"
  1904. CC_VERSION=`lslpp -Lcq vac.C 2>/dev/null | awk -F: '{ print $3 }'`
  1905. CXX_VERSION=`lslpp -Lcq vacpp.cmp.core 2>/dev/null | awk -F: '{ print $3 }'`
  1906. fi
  1907. fi
  1908. case "${target_os}" in
  1909. aix4.1*)
  1910. DLL_SUFFIX='_shr.a'
  1911. ;;
  1912. esac
  1913. if test "$COMPILE_ENVIRONMENT"; then
  1914. MOZ_CHECK_HEADERS(sys/inttypes.h)
  1915. fi
  1916. AC_DEFINE(JS_SYS_TYPES_H_DEFINES_EXACT_SIZE_TYPES)
  1917. AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
  1918. ;;
  1919. *-bsdi*)
  1920. dnl -pedantic doesn't play well with BSDI's _very_ modified gcc (shlicc2)
  1921. _PEDANTIC=
  1922. case $OS_RELEASE in
  1923. 4.*|5.*)
  1924. STRIP="$STRIP -d"
  1925. ;;
  1926. *)
  1927. DSO_CFLAGS=''
  1928. DSO_LDOPTS='-r'
  1929. _WARNINGS_CFLAGS="-Wall"
  1930. _WARNINGS_CXXFLAGS="-Wall"
  1931. # The test above doesn't work properly, at least on 3.1.
  1932. MKSHLIB_FORCE_ALL=''
  1933. MKSHLIB_UNFORCE_ALL=''
  1934. ;;
  1935. esac
  1936. ;;
  1937. *-darwin*)
  1938. MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
  1939. MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
  1940. MOZ_OPTIMIZE_FLAGS="-O3 -fno-stack-protector"
  1941. _PEDANTIC=
  1942. CFLAGS="$CFLAGS -fno-common"
  1943. CXXFLAGS="$CXXFLAGS -fno-common"
  1944. DLL_SUFFIX=".dylib"
  1945. DSO_LDOPTS=''
  1946. STRIP="$STRIP -x -S"
  1947. _PLATFORM_DEFAULT_TOOLKIT='cairo-cocoa'
  1948. TARGET_NSPR_MDCPUCFG='\"md/_darwin.cfg\"'
  1949. LDFLAGS="$LDFLAGS -lobjc"
  1950. LIBXUL_LIBS='$(XPCOM_FROZEN_LDOPTS) $(LIBXUL_DIST)/bin/XUL'
  1951. # The ExceptionHandling framework is needed for Objective-C exception
  1952. # logging code in nsObjCExceptions.h. Currently we only use that in debug
  1953. # builds.
  1954. _SAVE_LDFLAGS=$LDFLAGS
  1955. AC_MSG_CHECKING([for -framework ExceptionHandling])
  1956. LDFLAGS="$LDFLAGS -framework ExceptionHandling"
  1957. AC_TRY_LINK(,[return 0;],
  1958. ac_cv_have_framework_exceptionhandling="yes",
  1959. ac_cv_have_framework_exceptionhandling="no")
  1960. AC_MSG_RESULT([$ac_cv_have_framework_exceptionhandling])
  1961. if test "$ac_cv_have_framework_exceptionhandling" = "yes"; then
  1962. MOZ_DEBUG_LDFLAGS="$MOZ_DEBUG_LDFLAGS -framework ExceptionHandling";
  1963. fi
  1964. LDFLAGS=$_SAVE_LDFLAGS
  1965. if test "x$lto_is_enabled" = "xyes"; then
  1966. echo "Skipping -dead_strip because lto is enabled."
  1967. dnl DTrace and -dead_strip don't interact well. See bug 403132.
  1968. dnl ===================================================================
  1969. elif test "x$enable_dtrace" = "xyes"; then
  1970. echo "Skipping -dead_strip because DTrace is enabled. See bug 403132."
  1971. else
  1972. dnl check for the presence of the -dead_strip linker flag
  1973. AC_MSG_CHECKING([for -dead_strip option to ld])
  1974. _SAVE_LDFLAGS=$LDFLAGS
  1975. LDFLAGS="$LDFLAGS -Wl,-dead_strip"
  1976. AC_TRY_LINK(,[return 0;],_HAVE_DEAD_STRIP=1,_HAVE_DEAD_STRIP=)
  1977. if test -n "$_HAVE_DEAD_STRIP" ; then
  1978. AC_MSG_RESULT([yes])
  1979. MOZ_OPTIMIZE_LDFLAGS="-Wl,-dead_strip"
  1980. else
  1981. AC_MSG_RESULT([no])
  1982. fi
  1983. LDFLAGS=$_SAVE_LDFLAGS
  1984. fi
  1985. MOZ_FIX_LINK_PATHS='-Wl,-executable_path,$(LIBXUL_DIST)/bin'
  1986. ;;
  1987. *-freebsd*)
  1988. if test `test -x /usr/bin/objformat && /usr/bin/objformat || echo elf` != "elf"; then
  1989. DLL_SUFFIX=".so.1.0"
  1990. DSO_LDOPTS="-shared"
  1991. fi
  1992. if test ! "$GNU_CC"; then
  1993. DSO_LDOPTS="-Bshareable $DSO_LDOPTS"
  1994. fi
  1995. ;;
  1996. ia64*-hpux*)
  1997. DLL_SUFFIX=".so"
  1998. if test ! "$GNU_CC"; then
  1999. DSO_LDOPTS='-b'
  2000. DSO_CFLAGS=""
  2001. DSO_PIC_CFLAGS=
  2002. MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_LDOPTS) -o $@'
  2003. MKCSHLIB='$(CC) $(CFLAGS) $(DSO_LDOPTS) -o $@'
  2004. CXXFLAGS="$CXXFLAGS -Wc,-ansi_for_scope,on"
  2005. else
  2006. DSO_LDOPTS='-b -E'
  2007. MKSHLIB='$(LD) $(DSO_LDOPTS) -o $@'
  2008. MKCSHLIB='$(LD) $(DSO_LDOPTS) -o $@'
  2009. fi
  2010. MOZ_FIX_LINK_PATHS=
  2011. SYSTEM_MAKEDEPEND=
  2012. AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
  2013. AC_DEFINE(_LARGEFILE64_SOURCE)
  2014. ;;
  2015. *-hpux*)
  2016. DLL_SUFFIX=".sl"
  2017. if test ! "$GNU_CC"; then
  2018. DSO_LDOPTS='-b -Wl,+s'
  2019. DSO_CFLAGS=""
  2020. DSO_PIC_CFLAGS="+Z"
  2021. MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_LDOPTS) -L$(LIBXUL_DIST)/bin -o $@'
  2022. MKCSHLIB='$(LD) -b +s -L$(LIBXUL_DIST)/bin -o $@'
  2023. CXXFLAGS="$CXXFLAGS -Wc,-ansi_for_scope,on"
  2024. else
  2025. DSO_LDOPTS='-b -E +s'
  2026. MKSHLIB='$(LD) $(DSO_LDOPTS) -L$(LIBXUL_DIST)/bin -L$(LIBXUL_DIST)/lib -o $@'
  2027. MKCSHLIB='$(LD) $(DSO_LDOPTS) -L$(LIBXUL_DIST)/bin -L$(LIBXUL_DIST)/lib -o $@'
  2028. fi
  2029. MOZ_POST_PROGRAM_COMMAND='chatr +s enable'
  2030. AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
  2031. ;;
  2032. *-android*|*-linuxandroid*)
  2033. AC_DEFINE(NO_PW_GECOS)
  2034. no_x=yes
  2035. _PLATFORM_DEFAULT_TOOLKIT=cairo-android
  2036. TARGET_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
  2037. MOZ_GFX_OPTIMIZE_MOBILE=1
  2038. MOZ_OPTIMIZE_FLAGS="-O3 -freorder-blocks -fno-reorder-functions"
  2039. # The Maemo builders don't know about this flag
  2040. MOZ_ARM_VFP_FLAGS="-mfpu=vfp"
  2041. ;;
  2042. *-*linux*)
  2043. # Note: both GNU_CC and INTEL_CC are set when using Intel's C compiler.
  2044. # Similarly for GNU_CXX and INTEL_CXX.
  2045. if test "$INTEL_CC" -o "$INTEL_CXX"; then
  2046. # -Os has been broken on Intel's C/C++ compilers for quite a
  2047. # while; Intel recommends against using it.
  2048. MOZ_OPTIMIZE_FLAGS="-O2"
  2049. MOZ_DEBUG_FLAGS="-g"
  2050. elif test "$GNU_CC" -o "$GNU_CXX"; then
  2051. GCC_VERSION=`$CC -v 2>&1 | awk '/^gcc version/ { print $3 }'`
  2052. case $GCC_VERSION in
  2053. 4.1.*|4.2.*|4.5.*)
  2054. # -Os is broken on gcc 4.1.x 4.2.x, 4.5.x we need to tweak it to get good results.
  2055. MOZ_OPTIMIZE_SIZE_TWEAK="-finline-limit=50"
  2056. esac
  2057. MOZ_PGO_OPTIMIZE_FLAGS="-O3"
  2058. MOZ_OPTIMIZE_FLAGS="-O3 -freorder-blocks $MOZ_OPTIMIZE_SIZE_TWEAK"
  2059. MOZ_DEBUG_FLAGS="-g"
  2060. fi
  2061. TARGET_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
  2062. case "${target_cpu}" in
  2063. alpha*)
  2064. CFLAGS="$CFLAGS -mieee"
  2065. CXXFLAGS="$CXXFLAGS -mieee"
  2066. ;;
  2067. mips*)
  2068. MOZ_DEBUG_FLAGS="-g" # We want inlining
  2069. ;;
  2070. esac
  2071. if test -z "$MC"; then
  2072. MC=mc.exe
  2073. fi
  2074. ;;
  2075. *-mingw*)
  2076. DSO_CFLAGS=
  2077. DSO_PIC_CFLAGS=
  2078. DLL_SUFFIX=.dll
  2079. RC=rc.exe
  2080. MC=mc.exe
  2081. # certain versions of cygwin's makedepend barf on the
  2082. # #include <string> vs -I./dist/include/string issue so don't use it
  2083. SYSTEM_MAKEDEPEND=
  2084. if test -n "$GNU_CC"; then
  2085. CC="$CC -mwindows"
  2086. CXX="$CXX -mwindows"
  2087. CPP="$CPP -mwindows"
  2088. CFLAGS="$CFLAGS -mms-bitfields"
  2089. CXXFLAGS="$CXXFLAGS -mms-bitfields"
  2090. DSO_LDOPTS='-shared'
  2091. MKSHLIB='$(CXX) $(DSO_LDOPTS) -o $@'
  2092. MKCSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
  2093. RC='$(WINDRES)'
  2094. # Use temp file for windres (bug 213281)
  2095. RCFLAGS='-O coff --use-temp-file'
  2096. # mingw doesn't require kernel32, user32, and advapi32 explicitly
  2097. LIBS="$LIBS -lgdi32 -lwinmm -lwsock32"
  2098. MOZ_JS_LIBS='-L$(libdir) -lmozjs'
  2099. MOZ_FIX_LINK_PATHS=
  2100. DYNAMIC_XPCOM_LIBS='-L$(LIBXUL_DIST)/lib -lxpcom -lxpcom_core -lmozalloc'
  2101. XPCOM_FROZEN_LDOPTS='-L$(LIBXUL_DIST)/lib -lxpcom -lmozalloc'
  2102. DLL_PREFIX=
  2103. IMPORT_LIB_SUFFIX=dll.a
  2104. GCC_VERSION=`$CC -v 2>&1 | awk '/^gcc version/ { print $3 }'`
  2105. else
  2106. TARGET_COMPILER_ABI=msvc
  2107. HOST_CC='$(CC)'
  2108. HOST_CXX='$(CXX)'
  2109. HOST_LD='$(LD)'
  2110. if test "$AS_BIN"; then
  2111. AS="$(basename "$AS_BIN")"
  2112. fi
  2113. AR='lib'
  2114. AR_FLAGS='-NOLOGO -OUT:"$@"'
  2115. AR_EXTRACT=
  2116. RANLIB='echo not_ranlib'
  2117. STRIP='echo not_strip'
  2118. PKG_SKIP_STRIP=1
  2119. XARGS=xargs
  2120. DOXYGEN=:
  2121. GARBAGE='$(OBJDIR)/vc20.pdb $(OBJDIR)/vc40.pdb'
  2122. ASM_SUFFIX=asm
  2123. OBJ_SUFFIX=obj
  2124. LIB_SUFFIX=lib
  2125. DLL_PREFIX=
  2126. LIB_PREFIX=
  2127. IMPORT_LIB_SUFFIX=lib
  2128. MKSHLIB='$(LD) -NOLOGO -DLL -OUT:$@ -PDB:$(LINK_PDBFILE) $(DSO_LDOPTS)'
  2129. MKCSHLIB='$(LD) -NOLOGO -DLL -OUT:$@ -PDB:$(LINK_PDBFILE) $(DSO_LDOPTS)'
  2130. MKSHLIB_FORCE_ALL=
  2131. MKSHLIB_UNFORCE_ALL=
  2132. DSO_LDOPTS=-SUBSYSTEM:WINDOWS
  2133. _USE_CPP_INCLUDE_FLAG=1
  2134. _DEFINES_CFLAGS='-FI $(DEPTH)/js-confdefs.h -DMOZILLA_CLIENT'
  2135. _DEFINES_CXXFLAGS='-FI $(DEPTH)/js-confdefs.h -DMOZILLA_CLIENT'
  2136. CFLAGS="$CFLAGS -W3 -Gy -Fd\$(COMPILE_PDBFILE)"
  2137. CXXFLAGS="$CXXFLAGS -W3 -Gy -Fd\$(COMPILE_PDBFILE)"
  2138. # MSVC warnings C4244 and C4800 are ubiquitous, useless, and annoying.
  2139. CXXFLAGS="$CXXFLAGS -wd4244 -wd4800"
  2140. # make 'foo == bar;' error out
  2141. CFLAGS="$CFLAGS -we4553"
  2142. CXXFLAGS="$CXXFLAGS -we4553"
  2143. LIBS="$LIBS kernel32.lib user32.lib gdi32.lib winmm.lib wsock32.lib advapi32.lib"
  2144. MOZ_DEBUG_FLAGS='-Zi'
  2145. MOZ_DEBUG_LDFLAGS='-DEBUG -DEBUGTYPE:CV'
  2146. WARNINGS_AS_ERRORS='-WX'
  2147. MOZ_OPTIMIZE_FLAGS="-O2"
  2148. MOZ_JS_LIBS='$(libdir)/mozjs.lib'
  2149. MOZ_FIX_LINK_PATHS=
  2150. DYNAMIC_XPCOM_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xpcom_core.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
  2151. XPCOM_FROZEN_LDOPTS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
  2152. LIBXUL_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xul.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
  2153. MOZ_COMPONENT_NSPR_LIBS='$(NSPR_LIBS)'
  2154. if test $_MSC_VER -ge 1400; then
  2155. LDFLAGS="$LDFLAGS -LARGEADDRESSAWARE -NXCOMPAT"
  2156. dnl For profile-guided optimization
  2157. PROFILE_GEN_CFLAGS="-GL"
  2158. PROFILE_GEN_LDFLAGS="-LTCG:PGINSTRUMENT"
  2159. dnl XXX: PGO builds can fail with warnings treated as errors,
  2160. dnl specifically "no profile data available" appears to be
  2161. dnl treated as an error sometimes. This might be a consequence
  2162. dnl of using WARNINGS_AS_ERRORS in some modules, combined
  2163. dnl with the linker doing most of the work in the whole-program
  2164. dnl optimization/PGO case. I think it's probably a compiler bug,
  2165. dnl but we work around it here.
  2166. PROFILE_USE_CFLAGS="-GL -wd4624 -wd4952"
  2167. dnl XXX: should be -LTCG:PGOPTIMIZE, but that fails on libxul.
  2168. dnl Probably also a compiler bug, but what can you do?
  2169. PROFILE_USE_LDFLAGS="-LTCG:PGUPDATE"
  2170. LDFLAGS="$LDFLAGS -DYNAMICBASE"
  2171. fi
  2172. fi
  2173. AC_DEFINE(HAVE_SNPRINTF)
  2174. AC_DEFINE(_WINDOWS)
  2175. AC_DEFINE(WIN32)
  2176. AC_DEFINE(XP_WIN)
  2177. AC_DEFINE(XP_WIN32)
  2178. AC_DEFINE(HW_THREADS)
  2179. AC_DEFINE(STDC_HEADERS)
  2180. AC_DEFINE(NEW_H, <new>)
  2181. AC_DEFINE(WIN32_LEAN_AND_MEAN)
  2182. TARGET_MD_ARCH=win32
  2183. _PLATFORM_DEFAULT_TOOLKIT='cairo-windows'
  2184. BIN_SUFFIX='.exe'
  2185. MOZ_USER_DIR="Mozilla"
  2186. dnl Hardcode to win95 for now - cls
  2187. TARGET_NSPR_MDCPUCFG='\"md/_win95.cfg\"'
  2188. dnl set NO_X11 defines here as the general check is skipped on win32
  2189. no_x=yes
  2190. AC_DEFINE(NO_X11)
  2191. case "$host" in
  2192. *-mingw*)
  2193. MOZ_BUILD_ROOT=`cd $MOZ_BUILD_ROOT && pwd -W`
  2194. ;;
  2195. esac
  2196. case "$host" in
  2197. *-mingw*)
  2198. if test -z "$MOZ_TOOLS"; then
  2199. AC_MSG_ERROR([MOZ_TOOLS is not set])
  2200. fi
  2201. MOZ_TOOLS_DIR=`cd $MOZ_TOOLS && pwd -W`
  2202. if test "$?" != "0" -o -z "$MOZ_TOOLS_DIR"; then
  2203. AC_MSG_ERROR([cd \$MOZ_TOOLS failed. MOZ_TOOLS ==? $MOZ_TOOLS])
  2204. fi
  2205. MOZ_TOOLS_BIN_DIR="$(cd "$MOZ_TOOLS_DIR/bin" && pwd)"
  2206. if test `echo ${PATH}: | grep -ic "$MOZ_TOOLS_BINDIR:"` = 0; then
  2207. AC_MSG_ERROR([\$MOZ_TOOLS\\bin must be in your path.])
  2208. fi
  2209. ;;
  2210. esac
  2211. case "$host_os" in
  2212. cygwin*|msvc*|mks*)
  2213. AC_MSG_ERROR([Using a Cygwin build environment is unsupported. Configure cannot check for presence of necessary headers. Please upgrade to MozillaBuild; see https://developer.mozilla.org/en/Windows_Build_Prerequisites.])
  2214. ;;
  2215. esac
  2216. case "$target" in
  2217. i*86-*)
  2218. if test "$HAVE_64BIT_OS"; then
  2219. AC_MSG_ERROR([You are targeting i386 but using the 64-bit compiler.])
  2220. fi
  2221. if test $_MSC_VER -ge 1400; then
  2222. LDFLAGS="$LDFLAGS -SAFESEH"
  2223. fi
  2224. if test -n "$GNU_CC"; then
  2225. CFLAGS="$CFLAGS -mstackrealign -fno-keep-inline-dllexport"
  2226. CXXFLAGS="$CXXFLAGS -mstackrealign -fno-keep-inline-dllexport"
  2227. fi
  2228. MOZ_CHECK_HEADERS(mmintrin.h)
  2229. AC_DEFINE(_X86_)
  2230. ;;
  2231. x86_64-*)
  2232. AC_DEFINE(_AMD64_)
  2233. ;;
  2234. *)
  2235. AC_DEFINE(_CPU_ARCH_NOT_DEFINED)
  2236. ;;
  2237. esac
  2238. if test "$HAVE_64BIT_OS"; then
  2239. AC_DEFINE(_WIN64)
  2240. fi
  2241. ;;
  2242. *-netbsd*)
  2243. DSO_CFLAGS=''
  2244. CFLAGS="$CFLAGS -Dunix"
  2245. CXXFLAGS="$CXXFLAGS -Dunix"
  2246. if $CC -E - -dM </dev/null | grep __ELF__ >/dev/null; then
  2247. DLL_SUFFIX=".so"
  2248. DSO_PIC_CFLAGS='-fPIC -DPIC'
  2249. DSO_LDOPTS='-shared'
  2250. BIN_FLAGS='-Wl,--export-dynamic'
  2251. else
  2252. DSO_PIC_CFLAGS='-fPIC -DPIC'
  2253. DLL_SUFFIX=".so.1.0"
  2254. DSO_LDOPTS='-shared'
  2255. fi
  2256. # This will fail on a.out systems prior to 1.5.1_ALPHA.
  2257. MKSHLIB_FORCE_ALL='-Wl,--whole-archive'
  2258. MKSHLIB_UNFORCE_ALL='-Wl,--no-whole-archive'
  2259. if test "$LIBRUNPATH"; then
  2260. DSO_LDOPTS="-Wl,-R$LIBRUNPATH $DSO_LDOPTS"
  2261. fi
  2262. MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,lib$(LIBRARY_NAME)$(DLL_SUFFIX) -o $@'
  2263. MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,lib$(LIBRARY_NAME)$(DLL_SUFFIX) -o $@'
  2264. ;;
  2265. *-openbsd*)
  2266. DLL_SUFFIX=".so.1.0"
  2267. DSO_CFLAGS=''
  2268. DSO_PIC_CFLAGS='-fPIC'
  2269. DSO_LDOPTS='-shared -fPIC'
  2270. if test "$LIBRUNPATH"; then
  2271. DSO_LDOPTS="-R$LIBRUNPATH $DSO_LDOPTS"
  2272. fi
  2273. ;;
  2274. *-os2*)
  2275. MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
  2276. MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
  2277. AC_DEFINE(OS2)
  2278. AC_DEFINE(XP_OS2)
  2279. AC_DEFINE(OS2EMX_PLAIN_CHAR)
  2280. AC_DEFINE(TCPV40HDRS)
  2281. DLL_PREFIX=
  2282. LIB_PREFIX=
  2283. LIB_SUFFIX=lib
  2284. BIN_SUFFIX=".exe"
  2285. DLL_SUFFIX=".dll"
  2286. IMPORT_LIB_SUFFIX=lib
  2287. DSO_PIC_CFLAGS=
  2288. AR=emxomfar
  2289. AR_FLAGS='r $@'
  2290. CFLAGS="$CFLAGS -Zomf"
  2291. CXXFLAGS="$CXXFLAGS -Zomf"
  2292. DSO_LDOPTS='-Zdll'
  2293. BIN_FLAGS='-Zlinker /ST:0x100000'
  2294. IMPLIB='emximp -o'
  2295. FILTER='true'
  2296. LDFLAGS='-Zmap'
  2297. WARNINGS_AS_ERRORS='-Werror'
  2298. MOZ_DEBUG_FLAGS="-g -fno-inline"
  2299. MOZ_OPTIMIZE_FLAGS="-O2"
  2300. MOZ_OPTIMIZE_LDFLAGS="-s -Zlinker /EXEPACK:2 -Zlinker /PACKCODE -Zlinker /PACKDATA"
  2301. DYNAMIC_XPCOM_LIBS='-L$(LIBXUL_DIST)/lib $(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xpcom_core.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
  2302. LIBXUL_LIBS='-L$(LIBXUL_DIST)/lib $(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xul.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
  2303. TARGET_MD_ARCH=os2
  2304. _PLATFORM_DEFAULT_TOOLKIT="cairo-os2"
  2305. RC=rc.exe
  2306. MC=mc.exe
  2307. RCFLAGS='-n'
  2308. MOZ_USER_DIR="Mozilla"
  2309. if test "$MOZTOOLS"; then
  2310. MOZ_TOOLS_DIR=`echo $MOZTOOLS | sed -e 's|\\\\|/|g'`
  2311. else
  2312. AC_MSG_ERROR([MOZTOOLS is not set])
  2313. fi
  2314. if test -n "$MOZ_OS2_HIGH_MEMORY"; then
  2315. DSO_LDOPTS="$DSO_LDOPTS -Zhigh-mem"
  2316. LDFLAGS="$LDFLAGS -Zhigh-mem"
  2317. MOZ_OPTIMIZE_LDFLAGS="$MOZ_OPTIMIZE_LDFLAGS -Zhigh-mem"
  2318. AC_DEFINE(MOZ_OS2_HIGH_MEMORY)
  2319. fi
  2320. # GCC for OS/2 currently predefines these, but we don't want them
  2321. _DEFINES_CFLAGS="$_DEFINES_CFLAGS -Uunix -U__unix -U__unix__"
  2322. _DEFINES_CXXFLAGS="$_DEFINES_CXXFLAGS -Uunix -U__unix -U__unix__"
  2323. AC_CACHE_CHECK(for __declspec(dllexport),
  2324. ac_os2_declspec,
  2325. [AC_TRY_COMPILE([__declspec(dllexport) void ac_os2_declspec(void) {}],
  2326. [return 0;],
  2327. ac_os2_declspec="yes",
  2328. ac_os2_declspec="no")])
  2329. if test "$ac_os2_declspec" != "yes"; then
  2330. AC_MSG_ERROR([Compiler does not support __declspec(dllexport), install GCC-4.3.2 or newer])
  2331. fi
  2332. ;;
  2333. *-solaris*)
  2334. AC_DEFINE(SOLARIS)
  2335. TARGET_NSPR_MDCPUCFG='\"md/_solaris.cfg\"'
  2336. if test -z "$CROSS_COMPILE" && pkginfo -q SUNWpr && pkginfo -q SUNWprd; then
  2337. NO_NSPR_CONFIG_SYSTEM_LDFLAGS="-L/usr/lib/mps -R/usr/lib/mps -lnspr4"
  2338. NO_NSPR_CONFIG_SYSTEM_CFLAGS="-I/usr/include/mps"
  2339. NO_NSPR_CONFIG_SYSTEM_VERSION=["`pkgparam SUNWpr SUNW_PRODVERS | sed -e 's/^[1-9][0-9]*\.[0-9][0-9]*$/&.0/'`"]
  2340. fi
  2341. SYSTEM_MAKEDEPEND=
  2342. MOZ_FIX_LINK_PATHS=
  2343. # $ORIGIN/.. is for shared libraries under components/ to locate shared
  2344. # libraries one level up (e.g. libnspr4.so)
  2345. if test "$SOLARIS_SUNPRO_CC"; then
  2346. LDFLAGS="$LDFLAGS -z ignore -R '\$\$ORIGIN:\$\$ORIGIN/..' -z lazyload -z combreloc -z muldefs"
  2347. LIBS="-lCrun -lCstd -lc $LIBS"
  2348. AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
  2349. CFLAGS="$CFLAGS -xlibmieee -xstrconst -xbuiltin=%all -D__FUNCTION__=__func__"
  2350. CXXFLAGS="$CXXFLAGS -xlibmieee -xbuiltin=%all -features=tmplife,tmplrefstatic,extensions,no%except -norunpath -D__FUNCTION__=__func__ -template=no%extdef"
  2351. LDFLAGS="-xildoff $LDFLAGS"
  2352. if test -z "$CROSS_COMPILE" -a -f /usr/lib/ld/map.noexstk; then
  2353. _SAVE_LDFLAGS=$LDFLAGS
  2354. LDFLAGS="-M /usr/lib/ld/map.noexstk $LDFLAGS"
  2355. AC_TRY_LINK([#include <stdio.h>],
  2356. [printf("Hello World\n");],
  2357. ,
  2358. [LDFLAGS=$_SAVE_LDFLAGS])
  2359. fi
  2360. MOZ_OPTIMIZE_FLAGS="-xO4"
  2361. MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_FLAGS) $(DSO_LDOPTS) -h $@ -o $@'
  2362. MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_FLAGS) $(DSO_LDOPTS) -h $@ -o $@'
  2363. MKSHLIB_FORCE_ALL='-z allextract'
  2364. MKSHLIB_UNFORCE_ALL='-z defaultextract'
  2365. DSO_LDOPTS='-G'
  2366. AR_LIST="$AR t"
  2367. AR_EXTRACT="$AR x"
  2368. AR_DELETE="$AR d"
  2369. AR='$(CXX) -xar'
  2370. AR_FLAGS='-o $@'
  2371. AS='/usr/ccs/bin/as'
  2372. ASFLAGS="$ASFLAGS -K PIC -L -P -D_ASM -D__STDC__=0"
  2373. AS_DASH_C_FLAG=''
  2374. TARGET_COMPILER_ABI="sunc"
  2375. CC_VERSION=`$CC -V 2>&1 | grep '^cc:' 2>/dev/null | $AWK -F\: '{ print $2 }'`
  2376. CXX_VERSION=`$CXX -V 2>&1 | grep '^CC:' 2>/dev/null | $AWK -F\: '{ print $2 }'`
  2377. AC_MSG_CHECKING([for Sun C++ compiler version >= 5.9])
  2378. AC_LANG_SAVE
  2379. AC_LANG_CPLUSPLUS
  2380. AC_TRY_COMPILE([],
  2381. [#if (__SUNPRO_CC < 0x590)
  2382. #error "Denied"
  2383. #endif],
  2384. _BAD_COMPILER=,_BAD_COMPILER=1)
  2385. if test -n "$_BAD_COMPILER"; then
  2386. _res="no"
  2387. AC_MSG_ERROR([Sun C++ 5.9 (Sun Studio 12) or higher is required to build. Your compiler version is $CXX_VERSION .])
  2388. else
  2389. _res="yes"
  2390. fi
  2391. AC_TRY_COMPILE([],
  2392. [#if (__SUNPRO_CC >= 0x5100)
  2393. #error "Sun C++ 5.10 or above"
  2394. #endif],
  2395. _ABOVE_SS12U1=,_ABOVE_SS12U1=1)
  2396. if test "$_ABOVE_SS12U1"; then
  2397. # disable xannotate
  2398. CXXFLAGS="$CXXFLAGS -xannotate=no"
  2399. fi
  2400. AC_MSG_RESULT([$_res])
  2401. AC_LANG_RESTORE
  2402. else
  2403. LDFLAGS="$LDFLAGS -Wl,-z,ignore -Wl,-R,'\$\$ORIGIN:\$\$ORIGIN/..' -Wl,-z,lazyload -Wl,-z,combreloc -Wl,-z,muldefs"
  2404. LIBS="-lc $LIBS"
  2405. MKSHLIB_FORCE_ALL='-Wl,-z -Wl,allextract'
  2406. MKSHLIB_UNFORCE_ALL='-Wl,-z -Wl,defaultextract'
  2407. ASFLAGS="$ASFLAGS -fPIC"
  2408. DSO_LDOPTS='-shared'
  2409. WARNINGS_AS_ERRORS='-Werror'
  2410. _WARNINGS_CFLAGS=''
  2411. _WARNINGS_CXXFLAGS=''
  2412. if test "$OS_RELEASE" = "5.3"; then
  2413. AC_DEFINE(MUST_UNDEF_HAVE_BOOLEAN_AFTER_INCLUDES)
  2414. fi
  2415. fi
  2416. if test "$OS_RELEASE" = "5.5.1"; then
  2417. AC_DEFINE(NEED_USLEEP_PROTOTYPE)
  2418. fi
  2419. ;;
  2420. *-sunos*)
  2421. DSO_LDOPTS='-Bdynamic'
  2422. MKSHLIB='-$(LD) $(DSO_LDOPTS) -o $@'
  2423. MKCSHLIB='-$(LD) $(DSO_LDOPTS) -o $@'
  2424. AC_DEFINE(SUNOS4)
  2425. AC_DEFINE(SPRINTF_RETURNS_STRING)
  2426. case "$(target_os)" in
  2427. sunos4.1*)
  2428. DLL_SUFFIX='.so.1.0'
  2429. ;;
  2430. esac
  2431. ;;
  2432. *-os2*)
  2433. HOST_NSPR_MDCPUCFG='\"md/_os2.cfg\"'
  2434. ;;
  2435. esac
  2436. dnl Only one oddball right now (QNX), but this gives us flexibility
  2437. dnl if any other platforms need to override this in the future.
  2438. AC_DEFINE_UNQUOTED(D_INO,$DIRENT_INO)
  2439. dnl ========================================================
  2440. dnl Any platform that doesn't have MKSHLIB_FORCE_ALL defined
  2441. dnl by now will not have any way to link most binaries (tests
  2442. dnl as well as viewer, apprunner, etc.), because some symbols
  2443. dnl will be left out of the "composite" .so's by ld as unneeded.
  2444. dnl So, by defining NO_LD_ARCHIVE_FLAGS for these platforms,
  2445. dnl they can link in the static libs that provide the missing
  2446. dnl symbols.
  2447. dnl ========================================================
  2448. NO_LD_ARCHIVE_FLAGS=
  2449. if test -z "$MKSHLIB_FORCE_ALL" -o -z "$MKSHLIB_UNFORCE_ALL"; then
  2450. NO_LD_ARCHIVE_FLAGS=1
  2451. fi
  2452. case "$target" in
  2453. *-os2*)
  2454. NO_LD_ARCHIVE_FLAGS=
  2455. ;;
  2456. *-aix4.3*|*-aix5*)
  2457. NO_LD_ARCHIVE_FLAGS=
  2458. ;;
  2459. *-mingw*)
  2460. if test -z "$GNU_CC"; then
  2461. NO_LD_ARCHIVE_FLAGS=
  2462. fi
  2463. ;;
  2464. esac
  2465. AC_SUBST(NO_LD_ARCHIVE_FLAGS)
  2466. dnl ========================================================
  2467. dnl = Flags to strip unused symbols from .so components
  2468. dnl ========================================================
  2469. case "$target" in
  2470. *-linux*|*-kfreebsd*-gnu|*-gnu*)
  2471. MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,--version-script -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-version-script'
  2472. ;;
  2473. *-solaris*)
  2474. if test -z "$GNU_CC"; then
  2475. MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-M $(BUILD_TOOLS)/gnu-ld-scripts/components-mapfile'
  2476. else
  2477. if test -z "$GCC_USE_GNU_LD"; then
  2478. MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,-M -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-mapfile'
  2479. else
  2480. MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,--version-script -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-version-script'
  2481. fi
  2482. fi
  2483. ;;
  2484. *-darwin*)
  2485. MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,-exported_symbols_list -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-export-list'
  2486. ;;
  2487. *-mingw*)
  2488. if test -n "$GNU_CC"; then
  2489. MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,--version-script,$(BUILD_TOOLS)/gnu-ld-scripts/components-version-script'
  2490. fi
  2491. ;;
  2492. esac
  2493. if test -z "$COMPILE_ENVIRONMENT"; then
  2494. SKIP_COMPILER_CHECKS=1
  2495. SKIP_LIBRARY_CHECKS=1
  2496. fi
  2497. dnl Configure JIT support
  2498. case "$target" in
  2499. i?86-*)
  2500. ENABLE_METHODJIT=1
  2501. ENABLE_MONOIC=1
  2502. ENABLE_POLYIC=1
  2503. ENABLE_METHODJIT_TYPED_ARRAY=1
  2504. AC_DEFINE(JS_CPU_X86)
  2505. AC_DEFINE(JS_NUNBOX32)
  2506. ;;
  2507. x86_64*-*)
  2508. ENABLE_METHODJIT=1
  2509. ENABLE_MONOIC=1
  2510. ENABLE_POLYIC=1
  2511. ENABLE_METHODJIT_TYPED_ARRAY=1
  2512. AC_DEFINE(JS_CPU_X64)
  2513. AC_DEFINE(JS_PUNBOX64)
  2514. ;;
  2515. arm*-*)
  2516. ENABLE_METHODJIT=1
  2517. ENABLE_MONOIC=1
  2518. ENABLE_POLYIC=1
  2519. ENABLE_POLYIC_TYPED_ARRAY=1
  2520. AC_DEFINE(JS_CPU_ARM)
  2521. AC_DEFINE(JS_NUNBOX32)
  2522. ;;
  2523. sparc*-*)
  2524. if test ! "$HAVE_64BIT_OS" ; then
  2525. ENABLE_METHODJIT=1
  2526. ENABLE_MONOIC=1
  2527. ENABLE_POLYIC=1
  2528. ENABLE_METHODJIT_TYPED_ARRAY=1
  2529. AC_DEFINE(JS_CPU_SPARC)
  2530. AC_DEFINE(JS_NUNBOX32)
  2531. fi
  2532. ;;
  2533. mips*-*)
  2534. ENABLE_METHODJIT=1
  2535. ENABLE_MONOIC=1
  2536. ENABLE_POLYIC=1
  2537. ENABLE_METHODJIT_TYPED_ARRAY=1
  2538. AC_DEFINE(JS_CPU_MIPS)
  2539. AC_DEFINE(JS_NUNBOX32)
  2540. ;;
  2541. esac
  2542. MOZ_ARG_DISABLE_BOOL(methodjit,
  2543. [ --disable-methodjit Disable method JIT support],
  2544. ENABLE_METHODJIT= )
  2545. MOZ_ARG_DISABLE_BOOL(monoic,
  2546. [ --disable-monoic Disable use of MICs by JIT compiler],
  2547. ENABLE_MONOIC= )
  2548. MOZ_ARG_DISABLE_BOOL(polyic,
  2549. [ --disable-polyic Disable use of PICs by JIT compiler],
  2550. ENABLE_POLYIC= )
  2551. MOZ_ARG_ENABLE_BOOL(methodjit-spew,
  2552. [ --enable-methodjit-spew Enable method JIT spew support],
  2553. ENABLE_METHODJIT_SPEW=1,
  2554. ENABLE_METHODJIT_SPEW= )
  2555. AC_SUBST(ENABLE_METHODJIT)
  2556. if test "$ENABLE_METHODJIT"; then
  2557. AC_DEFINE(JS_METHODJIT)
  2558. fi
  2559. if test "$ENABLE_MONOIC"; then
  2560. AC_DEFINE(JS_MONOIC)
  2561. fi
  2562. if test "$ENABLE_POLYIC"; then
  2563. AC_DEFINE(JS_POLYIC)
  2564. fi
  2565. if test "$ENABLE_METHODJIT_TYPED_ARRAY"; then
  2566. AC_DEFINE(JS_METHODJIT_TYPED_ARRAY)
  2567. fi
  2568. if test "$ENABLE_METHODJIT_SPEW"; then
  2569. AC_DEFINE(JS_METHODJIT_SPEW)
  2570. fi
  2571. if test -z "$SKIP_COMPILER_CHECKS"; then
  2572. dnl Checks for typedefs, structures, and compiler characteristics.
  2573. dnl ========================================================
  2574. AC_HEADER_STDC
  2575. AC_C_CONST
  2576. AC_TYPE_MODE_T
  2577. AC_TYPE_OFF_T
  2578. AC_TYPE_PID_T
  2579. AC_TYPE_SIZE_T
  2580. AC_LANG_CPLUSPLUS
  2581. AC_MSG_CHECKING(for __stdcall)
  2582. AC_CACHE_VAL(ac_cv___stdcall,
  2583. [AC_TRY_COMPILE([template <typename Method> struct foo;
  2584. template <> struct foo<void (*)()> {};
  2585. template <> struct foo<void (__stdcall*)()> {};],
  2586. [],
  2587. [ac_cv___stdcall=true],
  2588. [ac_cv___stdcall=false])])
  2589. if test "$ac_cv___stdcall" = true ; then
  2590. AC_DEFINE(HAVE_STDCALL)
  2591. AC_MSG_RESULT(yes)
  2592. else
  2593. AC_MSG_RESULT(no)
  2594. fi
  2595. AC_LANG_C
  2596. AC_MSG_CHECKING(for ssize_t)
  2597. AC_CACHE_VAL(ac_cv_type_ssize_t,
  2598. [AC_TRY_COMPILE([#include <stdio.h>
  2599. #include <sys/types.h>],
  2600. [ssize_t foo = 0;],
  2601. [ac_cv_type_ssize_t=true],
  2602. [ac_cv_type_ssize_t=false])])
  2603. if test "$ac_cv_type_ssize_t" = true ; then
  2604. AC_DEFINE(HAVE_SSIZE_T)
  2605. AC_MSG_RESULT(yes)
  2606. else
  2607. AC_MSG_RESULT(no)
  2608. fi
  2609. AC_STRUCT_ST_BLKSIZE
  2610. AC_MSG_CHECKING(for siginfo_t)
  2611. AC_CACHE_VAL(ac_cv_siginfo_t,
  2612. [AC_TRY_COMPILE([#define _POSIX_C_SOURCE 199506L
  2613. #include <signal.h>],
  2614. [siginfo_t* info;],
  2615. [ac_cv_siginfo_t=true],
  2616. [ac_cv_siginfo_t=false])])
  2617. if test "$ac_cv_siginfo_t" = true ; then
  2618. AC_DEFINE(HAVE_SIGINFO_T)
  2619. AC_MSG_RESULT(yes)
  2620. else
  2621. AC_MSG_RESULT(no)
  2622. fi
  2623. MOZ_SIZE_OF_TYPE(JS_BYTES_PER_WORD, void*, 4 8)
  2624. if test "$moz_cv_size_of_JS_BYTES_PER_WORD" -eq "4"; then
  2625. AC_DEFINE(JS_BITS_PER_WORD_LOG2, 5)
  2626. elif test "$moz_cv_size_of_JS_BYTES_PER_WORD" -eq "8"; then
  2627. AC_DEFINE(JS_BITS_PER_WORD_LOG2, 6)
  2628. else
  2629. AC_MSG_ERROR([Unexpected JS_BYTES_PER_WORD])
  2630. fi
  2631. MOZ_ALIGN_OF_TYPE(JS_ALIGN_OF_POINTER, void*, 2 4 8 16)
  2632. MOZ_SIZE_OF_TYPE(JS_BYTES_PER_DOUBLE, double, 6 8 10 12 14)
  2633. MOZ_CHECK_HEADERS(endian.h)
  2634. if test "$ac_cv_header_endian_h" = yes; then
  2635. AC_DEFINE(JS_HAVE_ENDIAN_H)
  2636. fi
  2637. MOZ_CHECK_HEADERS([machine/endian.h],[],[],[#include <sys/types.h>])
  2638. if test "$ac_cv_header_machine_endian_h" = yes; then
  2639. AC_DEFINE(JS_HAVE_MACHINE_ENDIAN_H)
  2640. fi
  2641. MOZ_CHECK_HEADERS(sys/isa_defs.h)
  2642. if test "$ac_cv_header_sys_isa_defs_h" = yes; then
  2643. AC_DEFINE(JS_HAVE_SYS_ISA_DEFS_H)
  2644. fi
  2645. dnl Check for uint and uint_t.
  2646. dnl ========================================================
  2647. AC_MSG_CHECKING(for uint)
  2648. AC_CACHE_VAL(ac_cv_uint,
  2649. [AC_TRY_COMPILE([#include <stdio.h>
  2650. #include <sys/types.h>],
  2651. [uint foo = 0;],
  2652. [ac_cv_uint=true],
  2653. [ac_cv_uint=false])])
  2654. if test "$ac_cv_uint" = true ; then
  2655. AC_DEFINE(HAVE_UINT)
  2656. AC_MSG_RESULT(yes)
  2657. else
  2658. AC_MSG_RESULT(no)
  2659. fi
  2660. AC_MSG_CHECKING(for uint_t)
  2661. AC_CACHE_VAL(ac_cv_uint_t,
  2662. [AC_TRY_COMPILE([#include <stdio.h>
  2663. #include <sys/types.h>],
  2664. [uint_t foo = 0;],
  2665. [ac_cv_uint_t=true],
  2666. [ac_cv_uint_t=false])])
  2667. if test "$ac_cv_uint_t" = true ; then
  2668. AC_DEFINE(HAVE_UINT_T)
  2669. AC_MSG_RESULT(yes)
  2670. else
  2671. AC_MSG_RESULT(no)
  2672. fi
  2673. dnl On the gcc trunk (as of 2001-02-09) _GNU_SOURCE, and thus __USE_GNU,
  2674. dnl are defined when compiling C++ but not C. Since the result of this
  2675. dnl test is used only in C++, do it in C++.
  2676. AC_LANG_CPLUSPLUS
  2677. AC_MSG_CHECKING(for uname.domainname)
  2678. AC_CACHE_VAL(ac_cv_have_uname_domainname_field,
  2679. [AC_TRY_COMPILE([#include <sys/utsname.h>],
  2680. [ struct utsname *res; char *domain;
  2681. (void)uname(res); if (res != 0) { domain = res->domainname; } ],
  2682. [ac_cv_have_uname_domainname_field=true],
  2683. [ac_cv_have_uname_domainname_field=false])])
  2684. if test "$ac_cv_have_uname_domainname_field" = "true"; then
  2685. AC_DEFINE(HAVE_UNAME_DOMAINNAME_FIELD)
  2686. AC_MSG_RESULT(yes)
  2687. else
  2688. AC_MSG_RESULT(no)
  2689. fi
  2690. AC_MSG_CHECKING(for uname.__domainname)
  2691. AC_CACHE_VAL(ac_cv_have_uname_us_domainname_field,
  2692. [AC_TRY_COMPILE([#include <sys/utsname.h>],
  2693. [ struct utsname *res; char *domain;
  2694. (void)uname(res); if (res != 0) { domain = res->__domainname; } ],
  2695. [ac_cv_have_uname_us_domainname_field=true],
  2696. [ac_cv_have_uname_us_domainname_field=false])])
  2697. if test "$ac_cv_have_uname_us_domainname_field" = "true"; then
  2698. AC_DEFINE(HAVE_UNAME_US_DOMAINNAME_FIELD)
  2699. AC_MSG_RESULT(yes)
  2700. else
  2701. AC_MSG_RESULT(no)
  2702. fi
  2703. AC_LANG_C
  2704. dnl Check for .hidden assembler directive and visibility attribute.
  2705. dnl Borrowed from glibc configure.in
  2706. dnl ===============================================================
  2707. if test "$GNU_CC"; then
  2708. AC_CACHE_CHECK(for visibility(hidden) attribute,
  2709. ac_cv_visibility_hidden,
  2710. [cat > conftest.c <<EOF
  2711. int foo __attribute__ ((visibility ("hidden"))) = 1;
  2712. EOF
  2713. ac_cv_visibility_hidden=no
  2714. if ${CC-cc} -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
  2715. if egrep '\.(hidden|private_extern).*foo' conftest.s >/dev/null; then
  2716. ac_cv_visibility_hidden=yes
  2717. fi
  2718. fi
  2719. rm -f conftest.[cs]
  2720. ])
  2721. if test "$ac_cv_visibility_hidden" = "yes"; then
  2722. AC_DEFINE(HAVE_VISIBILITY_HIDDEN_ATTRIBUTE)
  2723. AC_CACHE_CHECK(for visibility(default) attribute,
  2724. ac_cv_visibility_default,
  2725. [cat > conftest.c <<EOF
  2726. int foo __attribute__ ((visibility ("default"))) = 1;
  2727. EOF
  2728. ac_cv_visibility_default=no
  2729. if ${CC-cc} -fvisibility=hidden -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
  2730. if ! egrep '\.(hidden|private_extern).*foo' conftest.s >/dev/null; then
  2731. ac_cv_visibility_default=yes
  2732. fi
  2733. fi
  2734. rm -f conftest.[cs]
  2735. ])
  2736. if test "$ac_cv_visibility_default" = "yes"; then
  2737. AC_DEFINE(HAVE_VISIBILITY_ATTRIBUTE)
  2738. AC_CACHE_CHECK(for visibility pragma support,
  2739. ac_cv_visibility_pragma,
  2740. [cat > conftest.c <<EOF
  2741. #pragma GCC visibility push(hidden)
  2742. int foo_hidden = 1;
  2743. #pragma GCC visibility push(default)
  2744. int foo_default = 1;
  2745. EOF
  2746. ac_cv_visibility_pragma=no
  2747. if ${CC-cc} -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
  2748. if egrep '\.(hidden|private_extern).*foo_hidden' conftest.s >/dev/null; then
  2749. if ! egrep '\.(hidden|private_extern).*foo_default' conftest.s > /dev/null; then
  2750. ac_cv_visibility_pragma=yes
  2751. fi
  2752. fi
  2753. fi
  2754. rm -f conftest.[cs]
  2755. ])
  2756. if test "$ac_cv_visibility_pragma" = "yes"; then
  2757. AC_CACHE_CHECK(For gcc visibility bug with class-level attributes (GCC bug 26905),
  2758. ac_cv_have_visibility_class_bug,
  2759. [cat > conftest.c <<EOF
  2760. #pragma GCC visibility push(hidden)
  2761. struct __attribute__ ((visibility ("default"))) TestStruct {
  2762. static void Init();
  2763. };
  2764. __attribute__ ((visibility ("default"))) void TestFunc() {
  2765. TestStruct::Init();
  2766. }
  2767. EOF
  2768. ac_cv_have_visibility_class_bug=no
  2769. if ! ${CXX-g++} ${CXXFLAGS} ${DSO_PIC_CFLAGS} ${DSO_LDOPTS} -S -o conftest.S conftest.c > /dev/null 2>&1 ; then
  2770. ac_cv_have_visibility_class_bug=yes
  2771. else
  2772. if test `egrep -c '@PLT|\\$stub' conftest.S` = 0; then
  2773. ac_cv_have_visibility_class_bug=yes
  2774. fi
  2775. fi
  2776. rm -rf conftest.{c,S}
  2777. ])
  2778. AC_CACHE_CHECK(For x86_64 gcc visibility bug with builtins (GCC bug 20297),
  2779. ac_cv_have_visibility_builtin_bug,
  2780. [cat > conftest.c <<EOF
  2781. #pragma GCC visibility push(hidden)
  2782. #pragma GCC visibility push(default)
  2783. #include <string.h>
  2784. #pragma GCC visibility pop
  2785. __attribute__ ((visibility ("default"))) void Func() {
  2786. char c[[100]];
  2787. memset(c, 0, sizeof(c));
  2788. }
  2789. EOF
  2790. ac_cv_have_visibility_builtin_bug=no
  2791. if ! ${CC-cc} ${CFLAGS} ${DSO_PIC_CFLAGS} ${DSO_LDOPTS} -O2 -S -o conftest.S conftest.c > /dev/null 2>&1 ; then
  2792. ac_cv_have_visibility_builtin_bug=yes
  2793. else
  2794. if test `grep -c "@PLT" conftest.S` = 0; then
  2795. ac_cv_visibility_builtin_bug=yes
  2796. fi
  2797. fi
  2798. rm -f conftest.{c,S}
  2799. ])
  2800. if test "$ac_cv_have_visibility_builtin_bug" = "no" -a \
  2801. "$ac_cv_have_visibility_class_bug" = "no"; then
  2802. VISIBILITY_FLAGS='-I$(DIST)/system_wrappers_js -include $(topsrcdir)/config/gcc_hidden.h'
  2803. WRAP_SYSTEM_INCLUDES=1
  2804. STL_FLAGS='-I$(DIST)/stl_wrappers'
  2805. WRAP_STL_INCLUDES=1
  2806. else
  2807. VISIBILITY_FLAGS='-fvisibility=hidden'
  2808. fi # have visibility pragma bug
  2809. fi # have visibility pragma
  2810. fi # have visibility(default) attribute
  2811. fi # have visibility(hidden) attribute
  2812. fi # GNU_CC
  2813. # visibility hidden flag for Sun Studio on Solaris
  2814. if test "$SOLARIS_SUNPRO_CC"; then
  2815. VISIBILITY_FLAGS='-xldscope=hidden'
  2816. fi # Sun Studio on Solaris
  2817. AC_SUBST(WRAP_SYSTEM_INCLUDES)
  2818. AC_SUBST(VISIBILITY_FLAGS)
  2819. MOZ_GCC_PR49911
  2820. dnl Check for __force_align_arg_pointer__ for SSE2 on gcc
  2821. dnl ========================================================
  2822. if test "$GNU_CC"; then
  2823. CFLAGS_save="${CFLAGS}"
  2824. CFLAGS="${CFLAGS} -Werror"
  2825. AC_CACHE_CHECK(for __force_align_arg_pointer__ attribute,
  2826. ac_cv_force_align_arg_pointer,
  2827. [AC_TRY_COMPILE([__attribute__ ((__force_align_arg_pointer__)) void test() {}],
  2828. [],
  2829. ac_cv_force_align_arg_pointer="yes",
  2830. ac_cv_force_align_arg_pointer="no")])
  2831. CFLAGS="${CFLAGS_save}"
  2832. if test "$ac_cv_force_align_arg_pointer" = "yes"; then
  2833. HAVE_GCC_ALIGN_ARG_POINTER=1
  2834. else
  2835. HAVE_GCC_ALIGN_ARG_POINTER=
  2836. fi
  2837. fi
  2838. AC_SUBST(HAVE_GCC_ALIGN_ARG_POINTER)
  2839. dnl Checks for header files.
  2840. dnl ========================================================
  2841. AC_HEADER_DIRENT
  2842. case "$target_os" in
  2843. freebsd*)
  2844. # for stuff like -lXshm
  2845. CPPFLAGS="${CPPFLAGS} ${X_CFLAGS}"
  2846. ;;
  2847. esac
  2848. MOZ_CHECK_COMMON_HEADERS
  2849. dnl These are all the places some variant of statfs can be hiding.
  2850. MOZ_CHECK_HEADERS(sys/statvfs.h sys/statfs.h sys/vfs.h sys/mount.h)
  2851. dnl Quota support
  2852. MOZ_CHECK_HEADERS(sys/quota.h)
  2853. MOZ_CHECK_HEADERS(linux/quota.h)
  2854. dnl Try for MMX support
  2855. dnl NB - later gcc versions require -mmmx for this header to be successfully
  2856. dnl included (or another option which implies it, such as -march=pentium-mmx)
  2857. MOZ_CHECK_HEADERS(mmintrin.h)
  2858. dnl Check whether the compiler supports the new-style C++ standard
  2859. dnl library headers (i.e. <new>) or needs the old "new.h"
  2860. AC_LANG_CPLUSPLUS
  2861. NEW_H=new.h
  2862. MOZ_CHECK_HEADER(new, [NEW_H=new])
  2863. AC_DEFINE_UNQUOTED(NEW_H, <$NEW_H>)
  2864. AC_LANG_C
  2865. AC_ARG_ENABLE(dtrace,
  2866. [ --enable-dtrace build with dtrace support if available (default=no)],
  2867. [enable_dtrace="yes"],)
  2868. if test "x$enable_dtrace" = "xyes"; then
  2869. MOZ_CHECK_HEADER(sys/sdt.h, HAVE_DTRACE=1)
  2870. if test -n "$HAVE_DTRACE"; then
  2871. AC_DEFINE(INCLUDE_MOZILLA_DTRACE)
  2872. else
  2873. AC_MSG_ERROR([dtrace enabled but sys/sdt.h not found]);
  2874. fi
  2875. fi
  2876. AC_SUBST(HAVE_DTRACE)
  2877. case $target in
  2878. *-aix4.3*|*-aix5*)
  2879. ;;
  2880. *)
  2881. MOZ_CHECK_HEADERS(sys/cdefs.h)
  2882. ;;
  2883. esac
  2884. dnl Performance measurement headers.
  2885. MOZ_CHECK_HEADER(linux/perf_event.h,
  2886. [AC_CACHE_CHECK(for perf_event_open system call,ac_cv_perf_event_open,
  2887. [AC_TRY_COMPILE([#include <sys/syscall.h>],[return sizeof(__NR_perf_event_open);],
  2888. ac_cv_perf_event_open=yes,
  2889. ac_cv_perf_event_open=no)])])
  2890. if test "$ac_cv_perf_event_open" = "yes"; then
  2891. HAVE_LINUX_PERF_EVENT_H=1
  2892. else
  2893. HAVE_LINUX_PERF_EVENT_H=
  2894. fi
  2895. AC_SUBST(HAVE_LINUX_PERF_EVENT_H)
  2896. dnl Checks for libraries.
  2897. dnl ========================================================
  2898. case $target in
  2899. *-hpux11.*)
  2900. ;;
  2901. *)
  2902. AC_CHECK_LIB(c_r, gethostbyname_r)
  2903. ;;
  2904. esac
  2905. dnl We don't want to link with libdl even if it's present on OS X, since
  2906. dnl it's not used and not part of the default installation. OS/2 has dlfcn
  2907. dnl in libc.
  2908. dnl We don't want to link against libm or libpthread on Darwin since
  2909. dnl they both are just symlinks to libSystem and explicitly linking
  2910. dnl against libSystem causes issues when debugging (see bug 299601).
  2911. case $target in
  2912. *-darwin*)
  2913. ;;
  2914. *-os2*)
  2915. ;;
  2916. *)
  2917. AC_SEARCH_LIBS(dlopen, dl,
  2918. MOZ_CHECK_HEADER(dlfcn.h,
  2919. AC_DEFINE(HAVE_DLOPEN)))
  2920. ;;
  2921. esac
  2922. _SAVE_CFLAGS="$CFLAGS"
  2923. CFLAGS="$CFLAGS -D_GNU_SOURCE"
  2924. AC_CHECK_FUNCS(dladdr)
  2925. CFLAGS="$_SAVE_CFLAGS"
  2926. if test ! "$GNU_CXX"; then
  2927. case $target in
  2928. *-aix*)
  2929. AC_CHECK_LIB(C_r, demangle)
  2930. ;;
  2931. *)
  2932. AC_CHECK_LIB(C, demangle)
  2933. ;;
  2934. esac
  2935. fi
  2936. dnl OS/2 has socket in libc.
  2937. case $target in
  2938. *-os2*)
  2939. ;;
  2940. *)
  2941. AC_CHECK_LIB(socket, socket)
  2942. esac
  2943. dnl ========================================================
  2944. dnl = pthread support
  2945. dnl = Start by checking whether the system support pthreads
  2946. dnl ========================================================
  2947. case "$target_os" in
  2948. darwin*)
  2949. USE_PTHREADS=1
  2950. ;;
  2951. *)
  2952. MOZ_CHECK_PTHREADS(pthreads,
  2953. USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads",
  2954. MOZ_CHECK_PTHREADS(pthread,
  2955. USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread",
  2956. MOZ_CHECK_PTHREADS(c_r,
  2957. USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r",
  2958. MOZ_CHECK_PTHREADS(c,
  2959. USE_PTHREADS=1
  2960. )
  2961. )
  2962. )
  2963. )
  2964. ;;
  2965. esac
  2966. dnl ========================================================
  2967. dnl Check the command line for --with-pthreads
  2968. dnl ========================================================
  2969. MOZ_ARG_WITH_BOOL(pthreads,
  2970. [ --with-pthreads Force use of system pthread library with NSPR ],
  2971. [ if test "$USE_PTHREADS"x = x; then
  2972. AC_MSG_ERROR([ --with-pthreads specified for a system without pthread support ]);
  2973. fi],
  2974. USE_PTHREADS=
  2975. _PTHREAD_LDFLAGS=
  2976. )
  2977. dnl ========================================================
  2978. dnl Do the platform specific pthread hackery
  2979. dnl ========================================================
  2980. if test "$USE_PTHREADS"x != x
  2981. then
  2982. dnl
  2983. dnl See if -pthread is supported.
  2984. dnl
  2985. rm -f conftest*
  2986. ac_cv_have_dash_pthread=no
  2987. AC_MSG_CHECKING(whether ${CC-cc} accepts -pthread)
  2988. echo 'int main() { return 0; }' | cat > conftest.c
  2989. ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
  2990. if test $? -eq 0; then
  2991. if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
  2992. ac_cv_have_dash_pthread=yes
  2993. case "$target_os" in
  2994. freebsd*)
  2995. # Freebsd doesn't use -pthread for compiles, it uses them for linking
  2996. ;;
  2997. *)
  2998. CFLAGS="$CFLAGS -pthread"
  2999. CXXFLAGS="$CXXFLAGS -pthread"
  3000. ;;
  3001. esac
  3002. fi
  3003. fi
  3004. rm -f conftest*
  3005. AC_MSG_RESULT($ac_cv_have_dash_pthread)
  3006. dnl
  3007. dnl See if -pthreads is supported.
  3008. dnl
  3009. ac_cv_have_dash_pthreads=no
  3010. if test "$ac_cv_have_dash_pthread" = "no"; then
  3011. AC_MSG_CHECKING(whether ${CC-cc} accepts -pthreads)
  3012. echo 'int main() { return 0; }' | cat > conftest.c
  3013. ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
  3014. if test $? -eq 0; then
  3015. if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthreads`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
  3016. ac_cv_have_dash_pthreads=yes
  3017. CFLAGS="$CFLAGS -pthreads"
  3018. CXXFLAGS="$CXXFLAGS -pthreads"
  3019. fi
  3020. fi
  3021. rm -f conftest*
  3022. AC_MSG_RESULT($ac_cv_have_dash_pthreads)
  3023. fi
  3024. case "$target" in
  3025. *-*-freebsd*)
  3026. AC_DEFINE(_REENTRANT)
  3027. AC_DEFINE(_THREAD_SAFE)
  3028. dnl -pthread links in -lc_r, so don't specify it explicitly.
  3029. if test "$ac_cv_have_dash_pthread" = "yes"; then
  3030. _PTHREAD_LDFLAGS="-pthread"
  3031. else
  3032. _PTHREAD_LDFLAGS="-lc_r"
  3033. fi
  3034. ;;
  3035. *-*-openbsd*|*-*-bsdi*)
  3036. AC_DEFINE(_REENTRANT)
  3037. AC_DEFINE(_THREAD_SAFE)
  3038. dnl -pthread links in -lc_r, so don't specify it explicitly.
  3039. if test "$ac_cv_have_dash_pthread" = "yes"; then
  3040. _PTHREAD_LDFLAGS="-pthread"
  3041. fi
  3042. ;;
  3043. *-*-linux*|*-*-kfreebsd*-gnu|*-*-gnu*)
  3044. AC_DEFINE(_REENTRANT)
  3045. ;;
  3046. *-aix4.3*|*-aix5*)
  3047. AC_DEFINE(_REENTRANT)
  3048. ;;
  3049. *-hpux11.*)
  3050. AC_DEFINE(_REENTRANT)
  3051. ;;
  3052. *-*-solaris*)
  3053. AC_DEFINE(_REENTRANT)
  3054. if test "$SOLARIS_SUNPRO_CC"; then
  3055. CFLAGS="$CFLAGS -mt"
  3056. CXXFLAGS="$CXXFLAGS -mt"
  3057. fi
  3058. ;;
  3059. esac
  3060. LDFLAGS="${_PTHREAD_LDFLAGS} ${LDFLAGS}"
  3061. fi
  3062. dnl Checks for library functions.
  3063. dnl ========================================================
  3064. AC_PROG_GCC_TRADITIONAL
  3065. AC_FUNC_MEMCMP
  3066. AC_CHECK_FUNCS([fchmod flockfile getc_unlocked _getc_nolock getpagesize \
  3067. lchown localtime_r lstat64 memmove random rint sbrk snprintf \
  3068. stat64 statvfs statvfs64 strerror strtok_r truncate64])
  3069. dnl check for clock_gettime(), the CLOCK_MONOTONIC clock, and -lrt
  3070. _SAVE_LDFLAGS=$LDFLAGS
  3071. LDFLAGS="$LDFLAGS -lrt"
  3072. AC_CACHE_CHECK(for clock_gettime(CLOCK_MONOTONIC) and -lrt,
  3073. ac_cv_have_clock_monotonic,
  3074. [AC_TRY_LINK([#include <time.h>],
  3075. [ struct timespec ts;
  3076. clock_gettime(CLOCK_MONOTONIC, &ts); ],
  3077. ac_cv_have_clock_monotonic=yes,
  3078. ac_cv_have_clock_monotonic=no)])
  3079. LDFLAGS=$_SAVE_LDFLAGS
  3080. if test "$ac_cv_have_clock_monotonic" = "yes"; then
  3081. HAVE_CLOCK_MONOTONIC=1
  3082. REALTIME_LIBS=-lrt
  3083. AC_DEFINE(HAVE_CLOCK_MONOTONIC)
  3084. AC_SUBST(HAVE_CLOCK_MONOTONIC)
  3085. AC_SUBST(REALTIME_LIBS)
  3086. fi
  3087. dnl Windows functions, for mingw.
  3088. AC_TRY_LINK([#include <windows.h>],
  3089. [SYSTEMTIME st;FILETIME ft;SystemTimeToFileTime(&st,&ft);],
  3090. ac_cv_have_systemtimetofiletime="yes",
  3091. ac_cv_have_systemtimetofiletime="no")
  3092. if test "$ac_cv_have_systemtimetofiletime" = "yes"; then
  3093. AC_DEFINE(HAVE_SYSTEMTIMETOFILETIME)
  3094. fi
  3095. AC_TRY_LINK([#include <windows.h>],
  3096. [FILETIME ft;GetSystemTimeAsFileTime(&ft);],
  3097. ac_cv_have_getsystemtimeasfiletime="yes",
  3098. ac_cv_have_getsystemtimeasfiletime="no")
  3099. if test "$ac_cv_have_getsystemtimeasfiletime" = "yes"; then
  3100. AC_DEFINE(HAVE_GETSYSTEMTIMEASFILETIME)
  3101. fi
  3102. dnl check for wcrtomb/mbrtowc
  3103. dnl =======================================================================
  3104. if test -z "$MACOS_DEPLOYMENT_TARGET" || test "$MACOS_DEPLOYMENT_TARGET" -ge "100300"; then
  3105. AC_LANG_SAVE
  3106. AC_LANG_CPLUSPLUS
  3107. AC_CACHE_CHECK(for wcrtomb,
  3108. ac_cv_have_wcrtomb,
  3109. [AC_TRY_LINK([#include <wchar.h>],
  3110. [mbstate_t ps={0};wcrtomb(0,'f',&ps);],
  3111. ac_cv_have_wcrtomb="yes",
  3112. ac_cv_have_wcrtomb="no")])
  3113. if test "$ac_cv_have_wcrtomb" = "yes"; then
  3114. AC_DEFINE(HAVE_WCRTOMB)
  3115. fi
  3116. AC_CACHE_CHECK(for mbrtowc,
  3117. ac_cv_have_mbrtowc,
  3118. [AC_TRY_LINK([#include <wchar.h>],
  3119. [mbstate_t ps={0};mbrtowc(0,0,0,&ps);],
  3120. ac_cv_have_mbrtowc="yes",
  3121. ac_cv_have_mbrtowc="no")])
  3122. if test "$ac_cv_have_mbrtowc" = "yes"; then
  3123. AC_DEFINE(HAVE_MBRTOWC)
  3124. fi
  3125. AC_LANG_RESTORE
  3126. fi
  3127. AC_CACHE_CHECK(
  3128. [for res_ninit()],
  3129. ac_cv_func_res_ninit,
  3130. [AC_TRY_LINK([
  3131. #ifdef linux
  3132. #define _BSD_SOURCE 1
  3133. #endif
  3134. #include <resolv.h>
  3135. ],
  3136. [int foo = res_ninit(&_res);],
  3137. [ac_cv_func_res_ninit=yes],
  3138. [ac_cv_func_res_ninit=no])
  3139. ])
  3140. if test "$ac_cv_func_res_ninit" = "yes"; then
  3141. AC_DEFINE(HAVE_RES_NINIT)
  3142. dnl must add the link line we do something as foolish as this... dougt
  3143. dnl else
  3144. dnl AC_CHECK_LIB(bind, res_ninit, AC_DEFINE(HAVE_RES_NINIT),
  3145. dnl AC_CHECK_LIB(resolv, res_ninit, AC_DEFINE(HAVE_RES_NINIT)))
  3146. fi
  3147. AC_LANG_CPLUSPLUS
  3148. AC_CACHE_CHECK(
  3149. [for gnu_get_libc_version()],
  3150. ac_cv_func_gnu_get_libc_version,
  3151. [AC_TRY_LINK([
  3152. #ifdef HAVE_GNU_LIBC_VERSION_H
  3153. #include <gnu/libc-version.h>
  3154. #endif
  3155. ],
  3156. [const char *glibc_version = gnu_get_libc_version();],
  3157. [ac_cv_func_gnu_get_libc_version=yes],
  3158. [ac_cv_func_gnu_get_libc_version=no]
  3159. )]
  3160. )
  3161. if test "$ac_cv_func_gnu_get_libc_version" = "yes"; then
  3162. AC_DEFINE(HAVE_GNU_GET_LIBC_VERSION)
  3163. fi
  3164. case $target_os in
  3165. darwin*|mingw*|os2*)
  3166. ;;
  3167. *)
  3168. AC_CHECK_LIB(c, iconv, [_ICONV_LIBS="$_ICONV_LIBS"],
  3169. AC_CHECK_LIB(iconv, iconv, [_ICONV_LIBS="$_ICONV_LIBS -liconv"],
  3170. AC_CHECK_LIB(iconv, libiconv, [_ICONV_LIBS="$_ICONV_LIBS -liconv"])))
  3171. _SAVE_LIBS=$LIBS
  3172. LIBS="$LIBS $_ICONV_LIBS"
  3173. AC_CACHE_CHECK(
  3174. [for iconv()],
  3175. ac_cv_func_iconv,
  3176. [AC_TRY_LINK([
  3177. #include <stdlib.h>
  3178. #include <iconv.h>
  3179. ],
  3180. [
  3181. iconv_t h = iconv_open("", "");
  3182. iconv(h, NULL, NULL, NULL, NULL);
  3183. iconv_close(h);
  3184. ],
  3185. [ac_cv_func_iconv=yes],
  3186. [ac_cv_func_iconv=no]
  3187. )]
  3188. )
  3189. if test "$ac_cv_func_iconv" = "yes"; then
  3190. AC_DEFINE(HAVE_ICONV)
  3191. DYNAMIC_XPCOM_LIBS="$DYNAMIC_XPCOM_LIBS $_ICONV_LIBS"
  3192. LIBXUL_LIBS="$LIBXUL_LIBS $_ICONV_LIBS"
  3193. LIBICONV="$_ICONV_LIBS"
  3194. AC_CACHE_CHECK(
  3195. [for iconv() with const input],
  3196. ac_cv_func_const_iconv,
  3197. [AC_TRY_COMPILE([
  3198. #include <stdlib.h>
  3199. #include <iconv.h>
  3200. ],
  3201. [
  3202. const char *input = "testing";
  3203. iconv_t h = iconv_open("", "");
  3204. iconv(h, &input, NULL, NULL, NULL);
  3205. iconv_close(h);
  3206. ],
  3207. [ac_cv_func_const_iconv=yes],
  3208. [ac_cv_func_const_iconv=no]
  3209. )]
  3210. )
  3211. if test "$ac_cv_func_const_iconv" = "yes"; then
  3212. AC_DEFINE(HAVE_ICONV_WITH_CONST_INPUT)
  3213. fi
  3214. fi
  3215. LIBS=$_SAVE_LIBS
  3216. ;;
  3217. esac
  3218. AC_LANG_C
  3219. dnl **********************
  3220. dnl *** va_copy checks ***
  3221. dnl **********************
  3222. dnl we currently check for all three va_copy possibilities, so we get
  3223. dnl all results in config.log for bug reports.
  3224. AC_MSG_CHECKING(for an implementation of va_copy())
  3225. AC_CACHE_VAL(ac_cv_va_copy,[
  3226. AC_TRY_RUN([
  3227. #include <stdarg.h>
  3228. void f (int i, ...) {
  3229. va_list args1, args2;
  3230. va_start (args1, i);
  3231. va_copy (args2, args1);
  3232. if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
  3233. exit (1);
  3234. va_end (args1); va_end (args2);
  3235. }
  3236. int main() { f (0, 42); return 0; }],
  3237. ac_cv_va_copy=yes,
  3238. ac_cv_va_copy=no,
  3239. ac_cv_va_copy=no
  3240. )
  3241. ])
  3242. AC_MSG_RESULT($ac_cv_va_copy)
  3243. AC_MSG_CHECKING(for an implementation of __va_copy())
  3244. AC_CACHE_VAL(ac_cv___va_copy,[
  3245. AC_TRY_RUN([
  3246. #include <stdarg.h>
  3247. void f (int i, ...) {
  3248. va_list args1, args2;
  3249. va_start (args1, i);
  3250. __va_copy (args2, args1);
  3251. if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
  3252. exit (1);
  3253. va_end (args1); va_end (args2);
  3254. }
  3255. int main() { f (0, 42); return 0; }],
  3256. ac_cv___va_copy=yes,
  3257. ac_cv___va_copy=no,
  3258. ac_cv___va_copy=no
  3259. )
  3260. ])
  3261. AC_MSG_RESULT($ac_cv___va_copy)
  3262. AC_MSG_CHECKING(whether va_lists can be copied by value)
  3263. AC_CACHE_VAL(ac_cv_va_val_copy,[
  3264. AC_TRY_RUN([
  3265. #include <stdarg.h>
  3266. void f (int i, ...) {
  3267. va_list args1, args2;
  3268. va_start (args1, i);
  3269. args2 = args1;
  3270. if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
  3271. exit (1);
  3272. va_end (args1); va_end (args2);
  3273. }
  3274. int main() { f (0, 42); return 0; }],
  3275. ac_cv_va_val_copy=yes,
  3276. ac_cv_va_val_copy=no,
  3277. ac_cv_va_val_copy=yes
  3278. )
  3279. ])
  3280. if test "x$ac_cv_va_copy" = "xyes"; then
  3281. AC_DEFINE(VA_COPY, va_copy)
  3282. AC_DEFINE(HAVE_VA_COPY)
  3283. elif test "x$ac_cv___va_copy" = "xyes"; then
  3284. AC_DEFINE(VA_COPY, __va_copy)
  3285. AC_DEFINE(HAVE_VA_COPY)
  3286. fi
  3287. if test "x$ac_cv_va_val_copy" = "xno"; then
  3288. AC_DEFINE(HAVE_VA_LIST_AS_ARRAY)
  3289. fi
  3290. AC_MSG_RESULT($ac_cv_va_val_copy)
  3291. dnl ===================================================================
  3292. dnl ========================================================
  3293. dnl Put your C++ language/feature checks below
  3294. dnl ========================================================
  3295. AC_LANG_CPLUSPLUS
  3296. ARM_ABI_PREFIX=
  3297. if test "$GNU_CC"; then
  3298. if test "$CPU_ARCH" = "arm" ; then
  3299. AC_CACHE_CHECK(for ARM EABI,
  3300. ac_cv_gcc_arm_eabi,
  3301. [AC_TRY_COMPILE([],
  3302. [
  3303. #if defined(__ARM_EABI__)
  3304. return 0;
  3305. #else
  3306. #error Not ARM EABI.
  3307. #endif
  3308. ],
  3309. ac_cv_gcc_arm_eabi="yes",
  3310. ac_cv_gcc_arm_eabi="no")])
  3311. if test "$ac_cv_gcc_arm_eabi" = "yes"; then
  3312. HAVE_ARM_EABI=1
  3313. ARM_ABI_PREFIX=eabi-
  3314. else
  3315. ARM_ABI_PREFIX=oabi-
  3316. fi
  3317. fi
  3318. TARGET_COMPILER_ABI="${TARGET_COMPILER_ABI-${ARM_ABI_PREFIX}gcc3}"
  3319. fi
  3320. dnl Check for support of modern template specialization syntax
  3321. dnl Test code and requirement from scc@netscape.com.
  3322. dnl Autoconf cut-and-paste job by waterson@netscape.com
  3323. AC_CACHE_CHECK(for modern C++ template specialization syntax support,
  3324. ac_cv_cpp_modern_specialize_template_syntax,
  3325. [AC_TRY_COMPILE(template <class T> struct X { int a; };
  3326. class Y {};
  3327. template <> struct X<Y> { double a; };,
  3328. X<int> int_x;
  3329. X<Y> y_x;,
  3330. ac_cv_cpp_modern_specialize_template_syntax=yes,
  3331. ac_cv_cpp_modern_specialize_template_syntax=no)])
  3332. if test "$ac_cv_cpp_modern_specialize_template_syntax" = no ; then
  3333. AC_MSG_ERROR([The C++ compiler does not support template specialization])
  3334. fi
  3335. dnl Some compilers support only full specialization, and some don't.
  3336. AC_CACHE_CHECK(whether partial template specialization works,
  3337. ac_cv_cpp_partial_specialization,
  3338. [AC_TRY_COMPILE(template <class T> class Foo {};
  3339. template <class T> class Foo<T*> {};,
  3340. return 0;,
  3341. ac_cv_cpp_partial_specialization=yes,
  3342. ac_cv_cpp_partial_specialization=no)])
  3343. if test "$ac_cv_cpp_partial_specialization" = yes ; then
  3344. AC_DEFINE(HAVE_CPP_PARTIAL_SPECIALIZATION)
  3345. fi
  3346. dnl Check to see if we can resolve ambiguity with |using|.
  3347. AC_CACHE_CHECK(whether the C++ \"using\" keyword resolves ambiguity,
  3348. ac_cv_cpp_ambiguity_resolving_using,
  3349. [AC_TRY_COMPILE(class X {
  3350. public: int go(const X&) {return 3;}
  3351. int jo(const X&) {return 3;}
  3352. };
  3353. class Y : public X {
  3354. public: int go(int) {return 2;}
  3355. int jo(int) {return 2;}
  3356. using X::jo;
  3357. private: using X::go;
  3358. };,
  3359. X x; Y y; y.jo(x);,
  3360. ac_cv_cpp_ambiguity_resolving_using=yes,
  3361. ac_cv_cpp_ambiguity_resolving_using=no)])
  3362. if test "$ac_cv_cpp_ambiguity_resolving_using" = yes ; then
  3363. AC_DEFINE(HAVE_CPP_AMBIGUITY_RESOLVING_USING)
  3364. fi
  3365. dnl See if a dynamic_cast to void* gives the most derived object.
  3366. AC_CACHE_CHECK(for C++ dynamic_cast to void*,
  3367. ac_cv_cpp_dynamic_cast_void_ptr,
  3368. [AC_TRY_RUN([class X { int i; public: virtual ~X() { } };
  3369. class Y { int j; public: virtual ~Y() { } };
  3370. class Z : public X, public Y { int k; };
  3371. int main() {
  3372. Z mdo;
  3373. X *subx = (X*)&mdo;
  3374. Y *suby = (Y*)&mdo;
  3375. return !((((void*)&mdo != (void*)subx) &&
  3376. ((void*)&mdo == dynamic_cast<void*>(subx))) ||
  3377. (((void*)&mdo != (void*)suby) &&
  3378. ((void*)&mdo == dynamic_cast<void*>(suby))));
  3379. }],
  3380. ac_cv_cpp_dynamic_cast_void_ptr=yes,
  3381. ac_cv_cpp_dynamic_cast_void_ptr=no,
  3382. ac_cv_cpp_dynamic_cast_void_ptr=no)])
  3383. if test "$ac_cv_cpp_dynamic_cast_void_ptr" = yes ; then
  3384. AC_DEFINE(HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR)
  3385. fi
  3386. dnl note that this one is reversed - if the test fails, then
  3387. dnl we require implementations of unused virtual methods. Which
  3388. dnl really blows because it means we'll have useless vtable
  3389. dnl bloat.
  3390. AC_CACHE_CHECK(whether C++ requires implementation of unused virtual methods,
  3391. ac_cv_cpp_unused_required,
  3392. [AC_TRY_LINK(class X {private: virtual void never_called();};,
  3393. X x;,
  3394. ac_cv_cpp_unused_required=no,
  3395. ac_cv_cpp_unused_required=yes)])
  3396. if test "$ac_cv_cpp_unused_required" = yes ; then
  3397. AC_DEFINE(NEED_CPP_UNUSED_IMPLEMENTATIONS)
  3398. fi
  3399. dnl Some compilers have trouble comparing a constant reference to a templatized
  3400. dnl class to zero, and require an explicit operator==() to be defined that takes
  3401. dnl an int. This test separates the strong from the weak.
  3402. AC_CACHE_CHECK(for trouble comparing to zero near std::operator!=(),
  3403. ac_cv_trouble_comparing_to_zero,
  3404. [AC_TRY_COMPILE([#include <algorithm>
  3405. template <class T> class Foo {};
  3406. class T2;
  3407. template <class T> int operator==(const T2*, const T&) { return 0; }
  3408. template <class T> int operator!=(const T2*, const T&) { return 0; }],
  3409. [Foo<int> f; return (0 != f);],
  3410. ac_cv_trouble_comparing_to_zero=no,
  3411. ac_cv_trouble_comparing_to_zero=yes)])
  3412. if test "$ac_cv_trouble_comparing_to_zero" = yes ; then
  3413. AC_DEFINE(HAVE_CPP_TROUBLE_COMPARING_TO_ZERO)
  3414. fi
  3415. # try harder, when checking for __thread support, see bug 521750 comment #33 and below
  3416. # We pass MOZ_OPTIMIZE_LDFLAGS to the linker because if dead_strip is
  3417. # enabled, the linker in xcode 4.1 will crash. Without this it would crash when
  3418. # linking XUL.
  3419. _SAVE_LDFLAGS=$LDFLAGS
  3420. LDFLAGS="$LDFLAGS $DSO_PIC_CFLAGS $DSO_LDOPTS $MOZ_OPTIMIZE_LDFLAGS"
  3421. AC_CACHE_CHECK(for __thread keyword for TLS variables,
  3422. ac_cv_thread_keyword,
  3423. [AC_TRY_LINK([__thread bool tlsIsMainThread = false;],
  3424. [return tlsIsMainThread;],
  3425. ac_cv_thread_keyword=yes,
  3426. ac_cv_thread_keyword=no)])
  3427. LDFLAGS=$_SAVE_LDFLAGS
  3428. if test "$ac_cv_thread_keyword" = yes; then
  3429. # mips builds fail with TLS variables because of a binutils bug.
  3430. # See bug 528687
  3431. case "${target}" in
  3432. mips*-*)
  3433. :
  3434. ;;
  3435. *-android*|*-linuxandroid*)
  3436. :
  3437. ;;
  3438. *)
  3439. AC_DEFINE(HAVE_THREAD_TLS_KEYWORD)
  3440. ;;
  3441. esac
  3442. fi
  3443. dnl Check for the existence of various allocation headers/functions
  3444. MALLOC_H=
  3445. MOZ_CHECK_HEADER(malloc.h, [MALLOC_H=malloc.h])
  3446. if test "$MALLOC_H" = ""; then
  3447. MOZ_CHECK_HEADER(malloc/malloc.h, [MALLOC_H=malloc/malloc.h])
  3448. if test "$MALLOC_H" = ""; then
  3449. MOZ_CHECK_HEADER(sys/malloc.h, [MALLOC_H=sys/malloc.h])
  3450. fi
  3451. fi
  3452. if test "$MALLOC_H" != ""; then
  3453. AC_DEFINE_UNQUOTED(MALLOC_H, <$MALLOC_H>)
  3454. fi
  3455. MOZ_ALLOCATING_FUNCS="strndup posix_memalign memalign valloc"
  3456. AC_CHECK_FUNCS(strndup posix_memalign memalign valloc)
  3457. dnl See if compiler supports some gcc-style attributes
  3458. AC_CACHE_CHECK(for __attribute__((always_inline)),
  3459. ac_cv_attribute_always_inline,
  3460. [AC_TRY_COMPILE([inline void f(void) __attribute__((always_inline));],
  3461. [],
  3462. ac_cv_attribute_always_inline=yes,
  3463. ac_cv_attribute_always_inline=no)])
  3464. AC_CACHE_CHECK(for __attribute__((malloc)),
  3465. ac_cv_attribute_malloc,
  3466. [AC_TRY_COMPILE([void* f(int) __attribute__((malloc));],
  3467. [],
  3468. ac_cv_attribute_malloc=yes,
  3469. ac_cv_attribute_malloc=no)])
  3470. AC_CACHE_CHECK(for __attribute__((warn_unused_result)),
  3471. ac_cv_attribute_warn_unused,
  3472. [AC_TRY_COMPILE([int f(void) __attribute__((warn_unused_result));],
  3473. [],
  3474. ac_cv_attribute_warn_unused=yes,
  3475. ac_cv_attribute_warn_unused=no)])
  3476. dnl End of C++ language/feature checks
  3477. AC_LANG_C
  3478. dnl ========================================================
  3479. dnl = Internationalization checks
  3480. dnl ========================================================
  3481. dnl
  3482. dnl Internationalization and Locale support is different
  3483. dnl on various UNIX platforms. Checks for specific i18n
  3484. dnl features go here.
  3485. dnl check for LC_MESSAGES
  3486. AC_CACHE_CHECK(for LC_MESSAGES,
  3487. ac_cv_i18n_lc_messages,
  3488. [AC_TRY_COMPILE([#include <locale.h>],
  3489. [int category = LC_MESSAGES;],
  3490. ac_cv_i18n_lc_messages=yes,
  3491. ac_cv_i18n_lc_messages=no)])
  3492. if test "$ac_cv_i18n_lc_messages" = yes; then
  3493. AC_DEFINE(HAVE_I18N_LC_MESSAGES)
  3494. fi
  3495. AC_HAVE_FUNCS(localeconv)
  3496. fi # ! SKIP_COMPILER_CHECKS
  3497. TARGET_XPCOM_ABI=
  3498. if test -n "${CPU_ARCH}" -a -n "${TARGET_COMPILER_ABI}"; then
  3499. TARGET_XPCOM_ABI="${CPU_ARCH}-${TARGET_COMPILER_ABI}"
  3500. fi
  3501. dnl Mozilla specific options
  3502. dnl ========================================================
  3503. dnl The macros used for command line options
  3504. dnl are defined in build/autoconf/altoptions.m4.
  3505. dnl If the compiler supports these attributes, define them as
  3506. dnl convenience macros.
  3507. if test "$ac_cv_attribute_always_inline" = yes ; then
  3508. AC_DEFINE(NS_ALWAYS_INLINE, [__attribute__((always_inline))])
  3509. else
  3510. AC_DEFINE(NS_ALWAYS_INLINE,)
  3511. fi
  3512. if test "$ac_cv_attribute_malloc" = yes ; then
  3513. AC_DEFINE(NS_ATTR_MALLOC, [__attribute__((malloc))])
  3514. else
  3515. AC_DEFINE(NS_ATTR_MALLOC,)
  3516. fi
  3517. if test "$ac_cv_attribute_warn_unused" = yes ; then
  3518. AC_DEFINE(NS_WARN_UNUSED_RESULT, [__attribute__((warn_unused_result))])
  3519. else
  3520. AC_DEFINE(NS_WARN_UNUSED_RESULT,)
  3521. fi
  3522. dnl We can't run TRY_COMPILE tests on Windows, so hard-code some
  3523. dnl features that Windows actually does support.
  3524. if test -n "$SKIP_COMPILER_CHECKS"; then
  3525. dnl Windows has malloc.h
  3526. AC_DEFINE(MALLOC_H, [<malloc.h>])
  3527. AC_DEFINE(HAVE_FORCEINLINE)
  3528. AC_DEFINE(HAVE_LOCALECONV)
  3529. fi # SKIP_COMPILER_CHECKS
  3530. dnl ========================================================
  3531. dnl =
  3532. dnl = Check for external package dependencies
  3533. dnl =
  3534. dnl ========================================================
  3535. MOZ_ARG_HEADER(External Packages)
  3536. dnl ========================================================
  3537. dnl = Find the right NSPR to use.
  3538. dnl ========================================================
  3539. MOZ_ARG_WITH_BOOL(system-nspr,
  3540. [ --with-system-nspr Use an NSPR that is already built and installed.
  3541. Use the 'nspr-config' script in the current path,
  3542. or look for the script in the directories given with
  3543. --with-nspr-exec-prefix or --with-nspr-prefix.
  3544. (Those flags are only checked if you specify
  3545. --with-system-nspr.)],
  3546. _USE_SYSTEM_NSPR=1 )
  3547. MOZ_ARG_WITH_STRING(nspr-cflags,
  3548. [ --with-nspr-cflags=FLAGS
  3549. Pass FLAGS to CC when building code that uses NSPR.
  3550. Use this when there's no accurate nspr-config
  3551. script available. This is the case when building
  3552. SpiderMonkey as part of the Mozilla tree: the
  3553. top-level configure script computes NSPR flags
  3554. that accomodate the quirks of that environment.],
  3555. NSPR_CFLAGS=$withval)
  3556. MOZ_ARG_WITH_STRING(nspr-libs,
  3557. [ --with-nspr-libs=LIBS Pass LIBS to LD when linking code that uses NSPR.
  3558. See --with-nspr-cflags for more details.],
  3559. NSPR_LIBS=$withval)
  3560. AC_SUBST(NSPR_CFLAGS)
  3561. AC_SUBST(NSPR_LIBS)
  3562. dnl Pass either --with-system-nspr or (--with-nspr-cflags and
  3563. dnl --with-nspr-libs), but not both.
  3564. if test "$_USE_SYSTEM_NSPR" && (test "$NSPR_CFLAGS" -o "$NSPR_LIBS"); then
  3565. AC_MSG_ERROR([--with-system-nspr and --with-nspr-libs/cflags are mutually exclusive.
  3566. See 'configure --help'.])
  3567. fi
  3568. dnl Top-level Mozilla switched to requiring NSPR 4.8.6 (bug 560582), but we don't need it in JS.
  3569. if test -n "$_USE_SYSTEM_NSPR"; then
  3570. MOZ_NATIVE_NSPR=
  3571. AM_PATH_NSPR(4.7.0, [MOZ_NATIVE_NSPR=1], [AC_MSG_ERROR([your don't have NSPR installed or your version is too old])])
  3572. fi
  3573. if test -n "$MOZ_NATIVE_NSPR"; then
  3574. _SAVE_CFLAGS=$CFLAGS
  3575. CFLAGS="$CFLAGS $NSPR_CFLAGS"
  3576. AC_TRY_COMPILE([#include "prlog.h"],
  3577. [#ifndef PR_STATIC_ASSERT
  3578. #error PR_STATIC_ASSERT not defined
  3579. #endif],
  3580. [MOZ_NATIVE_NSPR=1],
  3581. AC_MSG_ERROR([system NSPR does not support PR_STATIC_ASSERT]))
  3582. CFLAGS=$_SAVE_CFLAGS
  3583. fi
  3584. dnl ========================================================
  3585. dnl system libffi Support
  3586. dnl ========================================================
  3587. MOZ_ARG_ENABLE_BOOL(system-ffi,
  3588. [ --enable-system-ffi Use system libffi (located with pkgconfig)],
  3589. MOZ_NATIVE_FFI=1 )
  3590. if test -n "$MOZ_NATIVE_FFI"; then
  3591. # Vanilla libffi 3.0.9 needs a few patches from upcoming version 3.0.10
  3592. # for non-GCC compilers.
  3593. if test -z "$GNU_CC"; then
  3594. PKG_CHECK_MODULES(MOZ_FFI, libffi > 3.0.9)
  3595. else
  3596. PKG_CHECK_MODULES(MOZ_FFI, libffi >= 3.0.9)
  3597. fi
  3598. fi
  3599. AC_SUBST(MOZ_NATIVE_FFI)
  3600. dnl ========================================================
  3601. dnl =
  3602. dnl = Application
  3603. dnl =
  3604. dnl ========================================================
  3605. MOZ_ARG_HEADER(Application)
  3606. ENABLE_TESTS=1
  3607. USE_ARM_KUSER=
  3608. case "${target}" in
  3609. arm*-android*|arm*-linuxandroid*)
  3610. USE_ARM_KUSER=1
  3611. ;;
  3612. esac
  3613. dnl ========================================================
  3614. dnl Use ARM userspace kernel helpers; tell NSPR to enable
  3615. dnl their usage and use them in spidermonkey.
  3616. dnl ========================================================
  3617. MOZ_ARG_WITH_BOOL(arm-kuser,
  3618. [ --with-arm-kuser Use kuser helpers (Linux/ARM only -- requires kernel 2.6.13 or later)],
  3619. USE_ARM_KUSER=1,)
  3620. if test -n "$USE_ARM_KUSER"; then
  3621. AC_DEFINE(USE_ARM_KUSER)
  3622. fi
  3623. dnl ========================================================
  3624. dnl =
  3625. dnl = Components & Features
  3626. dnl =
  3627. dnl ========================================================
  3628. MOZ_ARG_HEADER(Components and Features)
  3629. dnl ========================================================
  3630. dnl = Localization
  3631. dnl ========================================================
  3632. MOZ_ARG_ENABLE_STRING(ui-locale,
  3633. [ --enable-ui-locale=ab-CD
  3634. Select the user interface locale (default: en-US)],
  3635. MOZ_UI_LOCALE=$enableval )
  3636. AC_SUBST(MOZ_UI_LOCALE)
  3637. dnl ========================================================
  3638. dnl build the tests by default
  3639. dnl ========================================================
  3640. MOZ_ARG_DISABLE_BOOL(tests,
  3641. [ --disable-tests Do not build test libraries & programs],
  3642. ENABLE_TESTS=,
  3643. ENABLE_TESTS=1 )
  3644. dnl ========================================================
  3645. dnl =
  3646. dnl = Module specific options
  3647. dnl =
  3648. dnl ========================================================
  3649. MOZ_ARG_HEADER(Individual module options)
  3650. dnl ========================================================
  3651. dnl =
  3652. dnl = Debugging Options
  3653. dnl =
  3654. dnl ========================================================
  3655. MOZ_ARG_HEADER(Debugging and Optimizations)
  3656. dnl ========================================================
  3657. dnl = Disable building with debug info.
  3658. dnl = Debugging is OFF by default
  3659. dnl ========================================================
  3660. if test -z "$MOZ_DEBUG_FLAGS"; then
  3661. MOZ_DEBUG_FLAGS="-g"
  3662. fi
  3663. MOZ_ARG_ENABLE_STRING(debug,
  3664. [ --enable-debug[=DBG] Enable building with developer debug info
  3665. (using compiler flags DBG)],
  3666. [ if test "$enableval" != "no"; then
  3667. MOZ_DEBUG=1
  3668. if test -n "$enableval" -a "$enableval" != "yes"; then
  3669. MOZ_DEBUG_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'`
  3670. _MOZ_DEBUG_FLAGS_SET=1
  3671. fi
  3672. else
  3673. MOZ_DEBUG=
  3674. fi ],
  3675. MOZ_DEBUG=)
  3676. MOZ_DEBUG_ENABLE_DEFS="-DDEBUG -D_DEBUG -DTRACING"
  3677. MOZ_ARG_WITH_STRING(debug-label,
  3678. [ --with-debug-label=LABELS
  3679. Define DEBUG_<value> for each comma-separated
  3680. value given.],
  3681. [ for option in `echo $withval | sed 's/,/ /g'`; do
  3682. MOZ_DEBUG_ENABLE_DEFS="$MOZ_DEBUG_ENABLE_DEFS -DDEBUG_${option}"
  3683. done])
  3684. MOZ_DEBUG_DISABLE_DEFS="-DNDEBUG -DTRIMMED"
  3685. if test -n "$MOZ_DEBUG"; then
  3686. AC_MSG_CHECKING([for valid debug flags])
  3687. _SAVE_CFLAGS=$CFLAGS
  3688. CFLAGS="$CFLAGS $MOZ_DEBUG_FLAGS"
  3689. AC_TRY_COMPILE([#include <stdio.h>],
  3690. [printf("Hello World\n");],
  3691. _results=yes,
  3692. _results=no)
  3693. AC_MSG_RESULT([$_results])
  3694. if test "$_results" = "no"; then
  3695. AC_MSG_ERROR([These compiler flags are invalid: $MOZ_DEBUG_FLAGS])
  3696. fi
  3697. CFLAGS=$_SAVE_CFLAGS
  3698. fi
  3699. dnl ========================================================
  3700. dnl = Enable code optimization. ON by default.
  3701. dnl ========================================================
  3702. if test -z "$MOZ_OPTIMIZE_FLAGS"; then
  3703. MOZ_OPTIMIZE_FLAGS="-O"
  3704. fi
  3705. MOZ_ARG_ENABLE_STRING(optimize,
  3706. [ --disable-optimize Disable compiler optimization
  3707. --enable-optimize=[OPT] Specify compiler optimization flags [OPT=-O]],
  3708. [ if test "$enableval" != "no"; then
  3709. MOZ_OPTIMIZE=1
  3710. if test -n "$enableval" -a "$enableval" != "yes"; then
  3711. MOZ_OPTIMIZE_FLAGS=`echo "$enableval" | sed -e 's|\\\ | |g'`
  3712. MOZ_OPTIMIZE=2
  3713. fi
  3714. else
  3715. MOZ_OPTIMIZE=
  3716. fi ], MOZ_OPTIMIZE=1)
  3717. MOZ_SET_FRAMEPTR_FLAGS
  3718. if test "$COMPILE_ENVIRONMENT"; then
  3719. if test -n "$MOZ_OPTIMIZE"; then
  3720. AC_MSG_CHECKING([for valid optimization flags])
  3721. _SAVE_CFLAGS=$CFLAGS
  3722. CFLAGS="$CFLAGS $MOZ_OPTIMIZE_FLAGS"
  3723. AC_TRY_COMPILE([#include <stdio.h>],
  3724. [printf("Hello World\n");],
  3725. _results=yes,
  3726. _results=no)
  3727. AC_MSG_RESULT([$_results])
  3728. if test "$_results" = "no"; then
  3729. AC_MSG_ERROR([These compiler flags are invalid: $MOZ_OPTIMIZE_FLAGS])
  3730. fi
  3731. CFLAGS=$_SAVE_CFLAGS
  3732. fi
  3733. fi # COMPILE_ENVIRONMENT
  3734. AC_SUBST(MOZ_OPTIMIZE)
  3735. AC_SUBST(MOZ_FRAMEPTR_FLAGS)
  3736. AC_SUBST(MOZ_OPTIMIZE_FLAGS)
  3737. AC_SUBST(MOZ_OPTIMIZE_LDFLAGS)
  3738. AC_SUBST(MOZ_OPTIMIZE_SIZE_TWEAK)
  3739. AC_SUBST(MOZ_PGO_OPTIMIZE_FLAGS)
  3740. dnl ========================================================
  3741. dnl = Enable generation of debug symbols
  3742. dnl ========================================================
  3743. MOZ_ARG_ENABLE_STRING(debug-symbols,
  3744. [ --enable-debug-symbols[=DBG]
  3745. Enable debugging symbols (using compiler flags DBG)],
  3746. [ if test "$enableval" != "no"; then
  3747. MOZ_DEBUG_SYMBOLS=1
  3748. if test -n "$enableval" -a "$enableval" != "yes"; then
  3749. if test -z "$_MOZ_DEBUG_FLAGS_SET"; then
  3750. MOZ_DEBUG_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'`
  3751. else
  3752. AC_MSG_ERROR([--enable-debug-symbols flags cannot be used with --enable-debug flags])
  3753. fi
  3754. fi
  3755. else
  3756. MOZ_DEBUG_SYMBOLS=
  3757. fi ],
  3758. MOZ_DEBUG_SYMBOLS=1)
  3759. if test -n "$MOZ_DEBUG" -o -n "$MOZ_DEBUG_SYMBOLS"; then
  3760. AC_DEFINE(MOZ_DEBUG_SYMBOLS)
  3761. export MOZ_DEBUG_SYMBOLS
  3762. fi
  3763. dnl ========================================================
  3764. dnl = Enable any treating of compile warnings as errors
  3765. dnl ========================================================
  3766. MOZ_ARG_DISABLE_BOOL(warnings-as-errors,
  3767. [ --enable-warnings-as-errors
  3768. Enable treating of warnings as errors],
  3769. MOZ_ENABLE_WARNINGS_AS_ERRORS=1,
  3770. MOZ_ENABLE_WARNINGS_AS_ERRORS=)
  3771. if test -z "$MOZ_ENABLE_WARNINGS_AS_ERRORS"; then
  3772. WARNINGS_AS_ERRORS=''
  3773. fi
  3774. dnl ========================================================
  3775. dnl = Enable treating compile warnings as errors
  3776. dnl ========================================================
  3777. MOZ_ARG_ENABLE_BOOL(sm-fail-on-warnings,
  3778. [ --enable-sm-fail-on-warnings
  3779. Enable warnings as errors],
  3780. FAIL_ON_WARNINGS=1,
  3781. FAIL_ON_WARNINGS= )
  3782. AC_SUBST(FAIL_ON_WARNINGS)
  3783. dnl = Enable trace malloc
  3784. dnl ========================================================
  3785. NS_TRACE_MALLOC=${MOZ_TRACE_MALLOC}
  3786. MOZ_ARG_ENABLE_BOOL(trace-malloc,
  3787. [ --enable-trace-malloc Enable malloc tracing],
  3788. NS_TRACE_MALLOC=1,
  3789. NS_TRACE_MALLOC= )
  3790. if test "$NS_TRACE_MALLOC"; then
  3791. # Please, Mr. Linker Man, don't take away our symbol names
  3792. MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS=
  3793. AC_DEFINE(NS_TRACE_MALLOC)
  3794. fi
  3795. AC_SUBST(NS_TRACE_MALLOC)
  3796. dnl ========================================================
  3797. dnl = Enable jemalloc
  3798. dnl ========================================================
  3799. MOZ_ARG_ENABLE_BOOL(jemalloc,
  3800. [ --enable-jemalloc Replace memory allocator with jemalloc],
  3801. MOZ_MEMORY=1,
  3802. MOZ_MEMORY=)
  3803. if test "$NS_TRACE_MALLOC"; then
  3804. MOZ_MEMORY=
  3805. fi
  3806. if test "$MOZ_MEMORY"; then
  3807. dnl Don't try to run compiler tests on Windows
  3808. if test "$OS_ARCH" = "WINNT"; then
  3809. if test -z "$HAVE_64BIT_OS"; then
  3810. AC_DEFINE_UNQUOTED([MOZ_MEMORY_SIZEOF_PTR_2POW], 2)
  3811. else
  3812. AC_DEFINE_UNQUOTED([MOZ_MEMORY_SIZEOF_PTR_2POW], 3)
  3813. fi
  3814. else
  3815. AC_CHECK_SIZEOF([int *], [4])
  3816. case "${ac_cv_sizeof_int_p}" in
  3817. 4)
  3818. AC_DEFINE_UNQUOTED([MOZ_MEMORY_SIZEOF_PTR_2POW], 2)
  3819. ;;
  3820. 8)
  3821. AC_DEFINE_UNQUOTED([MOZ_MEMORY_SIZEOF_PTR_2POW], 3)
  3822. ;;
  3823. *)
  3824. AC_MSG_ERROR([Unexpected pointer size])
  3825. ;;
  3826. esac
  3827. fi
  3828. AC_DEFINE(MOZ_MEMORY)
  3829. if test "x$MOZ_DEBUG" = "x1"; then
  3830. AC_DEFINE(MOZ_MEMORY_DEBUG)
  3831. fi
  3832. dnl The generic feature tests that determine how to compute ncpus are long and
  3833. dnl complicated. Therefore, simply define special cpp variables for the
  3834. dnl platforms we have special knowledge of.
  3835. case "${target}" in
  3836. *-darwin*)
  3837. AC_DEFINE(MOZ_MEMORY_DARWIN)
  3838. ;;
  3839. *-*freebsd*)
  3840. AC_DEFINE(MOZ_MEMORY_BSD)
  3841. ;;
  3842. *-android*|*-linuxandroid*)
  3843. AC_DEFINE(MOZ_MEMORY_LINUX)
  3844. AC_DEFINE(MOZ_MEMORY_ANDROID)
  3845. ;;
  3846. *-*linux*)
  3847. AC_DEFINE(MOZ_MEMORY_LINUX)
  3848. ;;
  3849. *-netbsd*)
  3850. AC_DEFINE(MOZ_MEMORY_BSD)
  3851. ;;
  3852. *-solaris*)
  3853. AC_DEFINE(MOZ_MEMORY_SOLARIS)
  3854. ;;
  3855. *-mingw*)
  3856. AC_DEFINE(MOZ_MEMORY_WINDOWS)
  3857. # the interesting bits will get passed down in MOZ_GLUE_LDFLAGS
  3858. ;;
  3859. *)
  3860. AC_MSG_ERROR([--enable-jemalloc not supported on ${target}])
  3861. ;;
  3862. esac
  3863. if test "$OS_ARCH" != "Darwin"; then
  3864. dnl NB: this must be kept in sync with jemalloc.h
  3865. AC_DEFINE(HAVE_JEMALLOC_VALLOC)
  3866. AC_DEFINE(HAVE_JEMALLOC_POSIX_MEMALIGN)
  3867. AC_DEFINE(HAVE_JEMALLOC_MEMALIGN)
  3868. fi
  3869. fi
  3870. AC_SUBST(MOZ_MEMORY)
  3871. AC_SUBST(MOZ_GLUE_LDFLAGS)
  3872. AC_SUBST(MOZ_GLUE_PROGRAM_LDFLAGS)
  3873. dnl ========================================================
  3874. dnl = Use malloc wrapper lib
  3875. dnl ========================================================
  3876. MOZ_ARG_ENABLE_BOOL(wrap-malloc,
  3877. [ --enable-wrap-malloc Wrap malloc calls (gnu linker only)],
  3878. _WRAP_MALLOC=1,
  3879. _WRAP_MALLOC= )
  3880. if test -n "$_WRAP_MALLOC"; then
  3881. if test "$GNU_CC"; then
  3882. WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=malloc,--wrap=calloc,--wrap=valloc,--wrap=free,--wrap=realloc,--wrap=memalign"
  3883. WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=__builtin_new,--wrap=__builtin_vec_new,--wrap=__builtin_delete,--wrap=__builtin_vec_delete"
  3884. WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=PR_Free,--wrap=PR_Malloc,--wrap=PR_Calloc,--wrap=PR_Realloc"
  3885. WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=strdup,--wrap=strndup"
  3886. WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=posix_memalign,--wrap=malloc_usable_size"
  3887. else
  3888. AC_MSG_ERROR([--enable-wrap-malloc is not supported for non-GNU toolchains])
  3889. fi
  3890. fi
  3891. dnl ========================================================
  3892. dnl = Location of malloc wrapper lib
  3893. dnl ========================================================
  3894. MOZ_ARG_WITH_STRING(wrap-malloc,
  3895. [ --with-wrap-malloc=DIR Location of malloc wrapper library],
  3896. WRAP_LDFLAGS="${WRAP_LDFLAGS} $withval")
  3897. dnl ========================================================
  3898. dnl = Use JS Call tracing
  3899. dnl ========================================================
  3900. MOZ_ARG_ENABLE_BOOL(trace-jscalls,
  3901. [ --enable-trace-jscalls Enable JS call enter/exit callback (default=no)],
  3902. MOZ_TRACE_JSCALLS=1,
  3903. MOZ_TRACE_JSCALLS= )
  3904. if test -n "$MOZ_TRACE_JSCALLS"; then
  3905. AC_DEFINE(MOZ_TRACE_JSCALLS)
  3906. fi
  3907. dnl ========================================================
  3908. dnl = Use incremental GC
  3909. dnl ========================================================
  3910. JSGC_INCREMENTAL=1
  3911. MOZ_ARG_DISABLE_BOOL(gcincremental,
  3912. [ --disable-gcincremental Disable incremental GC],
  3913. JSGC_INCREMENTAL= )
  3914. if test -n "$JSGC_INCREMENTAL"; then
  3915. AC_DEFINE(JSGC_INCREMENTAL)
  3916. fi
  3917. dnl ========================================================
  3918. dnl = Use generational GC
  3919. dnl ========================================================
  3920. MOZ_ARG_ENABLE_BOOL(gcgenerational,
  3921. [ --enable-gcgenerational Enable generational GC],
  3922. JSGC_GENERATIONAL=1,
  3923. JSGC_GENERATIONAL= )
  3924. if test -n "$JSGC_GENERATIONAL"; then
  3925. AC_DEFINE(JSGC_GENERATIONAL)
  3926. fi
  3927. dnl ========================================================
  3928. dnl = Perform moving GC stack rooting analysis
  3929. dnl ========================================================
  3930. MOZ_ARG_ENABLE_BOOL(gcrootanalysis,
  3931. [ --enable-root-analysis Enable moving GC stack root analysis],
  3932. JSGC_ROOT_ANALYSIS=1,
  3933. JSGC_ROOT_ANALYSIS= )
  3934. if test -n "$JSGC_ROOT_ANALYSIS"; then
  3935. AC_DEFINE(JSGC_ROOT_ANALYSIS)
  3936. fi
  3937. dnl ========================================================
  3938. dnl = Use Valgrind
  3939. dnl ========================================================
  3940. MOZ_ARG_ENABLE_BOOL(valgrind,
  3941. [ --enable-valgrind Enable Valgrind integration hooks (default=no)],
  3942. MOZ_VALGRIND=1,
  3943. MOZ_VALGRIND= )
  3944. if test -n "$MOZ_VALGRIND"; then
  3945. MOZ_CHECK_HEADER([valgrind/valgrind.h], [],
  3946. AC_MSG_ERROR(
  3947. [--enable-valgrind specified but Valgrind is not installed]))
  3948. AC_DEFINE(MOZ_VALGRIND)
  3949. MOZ_VALGRIND=1
  3950. fi
  3951. AC_SUBST(MOZ_VALGRIND)
  3952. dnl ========================================================
  3953. dnl jprof
  3954. dnl ========================================================
  3955. MOZ_ARG_ENABLE_BOOL(jprof,
  3956. [ --enable-jprof Enable jprof profiling tool (needs mozilla/tools/jprof). Implies --enable-profiling.],
  3957. MOZ_JPROF=1,
  3958. MOZ_JPROF= )
  3959. if test -n "$MOZ_JPROF"; then
  3960. MOZ_PROFILING=1
  3961. AC_DEFINE(MOZ_JPROF)
  3962. fi
  3963. dnl ========================================================
  3964. dnl shark
  3965. dnl ========================================================
  3966. MOZ_ARG_ENABLE_BOOL(shark,
  3967. [ --enable-shark Enable shark remote profiling. Implies --enable-profiling.],
  3968. MOZ_SHARK=1,
  3969. MOZ_SHARK= )
  3970. if test -n "$MOZ_SHARK"; then
  3971. MOZ_PROFILING=1
  3972. AC_DEFINE(MOZ_SHARK)
  3973. fi
  3974. dnl ========================================================
  3975. dnl callgrind
  3976. dnl ========================================================
  3977. MOZ_ARG_ENABLE_BOOL(callgrind,
  3978. [ --enable-callgrind Enable callgrind profiling. Implies --enable-profiling.],
  3979. MOZ_CALLGRIND=1,
  3980. MOZ_CALLGRIND= )
  3981. if test -n "$MOZ_CALLGRIND"; then
  3982. MOZ_PROFILING=1
  3983. AC_DEFINE(MOZ_CALLGRIND)
  3984. fi
  3985. dnl ========================================================
  3986. dnl vtune
  3987. dnl ========================================================
  3988. MOZ_ARG_ENABLE_BOOL(vtune,
  3989. [ --enable-vtune Enable vtune profiling. Implies --enable-profiling.],
  3990. MOZ_VTUNE=1,
  3991. MOZ_VTUNE= )
  3992. if test -n "$MOZ_VTUNE"; then
  3993. MOZ_PROFILING=1
  3994. AC_DEFINE(MOZ_VTUNE)
  3995. fi
  3996. dnl ========================================================
  3997. dnl ETW - Event Tracing for Windows
  3998. dnl ========================================================
  3999. MOZ_ARG_ENABLE_BOOL(ETW,
  4000. [ --enable-ETW Enable ETW (Event Tracing for Windows) event reporting],
  4001. MOZ_ETW=1,
  4002. MOZ_ETW= )
  4003. if test -n "$MOZ_ETW"; then
  4004. AC_DEFINE(MOZ_ETW)
  4005. WINVER=600
  4006. fi
  4007. if test -n "$MOZ_ETW"; then
  4008. if test -z "$MOZ_WINSDK_TARGETVER"; then
  4009. AC_MSG_ERROR([--enable-ETW is only valid on Windows])
  4010. fi
  4011. fi
  4012. dnl ========================================================
  4013. dnl Profiling
  4014. dnl ========================================================
  4015. if test -n "$MOZ_PROFILING"; then
  4016. AC_DEFINE(MOZ_PROFILING)
  4017. fi
  4018. dnl ========================================================
  4019. dnl Zealous JavaScript GC
  4020. dnl ========================================================
  4021. MOZ_ARG_ENABLE_BOOL(gczeal,
  4022. [ --enable-gczeal Enable zealous GCing],
  4023. JS_GC_ZEAL=1,
  4024. JS_GC_ZEAL= )
  4025. if test -n "$JS_GC_ZEAL"; then
  4026. AC_DEFINE(JS_GC_ZEAL)
  4027. fi
  4028. dnl ========================================================
  4029. dnl JS opt-mode assertions and minidump instrumentation
  4030. dnl ========================================================
  4031. MOZ_ARG_ENABLE_BOOL(js-diagnostics,
  4032. [ --enable-js-diagnostics
  4033. Enable JS diagnostic assertions and breakpad data],
  4034. JS_CRASH_DIAGNOSTICS=1,
  4035. JS_CRASH_DIAGNOSTICS= )
  4036. if test -n "$JS_CRASH_DIAGNOSTICS"; then
  4037. AC_DEFINE(JS_CRASH_DIAGNOSTICS)
  4038. fi
  4039. dnl ========================================================
  4040. dnl Enable changes that make the shell more deterministic
  4041. dnl ========================================================
  4042. MOZ_ARG_ENABLE_BOOL(more-deterministic,
  4043. [ --enable-more-deterministic
  4044. Enable changes that make the shell more deterministic],
  4045. JS_MORE_DETERMINISTIC=1,
  4046. JS_MORE_DETERMINISTIC= )
  4047. if test -n "$JS_MORE_DETERMINISTIC"; then
  4048. AC_DEFINE(JS_MORE_DETERMINISTIC)
  4049. fi
  4050. dnl ======================================================
  4051. dnl = Enable compiling with ccache
  4052. dnl ======================================================
  4053. MOZ_ARG_WITH_STRING(ccache,
  4054. [ --with-ccache[=path/to/ccache]
  4055. Enable compiling with ccache],
  4056. CCACHE=$withval, CCACHE="no")
  4057. if test "$CCACHE" != "no"; then
  4058. if test -z "$CCACHE" -o "$CCACHE" = "yes"; then
  4059. CCACHE=
  4060. else
  4061. if test ! -e "$CCACHE"; then
  4062. AC_MSG_ERROR([$CCACHE not found])
  4063. fi
  4064. fi
  4065. MOZ_PATH_PROGS(CCACHE, $CCACHE ccache)
  4066. if test -z "$CCACHE" -o "$CCACHE" = ":"; then
  4067. AC_MSG_ERROR([ccache not found])
  4068. elif test -x "$CCACHE"; then
  4069. CC="$CCACHE $CC"
  4070. CXX="$CCACHE $CXX"
  4071. else
  4072. AC_MSG_ERROR([$CCACHE is not executable])
  4073. fi
  4074. fi
  4075. dnl ========================================================
  4076. dnl = Enable static checking using gcc-dehydra
  4077. dnl ========================================================
  4078. MOZ_ARG_WITH_STRING(static-checking,
  4079. [ --with-static-checking=path/to/gcc_dehydra.so
  4080. Enable static checking of code using GCC-dehydra],
  4081. DEHYDRA_PATH=$withval,
  4082. DEHYDRA_PATH= )
  4083. if test -n "$DEHYDRA_PATH"; then
  4084. if test ! -f "$DEHYDRA_PATH"; then
  4085. AC_MSG_ERROR([The dehydra plugin is not at the specified path.])
  4086. fi
  4087. AC_DEFINE(NS_STATIC_CHECKING)
  4088. fi
  4089. AC_SUBST(DEHYDRA_PATH)
  4090. dnl ========================================================
  4091. dnl = Enable stripping of libs & executables
  4092. dnl ========================================================
  4093. MOZ_ARG_ENABLE_BOOL(strip,
  4094. [ --enable-strip Enable stripping of libs & executables ],
  4095. ENABLE_STRIP=1,
  4096. ENABLE_STRIP= )
  4097. dnl ========================================================
  4098. dnl = Enable stripping of libs & executables when packaging
  4099. dnl ========================================================
  4100. MOZ_ARG_ENABLE_BOOL(install-strip,
  4101. [ --enable-install-strip Enable stripping of libs & executables when packaging ],
  4102. PKG_SKIP_STRIP= ,
  4103. PKG_SKIP_STRIP=1)
  4104. dnl ========================================================
  4105. dnl =
  4106. dnl = Profiling and Instrumenting
  4107. dnl =
  4108. dnl ========================================================
  4109. MOZ_ARG_HEADER(Profiling and Instrumenting)
  4110. dnl ========================================================
  4111. dnl = Support for Quantify (Windows)
  4112. dnl ========================================================
  4113. MOZ_ARG_ENABLE_BOOL(quantify,
  4114. [ --enable-quantify Enable Quantify support (Windows only) ],
  4115. MOZ_QUANTIFY=1,
  4116. MOZ_QUANTIFY= )
  4117. dnl ========================================================
  4118. dnl = Support for demangling undefined symbols
  4119. dnl ========================================================
  4120. if test -z "$SKIP_LIBRARY_CHECKS"; then
  4121. AC_LANG_SAVE
  4122. AC_LANG_CPLUSPLUS
  4123. AC_CHECK_FUNCS(__cxa_demangle, HAVE_DEMANGLE=1, HAVE_DEMANGLE=)
  4124. AC_LANG_RESTORE
  4125. fi
  4126. # Demangle only for debug or trace-malloc builds
  4127. MOZ_DEMANGLE_SYMBOLS=
  4128. if test "$HAVE_DEMANGLE" && test "$MOZ_DEBUG" -o "$NS_TRACE_MALLOC"; then
  4129. MOZ_DEMANGLE_SYMBOLS=1
  4130. AC_DEFINE(MOZ_DEMANGLE_SYMBOLS)
  4131. fi
  4132. AC_SUBST(MOZ_DEMANGLE_SYMBOLS)
  4133. dnl ========================================================
  4134. dnl = Support for gcc stack unwinding (from gcc 3.3)
  4135. dnl ========================================================
  4136. if test -z "$SKIP_LIBRARY_CHECKS"; then
  4137. MOZ_CHECK_HEADER(unwind.h, AC_CHECK_FUNCS(_Unwind_Backtrace))
  4138. fi
  4139. dnl ========================================================
  4140. dnl JIT observers
  4141. dnl ========================================================
  4142. MOZ_ARG_WITH_STRING(jitreport-granularity,
  4143. [ --jitreport-granularity=N
  4144. Default granularity at which to report JIT code
  4145. to external tools
  4146. 0 - no info
  4147. 1 - code ranges for whole functions only
  4148. 2 - per-line information
  4149. 3 - per-op information],
  4150. JITREPORT_GRANULARITY=$withval,
  4151. JITREPORT_GRANULARITY=3)
  4152. AC_DEFINE_UNQUOTED(JS_DEFAULT_JITREPORT_GRANULARITY, $JITREPORT_GRANULARITY)
  4153. dnl ========================================================
  4154. dnl =
  4155. dnl = Misc. Options
  4156. dnl =
  4157. dnl ========================================================
  4158. MOZ_ARG_HEADER(Misc. Options)
  4159. dnl ========================================================
  4160. dnl update xterm title
  4161. dnl ========================================================
  4162. MOZ_ARG_ENABLE_BOOL(xterm-updates,
  4163. [ --enable-xterm-updates Update XTERM titles with current command.],
  4164. MOZ_UPDATE_XTERM=1,
  4165. MOZ_UPDATE_XTERM= )
  4166. if test -z "$SKIP_COMPILER_CHECKS"; then
  4167. dnl ========================================================
  4168. dnl =
  4169. dnl = Compiler Options
  4170. dnl =
  4171. dnl ========================================================
  4172. MOZ_ARG_HEADER(Compiler Options)
  4173. dnl ========================================================
  4174. dnl Check for gcc -pipe support
  4175. dnl ========================================================
  4176. AC_MSG_CHECKING([for -pipe support])
  4177. if test -n "$GNU_CC" -a -n "$GNU_CXX"; then
  4178. dnl Any gcc that supports firefox supports -pipe.
  4179. CFLAGS="$CFLAGS -pipe"
  4180. CXXFLAGS="$CXXFLAGS -pipe"
  4181. AC_MSG_RESULT([yes])
  4182. else
  4183. AC_MSG_RESULT([no])
  4184. fi
  4185. dnl ========================================================
  4186. dnl Profile guided optimization (gcc checks)
  4187. dnl ========================================================
  4188. dnl Test for profiling options
  4189. dnl Under gcc 3.4+, use -fprofile-generate/-fprofile-use
  4190. _SAVE_CFLAGS="$CFLAGS"
  4191. CFLAGS="$CFLAGS -fprofile-generate -fprofile-correction"
  4192. AC_MSG_CHECKING([whether C compiler supports -fprofile-generate])
  4193. AC_TRY_COMPILE([], [return 0;],
  4194. [ PROFILE_GEN_CFLAGS="-fprofile-generate"
  4195. result="yes" ], result="no")
  4196. AC_MSG_RESULT([$result])
  4197. if test $result = "yes"; then
  4198. PROFILE_GEN_LDFLAGS="-fprofile-generate"
  4199. PROFILE_USE_CFLAGS="-fprofile-use -fprofile-correction -Wcoverage-mismatch"
  4200. PROFILE_USE_LDFLAGS="-fprofile-use"
  4201. fi
  4202. CFLAGS="$_SAVE_CFLAGS"
  4203. if test -n "$INTEL_CC"; then
  4204. PROFILE_GEN_CFLAGS="-prof-gen -prof-dir ."
  4205. PROFILE_GEN_LDFLAGS=
  4206. PROFILE_USE_CFLAGS="-prof-use -prof-dir ."
  4207. PROFILE_USE_LDFLAGS=
  4208. fi
  4209. dnl Sun Studio on Solaris
  4210. if test "$SOLARIS_SUNPRO_CC"; then
  4211. PROFILE_GEN_CFLAGS="-xprofile=collect:$_objdir/$enable_application"
  4212. PROFILE_GEN_LDFLAGS="-xprofile=collect:$_objdir/$enable_application"
  4213. PROFILE_USE_CFLAGS="-xprofile=use:$_objdir/$enable_application"
  4214. PROFILE_USE_LDFLAGS="-xprofile=use:$_objdir/$enable_application"
  4215. fi
  4216. AC_SUBST(PROFILE_GEN_CFLAGS)
  4217. AC_SUBST(PROFILE_GEN_LDFLAGS)
  4218. AC_SUBST(PROFILE_USE_CFLAGS)
  4219. AC_SUBST(PROFILE_USE_LDFLAGS)
  4220. AC_LANG_CPLUSPLUS
  4221. dnl ========================================================
  4222. dnl Test for -pedantic bustage
  4223. dnl ========================================================
  4224. MOZ_ARG_DISABLE_BOOL(pedantic,
  4225. [ --disable-pedantic Issue all warnings demanded by strict ANSI C ],
  4226. _PEDANTIC= )
  4227. if test "$_PEDANTIC"; then
  4228. _SAVE_CXXFLAGS=$CXXFLAGS
  4229. CXXFLAGS="$CXXFLAGS -pedantic ${_WARNINGS_CXXFLAGS} -Wno-long-long"
  4230. AC_MSG_CHECKING([whether C++ compiler has -pedantic long long bug])
  4231. AC_TRY_COMPILE([$configure_static_assert_macros],
  4232. [CONFIGURE_STATIC_ASSERT(sizeof(long long) == 8)],
  4233. result="no", result="yes" )
  4234. AC_MSG_RESULT([$result])
  4235. CXXFLAGS="$_SAVE_CXXFLAGS"
  4236. case "$result" in
  4237. no)
  4238. _WARNINGS_CFLAGS="-pedantic ${_WARNINGS_CFLAGS} -Wno-long-long"
  4239. _WARNINGS_CXXFLAGS="-pedantic ${_WARNINGS_CXXFLAGS} -Wno-long-long"
  4240. ;;
  4241. yes)
  4242. AC_MSG_ERROR([Your compiler appears to have a known bug where long long is miscompiled when using -pedantic. Reconfigure using --disable-pedantic. ])
  4243. ;;
  4244. esac
  4245. fi
  4246. dnl ========================================================
  4247. dnl Autoconf test for gcc 2.7.2.x (and maybe others?) so that we don't
  4248. dnl provide non-const forms of the operator== for comparing nsCOMPtrs to
  4249. dnl raw pointers in nsCOMPtr.h. (VC++ has the same bug.)
  4250. dnl ========================================================
  4251. _SAVE_CXXFLAGS=$CXXFLAGS
  4252. CXXFLAGS="$CXXFLAGS ${_WARNINGS_CXXFLAGS}"
  4253. AC_CACHE_CHECK(for correct overload resolution with const and templates,
  4254. ac_nscap_nonconst_opeq_bug,
  4255. [AC_TRY_COMPILE([
  4256. template <class T>
  4257. class Pointer
  4258. {
  4259. public:
  4260. T* myPtr;
  4261. };
  4262. template <class T, class U>
  4263. int operator==(const Pointer<T>& rhs, U* lhs)
  4264. {
  4265. return rhs.myPtr == lhs;
  4266. }
  4267. template <class T, class U>
  4268. int operator==(const Pointer<T>& rhs, const U* lhs)
  4269. {
  4270. return rhs.myPtr == lhs;
  4271. }
  4272. ],
  4273. [
  4274. Pointer<int> foo;
  4275. const int* bar;
  4276. return foo == bar;
  4277. ],
  4278. ac_nscap_nonconst_opeq_bug="no",
  4279. ac_nscap_nonconst_opeq_bug="yes")])
  4280. CXXFLAGS="$_SAVE_CXXFLAGS"
  4281. if test "$ac_nscap_nonconst_opeq_bug" = "yes" ; then
  4282. AC_DEFINE(NSCAP_DONT_PROVIDE_NONCONST_OPEQ)
  4283. fi
  4284. dnl ========================================================
  4285. dnl Check for tm_zone, tm_gmtoff in struct tm
  4286. dnl ========================================================
  4287. AC_CACHE_CHECK(for tm_zone tm_gmtoff in struct tm,
  4288. ac_cv_struct_tm_zone_tm_gmtoff,
  4289. [AC_TRY_COMPILE([#include <time.h>],
  4290. [struct tm tm; tm.tm_zone = 0; tm.tm_gmtoff = 1;],
  4291. [ac_cv_struct_tm_zone_tm_gmtoff="yes"],
  4292. [ac_cv_struct_tm_zone_tm_gmtoff="no"])])
  4293. if test "$ac_cv_struct_tm_zone_tm_gmtoff" = "yes" ; then
  4294. AC_DEFINE(HAVE_TM_ZONE_TM_GMTOFF)
  4295. fi
  4296. fi # ! SKIP_COMPILER_CHECKS
  4297. dnl ========================================================
  4298. dnl C++ rtti
  4299. dnl Should be smarter and check that the compiler does indeed have rtti
  4300. dnl ========================================================
  4301. MOZ_ARG_ENABLE_BOOL(cpp-rtti,
  4302. [ --enable-cpp-rtti Enable C++ RTTI ],
  4303. [ _MOZ_USE_RTTI=1 ],
  4304. [ _MOZ_USE_RTTI= ])
  4305. if test "$_MOZ_USE_RTTI"; then
  4306. _MOZ_RTTI_FLAGS=$_MOZ_RTTI_FLAGS_ON
  4307. else
  4308. _MOZ_RTTI_FLAGS=$_MOZ_RTTI_FLAGS_OFF
  4309. fi
  4310. AC_SUBST(_MOZ_RTTI_FLAGS_ON)
  4311. AC_DEFINE(CPP_THROW_NEW, [throw()])
  4312. AC_LANG_C
  4313. dnl ========================================================
  4314. dnl =
  4315. dnl = Check what kind of list files are supported by the
  4316. dnl = linker
  4317. dnl =
  4318. dnl ========================================================
  4319. AC_CACHE_CHECK(what kind of list files are supported by the linker,
  4320. EXPAND_LIBS_LIST_STYLE,
  4321. [echo "int main() {return 0;}" > conftest.${ac_ext}
  4322. if AC_TRY_COMMAND(${CC-cc} -o conftest.${OBJ_SUFFIX} -c $CFLAGS $CPPFLAGS conftest.${ac_ext} 1>&2) && test -s conftest.${OBJ_SUFFIX}; then
  4323. echo "INPUT(conftest.${OBJ_SUFFIX})" > conftest.list
  4324. if AC_TRY_COMMAND(${CC-cc} -o conftest${ac_exeext} $LDFLAGS conftest.list $LIBS 1>&2) && test -s conftest${ac_exeext}; then
  4325. EXPAND_LIBS_LIST_STYLE=linkerscript
  4326. else
  4327. echo "conftest.${OBJ_SUFFIX}" > conftest.list
  4328. if AC_TRY_COMMAND(${CC-cc} -o conftest${ac_exeext} $LDFLAGS @conftest.list $LIBS 1>&2) && test -s conftest${ac_exeext}; then
  4329. EXPAND_LIBS_LIST_STYLE=list
  4330. else
  4331. EXPAND_LIBS_LIST_STYLE=none
  4332. fi
  4333. fi
  4334. else
  4335. dnl We really don't expect to get here, but just in case
  4336. AC_ERROR([couldn't compile a simple C file])
  4337. fi
  4338. rm -rf conftest*])
  4339. LIBS_DESC_SUFFIX=desc
  4340. AC_SUBST(LIBS_DESC_SUFFIX)
  4341. AC_SUBST(EXPAND_LIBS_LIST_STYLE)
  4342. dnl ========================================================
  4343. dnl =
  4344. dnl = Build depencency options
  4345. dnl =
  4346. dnl ========================================================
  4347. MOZ_ARG_HEADER(Build dependencies)
  4348. dnl ========================================================
  4349. dnl = Do not auto generate dependency info
  4350. dnl ========================================================
  4351. MOZ_AUTO_DEPS=1
  4352. MOZ_ARG_DISABLE_BOOL(auto-deps,
  4353. [ --disable-auto-deps Do not automatically generate dependency info],
  4354. MOZ_AUTO_DEPS=,
  4355. MOZ_AUTO_DEPS=1)
  4356. if test -n "$MOZ_AUTO_DEPS"; then
  4357. dnl ========================================================
  4358. dnl = Use mkdepend instead of $CC -MD for dependency generation
  4359. dnl ========================================================
  4360. _cpp_md_flag=
  4361. MOZ_ARG_DISABLE_BOOL(md,
  4362. [ --disable-md Do not use compiler-based dependencies ],
  4363. [_cpp_md_flag=],
  4364. [_cpp_md_flag=1],
  4365. [dnl Default is to turn on -MD if using GNU-compatible compilers
  4366. if test "$GNU_CC" -a "$GNU_CXX"; then
  4367. _cpp_md_flag=1
  4368. fi
  4369. dnl Default is to use -xM if using Sun Studio on Solaris
  4370. if test "$SOLARIS_SUNPRO_CC"; then
  4371. _cpp_md_flag=1
  4372. fi])
  4373. if test "$_cpp_md_flag"; then
  4374. COMPILER_DEPEND=1
  4375. _DEPEND_CFLAGS='$(filter-out %/.pp,-MD -MF $(MDDEPDIR)/$(basename $(@F)).pp)'
  4376. dnl Sun Studio on Solaris use -xM instead of -MD, see config/rules.mk
  4377. if test "$SOLARIS_SUNPRO_CC"; then
  4378. _DEPEND_CFLAGS=
  4379. fi
  4380. else
  4381. COMPILER_DEPEND=
  4382. dnl Don't override this for MSVC
  4383. if test -z "$_WIN32_MSVC"; then
  4384. _USE_CPP_INCLUDE_FLAG=
  4385. _DEFINES_CFLAGS='$(ACDEFINES) -D_JS_CONFDEFS_H_ -DMOZILLA_CLIENT'
  4386. _DEFINES_CXXFLAGS='$(ACDEFINES) -D_JS_CONFDEFS_H_ -DMOZILLA_CLIENT'
  4387. else
  4388. echo '#include <stdio.h>' > dummy-hello.c
  4389. changequote(,)
  4390. CL_INCLUDES_PREFIX=`${CC} -showIncludes -c -Fonul dummy-hello.c 2>&1 | sed -ne 's/^\([^:]*:[^:]*:\).*stdio.h$/\1/p'`
  4391. changequote([,])
  4392. if test -z "$CL_INCLUDES_PREFIX"; then
  4393. AC_MSG_ERROR([Cannot find cl -showIncludes prefix.])
  4394. fi
  4395. AC_SUBST(CL_INCLUDES_PREFIX)
  4396. rm -f dummy-hello.c
  4397. _topsrcdirwin=`cd \`dirname $0\`; pwd -W`
  4398. dnl cl.py provides dependency generation for MSVC
  4399. CC_WRAPPER="$PYTHON -O $_topsrcdirwin/build/cl.py"
  4400. CXX_WRAPPER="$PYTHON -O $_topsrcdirwin/build/cl.py"
  4401. COMPILER_DEPEND=1
  4402. fi
  4403. fi
  4404. fi # MOZ_AUTO_DEPS
  4405. MDDEPDIR='.deps'
  4406. AC_SUBST(MOZ_AUTO_DEPS)
  4407. AC_SUBST(COMPILER_DEPEND)
  4408. AC_SUBST(MDDEPDIR)
  4409. AC_SUBST(CC_WRAPPER)
  4410. AC_SUBST(CXX_WRAPPER)
  4411. dnl ========================================================
  4412. dnl = Link js shell to system readline
  4413. dnl ========================================================
  4414. MOZ_ARG_ENABLE_BOOL(readline,
  4415. [ --enable-readline Link js shell to system readline library],
  4416. JS_WANT_READLINE=1,
  4417. JS_WANT_READLINE= )
  4418. JS_NATIVE_EDITLINE=
  4419. EDITLINE_LIBS=
  4420. JS_DISABLE_SHELL=
  4421. case "$target" in
  4422. *-mingw*)
  4423. NO_EDITLINE=1
  4424. ;;
  4425. *)
  4426. ;;
  4427. esac
  4428. if test -z "$SKIP_LIBRARY_CHECKS" -a -z "$NO_EDITLINE"; then
  4429. if test -n "$JS_WANT_READLINE"; then
  4430. AC_CHECK_LIB(readline, readline,
  4431. EDITLINE_LIBS="-lreadline",
  4432. AC_MSG_ERROR([No system readline library found.]))
  4433. else
  4434. dnl By default, we use editline
  4435. JS_NATIVE_EDITLINE=1
  4436. EDITLINE_LIBS='$(DEPTH)/editline/$(LIB_PREFIX)editline.$(LIB_SUFFIX)'
  4437. fi
  4438. dnl Either way, we want to build with line editing support.
  4439. AC_DEFINE(EDITLINE)
  4440. fi
  4441. AC_SUBST(JS_NATIVE_EDITLINE)
  4442. AC_SUBST(JS_DISABLE_SHELL)
  4443. AC_SUBST(EDITLINE_LIBS)
  4444. dnl ========================================================
  4445. dnl =
  4446. dnl = Standalone module options
  4447. dnl =
  4448. dnl ========================================================
  4449. MOZ_ARG_HEADER(Standalone module options (Not for building Mozilla))
  4450. dnl ========================================================
  4451. dnl = Build jsctypes if it's enabled
  4452. dnl ========================================================
  4453. MOZ_ARG_ENABLE_BOOL(ctypes,
  4454. [ --enable-ctypes Enable js-ctypes (default=no)],
  4455. JS_HAS_CTYPES=1,
  4456. JS_HAS_CTYPES= )
  4457. AC_SUBST(JS_HAS_CTYPES)
  4458. if test "$JS_HAS_CTYPES"; then
  4459. dnl Error out if we're on MSVC and MASM is unavailable.
  4460. if test -n "$_MSC_VER" -a \( "$AS" != "ml.exe" -a "$AS" != "ml64.exe" \); then
  4461. AC_MSG_ERROR([\"$AS\" is not a suitable assembler to build js-ctypes. If you are building with MS Visual Studio 8 Express, you may download the MASM 8.0 package, upgrade to Visual Studio 9 Express, or install the Vista SDK. Or do not use --enable-ctypes.])
  4462. fi
  4463. AC_DEFINE(JS_HAS_CTYPES)
  4464. fi
  4465. if test "$MOZ_DEBUG" -o "$NS_TRACE_MALLOC"; then
  4466. MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS=
  4467. fi
  4468. MOZ_ARG_WITH_STRING(sync-build-files,
  4469. [ --with-sync-build-files=DIR
  4470. Check that files in 'config' and 'build' match
  4471. their originals in 'DIR/config' and 'DIR/build'.
  4472. This helps keep the SpiderMonkey build machinery
  4473. in sync with Mozilla's, on which it is based.],
  4474. [MOZ_SYNC_BUILD_FILES=$withval ] )
  4475. AC_SUBST(MOZ_SYNC_BUILD_FILES)
  4476. dnl ========================================================
  4477. dnl =
  4478. dnl = Maintainer debug option (no --enable equivalent)
  4479. dnl =
  4480. dnl ========================================================
  4481. AC_SUBST(AR)
  4482. AC_SUBST(AR_FLAGS)
  4483. AC_SUBST(AR_LIST)
  4484. AC_SUBST(AR_EXTRACT)
  4485. AC_SUBST(AR_DELETE)
  4486. AC_SUBST(AS)
  4487. AC_SUBST(ASFLAGS)
  4488. AC_SUBST(AS_DASH_C_FLAG)
  4489. AC_SUBST(LD)
  4490. AC_SUBST(RC)
  4491. AC_SUBST(RCFLAGS)
  4492. AC_SUBST(MC)
  4493. AC_SUBST(WINDRES)
  4494. AC_SUBST(IMPLIB)
  4495. AC_SUBST(FILTER)
  4496. AC_SUBST(BIN_FLAGS)
  4497. AC_SUBST(MOZ_JS_LIBS)
  4498. AC_SUBST(MOZ_PSM)
  4499. AC_SUBST(MOZ_DEBUG)
  4500. AC_SUBST(MOZ_DEBUG_SYMBOLS)
  4501. AC_SUBST(MOZ_DEBUG_ENABLE_DEFS)
  4502. AC_SUBST(MOZ_DEBUG_DISABLE_DEFS)
  4503. AC_SUBST(MOZ_DEBUG_FLAGS)
  4504. AC_SUBST(MOZ_DEBUG_LDFLAGS)
  4505. AC_SUBST(WARNINGS_AS_ERRORS)
  4506. AC_SUBST(MOZ_LEAKY)
  4507. AC_SUBST(MOZ_JPROF)
  4508. AC_SUBST(MOZ_SHARK)
  4509. AC_SUBST(MOZ_CALLGRIND)
  4510. AC_SUBST(MOZ_VTUNE)
  4511. AC_SUBST(MOZ_ETW)
  4512. AC_SUBST(MOZ_PROFILING)
  4513. AC_SUBST(MOZ_QUANTIFY)
  4514. AC_SUBST(LIBICONV)
  4515. AC_SUBST(ENABLE_TESTS)
  4516. AC_SUBST(ENABLE_STRIP)
  4517. AC_SUBST(PKG_SKIP_STRIP)
  4518. AC_SUBST(INCREMENTAL_LINKER)
  4519. AC_SUBST(MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS)
  4520. AC_SUBST(MOZ_COMPONENT_NSPR_LIBS)
  4521. AC_SUBST(MOZ_FIX_LINK_PATHS)
  4522. AC_SUBST(USE_DEPENDENT_LIBS)
  4523. AC_SUBST(MOZ_BUILD_ROOT)
  4524. AC_SUBST(MOZ_OS2_TOOLS)
  4525. AC_SUBST(MOZ_POST_DSO_LIB_COMMAND)
  4526. AC_SUBST(MOZ_POST_PROGRAM_COMMAND)
  4527. AC_SUBST(MOZ_APP_NAME)
  4528. AC_SUBST(MOZ_APP_DISPLAYNAME)
  4529. AC_SUBST(MOZ_APP_UA_NAME)
  4530. AC_SUBST(MOZ_APP_VERSION)
  4531. AC_SUBST(FIREFOX_VERSION)
  4532. AC_SUBST(MOZ_PKG_SPECIAL)
  4533. AC_SUBST(MOZILLA_OFFICIAL)
  4534. dnl win32 options
  4535. AC_SUBST(MOZ_MAPINFO)
  4536. AC_SUBST(MOZ_BROWSE_INFO)
  4537. AC_SUBST(MOZ_TOOLS_DIR)
  4538. AC_SUBST(PYTHON)
  4539. dnl Echo the CFLAGS to remove extra whitespace.
  4540. CFLAGS=`echo \
  4541. $_WARNINGS_CFLAGS \
  4542. $CFLAGS`
  4543. CXXFLAGS=`echo \
  4544. $_MOZ_RTTI_FLAGS \
  4545. $_WARNINGS_CXXFLAGS \
  4546. $CXXFLAGS`
  4547. COMPILE_CFLAGS=`echo \
  4548. $_DEFINES_CFLAGS \
  4549. $_DEPEND_CFLAGS \
  4550. $COMPILE_CFLAGS`
  4551. COMPILE_CXXFLAGS=`echo \
  4552. $_DEFINES_CXXFLAGS \
  4553. $_DEPEND_CFLAGS \
  4554. $COMPILE_CXXFLAGS`
  4555. AC_SUBST(SYSTEM_MAKEDEPEND)
  4556. AC_SUBST(NSPR_CFLAGS)
  4557. AC_SUBST(NSPR_LIBS)
  4558. AC_SUBST(MOZ_NATIVE_NSPR)
  4559. AC_SUBST(CFLAGS)
  4560. AC_SUBST(CXXFLAGS)
  4561. AC_SUBST(CPPFLAGS)
  4562. AC_SUBST(COMPILE_CFLAGS)
  4563. AC_SUBST(COMPILE_CXXFLAGS)
  4564. AC_SUBST(LDFLAGS)
  4565. AC_SUBST(LIBS)
  4566. AC_SUBST(CROSS_COMPILE)
  4567. AC_SUBST(HOST_CC)
  4568. AC_SUBST(HOST_CXX)
  4569. AC_SUBST(HOST_CFLAGS)
  4570. AC_SUBST(HOST_CXXFLAGS)
  4571. AC_SUBST(HOST_LDFLAGS)
  4572. AC_SUBST(HOST_OPTIMIZE_FLAGS)
  4573. AC_SUBST(HOST_AR)
  4574. AC_SUBST(HOST_AR_FLAGS)
  4575. AC_SUBST(HOST_LD)
  4576. AC_SUBST(HOST_RANLIB)
  4577. AC_SUBST(HOST_NSPR_MDCPUCFG)
  4578. AC_SUBST(HOST_BIN_SUFFIX)
  4579. AC_SUBST(HOST_OS_ARCH)
  4580. AC_SUBST(TARGET_CPU)
  4581. AC_SUBST(TARGET_VENDOR)
  4582. AC_SUBST(TARGET_OS)
  4583. AC_SUBST(TARGET_NSPR_MDCPUCFG)
  4584. AC_SUBST(TARGET_MD_ARCH)
  4585. AC_SUBST(TARGET_XPCOM_ABI)
  4586. AC_SUBST(OS_TARGET)
  4587. AC_SUBST(OS_ARCH)
  4588. AC_SUBST(OS_RELEASE)
  4589. AC_SUBST(OS_TEST)
  4590. AC_SUBST(CPU_ARCH)
  4591. AC_SUBST(INTEL_ARCHITECTURE)
  4592. AC_SUBST(WRAP_LDFLAGS)
  4593. AC_SUBST(MKSHLIB)
  4594. AC_SUBST(MKCSHLIB)
  4595. AC_SUBST(MKSHLIB_FORCE_ALL)
  4596. AC_SUBST(MKSHLIB_UNFORCE_ALL)
  4597. AC_SUBST(DSO_CFLAGS)
  4598. AC_SUBST(DSO_PIC_CFLAGS)
  4599. AC_SUBST(DSO_LDOPTS)
  4600. AC_SUBST(LIB_PREFIX)
  4601. AC_SUBST(DLL_PREFIX)
  4602. AC_SUBST(DLL_SUFFIX)
  4603. AC_DEFINE_UNQUOTED(MOZ_DLL_SUFFIX, "$DLL_SUFFIX")
  4604. AC_SUBST(LIB_SUFFIX)
  4605. AC_SUBST(OBJ_SUFFIX)
  4606. AC_SUBST(BIN_SUFFIX)
  4607. AC_SUBST(ASM_SUFFIX)
  4608. AC_SUBST(IMPORT_LIB_SUFFIX)
  4609. AC_SUBST(USE_N32)
  4610. AC_SUBST(CC_VERSION)
  4611. AC_SUBST(CXX_VERSION)
  4612. AC_SUBST(MSMANIFEST_TOOL)
  4613. AC_MSG_CHECKING([for posix_fallocate])
  4614. AC_TRY_LINK([#define _XOPEN_SOURCE 600
  4615. #include <fcntl.h>],
  4616. [posix_fallocate(0, 0, 0);],
  4617. [ac_cv___posix_fallocate=true],
  4618. [ac_cv___posix_fallocate=false])
  4619. if test "$ac_cv___posix_fallocate" = true ; then
  4620. AC_DEFINE(HAVE_POSIX_FALLOCATE)
  4621. AC_MSG_RESULT(yes)
  4622. else
  4623. AC_MSG_RESULT(no)
  4624. fi
  4625. dnl Check for missing components
  4626. if test "$COMPILE_ENVIRONMENT"; then
  4627. if test "$MOZ_X11"; then
  4628. dnl ====================================================
  4629. dnl = Check if X headers exist
  4630. dnl ====================================================
  4631. _SAVE_CFLAGS=$CFLAGS
  4632. CFLAGS="$CFLAGS $XCFLAGS"
  4633. AC_TRY_COMPILE([
  4634. #include <stdio.h>
  4635. #include <stdlib.h>
  4636. #include <X11/Xlib.h>
  4637. #include <X11/Intrinsic.h>
  4638. ],
  4639. [
  4640. Display *dpy = 0;
  4641. if ((dpy = XOpenDisplay(NULL)) == NULL) {
  4642. fprintf(stderr, ": can't open %s\n", XDisplayName(NULL));
  4643. exit(1);
  4644. }
  4645. ], [],
  4646. [ AC_MSG_ERROR([Could not compile basic X program.]) ])
  4647. CFLAGS="$_SAVE_CFLAGS"
  4648. if test -n "$MISSING_X"; then
  4649. AC_MSG_ERROR([ Could not find the following X libraries: $MISSING_X ]);
  4650. fi
  4651. fi # MOZ_X11
  4652. fi # COMPILE_ENVIRONMENT
  4653. dnl Set various defines and substitutions
  4654. dnl ========================================================
  4655. if test "$OS_ARCH" = "Darwin"; then
  4656. AC_DEFINE(XP_MACOSX)
  4657. AC_DEFINE(XP_UNIX)
  4658. AC_DEFINE(UNIX_ASYNC_DNS)
  4659. elif test "$OS_ARCH" != "WINNT" -a "$OS_ARCH" != "OS2"; then
  4660. AC_DEFINE(XP_UNIX)
  4661. AC_DEFINE(UNIX_ASYNC_DNS)
  4662. fi
  4663. AC_ARG_ENABLE(threadsafe,
  4664. [ --enable-threadsafe Enable support for multiple threads.],
  4665. [AC_DEFINE(JS_THREADSAFE)],)
  4666. if test "$MOZ_DEBUG"; then
  4667. AC_DEFINE(MOZ_REFLOW_PERF)
  4668. AC_DEFINE(MOZ_REFLOW_PERF_DSP)
  4669. fi
  4670. if test "$ACCESSIBILITY" -a "$MOZ_ENABLE_GTK2" ; then
  4671. AC_DEFINE(MOZ_ACCESSIBILITY_ATK)
  4672. ATK_FULL_VERSION=`$PKG_CONFIG --modversion atk`
  4673. ATK_MAJOR_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
  4674. ATK_MINOR_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $2 }'`
  4675. ATK_REV_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $3 }'`
  4676. AC_DEFINE_UNQUOTED(ATK_MAJOR_VERSION, $ATK_MAJOR_VERSION)
  4677. AC_DEFINE_UNQUOTED(ATK_MINOR_VERSION, $ATK_MINOR_VERSION)
  4678. AC_DEFINE_UNQUOTED(ATK_REV_VERSION, $ATK_REV_VERSION)
  4679. fi
  4680. dnl ========================================================
  4681. dnl JavaScript shell
  4682. dnl ========================================================
  4683. AC_HAVE_FUNCS(setlocale)
  4684. AC_HAVE_FUNCS(localeconv)
  4685. case "$host_os" in
  4686. mingw*)
  4687. WIN_TOP_SRC=`cd $srcdir; pwd -W`
  4688. ;;
  4689. esac
  4690. AC_SUBST(WIN_TOP_SRC)
  4691. AC_SUBST(MOZILLA_VERSION)
  4692. AC_SUBST(ac_configure_args)
  4693. dnl Spit out some output
  4694. dnl ========================================================
  4695. # Save the defines header file before autoconf removes it.
  4696. # (Do not add AC_DEFINE calls after this line.)
  4697. _CONFIG_TMP=confdefs-tmp.h
  4698. _CONFIG_DEFS_H=js-confdefs.h
  4699. cat > $_CONFIG_TMP <<\EOF
  4700. /* List of defines generated by configure. Included with preprocessor flag,
  4701. * -include, to avoid long list of -D defines on the compile command-line.
  4702. * Do not edit.
  4703. */
  4704. #ifndef _JS_CONFDEFS_H_
  4705. #define _JS_CONFDEFS_H_
  4706. EOF
  4707. _EGREP_PATTERN='^#define ('
  4708. if test -n "$_NON_GLOBAL_ACDEFINES"; then
  4709. for f in $_NON_GLOBAL_ACDEFINES; do
  4710. _EGREP_PATTERN="${_EGREP_PATTERN}$f|"
  4711. done
  4712. fi
  4713. _EGREP_PATTERN="${_EGREP_PATTERN}dummy_never_defined)"
  4714. sort confdefs.h | egrep -v "$_EGREP_PATTERN" >> $_CONFIG_TMP
  4715. if test "$?" != 0; then
  4716. AC_MSG_ERROR([Error outputting config definitions])
  4717. fi
  4718. cat >> $_CONFIG_TMP <<\EOF
  4719. /* The c99 defining the limit macros (UINT32_MAX for example), says:
  4720. * C++ implementations should define these macros only when __STDC_LIMIT_MACROS
  4721. * is defined before <stdint.h> is included. */
  4722. #define __STDC_LIMIT_MACROS
  4723. #endif /* _JS_CONFDEFS_H_ */
  4724. EOF
  4725. # Only write js-confdefs.h when something changes (or it doesn't exist)
  4726. if cmp -s $_CONFIG_TMP $_CONFIG_DEFS_H; then
  4727. rm $_CONFIG_TMP
  4728. else
  4729. AC_MSG_RESULT("creating $_CONFIG_DEFS_H")
  4730. mv -f $_CONFIG_TMP $_CONFIG_DEFS_H
  4731. echo ==== $_CONFIG_DEFS_H =================================
  4732. cat $_CONFIG_DEFS_H
  4733. fi
  4734. dnl Probably shouldn't call this manually but we always want the output of DEFS
  4735. rm -f confdefs.h.save
  4736. mv confdefs.h confdefs.h.save
  4737. egrep -v "$_EGREP_PATTERN" confdefs.h.save > confdefs.h
  4738. if test "$?" != 0; then
  4739. AC_MSG_ERROR([Error outputting confdefs.h])
  4740. fi
  4741. AC_OUTPUT_MAKE_DEFS()
  4742. MOZ_DEFINES=$DEFS
  4743. AC_SUBST(MOZ_DEFINES)
  4744. rm -f confdefs.h
  4745. mv confdefs.h.save confdefs.h
  4746. MAKEFILES="
  4747. Makefile
  4748. shell/Makefile
  4749. config/Makefile
  4750. config/autoconf.mk
  4751. config/expandlibs_config.py
  4752. v8api/test/Makefile
  4753. "
  4754. if test "$JS_NATIVE_EDITLINE"; then
  4755. MAKEFILES="$MAKEFILES
  4756. editline/Makefile
  4757. "
  4758. fi
  4759. if test ! "$COMPILER_DEPEND" -a ! "$MOZ_NATIVE_MAKEDEPEND"; then
  4760. MAKEFILES="$MAKEFILES
  4761. config/mkdepend/Makefile
  4762. "
  4763. fi
  4764. if test "$ENABLE_TESTS"; then
  4765. MAKEFILES="$MAKEFILES
  4766. jsapi-tests/Makefile
  4767. tests/Makefile
  4768. "
  4769. fi
  4770. dnl
  4771. dnl Run a perl script to quickly create the makefiles.
  4772. dnl If it succeeds, it outputs a shell command to set CONFIG_FILES
  4773. dnl for the files it cannot handle correctly. This way, config.status
  4774. dnl will handle these files.
  4775. dnl If it fails, nothing is set and config.status will run as usual.
  4776. dnl
  4777. dnl This does not change the $MAKEFILES variable.
  4778. dnl
  4779. echo $MAKEFILES | ${PERL} $srcdir/build/autoconf/acoutput-fast.pl > conftest.sh
  4780. . ./conftest.sh
  4781. rm conftest.sh
  4782. echo $MAKEFILES > unallmakefiles
  4783. mv -f config/autoconf.mk config/autoconf.mk.orig 2> /dev/null
  4784. AC_OUTPUT($MAKEFILES)
  4785. dnl Prevent the regeneration of autoconf.mk forcing rebuilds of the world
  4786. if cmp -s config/autoconf.mk config/autoconf.mk.orig; then
  4787. echo "config/autoconf.mk is unchanged"
  4788. mv -f config/autoconf.mk.orig config/autoconf.mk 2> /dev/null
  4789. else
  4790. rm -f config/autoconf.mk.orig 2> /dev/null
  4791. fi
  4792. # Produce the js-config script at configure time; see the comments for
  4793. # 'js-config' in Makefile.in.
  4794. AC_MSG_RESULT(invoking $MAKE to create js-config script)
  4795. $MAKE js-config
  4796. # Build jsctypes if it's enabled.
  4797. if test "$JS_HAS_CTYPES" -a -z "$MOZ_NATIVE_FFI"; then
  4798. # Run the libffi 'configure' script.
  4799. ac_configure_args="--disable-shared --enable-static --disable-raw-api"
  4800. if test "$MOZ_DEBUG"; then
  4801. ac_configure_args="$ac_configure_args --enable-debug"
  4802. fi
  4803. if test "$DSO_PIC_CFLAGS"; then
  4804. ac_configure_args="$ac_configure_args --with-pic"
  4805. fi
  4806. if test "$CROSS_COMPILE"; then
  4807. case "$target" in
  4808. *-android*|*-linuxandroid*)
  4809. export AS CC CXX CPP LD AR RANLIB STRIP CPPFLAGS CFLAGS LDFLAGS
  4810. ac_configure_args="$ac_configure_args --build=$build --host=$target HOST_CC=\"$HOST_CC\""
  4811. ;;
  4812. *)
  4813. ac_configure_args="$ac_configure_args --build=$build --host=$target HOST_CC=\"$HOST_CC\" CC=\"$CC\""
  4814. ;;
  4815. esac
  4816. fi
  4817. if test "$_MSC_VER"; then
  4818. # Use a wrapper script for cl and ml that looks more like gcc.
  4819. # autotools can't quite handle an MSVC build environment yet.
  4820. ac_configure_args="$ac_configure_args LD=link CPP=\"cl -nologo -EP\" SHELL=sh.exe"
  4821. case "${target_cpu}" in
  4822. x86_64)
  4823. # Need target since MSYS tools into mozilla-build may be 32bit
  4824. ac_configure_args="$ac_configure_args CC=\"$_topsrcdir/ctypes/libffi/msvcc.sh -m64\" --build=$build --host=$target"
  4825. ;;
  4826. *)
  4827. ac_configure_args="$ac_configure_args CC=$_topsrcdir/ctypes/libffi/msvcc.sh"
  4828. ;;
  4829. esac
  4830. fi
  4831. if test "$SOLARIS_SUNPRO_CC"; then
  4832. # Always use gcc for libffi on Solaris
  4833. if test ! "$HAVE_64BIT_OS"; then
  4834. ac_configure_args="$ac_configure_args CC=gcc CFLAGS=-m32 LD= LDFLAGS="
  4835. else
  4836. ac_configure_args="$ac_configure_args CC=gcc CFLAGS=-m64 LD= LDFLAGS="
  4837. fi
  4838. fi
  4839. if test "$AIX_IBM_XLC"; then
  4840. # Always use gcc for libffi on IBM AIX5/AIX6
  4841. if test ! "$HAVE_64BIT_OS"; then
  4842. ac_configure_args="$ac_configure_args CC=gcc CFLAGS=-maix32"
  4843. else
  4844. ac_configure_args="$ac_configure_args CC=gcc CFLAGS=-maix64"
  4845. fi
  4846. fi
  4847. if test "$OS_ARCH" = "OS2"; then
  4848. ac_configure_args="$ac_configure_args CFLAGS=-Zomf AR=emxomfar"
  4849. fi
  4850. # Use a separate cache file for libffi, since it does things differently
  4851. # from our configure.
  4852. mkdir -p $_objdir/ctypes/libffi
  4853. old_cache_file=$cache_file
  4854. cache_file=$_objdir/ctypes/libffi/config.cache
  4855. old_config_files=$CONFIG_FILES
  4856. unset CONFIG_FILES
  4857. AC_OUTPUT_SUBDIRS(ctypes/libffi)
  4858. cache_file=$old_cache_file
  4859. ac_configure_args="$_SUBDIR_CONFIG_ARGS"
  4860. CONFIG_FILES=$old_config_files
  4861. fi