]> git.donarmstrong.com Git - deb_pkgs/spamass-milter.git/blob - ac_pike_compiler_flag.m4
[svn-inject] Installing original source of spamass-milter
[deb_pkgs/spamass-milter.git] / ac_pike_compiler_flag.m4
1 dnl AC_SYS_COMPILER_FLAG, taken from the Pike 7.5 distribution at http://pike.ida.liu.se
2 dnl $Id: ac_pike_compiler_flag.m4,v 1.3 2004/05/13 21:50:08 dnelson Exp $
3
4 # option, cache_name, variable, do_if_failed, do_if_ok
5 AC_DEFUN([AC_PIKE_COMPILER_FLAG],
6 [
7   AC_MSG_CHECKING(for $1)
8   AC_CACHE_VAL(pike_cv_option_$2,
9   [
10     OLD_CPPFLAGS="[$]CPPFLAGS"
11     CPPFLAGS="[$]OLD_CPPFLAGS $1"
12     old_ac_link="[$]ac_link"
13     ac_link="[$]old_ac_link 2>conftezt.out.2"
14     AC_TRY_RUN([
15       int foo;
16       int main(int argc, char **argv)
17       {
18         /* The following code triggs gcc:s generation of aline opcodes,
19          * which some versions of as does not support.
20          */
21         if (argc > 0) argc = 0;
22         return argc;
23       }
24     ],pike_cv_option_$2=yes,
25       pike_cv_option_$2=no, [
26       AC_TRY_LINK([], [], pike_cv_option_$2=yes, pike_cv_option_$2=no)
27     ])
28     if grep -i 'unrecognized option' <conftezt.out.2 >/dev/null; then
29       pike_cv_option_$2=no
30     elif grep -i 'unknown option' <conftezt.out.2 >/dev/null; then
31       # cc/HPUX says the following regarding -q64:
32       #
33       # cc: warning 422: Unknown option "6" ignored.
34       # cc: warning 422: Unknown option "4" ignored.
35       pike_cv_option_$2=no
36     elif grep -i 'optimizer bugs' <conftezt.out.2 >/dev/null; then
37       # gcc/FreeBSD-4.6/alpha says the following regarding -O2:
38       #
39       # cc1: warning: 
40       # ***
41       # ***     The -O2 flag TRIGGERS KNOWN OPTIMIZER BUGS ON THIS PLATFORM
42       # ***
43       pike_cv_option_$2=no
44     elif grep -i 'not found' <conftezt.out.2 >/dev/null; then
45       # cc/AIX says the following regarding +O3:
46       #
47       # cc: 1501-228 input file +O3 not found
48       pike_cv_option_$2=no
49     elif grep -i 'ignored' <conftezt.out.2 >/dev/null; then
50       # gcc/AIX says the following regarding -fpic:
51       #
52       # cc1: warning: -fpic ignored (all code is position independent)
53       pike_cv_option_$2=no
54     else :; fi
55     rm conftezt.out.2
56     CPPFLAGS="[$]OLD_CPPFLAGS"
57     ac_link="[$]old_ac_link"
58   ])
59   
60   if test x"[$]pike_cv_option_$2" = "xyes" ; then
61     $3="[$]$3 $1"
62     case "$3" in
63       OPTIMIZE)
64         CFLAGS="[$]CFLAGS $1"
65       ;;
66     esac
67     AC_MSG_RESULT(yes)
68     $5
69   else
70     AC_MSG_RESULT(no)
71     $4
72   fi
73 ])