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
328 ])dnl SXE_CHECK_CC_CHAR
330 AC_DEFUN([SXE_CHECK_CC_HACKS], [dnl
332 ## Identify compilers to enable compiler-specific hacks.
333 ## Add support for other compilers HERE!
334 ## GCC is already identified elsewhere.
335 AC_RUN_IFELSE([AC_LANG_SOURCE([[
338 #if defined __SUNPRO_C
342 #elif defined __USLC__ && defined __SCO_VERSION__
344 #elif defined __INTEL_COMPILER
352 echo "You appear to be using the SunPro C compiler."
356 echo "You appear to be using the DEC C compiler."
360 echo "You appear to be using the SCO C compiler."
364 echo "You appear to be using the Intel C++ compiler."
366 ## Newer versions of icc claim to be GCC
369 esac], [AS_MESSAGE([cannot cross-compile])])
370 ])dnl SXE_CHECK_CC_HACKS
373 AC_DEFUN([SXE_DO_CC_HACKS], [dnl
374 ## -----------------------
375 ## Compiler-specific hacks
376 ## -----------------------
378 dnl DEC C `-std1' means ANSI C mode
379 if test "$__DECC" = "yes"; then
380 SXE_APPEND_UNDUP([-std1], [CFLAGS])
383 dnl Some versions of SCO native compiler need -Kalloca
384 if test "$__USLC__" = yes; then
385 AC_MSG_CHECKING([whether the -Kalloca compiler flag is needed])
387 AC_LINK_IFELSE([AC_LANG_SOURCE([[void *x = alloca(4);]])], [:], [
389 CFLAGS="$CFLAGS -Kalloca"
390 AC_LINK_IFELSE([AC_LANG_SOURCE([[void *x = alloca(4);]])],
391 [ need_kalloca=yes ])
393 AC_MSG_RESULT([$need_kalloca])
394 if test "$need_kalloca" = "yes"; then
395 SXE_APPEND_UNDUP([-Kalloca], [c_switch_system])
396 SXE_APPEND_UNDUP([-Kalloca], [CFLAGS])
401 if test "$CC" = "g++" -o "$SXE_CC" = "g++" ; then
402 SXE_DIE("Building with g++ is not supported")
406 ])dnl SXE_DO_CC_HACKS
408 AC_DEFUN([SXE_CHECK_CC_NESTED_FUNS], [dnl
409 ## defines HAVE_NESTED_FUNS
411 AC_MSG_CHECKING([whether functions can be nested])
412 _SXE_CHECK_CC_NESTED_FUNS
413 AC_MSG_RESULT([$sxe_cv_c_nested_funs])
415 if test "$sxe_cv_c_nested_funs" != "yes"; then
416 ## in this case we check if we can do with -fnested-functions
417 SXE_CHECK_COMPILER_FLAGS([-fnested-functions])
418 if test "$sxe_cv_c_flags__fnested_functions" = "yes"; then
419 AC_MSG_CHECKING([whether functions can be nested now])
420 _SXE_CHECK_CC_NESTED_FUNS([-fnested-functions])
421 AC_MSG_RESULT([$sxe_cv_c_nested_funs])
425 if test "$sxe_cv_c_nested_funs" = "yes"; then
426 AC_DEFINE([HAVE_NESTED_FUNS], [1], [Whether funs can be nested])
428 AC_MSG_WARN([Uh oh.])
429 AC_MSG_WARN([A look into my crystal ball reveals a broken build.])
430 AC_MSG_WARN([Get a compiler that is capable of nested functions.])
432 ])dnl SXE_CHECK_CC_NESTED_FUNS
434 AC_DEFUN([_SXE_CHECK_CC_NESTED_FUNS], [dnl
435 ## defines sxe_cv_c_nested_funs
436 ## optional arg 1 may be additional CFLAGS
437 pushdef([ADDCFLAGS], [$1])
440 CFLAGS="${CFLAGS} []ADDCFLAGS[]"
441 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
442 /* we are in main now and we nest another function */
443 auto inline int foobar();
445 inline int foobar(int counter)
452 [sxe_cv_c_nested_funs="yes"],
453 [sxe_cv_c_nested_funs="no"])
457 ])dnl _SXE_CHECK_CC_NESTED_FUNS
460 AC_DEFUN([SXE_CHECK_BROKEN_GCC], [
461 dnl This section needs a rewrite. I think it should just bomb if we
462 dnl find a gcc that is older than 2.95.3 --SY.
463 dnl Search for GCC specific build problems we know about
465 AC_MSG_CHECKING([for buggy gcc versions])
466 GCC_VERSION=`$CC --version`
469 2.6.*|2.7.*|2.8.*|2.9* )
471 AC_MSG_WARN([Don't use medieval compilers])
472 AC_MSG_ERROR([Aborting due to known problem])
474 3.0.*|3.1.*|3.2.*|3.3.* )
476 AC_MSG_WARN([You are using an antiquated compiler. Proceed at your own risk.])
477 AC_MSG_CHECKING([for other known compiler bugs])
481 case `uname -s`:`uname -m`:$GCC_VERSION in
482 dnl pie-enabled GCC on Linux needs -nopie to build SXEmacs
483 Linux:i?86:gcc*pie-*)
486 dnl egcs 2.90.21 (egcs-1.00 release)
487 dnl egcs 2.90.29 (egcs-1.0.3 release)
488 *:sun4*:2.8.1|*:sun4*:egcs-2.90.*)
489 dnl Don't use -O2 with gcc 2.8.1 and egcs 1.0 under SPARC architectures
490 dnl without also using `-fno-schedule-insns'.
494 *-fno-schedule-insns*)
498 AC_MSG_WARN([Don't use -O2 with gcc 2.8.1 and egcs 1.0 under SPARC architectures])
499 AC_MSG_WARN([without also using -fno-schedule-insns.])
500 AC_MSG_ERROR([Aborting due to known problem])
507 dnl egcs-2.91.57 (egcs-1.1 release)
508 dnl egcs-2.91.66 (egcs-1.1.2 release)
509 Linux:alpha:egcs-2.91.*)
511 AC_MSG_WARN([There have been reports of egcs-1.1 not compiling SXEmacs correctly on])
512 AC_MSG_WARN([Alpha Linux. There have also been reports that egcs-1.0.3a is O.K.])
513 AC_MSG_ERROR([Aborting due to known problem])
520 ])dnl SXE_CHECK_BROKEN_GCC
523 AC_DEFUN([SXE_DEBUGFLAGS], [dnl
524 ## distinguish between different compilers, no?
525 SXE_CHECK_COMPILER_FLAGS([-g])
526 SXE_CHECK_COMPILER_FLAGS([-g3])
528 AC_PATH_PROG([DBX], [dbx])
529 if test -n "$ac_cv_path_DBX"; then
530 SXE_CHECK_COMPILER_FLAGS([-gstabs])
531 SXE_CHECK_COMPILER_FLAGS([-gstabs3])
532 SXE_CHECK_COMPILER_FLAGS([-gxcoff])
533 SXE_CHECK_COMPILER_FLAGS([-gxcoff3])
536 AC_PATH_PROG([GDB], [gdb])
537 if test -n "$ac_cv_path_GDB"; then
538 SXE_CHECK_COMPILER_FLAGS([-ggdb])
539 SXE_CHECK_COMPILER_FLAGS([-ggdb3])
542 AC_PATH_PROG([SDB], [sdb])
543 if test -n "$ac_cv_path_SDB"; then
544 SXE_CHECK_COMPILER_FLAGS([-gcoff])
545 SXE_CHECK_COMPILER_FLAGS([-gcoff3])
551 if test "$sxe_cv_c_flags__ggdb3" = "yes"; then
552 debugflags="$debugflags -ggdb3"
553 elif test "$sxe_cv_c_flags__ggdb" = "yes"; then
554 debugflags="$debugflags -ggdb"
557 if test "$sxe_cv_c_flags__gstabs3" = "yes"; then
558 debugflags="$debugflags -gstabs3"
559 elif test "$sxe_cv_c_flags__gstabs" = "yes"; then
560 debugflags="$debugflags -gstabs"
563 if test "$sxe_cv_c_flags__gcoff3" = "yes"; then
564 debugflags="$debugflags -gcoff3"
565 elif test "$sxe_cv_c_flags__gcoff" = "yes"; then
566 debugflags="$debugflags -gcoff"
569 if test "$sxe_cv_c_flags__gxcoff3" = "yes"; then
570 debugflags="$debugflags -gxcoff3"
571 elif test "$sxe_cv_c_flags__gxcoff" = "yes"; then
572 debugflags="$debugflags -gxcoff"
575 if test -z "debugflags" -a \
576 "$sxe_cv_c_flags__g" = "yes"; then
577 debugflags="$debugflags -g"
580 SXE_CHECK_COMPILER_FLAGS([-ftime-report])
581 SXE_CHECK_COMPILER_FLAGS([-fmem-report])
582 SXE_CHECK_COMPILER_FLAGS([-fvar-tracking])
583 SXE_CHECK_COMPILER_FLAGS([-save-temps])
585 #if test "$sxe_cv_c_flags__ggdb3" = "yes" -a \
586 # "$sxe_cv_c_flags__fvar_tracking" = "yes"; then
587 # debugflags="$debugflags -fvar-tracking"
590 AC_MSG_CHECKING([for preferred debugging flags])
591 AC_MSG_RESULT([${debugflags}])
594 AC_DEFUN([SXE_WARNFLAGS], [dnl
595 ## Calculate warning flags. We separate the flags for warnings from
596 ## the other flags because we want to force the warnings to be seen
597 ## by everyone who doesn't specifically override them.
599 ## by default we want the -Wall level
600 SXE_CHECK_COMPILER_FLAGS([-Wall], [warnflags="-Wall"])
602 SXE_CHECK_COMPILER_FLAGS([-qinfo], [
603 warnflags="${warnflags} -qinfo"])
605 ## Yuck, bad compares have been worth at
607 ## Warnings about char subscripts are pretty
608 ## pointless, though,
609 ## and we use them in various places.
610 if test "${with_maximum_warning_output}" = "yes"; then
611 SXE_CHECK_COMPILER_FLAGS([-Wsign-compare], [
612 warnflags="$warnflags -Wsign-compare"])
613 SXE_CHECK_COMPILER_FLAGS([-Wno-char-subscripts], [
614 warnflags="$warnflags -Wno-char-subscripts"])
615 SXE_CHECK_COMPILER_FLAGS([-Wundef], [
616 warnflags="$warnflags -Wundef"])
619 ## too much at the moment, we rarely define protos
620 #warnflags="$warnflags -Wmissing-prototypes -Wstrict-prototypes"
621 SXE_CHECK_COMPILER_FLAGS([-Wpacked], [
622 warnflags="$warnflags -Wpacked"])
624 ## glibc is intentionally not `-Wpointer-arith'-clean.
625 ## Ulrich Drepper has rejected patches to fix
626 ## the glibc header files.
628 SXE_CHECK_COMPILER_FLAGS([-Wpointer-arith], [
629 warnflags="$warnflags -Wpointer-arith"])
631 SXE_CHECK_COMPILER_FLAGS([-Wshadow], [
632 warnflags="$warnflags -Wshadow"])
634 ## our code lacks declarations almost all the time
635 SXE_CHECK_COMPILER_FLAGS([-Wmissing-declarations], [
636 warnflags="$warnflags -Wmissing-declarations"])
637 SXE_CHECK_COMPILER_FLAGS([-Wmissing-prototypes], [
638 warnflags="$warnflags -Wmissing-prototypes"])
639 SXE_CHECK_COMPILER_FLAGS([-Wbad-function-cast], [
640 warnflags="$warnflags -Wbad-function-cast"])
641 SXE_CHECK_COMPILER_FLAGS([-Wcast-qual], [
642 warnflags="$warnflags -Wcast-qual"])
643 SXE_CHECK_COMPILER_FLAGS([-Wcast-align], [
644 warnflags="$warnflags -Wcast-align"])
646 ## too aggressive innit
647 if test "${with_maximum_warning_output}" = "yes"; then
648 SXE_CHECK_COMPILER_FLAGS([-Winline], [
649 warnflags="$warnflags -Winline"])
652 ## warn about incomplete switches
653 if test "${with_maximum_warning_output}" = "yes"; then
654 SXE_CHECK_COMPILER_FLAGS([-Wswitch], [
655 warnflags="$warnflags -Wswitch"])
656 SXE_CHECK_COMPILER_FLAGS([-Wswitch-default], [
657 warnflags="$warnflags -Wswitch-default"])
658 SXE_CHECK_COMPILER_FLAGS([-Wswitch-enum], [
659 warnflags="$warnflags -Wswitch-enum"])
663 if test "${with_maximum_warning_output}" = "yes"; then
664 SXE_CHECK_COMPILER_FLAGS([-Wunused-function], [
665 warnflags="$warnflags -Wunused-function"])
666 SXE_CHECK_COMPILER_FLAGS([-Wunused-variable], [
667 warnflags="$warnflags -Wunused-variable"])
668 SXE_CHECK_COMPILER_FLAGS([-Wunused-parameter], [
669 warnflags="$warnflags -Wunused-parameter"])
670 SXE_CHECK_COMPILER_FLAGS([-Wunused-value], [
671 warnflags="$warnflags -Wunused-value"])
672 SXE_CHECK_COMPILER_FLAGS([-Wunused], [
673 warnflags="$warnflags -Wunused"])
677 SXE_CHECK_COMPILER_FLAGS([-Wreorder], [
678 warnflags="$warnflags -Wreorder"])
679 SXE_CHECK_COMPILER_FLAGS([-Wdeprecated], [
680 warnflags="$warnflags -Wdeprecated"])
681 SXE_CHECK_COMPILER_FLAGS([-Wnopragma], [
682 warnflags="$warnflags -Wnopragma"])
684 ## for upcoming libev support
685 ## libev is a warning emitting cow, the developers can't
686 ## be arsed to fix it, as it turns out
687 SXE_CHECK_COMPILER_FLAGS([-fno-strict-aliasing], [
688 warnflags="$warnflags -fno-strict-aliasing"])
691 SXE_CHECK_COMPILER_FLAGS([-diag-disable 10237], [dnl
692 warnflags="${warnflags} -diag-disable 10237"], [
693 SXE_CHECK_COMPILER_FLAGS([-wd 10237], [dnl
694 warnflags="${warnflags} -wd 10237"])])
696 AC_MSG_CHECKING([for preferred warning flags])
697 AC_MSG_RESULT([${warnflags}])
700 AC_DEFUN([SXE_OPTIFLAGS], [dnl
704 case $sxe_cv_c_compiler_vendor in
731 AC_MSG_CHECKING([for preferred optimising flags])
732 AC_MSG_RESULT([$optiflags])
733 if test -z "$optiflags"; then
735 echo "********************************************************"
736 echo "* WARNING: Don't know the best CFLAGS for this system *"
737 echo "* Use ./configure CFLAGS=... to specify your own flags *"
738 echo "* (otherwise, a default of CFLAGS=-O3 will be used) *"
739 echo "********************************************************"
744 SXE_CHECK_COMPILER_FLAGS([$optiflags], [:], [
746 echo "********************************************************"
747 echo "* WARNING: The guessed CFLAGS don't seem to work with *"
748 echo "* your compiler. *"
749 echo "* Use ./configure CFLAGS=... to specify your own flags *"
750 echo "********************************************************"
756 AC_DEFUN([SXE_FEATFLAGS], [dnl
757 ## default flags for needed features
759 ## we need nested functions ... hm, i dont think we do
760 ## but it's always nice to have them
761 SXE_CHECK_COMPILER_FLAGS([-fnested-functions], [
762 featflags="$featflags -fnested-functions"])
764 ## recent gentoos went ballistic again, they compile PIE gcc's
765 ## but there's no way to turn that misconduct off ...
766 ## however I've got one report about a working PIE build
767 ## we'll just check for -nopie here, if it works, we turn it on
768 ## (and hence PIE off) and hope bug 16 remains fixed
769 SXE_CHECK_COMPILER_FLAGS([-nopie],
770 [featflags="$featflags -nopie"])
772 ## icc and gcc related
773 ## check if some stuff can be staticalised
774 ## actually requires SXE_WARNFLAGS so warnings would be disabled
775 ## that affect the outcome of the following tests
776 SXE_CHECK_COMPILER_FLAGS([-static-intel], [
777 featflags="${featflags} -static-intel"
778 XCCLDFLAGS="${XCCLDFLAGS} -static-intel"], [:], [${SXE_CFLAGS}])
779 SXE_CHECK_COMPILER_FLAGS([-static-libgcc], [
780 featflags="${featflags} -static-libgcc"
781 XCCLDFLAGS="${XCCLDFLAGS} -static-libgcc"], [:], [${SXE_CFLAGS}])
783 AC_SUBST([XCCLDFLAGS])
787 AC_DEFUN([SXE_COMPILER_VENDOR], [dnl
788 AC_CACHE_CHECK([for _AC_LANG compiler vendor],
789 sxe_cv_[]_AC_LANG_ABBREV[]_compiler_vendor,
790 [sxe_cv_[]_AC_LANG_ABBREV[]_compiler_vendor=unknown
791 # note: don't check for gcc first since some other compilers define __GNUC__
793 intel:__ICC,__ECC,__INTEL_COMPILER \
794 ibm:__xlc__,__xlC__,__IBMC__,__IBMCPP__ \
795 gnu:__GNUC__ sun:__SUNPRO_C,__SUNPRO_CC \
796 hp:__HP_cc,__HP_aCC \
797 dec:__DECC,__DECCXX,__DECC_VER,__DECCXX_VER \
798 borland:__BORLANDC__,__TURBOC__ \
803 metrowerks:__MWERKS__ \
809 vencpp="defined("$(echo \
810 $ventest | cut -d: -f2 | sed "s/,/) || defined(/g")")"
811 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[
815 ])], [sxe_cv_]_AC_LANG_ABBREV[_compiler_vendor=$(echo $ventest | cut -d: -f1); break; ])
818 ])dnl SXE_COMPILER_VENDOR
821 AC_DEFUN([SXE_CC_MAXOPT_DEC], [dnl
822 optiflags="-newc -w0 -O5 -ansi_alias -ansi_args -fp_reorder -tune host"
823 if test "$acx_maxopt_portable" = "no"; then
824 optiflags="$optiflags -arch host"
826 ])dnl SXE_CC_MAXOPT_DEC
828 AC_DEFUN([SXE_CC_MAXOPT_SUN], [dnl
829 optiflags="-native -fast -xO5 -dalign"
830 if test "$acx_maxopt_portable" = "yes"; then
831 optiflags="$optiflags -xarch=generic"
833 ])dnl SXE_CC_MAXOPT_SUN
835 AC_DEFUN([SXE_CC_MAXOPT_HP], [dnl
836 optiflags="+Oall +Optrs_ansi +DSnative"
837 if test "$acx_maxopt_portable" = "yes"; then
838 optiflags="$optiflags +DAportable"
840 ])dnl SXE_CC_MAXOPT_HP
842 AC_DEFUN([SXE_CC_MAXOPT_IBM], [dnl
843 if test "$acx_maxopt_portable" = "no"; then
844 xlc_opt="-qarch=auto -qtune=auto"
846 xlc_opt="-qtune=auto"
848 SXE_CHECK_COMPILER_FLAGS([$xlc_opt],
849 [optiflags="-O3 -qansialias -w $xlc_opt"],
850 [optiflags="-O3 -qansialias -w"
851 echo "******************************************************"
852 echo "* You seem to have the IBM C compiler. It is *"
853 echo "* recommended for best performance that you use: *"
855 echo "* CFLAGS=-O3 -qarch=xxx -qtune=xxx -qansialias -w *"
857 echo "* where xxx is pwr2, pwr3, 604, or whatever kind of *"
858 echo "* CPU you have. (Set the CFLAGS environment var. *"
859 echo "* and re-run configure.) For more info, man cc. *"
860 echo "******************************************************"])
861 ])dnl SXE_CC_MAXOPT_IBM
863 AC_DEFUN([SXE_CC_MAXOPT_INTEL], [dnl
864 optiflags="-O3 -ansi_alias"
865 if test "$acx_maxopt_portable" = "no"; then
871 # icc accepts gcc assembly syntax,
872 # so these should work:
876 if test "$icc_flags" != ""; then
877 for flag in $icc_flags; do
878 SXE_CHECK_COMPILER_FLAGS([$flag],
879 [icc_archflag=$flag; break])
882 AC_MSG_CHECKING([for icc architecture flag])
883 AC_MSG_RESULT([$icc_archflag])
884 if test "$icc_archflag" != "unknown"; then
885 optiflags="$optiflags $icc_archflag"
888 ])dnl SXE_CC_MAXOPT_INTEL
890 AC_DEFUN([SXE_CC_MAXOPT_GNU], [dnl
891 ## default optimisation flags for gcc on all systems
892 ## this is the preferred compiler
895 AC_REQUIRE([SXE_CHECK_SIMD_EXTENSIONS])
896 optiflags="$optiflags $simdflags"
898 ## note that we enable "unsafe" fp optimisation with other compilers, too
899 SXE_CHECK_COMPILER_FLAGS([-ftree-vectorize],
900 [optiflags="$optiflags -ftree-vectorize"])
902 ## check for -march and/or -mtune
903 SXE_GCC_ARCHFLAG([$acx_maxopt_portable])
904 optiflags="$optiflags $archflags"
906 ## a softer variant of omit-frame-pointer
907 SXE_CHECK_COMPILER_FLAGS([-momit-leaf-frame-pointer],
908 [optiflags="$optiflags -momit-leaf-frame-pointer"])
910 ## check for openmp support
911 ## there are: -fopenmp -xopenmp -openmp -mp -omp -qsmp=omp
912 SXE_CHECK_COMPILER_FLAGS([-fopenmp])
914 if test "$sxe_cv_c_flags__fopenmp" = "yes" -a "$with_omp"; then
915 SXE_MSG_CHECKING([whether it is safe to use -fopenmp])
916 case "$compiler_version" in
918 optiflags="$optiflags -fopenmp"
919 sxe_cv_feat_omp="yes"
920 SXE_MSG_RESULT([yes])
928 ## these belong to the corresponding MAXOPT macro
929 dnl SXE_CHECK_COMPILER_FLAGS([-xopenmp], [
930 dnl optiflags="$optiflags -xopenmp"
931 dnl sxe_cv_feat_omp="yes"
933 dnl SXE_CHECK_COMPILER_FLAGS([-openmp], [
934 dnl optiflags="$optiflags -openmp"
935 dnl sxe_cv_feat_omp="yes"
937 dnl SXE_CHECK_COMPILER_FLAGS([-mp], [
938 dnl optiflags="$optiflags -mp"
939 dnl sxe_cv_feat_omp="yes"
941 dnl SXE_CHECK_COMPILER_FLAGS([-omp], [
942 dnl optiflags="$optiflags -omp"
943 dnl sxe_cv_feat_omp="yes"
945 dnl SXE_CHECK_COMPILER_FLAGS([-qsmp=omp], [
946 dnl optiflags="$optiflags -qsmp=omp"
947 dnl sxe_cv_feat_omp="yes"
949 ## add -lgomp to ldflags
950 if test "$sxe_cv_feat_omp" = "yes"; then
951 LDFLAGS="$LDFLAGS -lgomp"
954 # -malign-double for x86 systems
955 SXE_CHECK_COMPILER_FLAGS([-malign-double])
956 ## won't add this one, since it is causing problems
957 ## [optiflags="$optiflags -malign-double"])
959 ## would be nice to have this but it triggers too many
960 ## meaningless warnings
961 dnl ## -fstrict-aliasing for gcc-2.95+
962 dnl SXE_CHECK_COMPILER_FLAGS([-fstrict-aliasing],
963 dnl [optiflags="$optiflags -fstrict-aliasing"])
965 SXE_CHECK_COMPILER_FLAGS([-fearly-inlining],
966 [optiflags="$optiflags -fearly-inlining"])
968 SXE_CHECK_COMPILER_FLAGS([-fdelete-null-pointer-checks],
969 [optiflags="$optiflags -fdelete-null-pointer-checks"])
971 SXE_CHECK_COMPILER_FLAGS([-fmodulo-sched],
972 [optiflags="$optiflags -fmodulo-sched"])
974 SXE_CHECK_COMPILER_FLAGS([-fmudflap])
975 SXE_CHECK_COMPILER_FLAGS([-fmudflapth])
976 SXE_CHECK_COMPILER_FLAGS([-fmudflapir])
977 if test "$sxe_cv_c_flags__fmudflapth" -a \
978 "$sxe_cv_c_flags__fmudflapir"; then
980 : ##optiflags="$optiflags -fmudflapth -fmudflapir"
981 elif test "$sxe_cv_c_flags__fmudflap" -a \
982 "$sxe_cv_c_flags__fmudflapir"; then
983 : ##optiflags="$optiflags -fmudflap -fmudflapir"
985 SXE_CHECK_COMPILER_FLAGS([-fsection-anchors],
986 [optiflags="$optiflags -fsection-anchors"])
988 SXE_CHECK_COMPILER_FLAGS([-fbranch-target-load-optimize])
989 SXE_CHECK_COMPILER_FLAGS([-fbranch-target-load-optimize2])
990 if test "$sxe_cv_c_flags__fbranch_target_load_optimize2" = "yes"; then
991 optiflags="$optiflags -fbranch-target-load-optimize2"
992 elif test "$sxe_cv_c_flags__fbranch_target_load_optimize" = "yes"; then
993 optiflags="$optiflags -fbranch-target-load-optimize"
996 SXE_CHECK_COMPILER_FLAGS([-fgcse],
997 [optiflags="$optiflags -fgcse"])
998 SXE_CHECK_COMPILER_FLAGS([-fgcse-lm],
999 [optiflags="$optiflags -fgcse-lm"])
1000 SXE_CHECK_COMPILER_FLAGS([-fgcse-sm],
1001 [optiflags="$optiflags -fgcse-sm"])
1002 SXE_CHECK_COMPILER_FLAGS([-fgcse-las],
1003 [optiflags="$optiflags -fgcse-las"])
1004 SXE_CHECK_COMPILER_FLAGS([-fgcse-after-reload],
1005 [optiflags="$optiflags -fgcse-after-reload"])
1006 SXE_CHECK_COMPILER_FLAGS([-funsafe-loop-optimizations],
1007 [optiflags="$optiflags -funsafe-loop-optimizations"])
1008 SXE_CHECK_COMPILER_FLAGS([-funroll-loops],
1009 [optiflags="$optiflags -funswitch-loops"])
1010 SXE_CHECK_COMPILER_FLAGS([-funswitch-loops],
1011 [optiflags="$optiflags -funswitch-loops"])
1012 SXE_CHECK_COMPILER_FLAGS([-frename-registers],
1013 [optiflags="$optiflags -frename-registers"])
1016 SXE_CHECK_COMPILER_FLAGS([-funsafe-math-optimizations -fno-signaling-nans],
1017 [optiflags="$optiflags -fno-signaling-nans"])
1018 SXE_CHECK_COMPILER_FLAGS([-funsafe-math-optimizations -fno-trapping-math],
1019 [optiflags="$optiflags -fno-trapping-math"])
1020 SXE_CHECK_COMPILER_FLAGS([-funsafe-math-optimizations -fno-signed-zeros],
1021 [optiflags="$optiflags -fno-signed-zeros"])
1022 SXE_CHECK_COMPILER_FLAGS([-funsafe-math-optimizations -fassociative-math],
1023 [optiflags="$optiflags -fassociative-math"])
1024 SXE_CHECK_COMPILER_FLAGS([-funsafe-math-optimizations -fno-rounding-math],
1025 [optiflags="$optiflags -fno-rounding-math"])
1026 SXE_CHECK_COMPILER_FLAGS([-funsafe-math-optimizations -fno-math-errno],
1027 [optiflags="$optiflags -fno-math-errno"])
1028 ## the same as the previous 5, but sometimes gcc doesn't know'em all
1029 SXE_CHECK_COMPILER_FLAGS([-funsafe-math-optimizations],
1030 [optiflags="$optiflags -funsafe-math-optimizations"])
1032 SXE_CHECK_COMPILER_FLAGS([-ffast-math],
1033 [optiflags="$optiflags -ffast-math"])
1034 ## and yet some more
1035 SXE_CHECK_COMPILER_FLAGS([-mrecip],
1036 [optiflags="$optiflags -mrecip"])
1037 SXE_CHECK_COMPILER_FLAGS([-msahf],
1038 [optiflags="$optiflags -msahf"])
1040 SXE_CHECK_COMPILER_FLAGS([-minline-all-stringops],
1041 [optiflags="$optiflags -minline-all-stringops"])
1043 ])dnl SXE_CC_MAXOPT_GNU
1046 ##### http://autoconf-archive.cryp.to/ax_check_compiler_flags.html
1047 ## renamed the prefix to SXE_
1048 AC_DEFUN([SXE_CHECK_COMPILER_FLAGS], [dnl
1049 dnl SXE_CHECK_COMPILER_FLAGS(<FLAG>, <ACTION-IF-FOUND>, <ACTION-IF-NOT-FOUND>,
1050 dnl <ADDITIONAL-FLAGS>)
1051 AC_MSG_CHECKING([whether _AC_LANG compiler accepts $1])
1053 dnl Some hackery here since AC_CACHE_VAL can't handle a non-literal varname:
1054 SXE_LANG_WERROR([push+on])
1055 AS_LITERAL_IF([$1], [
1056 AC_CACHE_VAL(AS_TR_SH(sxe_cv_[]_AC_LANG_ABBREV[]_flags_$1), [
1057 sxe_save_FLAGS=$[]_AC_LANG_PREFIX[]FLAGS
1058 _AC_LANG_PREFIX[]FLAGS="$4 $1"
1059 AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
1060 AS_TR_SH(sxe_cv_[]_AC_LANG_ABBREV[]_flags_$1)="yes",
1061 AS_TR_SH(sxe_cv_[]_AC_LANG_ABBREV[]_flags_$1)="no")
1062 _AC_LANG_PREFIX[]FLAGS=$sxe_save_FLAGS])], [
1063 sxe_save_FLAGS=$[]_AC_LANG_PREFIX[]FLAGS
1064 _AC_LANG_PREFIX[]FLAGS="$4 $1"
1065 AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
1066 eval AS_TR_SH(sxe_cv_[]_AC_LANG_ABBREV[]_flags_$1)="yes",
1067 eval AS_TR_SH(sxe_cv_[]_AC_LANG_ABBREV[]_flags_$1)="no")
1068 _AC_LANG_PREFIX[]FLAGS=$sxe_save_FLAGS])
1069 eval sxe_check_compiler_flags=$AS_TR_SH(sxe_cv_[]_AC_LANG_ABBREV[]_flags_$1)
1070 SXE_LANG_WERROR([pop])
1072 AC_MSG_RESULT([$sxe_check_compiler_flags])
1073 if test "$sxe_check_compiler_flags" = "yes"; then
1078 ])dnl SXE_CHECK_COMPILER_FLAGS
1081 AC_DEFUN([SXE_CHECK_COMPILER_XFLAG], [dnl
1085 SXE_CHECK_COMPILER_FLAGS([-XCClinker], [
1086 XFLAG="-XCClinker"], [
1094 SXE_CHECK_COMPILER_FLAGS([-Xlinker], [
1095 XFLAG="-Xlinker"], [
1099 ])dnl SXE_CHECK_COMPILER_XFLAG
1102 AC_DEFUN([SXE_CHECK_CPU], [dnl
1106 ## pc-style hardware
1127 AC_DEFUN([SXE_CHECK_CPU_SPARC], [dnl
1128 AC_PATH_PROG([PRTDIAG], [prtdiag], [prtdiag],
1129 [$PATH:/usr/platform/`uname -i`/sbin/:/usr/platform/`uname -m`/sbin/])
1130 cputype=$((((grep cpu /proc/cpuinfo | cut -d: -f2) ; \
1131 ($PRTDIAG -v |grep -i sparc) ; \
1132 grep -i cpu "/var/run/dmesg.boot" ) | head -n 1) 2> /dev/null)
1133 cputype=$(echo "$cputype" | tr -d ' -' |tr $as_cr_LETTERS $as_cr_letters)
1138 sxe_gcc_arch="ultrasparc4 ultrasparc3 ultrasparc v9"
1142 sxe_gcc_arch="ultrasparc3 ultrasparc v9"
1146 sxe_gcc_arch="ultrasparc v9"
1149 *supersparc*|*tms390z5[[05]]*)
1150 sxe_gcc_arch="supersparc v8"
1153 *hypersparc*|*rt62[[056]]*)
1154 sxe_gcc_arch="hypersparc v8"
1158 sxe_gcc_arch=cypress
1161 ])dnl SXE_CHECK_CPU_SPARC
1163 AC_DEFUN([SXE_CHECK_CPU_ALPHA], [dnl
1175 sxe_gcc_arch="pca56 ev56"
1179 sxe_gcc_arch="pca57 pca56 ev56"
1191 sxe_gcc_arch="ev68 ev67"
1195 sxe_gcc_arch="ev69 ev68 ev67"
1199 sxe_gcc_arch="ev7 ev69 ev68 ev67"
1203 sxe_gcc_arch="ev79 ev7 ev69 ev68 ev67"
1206 ])dnl SXE_CHECK_CPU_ALPHA
1208 AC_DEFUN([SXE_CHECK_CPU_PPC], [dnl
1209 cputype=$(((grep cpu /proc/cpuinfo | head -n 1 | \
1210 cut -d: -f2 | cut -d, -f1 | sed 's/ //g') ; \
1211 /usr/bin/machine ; \
1213 grep CPU /var/run/dmesg.boot | \
1214 head -n 1 | cut -d" " -f2) 2> /dev/null)
1215 cputype=$(echo $cputype | sed -e 's/ppc//g;s/ *//g')
1220 sxe_gcc_arch="750 G3"
1224 sxe_gcc_arch="$cputype 7400 G4"
1228 sxe_gcc_arch="$cputype 7450 G4"
1232 sxe_gcc_arch="$cputype G4"
1236 sxe_gcc_arch="970 G5 power4"
1239 *POWER4*|*power4*|*gq*)
1240 sxe_gcc_arch="power4 970"
1243 *POWER5*|*power5*|*gr*|*gs*)
1244 sxe_gcc_arch="power5 power4 970"
1248 sxe_gcc_arch="$cputype 603e 603"
1252 sxe_gcc_arch="$cputype"
1255 sxe_gcc_arch="$sxe_gcc_arch powerpc"
1256 ])dnl SXE_CHECK_CPU_PPC
1258 AC_DEFUN([SXE_CHECK_CPU_PC], [dnl
1260 AC_REQUIRE([SXE_PROC_CPUID])
1262 case "$sxe_cv_proc_cpuid_00000000" in
1266 case "$sxe_cv_proc_cpuid_00000001" in
1269 sxe_gcc_arch="pentium-mmx pentium"
1273 sxe_gcc_arch="pentium"
1277 sxe_gcc_arch="pentium2 pentiumpro"
1281 sxe_gcc_arch="pentium2 pentiumpro"
1285 sxe_gcc_arch="pentium3 pentiumpro"
1290 sxe_gcc_arch="pentium-m pentium3 pentiumpro"
1295 sxe_gcc_arch="pentium-m pentium3 pentiumpro"
1299 sxe_gcc_arch="pentium3 pentiumpro"
1305 sxe_gcc_arch="nocona pentium4 pentiumpro"
1311 sxe_gcc_arch="pentiumpro"
1314 *f3[[347]]:*:*:*|*f4[1347]:*:*:*)
1315 icc_flags="-xP -xN -xW -xK"
1319 sxe_gcc_arch="nocona pentium4 pentiumpro"
1323 sxe_gcc_arch="prescott pentium4 pentiumpro"
1329 icc_flags="-xN -xW -xK"
1330 sxe_gcc_arch="pentium4 pentiumpro"
1337 case "$sxe_cv_proc_cpuid_00000001" in
1344 sxe_gcc_arch="k6-2 k6"
1348 sxe_gcc_arch="k6-3 k6"
1356 sxe_gcc_arch="athlon k7"
1360 sxe_gcc_arch="athlon-tbird k7"
1364 sxe_gcc_arch="athlon-4 athlon k7"
1368 case "$sxe_cv_proc_cpuid_80000006" in
1370 *:*:*[[1-9a-f]]??????:*) # (L2 = ecx >> 16) >= 256
1371 sxe_gcc_arch="athlon-xp athlon-4 athlon k7"
1375 sxe_gcc_arch="athlon-4 athlon k7"
1380 *f[[4cef8b]]?:*:*:*)
1381 sxe_gcc_arch="athlon64 k8"
1385 sxe_gcc_arch="opteron k8"
1389 sxe_gcc_arch="athlon-fx opteron k8"
1400 case "$sxe_cv_proc_cpuid_00000001" in
1403 sxe_gcc_arch="winchip-c6"
1407 sxe_gcc_arch="winchip2"
1415 sxe_gcc_arch="c3-2 c3"
1421 ## nothing found? => fallback
1422 if test -z "$sxe_gcc_arch"; then
1423 ## apply a generic strategy
1426 sxe_gcc_arch="pentium"
1429 sxe_gcc_arch="pentiumpro"
1433 ])dnl SXE_CHECK_CPU_PC
1436 AC_DEFUN([SXE_GCC_ARCHFLAG], [dnl
1437 AC_REQUIRE([AC_PROG_CC])
1438 AC_REQUIRE([AC_CANONICAL_HOST])
1440 AC_ARG_WITH([gcc-arch], AS_HELP_STRING([--with-gcc-arch=<arch>], [
1441 use architecture <arch> for gcc -march/-mtune,
1442 instead of guessing]),
1443 [sxe_gcc_arch=$withval], [sxe_gcc_arch=yes])
1445 AC_MSG_CHECKING([for gcc architecture flag])
1447 AC_CACHE_VAL([sxe_cv_gcc_archflag], [
1448 ## initialise to unknown
1449 sxe_cv_gcc_archflag="unknown"
1451 if test "$GCC" = yes; then
1452 if test "$sxe_gcc_arch" = "yes" -a \
1453 "$cross_compiling" = "no"; then
1458 if test -n "$sxe_gcc_arch" -a "$sxe_gcc_arch" != "no"; then
1459 for arch in $sxe_gcc_arch; do
1460 if test "[]m4_default([$1],yes)" = "yes"; then
1461 ## if we require portable code
1462 archflags="-mtune=$arch"
1463 ## -mcpu=$arch and m$arch generate
1464 ## nonportable code on every arch except
1465 ## x86. And some other arches
1466 ## (e.g. Alpha) don't accept -mtune.
1471 archflags="$archflags -mcpu=$arch -m$arch"
1475 archflags="-march=$arch -mcpu=$arch -m$arch"
1477 for flag in $archflags; do
1478 SXE_CHECK_COMPILER_FLAGS([$flag],
1479 [sxe_cv_gcc_archflag="$flag"; break])
1481 if test "$sxe_cv_gcc_archflag" != "unknown"; then
1489 AC_MSG_CHECKING([for gcc architecture flag])
1490 AC_MSG_RESULT([$sxe_cv_gcc_archflag])
1491 if test "$sxe_cv_gcc_archflag" = "unknown"; then
1494 m4_default([$2], [archflags="$sxe_cv_gcc_archflag"])
1496 ])dnl SXE_GCC_ARCHFLAG
1499 #### http://autoconf-archive.cryp.to/sxe_check_define.html
1500 AC_DEFUN([SXE_CHECK_DEFINED], [dnl
1501 AS_VAR_PUSHDEF([ac_var],[ac_cv_defined_$2])dnl
1503 AC_CACHE_CHECK([for $1 defined], ac_var,
1511 AS_VAR_SET(ac_var, [yes]),
1512 AS_VAR_SET(ac_var, [no])))
1514 AS_IF([test AS_VAR_GET(ac_var) != "no"], [$3], [$4])
1515 AS_VAR_POPDEF([ac_var])
1516 ])dnl SXE_CHECK_DEFINED
1518 AC_DEFUN([SXE_CHECK_FUNC], [dnl
1519 AS_VAR_PUSHDEF([ac_var], [ac_cv_func_$2])dnl
1520 AC_CACHE_CHECK([for $2], ac_var, [
1521 dnl AC_LANG_FUNC_LINK_TRY
1522 AC_LINK_IFELSE([AC_LANG_PROGRAM([$1
1529 AS_VAR_SET(ac_var, [yes])], [
1530 AS_VAR_SET(ac_var, [no])])])
1532 AS_IF([test AS_VAR_GET(ac_var) = "yes"], [$3], [$4])
1533 AS_VAR_POPDEF([ac_var])
1534 ])dnl SXE_CHECK_FUNC
1538 AC_DEFUN([SXE_CHECK_C99_NJSF], [dnl
1539 dnl If we have a compiler that could do c99 do try to add the flag
1540 if test "$__GCC3" = "yes" ; then
1541 SXE_APPEND_UNDUP("-std=c99", c_switch_site)
1542 AC_MSG_CHECKING([for C99 support])
1543 save_c_switch_site=$c_switch_site
1544 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1548 ]])], [AC_MSG_RESULT(yes)
1550 [c_switch_site=$sace_c_switch_site
1552 AC_MSG_WARN([C99 not supported, reverting option append])
1554 elif test "$__SUNPRO_C" = "yes" ; then
1555 AC_MSG_CHECKING([for C99 support])
1556 save_c_switch_site=$c_switch_site
1557 SXE_APPEND_UNDUP("-xc99", c_switch_site)
1558 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1562 ]])], [AC_MSG_RESULT(yes)
1564 [c_switch_site=$sace_c_switch_site
1568 ])dnl SXE_CHECK_C99_NJSF
1571 AC_DEFUN([SXE_C_TYPEOF], [dnl
1572 dnl check for the typeof extension
1573 AC_MSG_CHECKING([for typeof])
1574 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
1575 int i; __typeof__(i) j;
1576 ]])], [typeofname="__typeof__"], [dnl else
1577 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
1579 ]])], [typeofname="typeof"], [typeofname=no])])
1580 AC_MSG_RESULT([$typeofname])
1581 if test "$typeofname" != "no"; then
1582 AC_DEFINE_UNQUOTED([TYPEOF], [$typeofname],
1583 [How to use the typeof extension.])
1587 AC_DEFUN([SXE_C_INLINE], [dnl
1589 if test "$ac_cv_c_inline" != "no" -a "$GCC" = "yes"; then
1590 SXE_ADD_CRUFT_OBJS([inline.o])
1595 AC_DEFUN([SXE_CHECK_BROKEN_RESTRICT], [dnl
1596 AC_MSG_CHECKING([support for restrict keyword])
1597 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
1598 extern void f(void*restrict[]);
1599 ]])], [have_restrict="yes"], [have_restrict="no"])
1600 if test "$have_restrict" = "no"; then
1601 AC_DEFINE_UNQUOTED([restrict], [],
1602 [Define restrict to nothing])
1604 AC_MSG_RESULT([$typeofname])
1605 ])dnl SXE_CHECK_BROKEN_RESTRICT
1607 AC_DEFUN([SXE_STACK_FLAGS], [dnl
1608 ## actually this belongs to error-checking stuff
1609 SXE_CHECK_COMPILER_FLAGS([-fstack-protector])
1610 if test "${sxe_cv_c_flags__fstack_protector}" = "yes"; then
1613 diagflags="${diagflags} -fstack-protector"
1616 AC_CHECK_LIB([ssp], [__stack_chk_guard])
1617 if test "${ac_cv_lib_ssp___stack_chk_guard}" = "yes"; then
1618 diagflags="${diagflags} -fstack-protector"
1623 ])dnl SXE_STACK_FLAGS
1625 dnl recommended interface macros
1627 AC_DEFUN([SXE_CHECK_CC], [dnl
1631 AC_PROG_CC([gcc icc cc])
1635 ## check for machine and architecture
1638 ## check for C compiler characteristics
1639 SXE_CHECK_CC_VERSION
1640 if test "$GCC" = "yes"; then
1641 SXE_CHECK_BROKEN_GCC
1644 if test "$ac_cv_prog_cc_c99" != ""; then
1645 SXE_CHECK_BROKEN_RESTRICT
1650 SXE_CHECK_LIBC_VERSION
1651 dnl Non-ordinary link usually requires -lc
1652 if test "$ordinary_link" = "no" -a -z "$libs_standard"; then
1658 SXE_CHECK_CC_NESTED_FUNS
1660 ## Canonicalize the configuration name.
1661 ## Commented out, lets see if anything breaks. --SY.
1662 ## SXE_STRIP_4TH_COMPONENT(ac_cv_build_alias)
1663 ## SXE_STRIP_4TH_COMPONENT(ac_cv_build)
1664 AC_SUBST([configuration], [$ac_cv_build])
1671 AC_DEFUN([SXE_CHECK_CFLAGS], [dnl
1672 dnl #### This may need to be overhauled so that all of SXEMACS_CC's flags
1673 dnl are handled separately, not just the xe_cflags_warning stuff.
1675 ## diagnostic stuff and error checking
1676 ## this may somehow be in contradiction to optimisation flags later on
1677 ## so we issue the tests right here
1678 if test "${with_error_checking_stack}" = "yes"; then
1681 if test "${with_error_checking_malldbg}" = "yes"; then
1682 ## keep MALLOC_PERTURB_ and friends?
1685 EXTRA_BATCHENV="MALLOC_PERTURB_= MALLOC_CHECK_="
1686 AC_SUBST([EXTRA_BATCHENV])
1688 SXE_CFLAGS="${SXE_CFLAGS} ${diagflags}"
1690 ## Use either command line flag, environment var, or autodetection
1691 if test "$with_ridiculously_aggressive_optimisations" = "yes"; then
1696 SXE_CFLAGS="$SXE_CFLAGS $debugflags $optiflags $warnflags"
1699 SXE_CFLAGS="$SXE_CFLAGS $featflags"
1701 elif test "$CFLAGS_uspecified_p" = "no" -o \
1702 "$ac_test_CFLAGS" != "set"; then
1707 ## Following values of CFLAGS are known to work well.
1708 ## Should we take debugging options into consideration?
1709 SXE_CHECK_COMPILER_FLAGS([-xO4], [dnl
1711 optiflags="${optiflags} -xO4"], [dnl
1712 SXE_CHECK_COMPILER_FLAGS([-xO2], [dnl
1714 optiflags="${optiflags} -xO2"])])
1715 SXE_CHECK_COMPILER_FLAGS([-O3], [dnl
1716 ## gcc, icc, decc, et al.
1717 optiflags="${optiflags} -O3"])
1720 SXE_CHECK_COMPILER_FLAGS([-qnoansialias -qlibansi], [dnl
1721 optiflags="${optiflags} -qnoansialias -qlibansi"])
1722 SXE_CHECK_COMPILER_FLAGS([-qro -qmaxmem=20000], [dnl
1723 optiflags="${optiflags} -qro -qmaxmem=20000"])
1726 SXE_CHECK_COMPILER_FLAGS([-inline-level=2], [dnl
1727 ## ah, one of the new flavours, tasty
1728 optiflags="${optiflags} -inline-level=2"], [dnl
1729 SXE_CHECK_COMPILER_FLAGS([-Ob2], [dnl
1730 ## deprecated nowadays
1731 optiflags="${optiflags} -Ob2"])])
1734 if test -z "${optiflags}"; then
1735 SXE_CHECK_COMPILER_FLAGS([-O], [dnl
1736 ## The only POSIX-approved flag
1740 SXE_CFLAGS="$SXE_CFLAGS $debugflags $optiflags $warnflags"
1743 SXE_CFLAGS="$SXE_CFLAGS $featflags"
1745 SXE_CFLAGS="${SXE_CFLAGS} ${USER_CFLAGS}"
1753 ## unset the werror flag again
1754 SXE_LANG_WERROR([off])
1756 CFLAGS="$SXE_CFLAGS"
1757 AC_MSG_CHECKING([for preferred CFLAGS])
1758 AC_MSG_RESULT([${SXE_CFLAGS}])
1761 If you wish to ADD your own flags you want to stop here and rerun the
1762 configure script like so:
1763 configure CFLAGS=<to-be-added-flags>
1765 You can always override the determined CFLAGS, partially or totally,
1767 make -C <directory> CFLAGS=<your-own-flags> [target]
1769 make CFLAGS=<your-own-flags> [target]
1772 NOTE: -C <directory> option is not available on all systems
1774 ])dnl SXE_CHECK_CFLAGS
1777 AC_DEFUN([SXE_CC_LIBRARY_PATH], [dnl
1778 ## arg #1 variable to store name in,
1779 ## if omitted defaults to `sxe_cv_tmp_gcc_library_path'
1780 pushdef([VAR], ifelse($1,[],[sxe_cv_tmp_gcc_library_path],$1))
1782 for i in ${LDFLAGS}; do
1785 __LP=${i:2}:${__LP:-.}
1791 SXE_EXPAND_VAR([${libdir}], [__ld])
1792 []VAR[]=${__ld:-.}:${__LP:-.}
1795 ])dnl SXE_CC_LIBRARY_PATH
1798 AC_DEFUN([SXE_CC_LIBRARY_LOCATION], [dnl
1799 ## arg #1 the library to seek after
1800 ## arg #2 (optional) checking message
1801 pushdef([liborig], [$1])
1802 pushdef([liblink], patsubst(patsubst(liborig, [lib], [-l]), [\.[^.]+$], []))
1803 pushdef([libname], translit(liborig, [-,.], [___]))
1804 pushdef([LIBNAME], translit(liborig, [-,.a-z], [___A-Z]))
1805 pushdef([libchk], ifelse($2,[],[for absolute path of ]liborig,$2))
1807 ## use gcc's -print-file-name
1808 AC_REQUIRE([SXE_CC_LIBRARY_PATH])
1809 AC_MSG_CHECKING([]libchk[])
1810 ## not protected against other CCs (yet)!
1811 sxe_cv_loc_[]libname[]=$(LIBRARY_PATH=${sxe_cv_tmp_gcc_library_path} \
1812 ${CC} -print-file-name=[]liborig[])
1813 AC_MSG_RESULT(${sxe_cv_loc_[]libname[]})
1815 []LIBNAME[]=${sxe_cv_loc_[]libname[]}
1822 ])dnl SXE_CC_LIBRARY_LOCATION
1825 AC_DEFUN([SXE_CHECK_ANON_STRUCTS], [
1826 AC_MSG_CHECKING([whether C compiler can cope with anonymous structures])
1828 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1838 union __test_u tmp = {.c = '4'};
1840 sxe_cv_have_anon_structs="yes"
1842 sxe_cv_have_anon_structs="no"
1844 AC_MSG_RESULT([${sxe_cv_have_anon_structs}])
1846 if test "${sxe_cv_have_anon_structs}" = "yes"; then
1847 AC_DEFINE([HAVE_ANON_STRUCTS], [1], [
1848 Whether c1x anon structs work])
1856 ])dnl SXE_CHECK_ANON_STRUCTS
1858 dnl sxe-compiler.m4 ends here