vlc.m4 5.1 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
  PLUGINS="${PLUGINS} $1"
15
  AC_SUBST([LTLIB$1], ["lib$1_plugin.la"])
16 17 18
])

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

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

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

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

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

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

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

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

AC_DEFUN([VLC_OUTPUT_VLC_CONFIG_IN], [
86 87 88

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

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

91
  rm -f vlc-config.in
Sam Hocevar's avatar
Sam Hocevar committed
92
  sed -ne '/#@1@#/q;p' < "${srcdir}/vlc-config.in.in" \
93 94 95 96 97 98 99 100
    | 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}/" \
101 102
          -e "s/@CFLAGS_OPTIM_SIZE@/${CFLAGS_OPTIM_SIZE}/" \
          -e "s/@CFLAGS_OPTIM_SPEED@/${CFLAGS_OPTIM_SPEED}/" \
103 104 105 106 107
          -e "s/@CFLAGS_OPTIM_NODEBUG@/${CFLAGS_OPTIM_NODEBUG}/" \
          -e "s/@CFLAGS_NOOPTIM@/${CFLAGS_NOOPTIM}/" \
    > vlc-config.in

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

138 139
  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
140
   | sed -e '/#@.@#/d' >> vlc-config.in
141 142
])

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