1 dnl compiler.m4 --- compiler magic
3 dnl Copyright (C) 2005, 2006, 2007, 2008 Sebastian Freundt
4 dnl Copyright (c) 2005 Steven G. Johnson
5 dnl Copyright (c) 2005 Matteo Frigo
7 dnl Author: Sebastian Freundt <hroptatyr@sxemacs.org>
9 dnl Redistribution and use in source and binary forms, with or without
10 dnl modification, are permitted provided that the following conditions
13 dnl 1. Redistributions of source code must retain the above copyright
14 dnl notice, this list of conditions and the following disclaimer.
16 dnl 2. Redistributions in binary form must reproduce the above copyright
17 dnl notice, this list of conditions and the following disclaimer in the
18 dnl documentation and/or other materials provided with the distribution.
20 dnl 3. Neither the name of the author nor the names of any contributors
21 dnl may be used to endorse or promote products derived from this
22 dnl software without specific prior written permission.
24 dnl THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
25 dnl IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26 dnl WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 dnl DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 dnl FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 dnl CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 dnl SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
31 dnl BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
32 dnl WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
33 dnl OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
34 dnl IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 dnl This file is part of SXEmacs.
40 AC_DEFUN([SXE_CHECK_CC_VERSION], [dnl
41 ## ---------------------------------------------------------------
42 ## Get version information for:
44 ## #### should do CC compiler, too, if different from SXEMACS_CC
45 ## ---------------------------------------------------------------
49 AC_MSG_CHECKING([for compiler version information])
51 dnl First try portable compilers, then crack system secrets
52 dnl run through the AC_PROG_CC mill.
53 case "$(basename $CC)" in
56 compiler_version=$($CC --version | head -1)
57 gcc_compiler_specs=$($CC -v 2>&1 | sed 's/.* \([[^ ]]\)/\1/' | head -1)
59 dnl The Intel cc compiler
61 compiler_version=$($CC -V 2>&1 | head -1)
63 dnl a generic thing called `cc', we just hope that it accepts --version
65 compiler_version=$($CC --version 2>&1 | head -1)
67 dnl non-gcc machine-specific magic - contributions welcome
69 case "$ac_cv_build" in
71 dnl Yes, it's this ugly for AIX...
72 realcc=`which $SXEMACS_CC`
73 dnl Might be a symlink created by replaceCset command
74 if test -L $realcc ; then
75 ccdir=`dirname $realcc`
76 ccprog=`/bin/ls -l $realcc | sed 's/.* \([[^ ]]\)/\1/'`
77 dnl This doesn't handle ../../xlc type
78 dnl stuff, but I've not seen one...
88 lpp=`lslpp -wqc $realcc | cut -f2 -d:`
89 if test ! -z "$lpp" ; then
90 lppstr=`lslpp -Lqc $lpp`
91 lpplev=`echo "$lppstr" | cut -f3 -d:`
92 lppdesc=`echo "$lppstr" | cut -f8 -d:`
94 if test ! -z "$lpplev" ; then
95 compiler_version="$lpp $lpplev - $lppdesc"
100 compiler_version=`$SXEMACS_CC -V 2>&1 | head -1`
104 compiler_version=`$SXEMACS_CC -V | tr '\n' ' '`
108 compiler_version=`$SXEMACS_CC -version`
112 AC_MSG_RESULT([detection failed (please report this)])
113 AC_MSG_WARN([No C compiler available nor specified])
119 AC_SUBST([compiler_version])
120 AC_MSG_RESULT([$compiler_version])
123 if test -z "$compiler_version"; then
124 compiler_version="detection failed (please report this)"
126 ])dnl SXE_CHECK_CC_VERSION
128 AC_DEFUN([SXE_CHECK_CC__FGNU89_INLINE], [dnl
129 ## defines sxe_cc__fgnu89_inline
130 AC_MSG_CHECKING([whether $CC supports -fgnu89-inline])
132 SXE_LANG_WERROR([on])
133 CC="$CC -fgnu89-inline"
134 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]])],
135 [sxe_cc__fgnu89_inline="yes"],
136 [sxe_cc__fgnu89_inline="no"])
138 AC_MSG_RESULT([$sxe_cc__fgnu89_inline])
139 AC_DEFUN([SXE_CHECK_CC__FGNU89_INLINE], [])
140 ])dnl SXE_CHECK_CC__FGNU89_INLINE
142 AC_DEFUN([SXE_CHECK_CC_GNU89_EXTERN_INLINE], [dnl
143 ## defines sxe_cc_gnu89_extern_inline
144 AC_MSG_CHECKING([whether $CC supports `extern inline'])
146 SXE_LANG_WERROR([off])
147 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
154 [sxe_cc_gnu89_extern_inline="yes"],
155 [sxe_cc_gnu89_extern_inline="no"])
158 AC_MSG_RESULT([$sxe_cc_gnu89_extern_inline])
159 ])dnl SXE_CHECK_CC_GNU89_EXTERN_INLINE
161 AC_DEFUN([SXE_CHECK_CC_EXTERN_INLINE_DARWIN], [
162 AC_MSG_CHECKING([whether $CC supports `extern inline'])
164 case "$compiler_version" in
166 # For now we assume all MacOS compilers
167 # are not able to handle EXTERN_INLINE
168 AC_DEFINE([SXE_STATIC_EXTERN_INLINE], [1],
169 [The MacOS gcc does not support extern inline])
170 sxe_cc_gnu89_extern_inline="no"
174 AC_MSG_RESULT([$sxe_cc_gnu89_extern_inline])
175 ])dnl SXE_CHECK_CC_EXTERN_INLINE_DARWIN
178 AC_DEFUN([SXE_CHECK_CC_GNU89_EXTERN_INLINE_ALLERGY], [dnl
179 ## defines sxe_cc_gnu89_extern_inline_allergy
180 AC_MSG_CHECKING([whether $CC is allergic against gnu89 `extern inline' in C99])
182 SXE_LANG_WERROR([on])
183 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
190 [sxe_cc_gnu89_extern_inline_allergy="no"],
191 [sxe_cc_gnu89_extern_inline_allergy="yes"])
193 AC_MSG_RESULT([$sxe_cc_gnu89_extern_inline_allergy])
194 ])dnl SXE_CHECK_CC_GNU89_EXTERN_INLINE_ALLERGY
196 AC_DEFUN([SXE_CHECK_CC___ATTRIBUTE__GNU_INLINE], [dnl
197 ## defines sxe_cc___attribute__gnu_inline
199 AC_MSG_CHECKING([whether attribute `gnu_inline' is an efficacious medicine])
201 SXE_LANG_WERROR([on])
202 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
204 __attribute__((gnu_inline))
210 [sxe_cc___attribute__gnu_inline="yes"],
211 [sxe_cc___attribute__gnu_inline="no"])
213 AC_MSG_RESULT([$sxe_cc___attribute__gnu_inline])
214 ])dnl SXE_CHECK_CC___ATTRIBUTE__GNU_INLINE
216 AC_DEFUN([_SXE_CHECK_CC__FGNU89_INLINE_MEDICINE], [dnl
218 CC="$CC -fgnu89-inline"
219 save_sxe_cc_blabla="$sxe_cc_gnu89_extern_inline_allergy"
220 SXE_CHECK_CC_GNU89_EXTERN_INLINE_ALLERGY
221 if test "$save_sxe_cc_blabla" = "yes" -a \
222 "$sxe_cc_gnu89_extern_inline_allergy" = "no"; then
223 sxe_cc__fgnu89_inline_medicine="yes"
225 sxe_cc__fgnu89_inline_medicine="no"
228 sxe_cc_gnu89_extern_inline_allergy="$save_sxe_cc_blabla"
229 AC_MSG_CHECKING([whether flag -fgnu89-inline has been an efficacious medicine])
230 AC_MSG_RESULT([$sxe_cc__fgnu89_inline_medicine])
231 ])dnl _SXE_CHECK_CC__FGNU89_INLINE_MEDICINE
233 AC_DEFUN([SXE_CHECK_CC__FGNU89_INLINE_MEDICINE], [dnl
234 ## defines sxe_cc__fgnu89_inline_medicine
235 AC_REQUIRE([SXE_CHECK_CC__FGNU89_INLINE])
236 AC_MSG_CHECKING([whether flag -fgnu89-inline is an efficacious medicine])
237 if test "$sxe_cc__fgnu89_inline" = "yes"; then
239 _SXE_CHECK_CC__FGNU89_INLINE_MEDICINE
241 sxe_cc__fgnu89_inline_medicine="no"
242 AC_MSG_RESULT([$sxe_cc__fgnu89_inline_medicine])
244 ])dnl SXE_CHECK_CC__FGNU89_INLINE_MEDICINE
246 AC_DEFUN([SXE_CHECK_CC_GNU89_EXTERN_INLINE_MEDICINE], [dnl
247 ## check if we have a medicine against it
248 ## defines gnu89_extern_inline_medicine
249 AC_REQUIRE([SXE_CHECK_CC__FGNU89_INLINE])
250 if test "$sxe_cc_gnu89_extern_inline" = "yes" -a \
251 "$sxe_cc_gnu89_extern_inline_allergy" = "yes"; then
252 SXE_CHECK_CC___ATTRIBUTE__GNU_INLINE
253 SXE_CHECK_CC__FGNU89_INLINE_MEDICINE
255 if test "$sxe_cc__fgnu89_inline_medicine" = "yes"; then
256 CC="$CC -fgnu89-inline"
257 elif test "$sxe_cc__fgnu89_inline" = "yes"; then
258 ## use gnu89-inline anyway
259 ## this is to cope with gcc 4.3.0 which seems to support
260 ## real C99 extern inlines, which in turn would break
261 ## our build as we paid no heed at this (yet)
262 CC="$CC -fgnu89-inline"
264 ])dnl SXE_CHECK_CC_GNU89_EXTERN_INLINE_MEDICINE
266 AC_DEFUN([SXE_CHECK_CC_EXTERN_INLINE], [dnl
268 case "$ac_cv_build" in
270 ## don't bother at all ... just invoke the darwin handler
271 SXE_CHECK_CC_EXTERN_INLINE_DARWIN
274 ## we simply presume that extern inline is possible first
275 SXE_CHECK_CC_GNU89_EXTERN_INLINE
276 ## check if gcc dislikes gnu89 inlines in c99
277 SXE_CHECK_CC_GNU89_EXTERN_INLINE_ALLERGY
278 ## generally check if we support -fgnu89-inline
279 SXE_CHECK_CC__FGNU89_INLINE
282 if test "$sxe_cc_gnu89_extern_inline" = "yes" -a \
283 "$sxe_cc_gnu89_extern_inline_allergy" = "yes"; then
284 SXE_CHECK_CC_GNU89_EXTERN_INLINE_MEDICINE
285 elif test "$sxe_cc__fgnu89_inline" = "yes"; then
286 ## use gnu89-inline anyway
287 ## this is to cope with gcc 4.3.0 which seems to support
288 ## real C99 extern inlines, which in turn would break
289 ## our build as we paid no heed at this (yet)
290 CC="$CC -fgnu89-inline"
292 ])dnl SXE_CHECK_CC_EXTERN_INLINE
294 AC_DEFUN([SXE_CHECK_CC_CHAR], [dnl
296 ## ----------------------------------------------------------------
297 ## Checking for gnuc va list need in solaris
298 ## ----------------------------------------------------------------
299 if test "$GCC" = "yes" -a "$opsys" = "sol2" ; then
300 AC_MSG_CHECKING(for need to define gnuc_va_list)
301 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
303 #define __GNUC_VA_LIST
305 #define _VA_LIST va_list
306 typedef void *__gnuc_va_list;
307 typedef __gnuc_va_list va_list;]],[[1]])], [dnl
309 AC_DEFINE([NEED_GNUC_VA_LIST], [1], [Description here!])], [dnl
319 AC_TYPE_LONG_DOUBLE dnl only in >= 2.60
320 AC_TYPE_LONG_DOUBLE_WIDER dnl only in >= 2.60
324 dnl in case we need the modules
325 SXE_LD_EXPORT_DYNAMIC
326 dnl in case compiler issues PIE by default which breaks pdump
329 ## check whether CC reacts to `extern inline' gnu89 inline declarations
331 SXE_CHECK_CC_EXTERN_INLINE
332 ])dnl SXE_CHECK_CC_CHAR
334 AC_DEFUN([SXE_CHECK_CC_HACKS], [dnl
336 ## Identify compilers to enable compiler-specific hacks.
337 ## Add support for other compilers HERE!
338 ## GCC is already identified elsewhere.
339 AC_RUN_IFELSE([AC_LANG_SOURCE([[
342 #if defined __SUNPRO_C
346 #elif defined __USLC__ && defined __SCO_VERSION__
348 #elif defined __INTEL_COMPILER
356 echo "You appear to be using the SunPro C compiler."
360 echo "You appear to be using the DEC C compiler."
364 echo "You appear to be using the SCO C compiler."
368 echo "You appear to be using the Intel C++ compiler."
370 ## Newer versions of icc claim to be GCC
373 esac], [AS_MESSAGE([cannot cross-compile])])
374 ])dnl SXE_CHECK_CC_HACKS
377 AC_DEFUN([SXE_DO_CC_HACKS], [dnl
378 ## -----------------------
379 ## Compiler-specific hacks
380 ## -----------------------
382 dnl DEC C `-std1' means ANSI C mode
383 if test "$__DECC" = "yes"; then
384 SXE_APPEND_UNDUP([-std1], [CFLAGS])
387 dnl Some versions of SCO native compiler need -Kalloca
388 if test "$__USLC__" = yes; then
389 AC_MSG_CHECKING([whether the -Kalloca compiler flag is needed])
391 AC_LINK_IFELSE([AC_LANG_SOURCE([[void *x = alloca(4);]])], [:], [
393 CFLAGS="$CFLAGS -Kalloca"
394 AC_LINK_IFELSE([AC_LANG_SOURCE([[void *x = alloca(4);]])],
395 [ need_kalloca=yes ])
397 AC_MSG_RESULT([$need_kalloca])
398 if test "$need_kalloca" = "yes"; then
399 SXE_APPEND_UNDUP([-Kalloca], [c_switch_system])
400 SXE_APPEND_UNDUP([-Kalloca], [CFLAGS])
405 if test "$CC" = "g++" -o "$SXE_CC" = "g++" ; then
406 SXE_DIE("Building with g++ is not supported")
410 ])dnl SXE_DO_CC_HACKS
412 AC_DEFUN([SXE_CHECK_CC_NESTED_FUNS], [dnl
413 ## defines HAVE_NESTED_FUNS
415 AC_MSG_CHECKING([whether functions can be nested])
416 _SXE_CHECK_CC_NESTED_FUNS
417 AC_MSG_RESULT([$sxe_cv_c_nested_funs])
419 if test "$sxe_cv_c_nested_funs" != "yes"; then
420 ## in this case we check if we can do with -fnested-functions
421 SXE_CHECK_COMPILER_FLAGS([-fnested-functions])
422 if test "$sxe_cv_c_flags__fnested_functions" = "yes"; then
423 AC_MSG_CHECKING([whether functions can be nested now])
424 _SXE_CHECK_CC_NESTED_FUNS([-fnested-functions])
425 AC_MSG_RESULT([$sxe_cv_c_nested_funs])
429 if test "$sxe_cv_c_nested_funs" = "yes"; then
430 AC_DEFINE([HAVE_NESTED_FUNS], [1], [Whether funs can be nested])
432 AC_MSG_WARN([Uh oh.])
433 AC_MSG_WARN([A look into my crystal ball reveals a broken build.])
434 AC_MSG_WARN([Get a compiler that is capable of nested functions.])
436 ])dnl SXE_CHECK_CC_NESTED_FUNS
438 AC_DEFUN([_SXE_CHECK_CC_NESTED_FUNS], [dnl
439 ## defines sxe_cv_c_nested_funs
440 ## optional arg 1 may be additional CFLAGS
441 pushdef([ADDCFLAGS], [$1])
444 CFLAGS="${CFLAGS} []ADDCFLAGS[]"
445 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
446 /* we are in main now and we nest another function */
447 auto inline int foobar();
449 inline int foobar(int counter)
456 [sxe_cv_c_nested_funs="yes"],
457 [sxe_cv_c_nested_funs="no"])
461 ])dnl _SXE_CHECK_CC_NESTED_FUNS
464 AC_DEFUN([SXE_CHECK_BROKEN_GCC], [
465 dnl This section needs a rewrite. I think it should just bomb if we
466 dnl find a gcc that is older than 2.95.3 --SY.
467 dnl Search for GCC specific build problems we know about
469 AC_MSG_CHECKING([for buggy gcc versions])
470 GCC_VERSION=`$CC --version`
473 2.6.*|2.7.*|2.8.*|2.9* )
475 AC_MSG_WARN([Don't use medieval compilers])
476 AC_MSG_ERROR([Aborting due to known problem])
478 3.0.*|3.1.*|3.2.*|3.3.* )
480 AC_MSG_WARN([You are using an antiquated compiler. Proceed at your own risk.])
481 AC_MSG_CHECKING([for other known compiler bugs])
485 case `uname -s`:`uname -m`:$GCC_VERSION in
486 dnl pie-enabled GCC on Linux needs -nopie to build SXEmacs
487 Linux:i?86:gcc*pie-*)
490 dnl egcs 2.90.21 (egcs-1.00 release)
491 dnl egcs 2.90.29 (egcs-1.0.3 release)
492 *:sun4*:2.8.1|*:sun4*:egcs-2.90.*)
493 dnl Don't use -O2 with gcc 2.8.1 and egcs 1.0 under SPARC architectures
494 dnl without also using `-fno-schedule-insns'.
498 *-fno-schedule-insns*)
502 AC_MSG_WARN([Don't use -O2 with gcc 2.8.1 and egcs 1.0 under SPARC architectures])
503 AC_MSG_WARN([without also using -fno-schedule-insns.])
504 AC_MSG_ERROR([Aborting due to known problem])
511 dnl egcs-2.91.57 (egcs-1.1 release)
512 dnl egcs-2.91.66 (egcs-1.1.2 release)
513 Linux:alpha:egcs-2.91.*)
515 AC_MSG_WARN([There have been reports of egcs-1.1 not compiling SXEmacs correctly on])
516 AC_MSG_WARN([Alpha Linux. There have also been reports that egcs-1.0.3a is O.K.])
517 AC_MSG_ERROR([Aborting due to known problem])
524 ])dnl SXE_CHECK_BROKEN_GCC
527 AC_DEFUN([SXE_DEBUGFLAGS], [dnl
528 ## distinguish between different compilers, no?
529 SXE_CHECK_COMPILER_FLAGS([-g])
530 SXE_CHECK_COMPILER_FLAGS([-g3])
532 AC_PATH_PROG([DBX], [dbx])
533 if test -n "$ac_cv_path_DBX"; then
534 SXE_CHECK_COMPILER_FLAGS([-gstabs])
535 SXE_CHECK_COMPILER_FLAGS([-gstabs3])
536 SXE_CHECK_COMPILER_FLAGS([-gxcoff])
537 SXE_CHECK_COMPILER_FLAGS([-gxcoff3])
540 AC_PATH_PROG([GDB], [gdb])
541 if test -n "$ac_cv_path_GDB"; then
542 SXE_CHECK_COMPILER_FLAGS([-ggdb])
543 SXE_CHECK_COMPILER_FLAGS([-ggdb3])
546 AC_PATH_PROG([SDB], [sdb])
547 if test -n "$ac_cv_path_SDB"; then
548 SXE_CHECK_COMPILER_FLAGS([-gcoff])
549 SXE_CHECK_COMPILER_FLAGS([-gcoff3])
555 if test "$sxe_cv_c_flags__ggdb3" = "yes"; then
556 debugflags="$debugflags -ggdb3"
557 elif test "$sxe_cv_c_flags__ggdb" = "yes"; then
558 debugflags="$debugflags -ggdb"
561 if test "$sxe_cv_c_flags__gstabs3" = "yes"; then
562 debugflags="$debugflags -gstabs3"
563 elif test "$sxe_cv_c_flags__gstabs" = "yes"; then
564 debugflags="$debugflags -gstabs"
567 if test "$sxe_cv_c_flags__gcoff3" = "yes"; then
568 debugflags="$debugflags -gcoff3"
569 elif test "$sxe_cv_c_flags__gcoff" = "yes"; then
570 debugflags="$debugflags -gcoff"
573 if test "$sxe_cv_c_flags__gxcoff3" = "yes"; then
574 debugflags="$debugflags -gxcoff3"
575 elif test "$sxe_cv_c_flags__gxcoff" = "yes"; then
576 debugflags="$debugflags -gxcoff"
579 if test -z "debugflags" -a \
580 "$sxe_cv_c_flags__g" = "yes"; then
581 debugflags="$debugflags -g"
584 SXE_CHECK_COMPILER_FLAGS([-ftime-report])
585 SXE_CHECK_COMPILER_FLAGS([-fmem-report])
586 SXE_CHECK_COMPILER_FLAGS([-fvar-tracking])
587 SXE_CHECK_COMPILER_FLAGS([-save-temps])
589 #if test "$sxe_cv_c_flags__ggdb3" = "yes" -a \
590 # "$sxe_cv_c_flags__fvar_tracking" = "yes"; then
591 # debugflags="$debugflags -fvar-tracking"
594 AC_MSG_CHECKING([for preferred debugging flags])
595 AC_MSG_RESULT([${debugflags}])
598 AC_DEFUN([SXE_WARNFLAGS], [dnl
599 ## Calculate warning flags. We separate the flags for warnings from
600 ## the other flags because we want to force the warnings to be seen
601 ## by everyone who doesn't specifically override them.
603 ## by default we want the -Wall level
604 SXE_CHECK_COMPILER_FLAGS([-Wall], [warnflags="-Wall"])
606 SXE_CHECK_COMPILER_FLAGS([-qinfo], [
607 warnflags="${warnflags} -qinfo"])
609 ## Yuck, bad compares have been worth at
611 ## Warnings about char subscripts are pretty
612 ## pointless, though,
613 ## and we use them in various places.
614 SXE_CHECK_COMPILER_FLAGS([-Wsign-compare], [
615 warnflags="$warnflags -Wsign-compare"])
616 SXE_CHECK_COMPILER_FLAGS([-Wno-char-subscripts], [
617 warnflags="$warnflags -Wno-char-subscripts"])
618 SXE_CHECK_COMPILER_FLAGS([-Wundef], [
619 warnflags="$warnflags -Wundef"])
621 ## too much at the moment, we rarely define protos
622 #warnflags="$warnflags -Wmissing-prototypes -Wstrict-prototypes"
623 SXE_CHECK_COMPILER_FLAGS([-Wpacked], [
624 warnflags="$warnflags -Wpacked"])
626 ## glibc is intentionally not `-Wpointer-arith'-clean.
627 ## Ulrich Drepper has rejected patches to fix
628 ## the glibc header files.
630 SXE_CHECK_COMPILER_FLAGS([-Wpointer-arith], [
631 warnflags="$warnflags -Wpointer-arith"])
633 SXE_CHECK_COMPILER_FLAGS([-Wshadow], [
634 warnflags="$warnflags -Wshadow"])
636 ## our code lacks declarations almost all the time
637 SXE_CHECK_COMPILER_FLAGS([-Wmissing-declarations], [
638 warnflags="$warnflags -Wmissing-declarations"])
639 SXE_CHECK_COMPILER_FLAGS([-Wmissing-prototypes], [
640 warnflags="$warnflags -Wmissing-prototypes"])
641 SXE_CHECK_COMPILER_FLAGS([-Winline], [
642 warnflags="$warnflags -Winline"])
643 SXE_CHECK_COMPILER_FLAGS([-Wbad-function-cast], [
644 warnflags="$warnflags -Wbad-function-cast"])
645 SXE_CHECK_COMPILER_FLAGS([-Wcast-qual], [
646 warnflags="$warnflags -Wcast-qual"])
647 SXE_CHECK_COMPILER_FLAGS([-Wcast-align], [
648 warnflags="$warnflags -Wcast-align"])
650 ## warn about incomplete switches
651 SXE_CHECK_COMPILER_FLAGS([-Wswitch], [
652 warnflags="$warnflags -Wswitch"])
653 SXE_CHECK_COMPILER_FLAGS([-Wswitch-default], [
654 warnflags="$warnflags -Wswitch-default"])
655 SXE_CHECK_COMPILER_FLAGS([-Wswitch-enum], [
656 warnflags="$warnflags -Wswitch-enum"])
659 SXE_CHECK_COMPILER_FLAGS([-Wunused-function], [
660 warnflags="$warnflags -Wunused-function"])
661 SXE_CHECK_COMPILER_FLAGS([-Wunused-variable], [
662 warnflags="$warnflags -Wunused-variable"])
663 SXE_CHECK_COMPILER_FLAGS([-Wunused-parameter], [
664 warnflags="$warnflags -Wunused-parameter"])
665 SXE_CHECK_COMPILER_FLAGS([-Wunused-value], [
666 warnflags="$warnflags -Wunused-value"])
667 SXE_CHECK_COMPILER_FLAGS([-Wunused], [
668 warnflags="$warnflags -Wunused"])
671 SXE_CHECK_COMPILER_FLAGS([-Wreorder], [
672 warnflags="$warnflags -Wreorder"])
673 SXE_CHECK_COMPILER_FLAGS([-Wdeprecated], [
674 warnflags="$warnflags -Wdeprecated"])
675 SXE_CHECK_COMPILER_FLAGS([-Wnopragma], [
676 warnflags="$warnflags -Wnopragma"])
678 ## for upcoming libev support
679 ## libev is a warning emitting cow, the developers can't
680 ## be arsed to fix it, as it turns out
681 SXE_CHECK_COMPILER_FLAGS([-fno-strict-aliasing], [
682 warnflags="$warnflags -fno-strict-aliasing"])
684 AC_MSG_CHECKING([for preferred warning flags])
685 AC_MSG_RESULT([${warnflags}])
688 AC_DEFUN([SXE_OPTIFLAGS], [dnl
692 case $sxe_cv_c_compiler_vendor in
719 AC_MSG_CHECKING([for preferred optimising flags])
720 AC_MSG_RESULT([$optiflags])
721 if test -z "$optiflags"; then
723 echo "********************************************************"
724 echo "* WARNING: Don't know the best CFLAGS for this system *"
725 echo "* Use ./configure CFLAGS=... to specify your own flags *"
726 echo "* (otherwise, a default of CFLAGS=-O3 will be used) *"
727 echo "********************************************************"
732 SXE_CHECK_COMPILER_FLAGS([$optiflags], [:], [
734 echo "********************************************************"
735 echo "* WARNING: The guessed CFLAGS don't seem to work with *"
736 echo "* your compiler. *"
737 echo "* Use ./configure CFLAGS=... to specify your own flags *"
738 echo "********************************************************"
744 AC_DEFUN([SXE_FEATFLAGS], [dnl
745 ## default flags for needed features
747 ## we need nested functions ... hm, i dont think we do
748 ## but it's always nice to have them
749 SXE_CHECK_COMPILER_FLAGS([-fnested-functions], [
750 featflags="$featflags -fnested-functions"])
752 ## recent gentoos went ballistic again, they compile PIE gcc's
753 ## but there's no way to turn that misconduct off ...
754 ## however I've got one report about a working PIE build
755 ## we'll just check for -nopie here, if it works, we turn it on
756 ## (and hence PIE off) and hope bug 16 remains fixed
757 SXE_CHECK_COMPILER_FLAGS([-nopie],
758 [featflags="$featflags -nopie"])
761 dnl XFLAG="-XCClinker"
763 ## default flags for needed features
764 SXE_CHECK_COMPILER_FLAGS([-static-intel], [
765 ldflags="${ldflags} ${XFLAG} -static-intel"])
766 SXE_CHECK_COMPILER_FLAGS([-static-libgcc], [
767 ldflags="${ldflags} ${XFLAG} -static-libgcc"])
771 AC_DEFUN([SXE_COMPILER_VENDOR], [dnl
772 AC_CACHE_CHECK([for _AC_LANG compiler vendor],
773 sxe_cv_[]_AC_LANG_ABBREV[]_compiler_vendor,
774 [sxe_cv_[]_AC_LANG_ABBREV[]_compiler_vendor=unknown
775 # note: don't check for gcc first since some other compilers define __GNUC__
777 intel:__ICC,__ECC,__INTEL_COMPILER \
778 ibm:__xlc__,__xlC__,__IBMC__,__IBMCPP__ \
779 gnu:__GNUC__ sun:__SUNPRO_C,__SUNPRO_CC \
780 hp:__HP_cc,__HP_aCC \
781 dec:__DECC,__DECCXX,__DECC_VER,__DECCXX_VER \
782 borland:__BORLANDC__,__TURBOC__ \
787 metrowerks:__MWERKS__ \
793 vencpp="defined("$(echo \
794 $ventest | cut -d: -f2 | sed "s/,/) || defined(/g")")"
795 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[
799 ])], [sxe_cv_]_AC_LANG_ABBREV[_compiler_vendor=$(echo $ventest | cut -d: -f1); break; ])
802 ])dnl SXE_COMPILER_VENDOR
805 AC_DEFUN([SXE_CC_MAXOPT_DEC], [dnl
806 optiflags="-newc -w0 -O5 -ansi_alias -ansi_args -fp_reorder -tune host"
807 if test "$acx_maxopt_portable" = "no"; then
808 optiflags="$optiflags -arch host"
810 ])dnl SXE_CC_MAXOPT_DEC
812 AC_DEFUN([SXE_CC_MAXOPT_SUN], [dnl
813 optiflags="-native -fast -xO5 -dalign"
814 if test "$acx_maxopt_portable" = "yes"; then
815 optiflags="$optiflags -xarch=generic"
817 ])dnl SXE_CC_MAXOPT_SUN
819 AC_DEFUN([SXE_CC_MAXOPT_HP], [dnl
820 optiflags="+Oall +Optrs_ansi +DSnative"
821 if test "$acx_maxopt_portable" = "yes"; then
822 optiflags="$optiflags +DAportable"
824 ])dnl SXE_CC_MAXOPT_HP
826 AC_DEFUN([SXE_CC_MAXOPT_IBM], [dnl
827 if test "$acx_maxopt_portable" = "no"; then
828 xlc_opt="-qarch=auto -qtune=auto"
830 xlc_opt="-qtune=auto"
832 SXE_CHECK_COMPILER_FLAGS([$xlc_opt],
833 [optiflags="-O3 -qansialias -w $xlc_opt"],
834 [optiflags="-O3 -qansialias -w"
835 echo "******************************************************"
836 echo "* You seem to have the IBM C compiler. It is *"
837 echo "* recommended for best performance that you use: *"
839 echo "* CFLAGS=-O3 -qarch=xxx -qtune=xxx -qansialias -w *"
841 echo "* where xxx is pwr2, pwr3, 604, or whatever kind of *"
842 echo "* CPU you have. (Set the CFLAGS environment var. *"
843 echo "* and re-run configure.) For more info, man cc. *"
844 echo "******************************************************"])
845 ])dnl SXE_CC_MAXOPT_IBM
847 AC_DEFUN([SXE_CC_MAXOPT_INTEL], [dnl
848 optiflags="-O3 -ansi_alias"
849 if test "$acx_maxopt_portable" = "no"; then
855 # icc accepts gcc assembly syntax,
856 # so these should work:
860 if test "$icc_flags" != ""; then
861 for flag in $icc_flags; do
862 SXE_CHECK_COMPILER_FLAGS([$flag],
863 [icc_archflag=$flag; break])
866 AC_MSG_CHECKING([for icc architecture flag])
867 AC_MSG_RESULT([$icc_archflag])
868 if test "$icc_archflag" != "unknown"; then
869 optiflags="$optiflags $icc_archflag"
872 ])dnl SXE_CC_MAXOPT_INTEL
874 AC_DEFUN([SXE_CC_MAXOPT_GNU], [dnl
875 ## default optimisation flags for gcc on all systems
876 ## this is the preferred compiler
879 AC_REQUIRE([SXE_CHECK_SIMD_EXTENSIONS])
880 optiflags="$optiflags $simdflags"
882 ## note that we enable "unsafe" fp optimisation with other compilers, too
883 SXE_CHECK_COMPILER_FLAGS([-ftree-vectorize],
884 [optiflags="$optiflags -ftree-vectorize"])
886 ## check for -march and/or -mtune
887 SXE_GCC_ARCHFLAG([$acx_maxopt_portable])
888 optiflags="$optiflags $archflags"
890 ## a softer variant of omit-frame-pointer
891 SXE_CHECK_COMPILER_FLAGS([-momit-leaf-frame-pointer],
892 [optiflags="$optiflags -momit-leaf-frame-pointer"])
894 ## check for openmp support
895 ## there are: -fopenmp -xopenmp -openmp -mp -omp -qsmp=omp
896 SXE_CHECK_COMPILER_FLAGS([-fopenmp])
898 if test "$sxe_cv_c_flags__fopenmp" = "yes" -a "$with_omp"; then
899 SXE_MSG_CHECKING([whether it is safe to use -fopenmp])
900 case "$compiler_version" in
902 optiflags="$optiflags -fopenmp"
903 sxe_cv_feat_omp="yes"
904 SXE_MSG_RESULT([yes])
912 ## these belong to the corresponding MAXOPT macro
913 dnl SXE_CHECK_COMPILER_FLAGS([-xopenmp], [
914 dnl optiflags="$optiflags -xopenmp"
915 dnl sxe_cv_feat_omp="yes"
917 dnl SXE_CHECK_COMPILER_FLAGS([-openmp], [
918 dnl optiflags="$optiflags -openmp"
919 dnl sxe_cv_feat_omp="yes"
921 dnl SXE_CHECK_COMPILER_FLAGS([-mp], [
922 dnl optiflags="$optiflags -mp"
923 dnl sxe_cv_feat_omp="yes"
925 dnl SXE_CHECK_COMPILER_FLAGS([-omp], [
926 dnl optiflags="$optiflags -omp"
927 dnl sxe_cv_feat_omp="yes"
929 dnl SXE_CHECK_COMPILER_FLAGS([-qsmp=omp], [
930 dnl optiflags="$optiflags -qsmp=omp"
931 dnl sxe_cv_feat_omp="yes"
933 ## add -lgomp to ldflags
934 if test "$sxe_cv_feat_omp" = "yes"; then
935 LDFLAGS="$LDFLAGS -lgomp"
938 # -malign-double for x86 systems
939 SXE_CHECK_COMPILER_FLAGS([-malign-double])
940 ## won't add this one, since it is causing problems
941 ## [optiflags="$optiflags -malign-double"])
943 ## would be nice to have this but it triggers too many
944 ## meaningless warnings
945 dnl ## -fstrict-aliasing for gcc-2.95+
946 dnl SXE_CHECK_COMPILER_FLAGS([-fstrict-aliasing],
947 dnl [optiflags="$optiflags -fstrict-aliasing"])
949 SXE_CHECK_COMPILER_FLAGS([-fearly-inlining],
950 [optiflags="$optiflags -fearly-inlining"])
952 SXE_CHECK_COMPILER_FLAGS([-fdelete-null-pointer-checks],
953 [optiflags="$optiflags -fdelete-null-pointer-checks"])
955 SXE_CHECK_COMPILER_FLAGS([-fmodulo-sched],
956 [optiflags="$optiflags -fmodulo-sched"])
958 SXE_CHECK_COMPILER_FLAGS([-fmudflap])
959 SXE_CHECK_COMPILER_FLAGS([-fmudflapth])
960 SXE_CHECK_COMPILER_FLAGS([-fmudflapir])
961 if test "$sxe_cv_c_flags__fmudflapth" -a \
962 "$sxe_cv_c_flags__fmudflapir"; then
964 : ##optiflags="$optiflags -fmudflapth -fmudflapir"
965 elif test "$sxe_cv_c_flags__fmudflap" -a \
966 "$sxe_cv_c_flags__fmudflapir"; then
967 : ##optiflags="$optiflags -fmudflap -fmudflapir"
969 SXE_CHECK_COMPILER_FLAGS([-fsection-anchors],
970 [optiflags="$optiflags -fsection-anchors"])
972 dnl ## actually this belongs to error-checking stuff
973 dnl SXE_CHECK_COMPILER_FLAGS([-fstack-protector],
974 dnl [optiflags="$optiflags -fstack-protector"])
975 dnl if test "$sxe_cv_c_flags__fstack_protector" = "yes"; then
976 dnl ## just check for ssp in this case
977 dnl AC_CHECK_LIB([ssp], [__stack_chk_guard])
980 SXE_CHECK_COMPILER_FLAGS([-fbranch-target-load-optimize])
981 SXE_CHECK_COMPILER_FLAGS([-fbranch-target-load-optimize2])
982 if test "$sxe_cv_c_flags__fbranch_target_load_optimize2" = "yes"; then
983 optiflags="$optiflags -fbranch-target-load-optimize2"
984 elif test "$sxe_cv_c_flags__fbranch_target_load_optimize" = "yes"; then
985 optiflags="$optiflags -fbranch-target-load-optimize"
988 SXE_CHECK_COMPILER_FLAGS([-fgcse],
989 [optiflags="$optiflags -fgcse"])
990 SXE_CHECK_COMPILER_FLAGS([-fgcse-lm],
991 [optiflags="$optiflags -fgcse-lm"])
992 SXE_CHECK_COMPILER_FLAGS([-fgcse-sm],
993 [optiflags="$optiflags -fgcse-sm"])
994 SXE_CHECK_COMPILER_FLAGS([-fgcse-las],
995 [optiflags="$optiflags -fgcse-las"])
996 SXE_CHECK_COMPILER_FLAGS([-fgcse-after-reload],
997 [optiflags="$optiflags -fgcse-after-reload"])
998 SXE_CHECK_COMPILER_FLAGS([-funsafe-loop-optimizations],
999 [optiflags="$optiflags -funsafe-loop-optimizations"])
1000 SXE_CHECK_COMPILER_FLAGS([-funroll-loops],
1001 [optiflags="$optiflags -funswitch-loops"])
1002 SXE_CHECK_COMPILER_FLAGS([-funswitch-loops],
1003 [optiflags="$optiflags -funswitch-loops"])
1004 SXE_CHECK_COMPILER_FLAGS([-frename-registers],
1005 [optiflags="$optiflags -frename-registers"])
1008 SXE_CHECK_COMPILER_FLAGS([-funsafe-math-optimizations -fno-signaling-nans],
1009 [optiflags="$optiflags -fno-signaling-nans"])
1010 SXE_CHECK_COMPILER_FLAGS([-funsafe-math-optimizations -fno-trapping-math],
1011 [optiflags="$optiflags -fno-trapping-math"])
1012 SXE_CHECK_COMPILER_FLAGS([-funsafe-math-optimizations -fno-signed-zeros],
1013 [optiflags="$optiflags -fno-signed-zeros"])
1014 SXE_CHECK_COMPILER_FLAGS([-funsafe-math-optimizations -fassociative-math],
1015 [optiflags="$optiflags -fassociative-math"])
1016 SXE_CHECK_COMPILER_FLAGS([-funsafe-math-optimizations -fno-rounding-math],
1017 [optiflags="$optiflags -fno-rounding-math"])
1018 SXE_CHECK_COMPILER_FLAGS([-funsafe-math-optimizations -fno-math-errno],
1019 [optiflags="$optiflags -fno-math-errno"])
1020 ## the same as the previous 5, but sometimes gcc doesn't know'em all
1021 SXE_CHECK_COMPILER_FLAGS([-funsafe-math-optimizations],
1022 [optiflags="$optiflags -funsafe-math-optimizations"])
1024 SXE_CHECK_COMPILER_FLAGS([-ffast-math],
1025 [optiflags="$optiflags -ffast-math"])
1026 ## and yet some more
1027 SXE_CHECK_COMPILER_FLAGS([-mrecip],
1028 [optiflags="$optiflags -mrecip"])
1029 SXE_CHECK_COMPILER_FLAGS([-msahf],
1030 [optiflags="$optiflags -msahf"])
1032 SXE_CHECK_COMPILER_FLAGS([-minline-all-stringops],
1033 [optiflags="$optiflags -minline-all-stringops"])
1035 ])dnl SXE_CC_MAXOPT_GNU
1038 ##### http://autoconf-archive.cryp.to/ax_check_compiler_flags.html
1039 ## renamed the prefix to SXE_
1040 AC_DEFUN([SXE_CHECK_COMPILER_FLAGS], [dnl
1041 AC_MSG_CHECKING([whether _AC_LANG compiler accepts $1])
1043 dnl Some hackery here since AC_CACHE_VAL can't handle a non-literal varname:
1044 SXE_LANG_WERROR([push+on])
1045 AS_LITERAL_IF([$1], [
1046 AC_CACHE_VAL(AS_TR_SH(sxe_cv_[]_AC_LANG_ABBREV[]_flags_$1), [
1047 sxe_save_FLAGS=$[]_AC_LANG_PREFIX[]FLAGS
1048 _AC_LANG_PREFIX[]FLAGS="$1"
1049 AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
1050 AS_TR_SH(sxe_cv_[]_AC_LANG_ABBREV[]_flags_$1)="yes",
1051 AS_TR_SH(sxe_cv_[]_AC_LANG_ABBREV[]_flags_$1)="no")
1052 _AC_LANG_PREFIX[]FLAGS=$sxe_save_FLAGS])], [
1053 sxe_save_FLAGS=$[]_AC_LANG_PREFIX[]FLAGS
1054 _AC_LANG_PREFIX[]FLAGS="$1"
1055 AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
1056 eval AS_TR_SH(sxe_cv_[]_AC_LANG_ABBREV[]_flags_$1)="yes",
1057 eval AS_TR_SH(sxe_cv_[]_AC_LANG_ABBREV[]_flags_$1)="no")
1058 _AC_LANG_PREFIX[]FLAGS=$sxe_save_FLAGS])
1059 eval sxe_check_compiler_flags=$AS_TR_SH(sxe_cv_[]_AC_LANG_ABBREV[]_flags_$1)
1060 SXE_LANG_WERROR([pop])
1062 AC_MSG_RESULT([$sxe_check_compiler_flags])
1063 if test "$sxe_check_compiler_flags" = "yes"; then
1068 ])dnl SXE_CHECK_COMPILER_FLAGS
1071 AC_DEFUN([SXE_CHECK_CPU], [dnl
1075 ## pc-style hardware
1096 AC_DEFUN([SXE_CHECK_CPU_SPARC], [dnl
1097 AC_PATH_PROG([PRTDIAG], [prtdiag], [prtdiag],
1098 [$PATH:/usr/platform/`uname -i`/sbin/:/usr/platform/`uname -m`/sbin/])
1099 cputype=$((((grep cpu /proc/cpuinfo | cut -d: -f2) ; \
1100 ($PRTDIAG -v |grep -i sparc) ; \
1101 grep -i cpu "/var/run/dmesg.boot" ) | head -n 1) 2> /dev/null)
1102 cputype=$(echo "$cputype" | tr -d ' -' |tr $as_cr_LETTERS $as_cr_letters)
1107 sxe_gcc_arch="ultrasparc4 ultrasparc3 ultrasparc v9"
1111 sxe_gcc_arch="ultrasparc3 ultrasparc v9"
1115 sxe_gcc_arch="ultrasparc v9"
1118 *supersparc*|*tms390z5[[05]]*)
1119 sxe_gcc_arch="supersparc v8"
1122 *hypersparc*|*rt62[[056]]*)
1123 sxe_gcc_arch="hypersparc v8"
1127 sxe_gcc_arch=cypress
1130 ])dnl SXE_CHECK_CPU_SPARC
1132 AC_DEFUN([SXE_CHECK_CPU_ALPHA], [dnl
1144 sxe_gcc_arch="pca56 ev56"
1148 sxe_gcc_arch="pca57 pca56 ev56"
1160 sxe_gcc_arch="ev68 ev67"
1164 sxe_gcc_arch="ev69 ev68 ev67"
1168 sxe_gcc_arch="ev7 ev69 ev68 ev67"
1172 sxe_gcc_arch="ev79 ev7 ev69 ev68 ev67"
1175 ])dnl SXE_CHECK_CPU_ALPHA
1177 AC_DEFUN([SXE_CHECK_CPU_PPC], [dnl
1178 cputype=$(((grep cpu /proc/cpuinfo | head -n 1 | \
1179 cut -d: -f2 | cut -d, -f1 | sed 's/ //g') ; \
1180 /usr/bin/machine ; \
1182 grep CPU /var/run/dmesg.boot | \
1183 head -n 1 | cut -d" " -f2) 2> /dev/null)
1184 cputype=$(echo $cputype | sed -e 's/ppc//g;s/ *//g')
1189 sxe_gcc_arch="750 G3"
1193 sxe_gcc_arch="$cputype 7400 G4"
1197 sxe_gcc_arch="$cputype 7450 G4"
1201 sxe_gcc_arch="$cputype G4"
1205 sxe_gcc_arch="970 G5 power4"
1208 *POWER4*|*power4*|*gq*)
1209 sxe_gcc_arch="power4 970"
1212 *POWER5*|*power5*|*gr*|*gs*)
1213 sxe_gcc_arch="power5 power4 970"
1217 sxe_gcc_arch="$cputype 603e 603"
1221 sxe_gcc_arch="$cputype"
1224 sxe_gcc_arch="$sxe_gcc_arch powerpc"
1225 ])dnl SXE_CHECK_CPU_PPC
1227 AC_DEFUN([SXE_CHECK_CPU_PC], [dnl
1229 AC_REQUIRE([SXE_PROC_CPUID])
1231 case "$sxe_cv_proc_cpuid_00000000" in
1235 case "$sxe_cv_proc_cpuid_00000001" in
1238 sxe_gcc_arch="pentium-mmx pentium"
1242 sxe_gcc_arch="pentium"
1246 sxe_gcc_arch="pentium2 pentiumpro"
1250 sxe_gcc_arch="pentium2 pentiumpro"
1254 sxe_gcc_arch="pentium3 pentiumpro"
1259 sxe_gcc_arch="pentium-m pentium3 pentiumpro"
1264 sxe_gcc_arch="pentium-m pentium3 pentiumpro"
1268 sxe_gcc_arch="pentium3 pentiumpro"
1274 sxe_gcc_arch="nocona pentium4 pentiumpro"
1280 sxe_gcc_arch="pentiumpro"
1283 *f3[[347]]:*:*:*|*f4[1347]:*:*:*)
1284 icc_flags="-xP -xN -xW -xK"
1288 sxe_gcc_arch="nocona pentium4 pentiumpro"
1292 sxe_gcc_arch="prescott pentium4 pentiumpro"
1298 icc_flags="-xN -xW -xK"
1299 sxe_gcc_arch="pentium4 pentiumpro"
1306 case "$sxe_cv_proc_cpuid_00000001" in
1313 sxe_gcc_arch="k6-2 k6"
1317 sxe_gcc_arch="k6-3 k6"
1325 sxe_gcc_arch="athlon k7"
1329 sxe_gcc_arch="athlon-tbird k7"
1333 sxe_gcc_arch="athlon-4 athlon k7"
1337 case "$sxe_cv_proc_cpuid_80000006" in
1339 *:*:*[[1-9a-f]]??????:*) # (L2 = ecx >> 16) >= 256
1340 sxe_gcc_arch="athlon-xp athlon-4 athlon k7"
1344 sxe_gcc_arch="athlon-4 athlon k7"
1349 *f[[4cef8b]]?:*:*:*)
1350 sxe_gcc_arch="athlon64 k8"
1354 sxe_gcc_arch="opteron k8"
1358 sxe_gcc_arch="athlon-fx opteron k8"
1369 case "$sxe_cv_proc_cpuid_00000001" in
1372 sxe_gcc_arch="winchip-c6"
1376 sxe_gcc_arch="winchip2"
1384 sxe_gcc_arch="c3-2 c3"
1390 ## nothing found? => fallback
1391 if test -z "$sxe_gcc_arch"; then
1392 ## apply a generic strategy
1395 sxe_gcc_arch="pentium"
1398 sxe_gcc_arch="pentiumpro"
1402 ])dnl SXE_CHECK_CPU_PC
1405 AC_DEFUN([SXE_GCC_ARCHFLAG], [dnl
1406 AC_REQUIRE([AC_PROG_CC])
1407 AC_REQUIRE([AC_CANONICAL_HOST])
1409 AC_ARG_WITH([gcc-arch], AS_HELP_STRING([--with-gcc-arch=<arch>], [
1410 use architecture <arch> for gcc -march/-mtune,
1411 instead of guessing]),
1412 [sxe_gcc_arch=$withval], [sxe_gcc_arch=yes])
1414 AC_MSG_CHECKING([for gcc architecture flag])
1416 AC_CACHE_VAL([sxe_cv_gcc_archflag], [
1417 ## initialise to unknown
1418 sxe_cv_gcc_archflag="unknown"
1420 if test "$GCC" = yes; then
1421 if test "$sxe_gcc_arch" = "yes" -a \
1422 "$cross_compiling" = "no"; then
1427 if test -n "$sxe_gcc_arch" -a "$sxe_gcc_arch" != "no"; then
1428 for arch in $sxe_gcc_arch; do
1429 if test "[]m4_default([$1],yes)" = "yes"; then
1430 ## if we require portable code
1431 archflags="-mtune=$arch"
1432 ## -mcpu=$arch and m$arch generate
1433 ## nonportable code on every arch except
1434 ## x86. And some other arches
1435 ## (e.g. Alpha) don't accept -mtune.
1440 archflags="$archflags -mcpu=$arch -m$arch"
1444 archflags="-march=$arch -mcpu=$arch -m$arch"
1446 for flag in $archflags; do
1447 SXE_CHECK_COMPILER_FLAGS([$flag],
1448 [sxe_cv_gcc_archflag="$flag"; break])
1450 if test "$sxe_cv_gcc_archflag" != "unknown"; then
1458 AC_MSG_CHECKING([for gcc architecture flag])
1459 AC_MSG_RESULT([$sxe_cv_gcc_archflag])
1460 if test "$sxe_cv_gcc_archflag" = "unknown"; then
1463 m4_default([$2], [archflags="$sxe_cv_gcc_archflag"])
1465 ])dnl SXE_GCC_ARCHFLAG
1468 #### http://autoconf-archive.cryp.to/sxe_check_define.html
1469 AC_DEFUN([SXE_CHECK_DEFINED], [dnl
1470 AS_VAR_PUSHDEF([ac_var],[ac_cv_defined_$2])dnl
1472 AC_CACHE_CHECK([for $1 defined], ac_var,
1480 AS_VAR_SET(ac_var, [yes]),
1481 AS_VAR_SET(ac_var, [no])))
1483 AS_IF([test AS_VAR_GET(ac_var) != "no"], [$3], [$4])
1484 AS_VAR_POPDEF([ac_var])
1485 ])dnl SXE_CHECK_DEFINED
1487 AC_DEFUN([SXE_CHECK_FUNC], [dnl
1488 AS_VAR_PUSHDEF([ac_var], [ac_cv_func_$2])dnl
1489 AC_CACHE_CHECK([for $2], ac_var, [
1490 dnl AC_LANG_FUNC_LINK_TRY
1491 AC_LINK_IFELSE([AC_LANG_PROGRAM([$1
1498 AS_VAR_SET(ac_var, [yes])], [
1499 AS_VAR_SET(ac_var, [no])])])
1501 AS_IF([test AS_VAR_GET(ac_var) = "yes"], [$3], [$4])
1502 AS_VAR_POPDEF([ac_var])
1503 ])dnl SXE_CHECK_FUNC
1507 AC_DEFUN([SXE_CHECK_C99_NJSF], [dnl
1508 dnl If we have a compiler that could do c99 do try to add the flag
1509 if test "$__GCC3" = "yes" ; then
1510 SXE_APPEND_UNDUP("-std=c99", c_switch_site)
1511 AC_MSG_CHECKING([for C99 support])
1512 save_c_switch_site=$c_switch_site
1513 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1517 ]])], [AC_MSG_RESULT(yes)
1519 [c_switch_site=$sace_c_switch_site
1521 AC_MSG_WARN([C99 not supported, reverting option append])
1523 elif test "$__SUNPRO_C" = "yes" ; then
1524 AC_MSG_CHECKING([for C99 support])
1525 save_c_switch_site=$c_switch_site
1526 SXE_APPEND_UNDUP("-xc99", c_switch_site)
1527 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1531 ]])], [AC_MSG_RESULT(yes)
1533 [c_switch_site=$sace_c_switch_site
1537 ])dnl SXE_CHECK_C99_NJSF
1540 AC_DEFUN([SXE_C_TYPEOF], [dnl
1541 dnl check for the typeof extension
1542 AC_MSG_CHECKING([for typeof])
1543 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
1544 int i; __typeof__(i) j;
1545 ]])], [typeofname="__typeof__"], [dnl else
1546 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
1548 ]])], [typeofname="typeof"], [typeofname=no])])
1549 AC_MSG_RESULT([$typeofname])
1550 if test "$typeofname" != "no"; then
1551 AC_DEFINE_UNQUOTED([TYPEOF], [$typeofname],
1552 [How to use the typeof extension.])
1556 AC_DEFUN([SXE_C_INLINE], [dnl
1558 if test "$ac_cv_c_inline" != "no" -a "$GCC" = "yes"; then
1559 SXE_ADD_CRUFT_OBJS([inline.o])
1564 AC_DEFUN([SXE_CHECK_BROKEN_RESTRICT], [dnl
1565 AC_MSG_CHECKING([support for restrict keyword])
1566 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
1567 extern void f(void*restrict[]);
1568 ]])], [have_restrict="yes"], [have_restrict="no"])
1569 if test "$have_restrict" = "no"; then
1570 AC_DEFINE_UNQUOTED([restrict], [],
1571 [Define restrict to nothing])
1573 AC_MSG_RESULT([$typeofname])
1574 ])dnl SXE_CHECK_BROKEN_RESTRICT
1576 dnl recommended interface macros
1578 AC_DEFUN([SXE_CHECK_CC], [dnl
1582 AC_PROG_CC([gcc icc cc])
1586 ## check for machine and architecture
1589 ## check for C compiler characteristics
1590 SXE_CHECK_CC_VERSION
1591 if test "$GCC" = "yes"; then
1592 SXE_CHECK_BROKEN_GCC
1595 if test "$ac_cv_prog_cc_c99" != ""; then
1596 SXE_CHECK_BROKEN_RESTRICT
1601 SXE_CHECK_LIBC_VERSION
1602 dnl Non-ordinary link usually requires -lc
1603 if test "$ordinary_link" = "no" -a -z "$libs_standard"; then
1609 SXE_CHECK_CC_NESTED_FUNS
1611 ## Canonicalize the configuration name.
1612 ## Commented out, lets see if anything breaks. --SY.
1613 ## SXE_STRIP_4TH_COMPONENT(ac_cv_build_alias)
1614 ## SXE_STRIP_4TH_COMPONENT(ac_cv_build)
1615 AC_SUBST([configuration], [$ac_cv_build])
1622 AC_DEFUN([SXE_CHECK_CFLAGS], [dnl
1623 dnl #### This may need to be overhauled so that all of SXEMACS_CC's flags
1624 dnl are handled separately, not just the xe_cflags_warning stuff.
1626 ## Use either command line flag, environment var, or autodetection
1627 if test "$with_ridiculously_aggressive_optimisations" = "yes"; then
1633 SXE_CFLAGS="$debugflags $featflags $optiflags $warnflags"
1634 elif test "$CFLAGS_uspecified_p" = "no" -o \
1635 "$ac_test_CFLAGS" != "set"; then
1641 ## Following values of CFLAGS are known to work well.
1642 ## Should we take debugging options into consideration?
1643 if test "$GCC" = "yes"; then
1645 elif test "$__SUNPRO_C" = "yes"; then
1647 sol2 ) optiflags="-xO4" ;;
1648 sunos4* ) optiflags="-xO2" ;;
1650 elif test "$__DECC" = "yes"; then
1652 elif test "$CC" = "xlc"; then
1653 optiflags="-g -O3 -qstrict -qnoansialias -qlibansi -qro -qmaxmem=20000"
1654 elif test "$__ICC" = "yes"; then
1655 optiflags="-g -O3 -Ob2"
1656 ### Add optimal CFLAGS support for other compilers HERE!
1658 optiflags="-O" ## The only POSIX-approved flag
1661 SXE_CFLAGS="$debugflags $featflags $optiflags $warnflags"
1663 SXE_CFLAGS=${USER_CFLAGS}
1670 ## unset the werror flag again
1671 SXE_LANG_WERROR([off])
1673 CFLAGS="$SXE_CFLAGS"
1674 AC_MSG_CHECKING([for preferred CFLAGS])
1675 AC_MSG_RESULT([${SXE_CFLAGS}])
1678 If you wish to ADD your own flags you want to stop here and rerun the
1679 configure script like so:
1680 configure CFLAGS=<to-be-added-flags>
1682 You can always override the determined CFLAGS, partially or totally,
1684 make -C <directory> CFLAGS=<your-own-flags> [target]
1686 make CFLAGS=<your-own-flags> [target]
1689 NOTE: -C <directory> option is not available on all systems
1692 LDFLAGS="${ldflags} ${ac_cv_env_LDFLAGS_value}"
1693 AC_MSG_CHECKING([for preferred LDFLAGS])
1694 AC_MSG_RESULT([${LDFLAGS}])
1695 ])dnl SXE_CHECK_CFLAGS
1698 AC_DEFUN([SXE_CC_LIBRARY_PATH], [dnl
1699 ## arg #1 variable to store name in,
1700 ## if omitted defaults to `sxe_cv_tmp_gcc_library_path'
1701 pushdef([VAR], ifelse($1,[],[sxe_cv_tmp_gcc_library_path],$1))
1703 for i in ${LDFLAGS}; do
1706 __LP=${i:2}:${__LP:-.}
1712 SXE_EXPAND_VAR([${libdir}], [__ld])
1713 []VAR[]=${__ld:-.}:${__LP:-.}
1716 ])dnl SXE_CC_LIBRARY_PATH
1719 AC_DEFUN([SXE_CC_LIBRARY_LOCATION], [dnl
1720 ## arg #1 the library to seek after
1721 ## arg #2 (optional) checking message
1722 pushdef([liborig], [$1])
1723 pushdef([liblink], patsubst(patsubst(liborig, [lib], [-l]), [\.[^.]+$], []))
1724 pushdef([libname], translit(liborig, [-,.], [___]))
1725 pushdef([LIBNAME], translit(liborig, [-,.a-z], [___A-Z]))
1726 pushdef([libchk], ifelse($2,[],[for absolute path of ]liborig,$2))
1728 ## use gcc's -print-file-name
1729 AC_REQUIRE([SXE_CC_LIBRARY_PATH])
1730 AC_MSG_CHECKING([]libchk[])
1731 ## not protected against other CCs (yet)!
1732 sxe_cv_loc_[]libname[]=$(LIBRARY_PATH=${sxe_cv_tmp_gcc_library_path} \
1733 ${CC} -print-file-name=[]liborig[])
1734 AC_MSG_RESULT(${sxe_cv_loc_[]libname[]})
1736 []LIBNAME[]=${sxe_cv_loc_[]libname[]}
1743 ])dnl SXE_CC_LIBRARY_LOCATION
1746 AC_DEFUN([SXE_CHECK_ANON_STRUCTS], [
1747 AC_MSG_CHECKING([whether C compiler can cope with anonymous structures])
1749 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1759 union __test_u tmp = {.c = '4'};
1761 sxe_cv_have_anon_structs="yes"
1763 sxe_cv_have_anon_structs="no"
1765 AC_MSG_RESULT([${sxe_cv_have_anon_structs}])
1767 if test "${sxe_cv_have_anon_structs}" = "yes"; then
1768 AC_DEFINE([HAVE_ANON_STRUCTS], [1], [
1769 Whether c1x anon structs work])
1777 ])dnl SXE_CHECK_ANON_STRUCTS
1779 dnl sxe-compiler.m4 ends here