vlc.m4 5.04 KB
Newer Older
1
dnl  Macros needed for VLC
Sam Hocevar's avatar
Sam Hocevar committed
2
dnl  $Id$
3

Sam Hocevar's avatar
Sam Hocevar committed
4
5
dnl ===========================================================================
dnl  Macros to add plugins or builtins and handle their flags
6
7
m4_pattern_allow([^PKG_CONFIG(_LIBDIR)?$])

Sam Hocevar's avatar
Sam Hocevar committed
8
9

AC_DEFUN([VLC_ADD_BUILTINS], [
10
11
12
  BUILTINS="${BUILTINS} $1"
])

13
AC_DEFUN([VLC_ADD_PLUGIN], [
14
15
16
17
  m4_foreach_w([element], [$1], [
    [PLUGINS="${PLUGINS} ]element["]
    AC_SUBST([LTLIB]element, [lib]element[_plugin.la])
  ])
18
19
20
])

dnl  Special cases: vlc, pics, plugins, save
Sam Hocevar's avatar
Sam Hocevar committed
21
AC_DEFUN([VLC_ADD_CPPFLAGS], [
22
  m4_foreach_w([element], [$1], [
impulze's avatar
impulze committed
23
    [eval "CPPFLAGS_]element[="'"$'"{CPPFLAGS_]element[} $2"'"']
24
25
    [am_modules_with_cppflags="${am_modules_with_cppflags} ]element["]
  ])
26
27
])

Sam Hocevar's avatar
Sam Hocevar committed
28
AC_DEFUN([VLC_ADD_CFLAGS], [
29
  m4_foreach_w([element], [$1], [
impulze's avatar
impulze committed
30
    [eval "CFLAGS_]element[="'"$'"{CFLAGS_]element[} $2"'"']
31
32
    [am_modules_with_cflags="${am_modules_with_cflags} ]element["]
  ])
33
34
])

Sam Hocevar's avatar
Sam Hocevar committed
35
AC_DEFUN([VLC_ADD_CXXFLAGS], [
36
  m4_foreach_w([element], [$1], [
impulze's avatar
impulze committed
37
    [eval "CXXFLAGS_]element[="'"$'"{CXXFLAGS_]element[} $2"'"']
38
39
    [am_modules_with_cxxflags="${am_modules_with_cxxflags} ]element["]
  ])
40
41
])

Sam Hocevar's avatar
Sam Hocevar committed
42
AC_DEFUN([VLC_ADD_OBJCFLAGS], [
43
  m4_foreach_w([element], [$1], [
impulze's avatar
impulze committed
44
    [eval "OBJCFLAGS_]element[="'"$'"{OBJCFLAGS_]element[} $2"'"']
45
46
    [am_modules_with_objcflags="${am_modules_with_objcflags} ]element["]
  ])
47
48
])

Sam Hocevar's avatar
Sam Hocevar committed
49
AC_DEFUN([VLC_ADD_LDFLAGS], [
50
  m4_foreach_w([element], [$1], [
51
    [eval "LDFLAGS_]element[="'"$2 $'"{LDFLAGS_]element[}"'"']
52
53
    [am_modules_with_ldflags="${am_modules_with_ldflags} ]element["]
  ])
54
55
])

56
AC_DEFUN([VLC_ADD_LIBS], [
57
  m4_foreach_w([element], [$1], [
58
    [eval "LIBS_]element[="'"'"$2 "'$'"{LIBS_]element[}"'"']
59
60
    [am_modules_with_libs="${am_modules_with_libs} ]element["]
  ])
61
62
])

Sam Hocevar's avatar
Sam Hocevar committed
63
64
65
66
67
68
69
70
71
dnl ===========================================================================
dnl  Macros to save and restore default flags

AC_DEFUN([VLC_SAVE_FLAGS], [
  CPPFLAGS_save="${CPPFLAGS}"
  CFLAGS_save="${CFLAGS}"
  CXXFLAGS_save="${CXXFLAGS}"
  OBJCFLAGS_save="${OBJCFLAGS}"
  LDFLAGS_save="${LDFLAGS}"
72
  LIBS_save="${LIBS}"
Sam Hocevar's avatar
Sam Hocevar committed
73
74
75
76
77
78
79
80
])

AC_DEFUN([VLC_RESTORE_FLAGS], [
  CPPFLAGS="${CPPFLAGS_save}"
  CFLAGS="${CFLAGS_save}"
  CXXFLAGS="${CXXFLAGS_save}"
  OBJCFLAGS="${OBJCFLAGS_save}"
  LDFLAGS="${LDFLAGS_save}"
81
  LIBS="${LIBS_save}"
Sam Hocevar's avatar
Sam Hocevar committed
82
83
84
85
86
87
])

dnl ===========================================================================
dnl  Helper macro to generate the vlc-config.in file

AC_DEFUN([VLC_OUTPUT_VLC_CONFIG_IN], [
88
89
90

  AC_MSG_RESULT(configure: creating ./vlc-config.in)

91
  am_all_modules="`for x in ${am_modules_with_cppflags} ${am_modules_with_cflags} ${am_modules_with_cxxflags} ${am_modules_with_objcflags} ${am_modules_with_ldflags} ${am_modules_with_libs}; do echo $x; done | sort | uniq`"
92

93
  rm -f vlc-config.in
Sam Hocevar's avatar
Sam Hocevar committed
94
  sed -ne '/#@1@#/q;p' < "${srcdir}/vlc-config.in.in" \
95
96
97
98
99
100
101
    | sed -e "s/@gprof@/${enable_gprof}/" \
          -e "s/@cprof@/${enable_cprof}/" \
          -e "s/@optim@/${enable_optimizations}/" \
          -e "s/@debug@/${enable_debug}/" \
          -e "s/@PLUGINS@/${PLUGINS}/" \
          -e "s/@BUILTINS@/${BUILTINS}/" \
          -e "s/@CFLAGS_TUNING@/${CFLAGS_TUNING}/" \
102
          -e "s/@CFLAGS_OPTIM_SPEED@/${CFLAGS_OPTIM_SPEED}/" \
103
104
105
106
          -e "s/@CFLAGS_OPTIM_NODEBUG@/${CFLAGS_OPTIM_NODEBUG}/" \
    > vlc-config.in

  dnl  Switch/case loop
107
  for x in `echo ${am_all_modules}`
108
  do [
109
    echo "    ${x})"
110
    if test "`eval echo @'$'CPPFLAGS_${x}@`" != "@@"; then
111
      echo "      cppflags=\"\${cppflags} `eval echo '$'CPPFLAGS_${x}`\""
112
    fi
113
    if test "`eval echo @'$'CFLAGS_${x}@`" != "@@"; then
114
      echo "      cflags=\"\${cflags} `eval echo '$'CFLAGS_${x}`\""
115
    fi
116
    if test "`eval echo @'$'CXXFLAGS_${x}@`" != "@@"; then
117
      echo "      cxxflags=\"\${cxxflags} `eval echo '$'CXXFLAGS_${x}`\""
118
      if test "${x}" != "plugin" -a "${x}" != "builtin"; then
119
        echo "      linkage=\"c++\""
120
121
      fi
    fi
122
    if test "`eval echo @'$'OBJCFLAGS_${x}@`" != "@@"; then
123
      echo "      objcflags=\"\${objcflags} `eval echo '$'OBJCFLAGS_${x}`\""
124
      if test "${x}" != "plugin" -a "${x}" != "builtin"; then
125
        echo "      if test \"\${linkage}\" = \"c\"; then linkage=\"objc\"; fi"
126
127
      fi
    fi
128
    if test "`eval echo @'$'LDFLAGS_${x}@`" != "@@"; then
129
      echo "      ldflags=\"\${ldflags} `eval echo '$'LDFLAGS_${x}`\""
130
    fi
131
    if test "`eval echo @'$'LIBS_${x}@`" != "@@"; then
132
      echo "      libs=\"\${libs} `eval echo '$'LIBS_${x}`\""
133
    fi
134
135
136
    echo "    ;;"
  ] done >> vlc-config.in

137
138
  dnl  '/#@1@#/,${/#@.@#/d;p}' won't work on OS X
  sed -ne '/#@1@#/,$p' < "${srcdir}/vlc-config.in.in" \
Sam Hocevar's avatar
Sam Hocevar committed
139
   | sed -e '/#@.@#/d' >> vlc-config.in
140
141
])

Sam Hocevar's avatar
Sam Hocevar committed
142
143
144
145
146
dnl ===========================================================================
dnl  Macros for shared object handling (TODO)

AC_DEFUN([VLC_LIBRARY_SUFFIX], [
  AC_MSG_CHECKING(for shared objects suffix)
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
147
  case "${host_os}" in
Sam Hocevar's avatar
Sam Hocevar committed
148
149
150
    darwin*)
      LIBEXT=".dylib"
      ;;
151
    *mingw32* | *cygwin* | *wince* | *mingwce* | *os2*)
Sam Hocevar's avatar
Sam Hocevar committed
152
153
154
155
156
157
158
159
160
161
162
163
164
      LIBEXT=".dll"
      ;;
    hpux*)
      LIBEXT=".sl"
      ;;
    *)
      LIBEXT=".so"
      ;;
  esac
  AC_MSG_RESULT(${LIBEXT})
  AC_DEFINE_UNQUOTED(LIBEXT, "${LIBEXT}", [Dynamic object extension])
])