vlc.m4 4.89 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 6 7
dnl ===========================================================================
dnl  Macros to add plugins or builtins and handle their flags

AC_DEFUN([VLC_ADD_BUILTINS], [
8 9 10
  BUILTINS="${BUILTINS} $1"
])

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

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

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

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

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

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

Sam Hocevar's avatar
Sam Hocevar committed
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
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}"
])

AC_DEFUN([VLC_RESTORE_FLAGS], [
  CPPFLAGS="${CPPFLAGS_save}"
  CFLAGS="${CFLAGS_save}"
  CXXFLAGS="${CXXFLAGS_save}"
  OBJCFLAGS="${OBJCFLAGS_save}"
  LDFLAGS="${LDFLAGS_save}"
])

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

AC_DEFUN([VLC_OUTPUT_VLC_CONFIG_IN], [
74 75 76

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

77 78
  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}; do echo $x; done | sort | uniq`"

79
  rm -f vlc-config.in
Sam Hocevar's avatar
Sam Hocevar committed
80
  sed -ne '/#@1@#/q;p' < "${srcdir}/vlc-config.in.in" \
81 82 83 84 85 86 87 88 89 90 91 92 93 94
    | 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}/" \
          -e "s/@CFLAGS_OPTIM@/${CFLAGS_OPTIM}/" \
          -e "s/@CFLAGS_OPTIM_NODEBUG@/${CFLAGS_OPTIM_NODEBUG}/" \
          -e "s/@CFLAGS_NOOPTIM@/${CFLAGS_NOOPTIM}/" \
    > vlc-config.in

  dnl  Switch/case loop
95
  for x in `echo ${am_all_modules}`
96 97
  do [
    echo "    ${x})" >> vlc-config.in
98
    if test "`eval echo @'$'CPPFLAGS_${x}@`" != "@@"; then
99 100
      echo "      cppflags=\"\${cppflags} `eval echo '$'CPPFLAGS_${x}`\"" >> vlc-config.in
    fi
101
    if test "`eval echo @'$'CFLAGS_${x}@`" != "@@"; then
102 103
      echo "      cflags=\"\${cflags} `eval echo '$'CFLAGS_${x}`\"" >> vlc-config.in
    fi
104
    if test "`eval echo @'$'CXXFLAGS_${x}@`" != "@@"; then
105
      echo "      cxxflags=\"\${cxxflags} `eval echo '$'CXXFLAGS_${x}`\"" >> vlc-config.in
106
      if test "${x}" != "plugin" -a "${x}" != "builtin"; then
107 108 109
        echo "      linkage=\"c++\"" >> vlc-config.in
      fi
    fi
110
    if test "`eval echo @'$'OBJCFLAGS_${x}@`" != "@@"; then
111
      echo "      objcflags=\"\${objcflags} `eval echo '$'OBJCFLAGS_${x}`\"" >> vlc-config.in
112
      if test "${x}" != "plugin" -a "${x}" != "builtin"; then
113 114 115
        echo "      if test \"\${linkage}\" = \"c\"; then linkage=\"objc\"; fi" >> vlc-config.in
      fi
    fi
116
    if test "`eval echo @'$'LDFLAGS_${x}@`" != "@@"; then
117 118 119 120 121 122
      echo "      ldflags=\"\${ldflags} `eval echo '$'LDFLAGS_${x}`\"" >> vlc-config.in
    fi
    echo "    ;;" >> vlc-config.in
  ] done

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

Sam Hocevar's avatar
Sam Hocevar committed
126
  VLC_CONFIG_HELPER
127 128

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

Sam Hocevar's avatar
Sam Hocevar committed
133 134 135 136 137 138 139 140 141
dnl ===========================================================================
dnl  Macros for shared object handling (TODO)

AC_DEFUN([VLC_LIBRARY_SUFFIX], [
  AC_MSG_CHECKING(for shared objects suffix)
  case "${target_os}" in
    darwin*)
      LIBEXT=".dylib"
      ;;
142
    *mingw32* | *cygwin* | *wince* | *mingwce* | *pe*)
Sam Hocevar's avatar
Sam Hocevar committed
143 144 145 146 147 148 149 150 151 152 153 154 155
      LIBEXT=".dll"
      ;;
    hpux*)
      LIBEXT=".sl"
      ;;
    *)
      LIBEXT=".so"
      ;;
  esac
  AC_MSG_RESULT(${LIBEXT})
  AC_DEFINE_UNQUOTED(LIBEXT, "${LIBEXT}", [Dynamic object extension])
])