| 1 |
dnl nx-macros.m4. Generated from xorg-macros.m4.in xorgversion.m4 by configure. |
| 2 |
dnl |
| 3 |
dnl Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. |
| 4 |
dnl Copyright (c) 2017, Mike Gabriel <[email protected]> |
| 5 |
dnl |
| 6 |
dnl Permission is hereby granted, free of charge, to any person obtaining a |
| 7 |
dnl copy of this software and associated documentation files (the "Software"), |
| 8 |
dnl to deal in the Software without restriction, including without limitation |
| 9 |
dnl the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 10 |
dnl and/or sell copies of the Software, and to permit persons to whom the |
| 11 |
dnl Software is furnished to do so, subject to the following conditions: |
| 12 |
dnl |
| 13 |
dnl The above copyright notice and this permission notice (including the next |
| 14 |
dnl paragraph) shall be included in all copies or substantial portions of the |
| 15 |
dnl Software. |
| 16 |
dnl |
| 17 |
dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 18 |
dnl IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 19 |
dnl FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 20 |
dnl THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 21 |
dnl LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 22 |
dnl FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 23 |
dnl DEALINGS IN THE SOFTWARE. |
| 24 |
|
| 25 |
# NX_COMPILER_BRAND |
| 26 |
# ------------------- |
| 27 |
# Checks for various brands of compilers and sets flags as appropriate: |
| 28 |
# GNU gcc - relies on AC_PROG_CC (via AC_PROG_CC_C99) to set GCC to "yes" |
| 29 |
# GNU g++ - relies on AC_PROG_CXX to set GXX to "yes" |
| 30 |
# clang compiler - sets CLANGCC to "yes" |
| 31 |
# Intel compiler - sets INTELCC to "yes" |
| 32 |
# Sun/Oracle Solaris Studio cc - sets SUNCC to "yes" |
| 33 |
# |
| 34 |
# Derived from https://cgit.freedesktop.org/xorg/util/macros/ and adapted to |
| 35 |
# nxcomp{,shad}. |
| 36 |
|
| 37 |
AC_DEFUN([NX_COMPILER_BRAND], [ |
| 38 |
AC_LANG_CASE( |
| 39 |
[C], [ |
| 40 |
AC_REQUIRE([AC_PROG_CC_C99]) |
| 41 |
], |
| 42 |
[C++], [ |
| 43 |
AC_REQUIRE([AC_PROG_CXX]) |
| 44 |
] |
| 45 |
) |
| 46 |
AC_CHECK_DECL([__clang__], [CLANGCC="yes"], [CLANGCC="no"]) |
| 47 |
AC_CHECK_DECL([__INTEL_COMPILER], [INTELCC="yes"], [INTELCC="no"]) |
| 48 |
AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"]) |
| 49 |
]) # NX_COMPILER_BRAND |
| 50 |
|
| 51 |
# NX_TESTSET_CFLAG(<variable>, <flag>, [<alternative flag>, ...]) |
| 52 |
# --------------- |
| 53 |
# Test if the compiler works when passed the given flag as a command line argument. |
| 54 |
# If it succeeds, the flag is appended to the given variable. If not, it tries the |
| 55 |
# next flag in the list until there are no more options. |
| 56 |
# |
| 57 |
# Note that this does not guarantee that the compiler supports the flag as some |
| 58 |
# compilers will simply ignore arguments that they do not understand, but we do |
| 59 |
# attempt to weed out false positives by using -Werror=unknown-warning-option and |
| 60 |
# -Werror=unused-command-line-argument |
| 61 |
# |
| 62 |
# Derived from https://cgit.freedesktop.org/xorg/util/macros/ and adapted to |
| 63 |
# nxcomp{,shad}. |
| 64 |
|
| 65 |
AC_DEFUN([NX_TESTSET_CFLAG], [ |
| 66 |
m4_if([$#], 0, [m4_fatal([NX_TESTSET_CFLAG was given with an unsupported number of arguments])]) |
| 67 |
m4_if([$#], 1, [m4_fatal([NX_TESTSET_CFLAG was given with an unsupported number of arguments])]) |
| 68 |
|
| 69 |
AC_LANG_COMPILER_REQUIRE |
| 70 |
|
| 71 |
AC_LANG_CASE( |
| 72 |
[C], [ |
| 73 |
AC_REQUIRE([AC_PROG_CC_C99]) |
| 74 |
define([PREFIX], [C]) |
| 75 |
define([CACHE_PREFIX], [cc]) |
| 76 |
define([COMPILER], [$CC]) |
| 77 |
], |
| 78 |
[C++], [ |
| 79 |
define([PREFIX], [CXX]) |
| 80 |
define([CACHE_PREFIX], [cxx]) |
| 81 |
define([COMPILER], [$CXX]) |
| 82 |
] |
| 83 |
) |
| 84 |
|
| 85 |
[nx_testset_save_]PREFIX[FLAGS]="$PREFIX[FLAGS]" |
| 86 |
|
| 87 |
if test "x$[nx_testset_]CACHE_PREFIX[_unknown_warning_option]" = "x" ; then |
| 88 |
PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unknown-warning-option" |
| 89 |
AC_CACHE_CHECK([if ]COMPILER[ supports -Werror=unknown-warning-option], |
| 90 |
[nx_cv_]CACHE_PREFIX[_flag_unknown_warning_option], |
| 91 |
AC_COMPILE_IFELSE([AC_LANG_SOURCE([int i;])], |
| 92 |
[nx_cv_]CACHE_PREFIX[_flag_unknown_warning_option=yes], |
| 93 |
[nx_cv_]CACHE_PREFIX[_flag_unknown_warning_option=no])) |
| 94 |
[nx_testset_]CACHE_PREFIX[_unknown_warning_option]=$[nx_cv_]CACHE_PREFIX[_flag_unknown_warning_option] |
| 95 |
PREFIX[FLAGS]="$[nx_testset_save_]PREFIX[FLAGS]" |
| 96 |
fi |
| 97 |
|
| 98 |
if test "x$[nx_testset_]CACHE_PREFIX[_unused_command_line_argument]" = "x" ; then |
| 99 |
if test "x$[nx_testset_]CACHE_PREFIX[_unknown_warning_option]" = "xyes" ; then |
| 100 |
PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unknown-warning-option" |
| 101 |
fi |
| 102 |
PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unused-command-line-argument" |
| 103 |
AC_CACHE_CHECK([if ]COMPILER[ supports -Werror=unused-command-line-argument], |
| 104 |
[nx_cv_]CACHE_PREFIX[_flag_unused_command_line_argument], |
| 105 |
AC_COMPILE_IFELSE([AC_LANG_SOURCE([int i;])], |
| 106 |
[nx_cv_]CACHE_PREFIX[_flag_unused_command_line_argument=yes], |
| 107 |
[nx_cv_]CACHE_PREFIX[_flag_unused_command_line_argument=no])) |
| 108 |
[nx_testset_]CACHE_PREFIX[_unused_command_line_argument]=$[nx_cv_]CACHE_PREFIX[_flag_unused_command_line_argument] |
| 109 |
PREFIX[FLAGS]="$[nx_testset_save_]PREFIX[FLAGS]" |
| 110 |
fi |
| 111 |
|
| 112 |
found="no" |
| 113 |
m4_foreach([flag], m4_cdr($@), [ |
| 114 |
if test $found = "no" ; then |
| 115 |
if test "x$nx_testset_]CACHE_PREFIX[_unknown_warning_option" = "xyes" ; then |
| 116 |
PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unknown-warning-option" |
| 117 |
fi |
| 118 |
|
| 119 |
if test "x$nx_testset_]CACHE_PREFIX[_unused_command_line_argument" = "xyes" ; then |
| 120 |
PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unused-command-line-argument" |
| 121 |
fi |
| 122 |
|
| 123 |
PREFIX[FLAGS]="$PREFIX[FLAGS] ]flag[" |
| 124 |
|
| 125 |
dnl Some hackery here since AC_CACHE_VAL can't handle a non-literal varname |
| 126 |
AC_MSG_CHECKING([if ]COMPILER[ supports ]flag[]) |
| 127 |
cacheid=AS_TR_SH([nx_cv_]CACHE_PREFIX[_flag_]flag[]) |
| 128 |
AC_CACHE_VAL($cacheid, |
| 129 |
[AC_LINK_IFELSE([AC_LANG_PROGRAM([int i;])], |
| 130 |
[eval $cacheid=yes], |
| 131 |
[eval $cacheid=no])]) |
| 132 |
|
| 133 |
PREFIX[FLAGS]="$[nx_testset_save_]PREFIX[FLAGS]" |
| 134 |
|
| 135 |
eval supported=\$$cacheid |
| 136 |
AC_MSG_RESULT([$supported]) |
| 137 |
if test "$supported" = "yes" ; then |
| 138 |
$1="$$1 ]flag[" |
| 139 |
found="yes" |
| 140 |
fi |
| 141 |
fi |
| 142 |
]) |
| 143 |
]) # NX_TESTSET_CFLAG |
| 144 |
|
| 145 |
# NX_COMPILER_FLAGS |
| 146 |
# --------------- |
| 147 |
# Defines BASE_CFLAGS or BASE_CXXFLAGS to contain a set of command line |
| 148 |
# arguments supported by the selected compiler which do NOT alter the generated |
| 149 |
# code. These arguments will cause the compiler to print various warnings |
| 150 |
# during compilation AND turn a conservative set of warnings into errors. |
| 151 |
# |
| 152 |
# The set of flags supported by BASE_CFLAGS and BASE_CXXFLAGS will grow in |
| 153 |
# future versions of util-macros as options are added to new compilers. |
| 154 |
# |
| 155 |
# Derived from https://cgit.freedesktop.org/xorg/util/macros/ and adapted to |
| 156 |
# nxcomp{,shad}. |
| 157 |
|
| 158 |
AC_DEFUN([NX_COMPILER_FLAGS], [ |
| 159 |
AC_REQUIRE([NX_COMPILER_BRAND]) |
| 160 |
|
| 161 |
AC_ARG_ENABLE(selective-werror, |
| 162 |
AS_HELP_STRING([--disable-selective-werror], |
| 163 |
[Turn off selective compiler errors. (default: enabled)]), |
| 164 |
[SELECTIVE_WERROR=$enableval], |
| 165 |
[SELECTIVE_WERROR=yes]) |
| 166 |
|
| 167 |
AC_LANG_CASE( |
| 168 |
[C], [ |
| 169 |
define([PREFIX], [C]) |
| 170 |
], |
| 171 |
[C++], [ |
| 172 |
define([PREFIX], [CXX]) |
| 173 |
] |
| 174 |
) |
| 175 |
# -v is too short to test reliably with NX_TESTSET_CFLAG |
| 176 |
if test "x$SUNCC" = "xyes"; then |
| 177 |
[BASE_]PREFIX[FLAGS]="-v" |
| 178 |
else |
| 179 |
[BASE_]PREFIX[FLAGS]="" |
| 180 |
fi |
| 181 |
|
| 182 |
# This chunk of warnings were those that existed in the legacy CWARNFLAGS |
| 183 |
NX_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wall]) |
| 184 |
NX_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wpointer-arith]) |
| 185 |
NX_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmissing-declarations]) |
| 186 |
NX_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wformat=2], [-Wformat]) |
| 187 |
|
| 188 |
AC_LANG_CASE( |
| 189 |
[C], [ |
| 190 |
NX_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wstrict-prototypes]) |
| 191 |
NX_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmissing-prototypes]) |
| 192 |
NX_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wnested-externs]) |
| 193 |
NX_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wbad-function-cast]) |
| 194 |
NX_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wold-style-definition], [-fd]) |
| 195 |
NX_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wdeclaration-after-statement]) |
| 196 |
] |
| 197 |
) |
| 198 |
|
| 199 |
# This chunk adds additional warnings that could catch undesired effects. |
| 200 |
NX_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wunused]) |
| 201 |
NX_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wuninitialized]) |
| 202 |
NX_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wshadow]) |
| 203 |
NX_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmissing-noreturn]) |
| 204 |
NX_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmissing-format-attribute]) |
| 205 |
NX_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wredundant-decls]) |
| 206 |
NX_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wlogical-op]) |
| 207 |
|
| 208 |
# These are currently disabled because they are noisy. They will be enabled |
| 209 |
# in the future once the codebase is sufficiently modernized to silence |
| 210 |
# them. For now, I don't want them to drown out the other warnings. |
| 211 |
# NX_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wparentheses]) |
| 212 |
# NX_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wcast-align]) |
| 213 |
# NX_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wcast-qual]) |
| 214 |
|
| 215 |
# Turn some warnings into errors, so we don't accidentally get successful builds |
| 216 |
# when there are problems that should be fixed. |
| 217 |
|
| 218 |
if test "x$SELECTIVE_WERROR" = "xyes" ; then |
| 219 |
NX_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=implicit], [-errwarn=E_NO_EXPLICIT_TYPE_GIVEN -errwarn=E_NO_IMPLICIT_DECL_ALLOWED]) |
| 220 |
NX_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=nonnull]) |
| 221 |
NX_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=init-self]) |
| 222 |
NX_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=main]) |
| 223 |
NX_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=missing-braces]) |
| 224 |
NX_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=sequence-point]) |
| 225 |
NX_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=return-type], [-errwarn=E_FUNC_HAS_NO_RETURN_STMT]) |
| 226 |
NX_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=trigraphs]) |
| 227 |
NX_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=array-bounds]) |
| 228 |
NX_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=write-strings]) |
| 229 |
NX_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=address]) |
| 230 |
NX_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=int-to-pointer-cast], [-errwarn=E_BAD_PTR_INT_COMBINATION]) |
| 231 |
NX_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=pointer-to-int-cast]) # Also -errwarn=E_BAD_PTR_INT_COMBINATION |
| 232 |
else |
| 233 |
AC_MSG_WARN([You have chosen not to turn some select compiler warnings into errors. This should not be necessary. Please report why you needed to do so in a bug report at $PACKAGE_BUGREPORT]) |
| 234 |
NX_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wimplicit]) |
| 235 |
NX_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wnonnull]) |
| 236 |
NX_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Winit-self]) |
| 237 |
NX_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmain]) |
| 238 |
NX_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmissing-braces]) |
| 239 |
NX_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wsequence-point]) |
| 240 |
NX_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wreturn-type]) |
| 241 |
NX_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wtrigraphs]) |
| 242 |
NX_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Warray-bounds]) |
| 243 |
NX_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wwrite-strings]) |
| 244 |
NX_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Waddress]) |
| 245 |
NX_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wint-to-pointer-cast]) |
| 246 |
NX_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wpointer-to-int-cast]) |
| 247 |
fi |
| 248 |
|
| 249 |
AC_SUBST([BASE_]PREFIX[FLAGS]) |
| 250 |
]) # NX_COMPILER_FLAGS |
| 251 |
|
| 252 |
# NX_STRICT_OPTION |
| 253 |
# ----------------------- |
| 254 |
# |
| 255 |
# Add configure option to enable strict compilation flags, such as treating |
| 256 |
# warnings as fatal errors. |
| 257 |
# If --enable-strict-compilation is passed to configure, adds strict flags to |
| 258 |
# $BASE_CFLAGS or $BASE_CXXFLAGS. |
| 259 |
# |
| 260 |
# Also exports $STRICT_CFLAGS for use in other tests or when strict compilation |
| 261 |
# is unconditionally desired. |
| 262 |
AC_DEFUN([NX_STRICT_OPTION], [ |
| 263 |
AC_REQUIRE([NX_COMPILER_FLAGS]) |
| 264 |
|
| 265 |
AC_ARG_ENABLE(strict-compilation, |
| 266 |
AS_HELP_STRING([--enable-strict-compilation], |
| 267 |
[Enable all warnings from compiler and make them errors (default: disabled)]), |
| 268 |
[STRICT_COMPILE=$enableval], [STRICT_COMPILE=no]) |
| 269 |
|
| 270 |
AC_LANG_CASE( |
| 271 |
[C], [ |
| 272 |
define([PREFIX], [C]) |
| 273 |
], |
| 274 |
[C++], [ |
| 275 |
define([PREFIX], [CXX]) |
| 276 |
] |
| 277 |
) |
| 278 |
|
| 279 |
[STRICT_]PREFIX[FLAGS]="" |
| 280 |
NX_TESTSET_CFLAG([[STRICT_]PREFIX[FLAGS]], [-pedantic]) |
| 281 |
NX_TESTSET_CFLAG([[STRICT_]PREFIX[FLAGS]], [-Werror], [-errwarn]) |
| 282 |
|
| 283 |
# Earlier versions of gcc (eg: 4.2) support -Werror=attributes, but do not |
| 284 |
# activate it with -Werror, so we add it here explicitly. |
| 285 |
NX_TESTSET_CFLAG([[STRICT_]PREFIX[FLAGS]], [-Werror=attributes]) |
| 286 |
|
| 287 |
if test "x$STRICT_COMPILE" = "xyes"; then |
| 288 |
[BASE_]PREFIX[FLAGS]="$[BASE_]PREFIX[FLAGS] $[STRICT_]PREFIX[FLAGS]" |
| 289 |
fi |
| 290 |
AC_SUBST([STRICT_]PREFIX[FLAGS]) |
| 291 |
AC_SUBST([BASE_]PREFIX[FLAGS]) |
| 292 |
]) # NX_STRICT_OPTION |
| 293 |
|
| 294 |
# NX_DEFAULT_OPTIONS |
| 295 |
# -------------------- |
| 296 |
# |
| 297 |
# Defines default options for X.Org-like modules. |
| 298 |
# |
| 299 |
AC_DEFUN([NX_DEFAULT_OPTIONS], [ |
| 300 |
AC_REQUIRE([AC_PROG_INSTALL]) |
| 301 |
NX_COMPILER_FLAGS |
| 302 |
NX_STRICT_OPTION |
| 303 |
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])], |
| 304 |
[AC_SUBST([AM_DEFAULT_VERBOSITY], [1])]) |
| 305 |
]) # NX_DEFAULT_OPTIONS |
| 306 |
|
| 307 |
# NX_CHECK_MALLOC_ZERO |
| 308 |
# ---------------------- |
| 309 |
# Minimum version: 1.0.0 |
| 310 |
# |
| 311 |
# Defines {MALLOC,XMALLOC,XTMALLOC}_ZERO_CFLAGS appropriately if |
| 312 |
# malloc(0) returns NULL. Packages should add one of these cflags to |
| 313 |
# their AM_CFLAGS (or other appropriate *_CFLAGS) to use them. |
| 314 |
AC_DEFUN([NX_CHECK_MALLOC_ZERO],[ |
| 315 |
AC_ARG_ENABLE(malloc0returnsnull, |
| 316 |
AS_HELP_STRING([--enable-malloc0returnsnull], |
| 317 |
[malloc(0) returns NULL (default: auto)]), |
| 318 |
[MALLOC_ZERO_RETURNS_NULL=$enableval], |
| 319 |
[MALLOC_ZERO_RETURNS_NULL=auto]) |
| 320 |
|
| 321 |
AC_MSG_CHECKING([whether malloc(0) returns NULL]) |
| 322 |
if test "x$MALLOC_ZERO_RETURNS_NULL" = xauto; then |
| 323 |
AC_RUN_IFELSE([AC_LANG_PROGRAM([ |
| 324 |
#include <stdlib.h> |
| 325 |
],[ |
| 326 |
char *m0, *r0, *c0, *p; |
| 327 |
m0 = malloc(0); |
| 328 |
p = malloc(10); |
| 329 |
r0 = realloc(p,0); |
| 330 |
c0 = calloc(0,10); |
| 331 |
exit((m0 == 0 || r0 == 0 || c0 == 0) ? 0 : 1); |
| 332 |
])], |
| 333 |
[MALLOC_ZERO_RETURNS_NULL=yes], |
| 334 |
[MALLOC_ZERO_RETURNS_NULL=no], |
| 335 |
[MALLOC_ZERO_RETURNS_NULL=yes]) |
| 336 |
fi |
| 337 |
AC_MSG_RESULT([$MALLOC_ZERO_RETURNS_NULL]) |
| 338 |
|
| 339 |
if test "x$MALLOC_ZERO_RETURNS_NULL" = xyes; then |
| 340 |
MALLOC_ZERO_CFLAGS="-DMALLOC_0_RETURNS_NULL" |
| 341 |
XMALLOC_ZERO_CFLAGS=$MALLOC_ZERO_CFLAGS |
| 342 |
XTMALLOC_ZERO_CFLAGS="$MALLOC_ZERO_CFLAGS -DXTMALLOC_BC" |
| 343 |
else |
| 344 |
MALLOC_ZERO_CFLAGS="" |
| 345 |
XMALLOC_ZERO_CFLAGS="" |
| 346 |
XTMALLOC_ZERO_CFLAGS="" |
| 347 |
fi |
| 348 |
|
| 349 |
AC_SUBST([MALLOC_ZERO_CFLAGS]) |
| 350 |
AC_SUBST([XMALLOC_ZERO_CFLAGS]) |
| 351 |
AC_SUBST([XTMALLOC_ZERO_CFLAGS]) |
| 352 |
]) # NX_CHECK_MALLOC_ZERO |
| 353 |
|
| 354 |
|
| 355 |
dnl Check to see if we're running under Cygwin32. |
| 356 |
|
| 357 |
AC_DEFUN([NX_BUILD_ON_CYGWIN32], |
| 358 |
[AC_CACHE_CHECK([for Cygwin32 environment], nxconf_cv_cygwin32, |
| 359 |
[AC_TRY_COMPILE(,[return __CYGWIN32__;], |
| 360 |
nxconf_cv_cygwin32=yes, nxconf_cv_cygwin32=no) |
| 361 |
rm -f conftest*]) |
| 362 |
CYGWIN32= |
| 363 |
test "$nxconf_cv_cygwin32" = yes && CYGWIN32=yes |
| 364 |
]) # NX_BUILD_ON_CYGWIN32 |
| 365 |
|
| 366 |
dnl Check whether we're building on a AMD64. |
| 367 |
|
| 368 |
AC_DEFUN([NX_BUILD_ON_AMD64], |
| 369 |
[AC_CACHE_CHECK([for Amd64 environment], nxconf_cv_amd64, |
| 370 |
[AC_TRY_COMPILE(,[return (__amd64__ || __x86_64__);], |
| 371 |
nxconf_cv_amd64=yes, nxconf_cv_amd64=no) |
| 372 |
rm -f conftest*]) |
| 373 |
AMD64= |
| 374 |
test "$nxconf_cv_amd64" = yes && AMD64=yes |
| 375 |
]) # NX_BUILD_ON_AMD64 |
| 376 |
|
| 377 |
dnl Check for Darwin environment. |
| 378 |
|
| 379 |
AC_DEFUN([NX_BUILD_ON_DARWIN], |
| 380 |
[AC_CACHE_CHECK([for Darwin environment], nxconf_cv_darwin, |
| 381 |
[AC_TRY_COMPILE(,[return __APPLE__;], |
| 382 |
nxconf_cv_darwin=yes, nxconf_cv_darwin=no) |
| 383 |
rm -f conftest*]) |
| 384 |
DARWIN= |
| 385 |
test "$nxconf_cv_darwin" = yes && DARWIN=yes |
| 386 |
]) # NX_BUILD_ON_DARWIN |
| 387 |
|
| 388 |
# Check to see if we're running under Solaris. |
| 389 |
|
| 390 |
AC_DEFUN([NX_BUILD_ON_SUN], |
| 391 |
[AC_CACHE_CHECK([for Solaris environment], nxconf_cv_sun, |
| 392 |
[AC_TRY_COMPILE(,[return __sun;], |
| 393 |
nxconf_cv_sun=yes, nxconf_cv_sun=no) |
| 394 |
rm -f conftest*]) |
| 395 |
SUN= |
| 396 |
test "$nxconf_cv_sun" = yes && SUN=yes |
| 397 |
]) # NX_BUILD_ON_SUN |
| 398 |
|
| 399 |
# Check to see if we're running under FreeBSD. |
| 400 |
|
| 401 |
AC_DEFUN([NX_BUILD_ON_FreeBSD], |
| 402 |
[AC_CACHE_CHECK([for FreeBSD environment], nxconf_cv_freebsd, |
| 403 |
[AC_TRY_COMPILE(,[return __FreeBSD__;], |
| 404 |
nxconf_cv_freebsd=yes, nxconf_cv_freebsd=no) |
| 405 |
rm -f conftest*]) |
| 406 |
FreeBSD= |
| 407 |
test "$nxconf_cv_freebsd" = yes && FreeBSD=yes |
| 408 |
]) # NX_BUILD_ON_FreeBSD |
| 409 |
|
| 410 |
# Check to see if we're generating binaries in ELF format. |
| 411 |
|
| 412 |
AC_DEFUN([NX_TARGET_USE_ELF], |
| 413 |
[AC_CACHE_CHECK([if target system is ELF-based], [nxconf_cv_targetelf], |
| 414 |
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM( |
| 415 |
[[ |
| 416 |
#ifndef __ELF__ |
| 417 |
#error not an ELF-based system |
| 418 |
error! |
| 419 |
#endif |
| 420 |
]], |
| 421 |
[[ |
| 422 |
]])], |
| 423 |
[nxconf_cv_targetelf=yes], [nxconf_cv_targetelf=no])]) |
| 424 |
AM_CONDITIONAL([TARGET_ELF], [test x"$nxconf_cv_targetelf" = "xyes"]) |
| 425 |
]) # NX_TARGET_USE_ELF |
| 426 |
|
| 427 |
AC_DEFUN([LIBJPEG_FALLBACK_CHECK],[ |
| 428 |
AC_MSG_CHECKING([for libjpeg shared library file and headers]) |
| 429 |
AC_CHECK_LIB([jpeg], [jpeg_destroy_compress], |
| 430 |
[have_jpeg_lib=yes], [have_jpeg_lib=no]) |
| 431 |
AC_CHECK_HEADERS([jpeglib.h], |
| 432 |
[have_jpeg_headers=yes], [have_jpeg_headers=no]) |
| 433 |
|
| 434 |
if test x"$have_jpeg_lib" = "xyes" && test x"$have_jpeg_headers" = "xyes"; then |
| 435 |
AC_MSG_RESULT([yes]) |
| 436 |
JPEG_CFLAGS="" |
| 437 |
JPEG_LIBS="-ljpeg" |
| 438 |
else |
| 439 |
AC_MSG_RESULT([no]) |
| 440 |
AC_MSG_FAILURE([Could not find libjpeg on your system, make sure |
| 441 |
the JPEG shared library and header files are installed.]) |
| 442 |
fi |
| 443 |
]) # LIBJPEG_FALLBACK_CHECK |
| 444 |
|
| 445 |
AC_DEFUN([ZLIB_FALLBACK_CHECK],[ |
| 446 |
AC_MSG_CHECKING([for zlib shared library file and headers]) |
| 447 |
AC_CHECK_LIB([z], [inflateEnd], |
| 448 |
[have_zlib_lib=yes], [have_zlib_lib=no]) |
| 449 |
AC_CHECK_HEADERS([zlib.h], |
| 450 |
[have_zlib_headers=yes], [have_zlib_headers=no]) |
| 451 |
|
| 452 |
if test x"$have_zlib_lib" = "xyes" && test x"$have_zlib_headers" = "xyes"; then |
| 453 |
AC_MSG_RESULT([yes]) |
| 454 |
Z_CFLAGS="" |
| 455 |
Z_LIBS="-lz" |
| 456 |
else |
| 457 |
AC_MSG_RESULT([no]) |
| 458 |
AC_MSG_FAILURE([Could not find zlib on your system, make sure |
| 459 |
the zlib shared library and header files are installed.]) |
| 460 |
fi |
| 461 |
]) # ZLIB_FALLBACK_CHECK |