aboutsummaryrefslogtreecommitdiff
path: root/common/m4/ax_hack_cflags.m4
blob: 7e735a83ae5ac269b32e8fa7244e4078b21467cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#-*- Mode: autoconf -*-
#
# SYNOPSIS
#
#   AX_DISTRIBUTE_CFLAGS([$FLAGS], [cppflagsVar], [cflagsVar])
#     + distributes $FLAGS among $cppflagsVar and $cflagsVar
#
#   AX_SAFE_CFLAGS([$FLAGS], [safeVar], [unsafeVar]).
#     + distributes $FLAGS among $safeVar and $unsafeVar
#
# LAST MODIFICATION
#
#   Sun, 26 Apr 2009 23:53:21 +0200
#
# COPYLEFT
#
#   Copyright (c) 2009 Bryan Jurish <moocow@ling.uni-potsdam.de>
#
#   Copying and distribution of this file, with or without
#   modification, are permitted in any medium without royalty provided
#   the copyright notice and this notice are preserved.


# AX_DISTRIBUTE_CFLAGS($FLAGS, CPPFLAGS, CFLAGS)
#  + distribute $FLAGS between $CPPFLAGS and $CFLAGS
AC_DEFUN([AX_DISTRIBUTE_CFLAGS],
[
 ##vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
 ## BEGIN AX_DISTRIBUTE_CFLAGS
 axdf_cppflags=
 axdf_cflags=

 for axdf_flag in $1
 do
   case "$axdf_flag" in
     -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
       axdf_cppflags="$axdf_cppflags $axdf_flag"
       ;;
     *)
       axdf_cflags="$axdf_cflags $axdf_flag"
       ;;
   esac
 done

 test x$2 != x && $2="$$2 $axdf_cppflags"
 test x$3 != x && $3="$$3 $axdf_cflags"

 ## END AX_DISTRIBUTE_CFLAGS
 ##^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
])

# AX_SAFE_CFLAGS($FLAGS, SAFE, UNSAFE)
#  + distribute $FLAGS between $SAFE and $UNSAFE
AC_DEFUN([AX_SAFE_CFLAGS],
[
 ##vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
 ## BEGIN AX_SAFE_CFLAGS
 axsf_safe=
 axsf_unsafe=

 for axsf_flag in $1
 do
   axsf_flag_tmp=`echo $axsf_flag | sed -e 's/[[ '\''\"\(\)]]//g'`
   if test "${axsf_flag_tmp}" = "${axsf_flag}"; then
     axsf_safe="$axsf_safe $axsf_flag"
   else
     axsf_unsafe="$axsf_unsafe $axsf_flag"
   fi
 done

 test x$2 != x && $2="$$2 $axsf_safe"
 test x$3 != x && $3="$$3 $axsf_unsafe"
 ## END AX_SAFE_CFLAGS
 ##^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
])