vlc.m4 5.63 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"
])

Sam Hocevar's avatar
Sam Hocevar committed
13
AC_DEFUN([VLC_ADD_PLUGINS], [
14 15 16 17
  PLUGINS="${PLUGINS} $1"
])

dnl  Special cases: vlc, pics, plugins, save
Sam Hocevar's avatar
Sam Hocevar committed
18
AC_DEFUN([VLC_ADD_CPPFLAGS], [
19
  for element in [$1]; do
Sam Hocevar's avatar
Sam Hocevar committed
20
    eval "CPPFLAGS_${element}="'"$'"{CPPFLAGS_${element}} $2"'"'
21
    am_modules_with_cppflags="${am_modules_with_cppflags} ${element}"
22 23 24
  done
])

Sam Hocevar's avatar
Sam Hocevar committed
25
AC_DEFUN([VLC_ADD_CFLAGS], [
26
  for element in [$1]; do
Sam Hocevar's avatar
Sam Hocevar committed
27
    eval "CFLAGS_${element}="'"$'"{CFLAGS_${element}} $2"'"'
28
    am_modules_with_cflags="${am_modules_with_cflags} ${element}"
29 30 31
  done
])

Sam Hocevar's avatar
Sam Hocevar committed
32
AC_DEFUN([VLC_ADD_CXXFLAGS], [
33
  for element in [$1]; do
Sam Hocevar's avatar
Sam Hocevar committed
34
    eval "CXXFLAGS_${element}="'"$'"{CXXFLAGS_${element}} $2"'"'
35
    am_modules_with_cxxflags="${am_modules_with_cxxflags} ${element}"
36 37 38
  done
])

Sam Hocevar's avatar
Sam Hocevar committed
39
AC_DEFUN([VLC_ADD_OBJCFLAGS], [
40
  for element in [$1]; do
Sam Hocevar's avatar
Sam Hocevar committed
41
    eval "OBJCFLAGS_${element}="'"$'"{OBJCFLAGS_${element}} $2"'"'
42
    am_modules_with_objcflags="${am_modules_with_objcflags} ${element}"
43 44 45
  done
])

Sam Hocevar's avatar
Sam Hocevar committed
46
AC_DEFUN([VLC_ADD_LDFLAGS], [
47
  for element in [$1]; do
48
    eval "LDFLAGS_${element}="'"'"$2 "'$'"{LDFLAGS_${element}} "'"'
49
    am_modules_with_ldflags="${am_modules_with_ldflags} ${element}"
50 51 52
  done
])

53 54 55 56 57 58 59
AC_DEFUN([VLC_ADD_LIBS], [
  for element in [$1]; do
    eval "LIBS_${element}="'"'"$2 "'$'"{LIBS_${element}} "'"'
    am_modules_with_libs="${am_modules_with_libs} ${element}"
  done
])

Sam Hocevar's avatar
Sam Hocevar committed
60 61 62 63 64 65 66 67 68
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}"
69
  LIBS_save="${LIBS}"
Sam Hocevar's avatar
Sam Hocevar committed
70 71 72 73 74 75 76 77
])

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

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

AC_DEFUN([VLC_OUTPUT_VLC_CONFIG_IN], [
85 86 87

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

88
  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`"
89

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

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

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

Sam Hocevar's avatar
Sam Hocevar committed
141
  VLC_CONFIG_HELPER
142 143

  dnl  '/#@2@#/,${/#@.@#/d;p}' won't work on OS X
Sam Hocevar's avatar
Sam Hocevar committed
144 145
  sed -ne '/#@2@#/,$p' < "${srcdir}/vlc-config.in.in" \
   | sed -e '/#@.@#/d' >> vlc-config.in
146 147
])

Sam Hocevar's avatar
Sam Hocevar committed
148 149 150 151 152
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
153
  case "${host_os}" in
Sam Hocevar's avatar
Sam Hocevar committed
154 155 156
    darwin*)
      LIBEXT=".dylib"
      ;;
157
    *mingw32* | *cygwin* | *wince* | *mingwce* | *pe*)
Sam Hocevar's avatar
Sam Hocevar committed
158 159 160 161 162 163 164 165 166 167 168 169 170
      LIBEXT=".dll"
      ;;
    hpux*)
      LIBEXT=".sl"
      ;;
    *)
      LIBEXT=".so"
      ;;
  esac
  AC_MSG_RESULT(${LIBEXT})
  AC_DEFINE_UNQUOTED(LIBEXT, "${LIBEXT}", [Dynamic object extension])
])

171 172 173
AC_DEFUN([VLC_SYMBOL_PREFIX], [
  AC_MSG_CHECKING(for prefix to exported symbols)
  SYMPREF=""
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
174
  case "${host_os}" in
175
    darwin* | *mingw32* | *cygwin* | *wince* | *mingwce* | *pe*)
176 177 178 179 180 181
      SYMPREF="_"
      ;;
  esac
  AC_MSG_RESULT(${SYMPREF})
])