]> git.sesse.net Git - vlc/blob - m4/vlc.m4
* m4/vlc.m4: Prepend LDFLAGS instead of appending them.
[vlc] / m4 / vlc.m4
1 dnl  Macros needed for VLC
2 dnl  $Id: vlc.m4,v 1.4 2003/06/29 14:57:49 sam Exp $
3
4 dnl  Add plugins or builtins
5 AC_DEFUN([AX_ADD_BUILTINS], [
6   BUILTINS="${BUILTINS} $1"
7 ])
8
9 AC_DEFUN([AX_ADD_PLUGINS], [
10   PLUGINS="${PLUGINS} $1"
11 ])
12
13 dnl  Save and restore default flags
14 AC_DEFUN([AX_SAVE_FLAGS], [
15   CPPFLAGS_save="${CPPFLAGS}"
16   CFLAGS_save="${CFLAGS}"
17   CXXFLAGS_save="${CXXFLAGS}"
18   OBJCFLAGS_save="${OBJCFLAGS}"
19   LDFLAGS_save="${LDFLAGS}"
20 ])
21
22 AC_DEFUN([AX_RESTORE_FLAGS], [
23   CPPFLAGS="${CPPFLAGS_save}"
24   CFLAGS="${CFLAGS_save}"
25   CXXFLAGS="${CXXFLAGS_save}"
26   OBJCFLAGS="${OBJCFLAGS_save}"
27   LDFLAGS="${LDFLAGS_save}"
28 ])
29
30 dnl  Special cases: vlc, pics, plugins, save
31 AC_DEFUN([AX_ADD_CPPFLAGS], [
32   for element in [$1]; do
33     eval "CPPFLAGS_${element}="'"$'"{CPPFLAGS_${element}} $2"'"'
34     am_plugins_with_cppflags="${am_plugins_with_cppflags} ${element}"
35   done
36 ])
37
38 AC_DEFUN([AX_ADD_CFLAGS], [
39   for element in [$1]; do
40     eval "CFLAGS_${element}="'"$'"{CFLAGS_${element}} $2"'"'
41     am_plugins_with_cflags="${am_plugins_with_cflags} ${element}"
42   done
43 ])
44
45 AC_DEFUN([AX_ADD_CXXFLAGS], [
46   for element in [$1]; do
47     eval "CXXFLAGS_${element}="'"$'"{CXXFLAGS_${element}} $2"'"'
48     am_plugins_with_cxxflags="${am_plugins_with_cxxflags} ${element}"
49   done
50 ])
51
52 AC_DEFUN([AX_ADD_OBJCFLAGS], [
53   for element in [$1]; do
54     eval "OBJCFLAGS_${element}="'"$'"{OBJCFLAGS_${element}} $2"'"'
55     am_plugins_with_objcflags="${am_plugins_with_objcflags} ${element}"
56   done
57 ])
58
59 AC_DEFUN([AX_ADD_LDFLAGS], [
60   for element in [$1]; do
61     eval "LDFLAGS_${element}="'"'"$2 "'$'"{LDFLAGS_${element}} "'"'
62     am_plugins_with_ldflags="${am_plugins_with_ldflags} ${element}"
63   done
64 ])
65
66 AC_DEFUN([AX_OUTPUT_VLC_CONFIG_IN], [
67
68   AC_MSG_RESULT(configure: creating ./vlc-config.in)
69
70   rm -f vlc-config.in
71   sed -ne '/#@1@#/q;p' < "${srcdir}/vlc-config.in.in" \
72     | sed -e "s/@gprof@/${enable_gprof}/" \
73           -e "s/@cprof@/${enable_cprof}/" \
74           -e "s/@optim@/${enable_optimizations}/" \
75           -e "s/@debug@/${enable_debug}/" \
76           -e "s/@release@/${enable_release}/" \
77           -e "s/@PLUGINS@/${PLUGINS}/" \
78           -e "s/@BUILTINS@/${BUILTINS}/" \
79           -e "s/@CFLAGS_TUNING@/${CFLAGS_TUNING}/" \
80           -e "s/@CFLAGS_OPTIM@/${CFLAGS_OPTIM}/" \
81           -e "s/@CFLAGS_OPTIM_NODEBUG@/${CFLAGS_OPTIM_NODEBUG}/" \
82           -e "s/@CFLAGS_NOOPTIM@/${CFLAGS_NOOPTIM}/" \
83     > vlc-config.in
84
85   dnl  Switch/case loop
86   for x in `echo ${am_plugins_with_ldflags}`
87   do [
88     echo "    ${x})" >> vlc-config.in
89     if test -n "`eval echo '$'CPPFLAGS_${x}`"; then
90       echo "      cppflags=\"\${cppflags} `eval echo '$'CPPFLAGS_${x}`\"" >> vlc-config.in
91     fi
92     if test -n "`eval echo '$'CFLAGS_${x}`"; then
93       echo "      cflags=\"\${cflags} `eval echo '$'CFLAGS_${x}`\"" >> vlc-config.in
94     fi
95     if test -n "`eval echo '$'CXXFLAGS_${x}`"; then
96       echo "      cxxflags=\"\${cxxflags} `eval echo '$'CXXFLAGS_${x}`\"" >> vlc-config.in
97       if test "${x}" != "plugins" -a "${x}" != "builtins"; then
98         echo "      linkage=\"c++\"" >> vlc-config.in
99       fi
100     fi
101     if test -n "`eval echo '$'OBJCFLAGS_${x}`"; then
102       echo "      objcflags=\"\${objcflags} `eval echo '$'OBJCFLAGS_${x}`\"" >> vlc-config.in
103       if test "${x}" != "plugins" -a "${x}" != "builtins"; then
104         echo "      if test \"\${linkage}\" = \"c\"; then linkage=\"objc\"; fi" >> vlc-config.in
105       fi
106     fi
107     if test -n "`eval echo '$'LDFLAGS_${x}`"; then
108       echo "      ldflags=\"\${ldflags} `eval echo '$'LDFLAGS_${x}`\"" >> vlc-config.in
109     fi
110     echo "    ;;" >> vlc-config.in
111   ] done
112
113   dnl  '/#@1@#/,/#@2@#/{/#@.@#/d;p}' won't work on OS X
114   sed -ne '/#@1@#/,/#@2@#/p' < "${srcdir}/vlc-config.in.in" \
115    | sed -e '/#@.@#/d' >> vlc-config.in
116
117   AX_VLC_CONFIG_HELPER
118
119   dnl  '/#@2@#/,${/#@.@#/d;p}' won't work on OS X
120   sed -ne '/#@2@#/,$p' < "${srcdir}/vlc-config.in.in" \
121    | sed -e '/#@.@#/d' >> vlc-config.in
122 ])
123