gst-feature.m4 9.1 KB
Newer Older
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
1 2 3 4
dnl Perform a check for a feature for GStreamer
dnl Richard Boulton <richard-alsa@tartarus.org>
dnl Thomas Vander Stichele <thomas@apestaart.org> added useful stuff
dnl Last modification: 25/06/2001
5
dnl
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
6
dnl AG_GST_CHECK_FEATURE(FEATURE-NAME, FEATURE-DESCRIPTION,
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
7 8 9
dnl                   DEPENDENT-PLUGINS, TEST-FOR-FEATURE,
dnl                   DISABLE-BY-DEFAULT, ACTION-IF-USE, ACTION-IF-NOTUSE)
dnl
10
dnl This macro adds a command line argument to allow the user to enable
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
11 12 13 14 15 16 17 18 19 20 21
dnl or disable a feature, and if the feature is enabled, performs a supplied
dnl test to check if the feature is available.
dnl
dnl The test should define HAVE_<FEATURE-NAME> to "yes" or "no" depending
dnl on whether the feature is available.
dnl
dnl The macro will set USE_<FEATURE-NAME> to "yes" or "no" depending on
dnl whether the feature is to be used.
dnl Thomas changed this, so that when USE_<FEATURE-NAME> was already set
dnl to no, then it stays that way.
dnl
22
dnl The macro will call AM_CONDITIONAL(USE_<FEATURE-NAME>, ...) to allow
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
23 24 25
dnl the feature to control what is built in Makefile.ams.  If you want
dnl additional actions resulting from the test, you can add them with the
dnl ACTION-IF-USE and ACTION-IF-NOTUSE parameters.
26
dnl
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
27 28 29 30
dnl FEATURE-NAME        is the name of the feature, and should be in
dnl                     purely upper case characters.
dnl FEATURE-DESCRIPTION is used to describe the feature in help text for
dnl                     the command line argument.
31
dnl DEPENDENT-PLUGINS   lists any plug-ins which depend on this feature.
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
32 33 34 35 36 37 38 39 40 41 42 43
dnl TEST-FOR-FEATURE    is a test which sets HAVE_<FEATURE-NAME> to "yes"
dnl                     or "no" depending on whether the feature is
dnl                     available.
dnl DISABLE-BY-DEFAULT  if "disabled", the feature is disabled by default,
dnl                     if any other value, the feature is enabled by default.
dnl ACTION-IF-USE       any extra actions to perform if the feature is to be
dnl                     used.
dnl ACTION-IF-NOTUSE    any extra actions to perform if the feature is not to
dnl                     be used.
dnl
dnl
dnl thomas :
44
dnl we also added a history.
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
45
dnl GST_PLUGINS_YES will contain all plugins to be built
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
46
dnl                 that were checked through AG_GST_CHECK_FEATURE
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
47 48
dnl GST_PLUGINS_NO will contain those that won't be built

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
49
AC_DEFUN([AG_GST_CHECK_FEATURE],
50
[echo
51 52 53 54 55
AC_MSG_NOTICE(*** checking feature: [$2] ***)
if test "x[$3]" != "x"
then
  AC_MSG_NOTICE(*** for plug-ins: [$3] ***)
fi
56
dnl
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
57 58 59 60 61 62 63
builtin(define, [gst_endisable], ifelse($5, [disabled], [enable], [disable]))dnl
dnl if it is set to NO, then don't even consider it for building
NOUSE=
if test "x$USE_[$1]" = "xno"; then
  NOUSE="yes"
fi
AC_ARG_ENABLE(translit([$1], A-Z, a-z),
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
64 65
  [  ]builtin(format, --%-26s gst_endisable %s, gst_endisable-translit([$1], A-Z, a-z), [$2]ifelse([$3],,,: [$3])),
  [ case "${enableval}" in
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
      yes) USE_[$1]=yes;;
      no) USE_[$1]=no;;
      *) AC_MSG_ERROR(bad value ${enableval} for --enable-translit([$1], A-Z, a-z)) ;;
    esac],
  [ USE_$1=]ifelse($5, [disabled], [no], [yes]))           dnl DEFAULT

dnl *** set it back to no if it was preset to no
if test "x$NOUSE" = "xyes"; then
  USE_[$1]="no"
  AC_MSG_WARN(*** $3 pre-configured not to be built)
fi
NOUSE=

dnl *** If it's enabled

if test x$USE_[$1] = xyes; then
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
82 83
  dnl save compile variables before the test

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
84 85 86 87 88
  gst_check_save_LIBS=$LIBS
  gst_check_save_LDFLAGS=$LDFLAGS
  gst_check_save_CFLAGS=$CFLAGS
  gst_check_save_CPPFLAGS=$CPPFLAGS
  gst_check_save_CXXFLAGS=$CXXFLAGS
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
89

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
90
  HAVE_[$1]=no
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
91
  dnl TEST_FOR_FEATURE
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
92
  $4
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
93

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
94 95 96 97 98 99 100 101 102
  LIBS=$gst_check_save_LIBS
  LDFLAGS=$gst_check_save_LDFLAGS
  CFLAGS=$gst_check_save_CFLAGS
  CPPFLAGS=$gst_check_save_CPPFLAGS
  CXXFLAGS=$gst_check_save_CXXFLAGS

  dnl If it isn't found, unset USE_[$1]
  if test x$HAVE_[$1] = xno; then
    USE_[$1]=no
103 104
  else
    ifelse([$3], , :, [AC_MSG_NOTICE(*** These plugins will be built: [$3])])
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
105 106 107 108 109
  fi
fi
dnl *** Warn if it's disabled or not found
if test x$USE_[$1] = xyes; then
  ifelse([$6], , :, [$6])
110 111 112
  if test "x$3" != "x"; then
    GST_PLUGINS_YES="\t[$3]\n$GST_PLUGINS_YES"
  fi
113
  AC_DEFINE(HAVE_[$1], , [Define to enable $2]ifelse($3,,, [ (used by $3)]).)
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
114
else
115
  ifelse([$3], , :, [AC_MSG_NOTICE(*** These plugins will not be built: [$3])])
116 117 118
  if test "x$3" != "x"; then
    GST_PLUGINS_NO="\t[$3]\n$GST_PLUGINS_NO"
  fi
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
119 120 121 122 123 124 125 126 127 128
  ifelse([$7], , :, [$7])
fi
dnl *** Define the conditional as appropriate
AM_CONDITIONAL(USE_[$1], test x$USE_[$1] = xyes)
])

dnl Use a -config program which accepts --cflags and --libs parameters
dnl to set *_CFLAGS and *_LIBS and check existence of a feature.
dnl Richard Boulton <richard-alsa@tartarus.org>
dnl Last modification: 26/06/2001
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
129
dnl AG_GST_CHECK_CONFIGPROG(FEATURE-NAME, CONFIG-PROG-FILENAME, MODULES)
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
130 131 132 133
dnl
dnl This check was written for GStreamer: it should be renamed and checked
dnl for portability if you decide to use it elsewhere.
dnl
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
134
AC_DEFUN([AG_GST_CHECK_CONFIGPROG],
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
135 136 137 138 139 140 141
[
  AC_PATH_PROG([$1]_CONFIG, [$2], no)
  if test x$[$1]_CONFIG = xno; then
    [$1]_LIBS=
    [$1]_CFLAGS=
    HAVE_[$1]=no
  else
142 143 144
    if [$2] --plugin-libs [$3] &> /dev/null; then
      [$1]_LIBS=`[$2] --plugin-libs [$3]`
    else
145 146
      [$1]_LIBS=`[$2] --libs [$3]`
    fi
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
147 148 149 150 151 152 153 154 155 156 157
    [$1]_CFLAGS=`[$2] --cflags [$3]`
    HAVE_[$1]=yes
  fi
  AC_SUBST([$1]_LIBS)
  AC_SUBST([$1]_CFLAGS)
])

dnl Use AC_CHECK_LIB and AC_CHECK_HEADER to do both tests at once
dnl sets HAVE_module if we have it
dnl Richard Boulton <richard-alsa@tartarus.org>
dnl Last modification: 26/06/2001
158
dnl AG_GST_CHECK_LIBHEADER(FEATURE-NAME, LIB NAME, LIB FUNCTION, EXTRA LD FLAGS,
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
159 160 161 162 163
dnl                     HEADER NAME, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
dnl
dnl This check was written for GStreamer: it should be renamed and checked
dnl for portability if you decide to use it elsewhere.
dnl
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
164
AC_DEFUN([AG_GST_CHECK_LIBHEADER],
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
165 166 167 168 169 170 171 172 173 174 175
[
  AC_CHECK_LIB([$2], [$3], HAVE_[$1]=yes, HAVE_[$1]=no,[$4])
  if test "x$HAVE_[$1]" = "xyes"; then
    AC_CHECK_HEADER([$5], :, HAVE_[$1]=no)
    if test "x$HAVE_[$1]" = "xyes"; then
      dnl execute what needs to be
      ifelse([$6], , :, [$6])
    else
      ifelse([$7], , :, [$7])
    fi
  else
176
    ifelse([$7], , :, [$7])
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
177 178 179 180 181
  fi
  AC_SUBST(HAVE_[$1])
]
)

182 183
dnl 2004-02-14 Thomas - changed to get set properly and use proper output
dnl 2003-06-27 Benjamin Otte - changed to make this work with gstconfig.h
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
184 185 186
dnl
dnl Add a subsystem --disable flag and all the necessary symbols and substitions
dnl
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
187
dnl AG_GST_CHECK_SUBSYSTEM_DISABLE(SYSNAME, [subsystem name])
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
188
dnl
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
189
AC_DEFUN([AG_GST_CHECK_SUBSYSTEM_DISABLE],
190 191 192 193 194 195
[
  dnl this define will replace each literal subsys_def occurrence with
  dnl the lowercase hyphen-separated subsystem
  dnl e.g. if $1 is GST_DEBUG then subsys_def will be a macro with gst-debug
  define([subsys_def],translit([$1], _A-Z, -a-z))

196
  AC_ARG_ENABLE(subsys_def,
197 198 199 200 201 202 203 204 205 206 207 208
    AC_HELP_STRING(--disable-subsys_def, [disable $2]),
    [
      case "${enableval}" in
        yes) GST_DISABLE_[$1]=no ;;
        no) GST_DISABLE_[$1]=yes ;;
        *) AC_MSG_ERROR([bad value ${enableval} for --enable-subsys_def]) ;;
       esac
    ],
    [GST_DISABLE_[$1]=no]) dnl Default value

  if test x$GST_DISABLE_[$1] = xyes; then
    AC_MSG_NOTICE([disabled subsystem [$2]])
209
    GST_DISABLE_[$1]_DEFINE="#define GST_DISABLE_$1 1"
210 211 212 213 214
  else
    GST_DISABLE_[$1]_DEFINE="/* #undef GST_DISABLE_$1 */"
  fi
  AC_SUBST(GST_DISABLE_[$1]_DEFINE)
  undefine([subsys_def])
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
215
])
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
216

217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251

dnl Parse gstconfig.h for feature and defines add the symbols and substitions
dnl
dnl AG_GST_PARSE_SUBSYSTEM_DISABLE(GST_CONFIGPATH, FEATURE)
dnl
AC_DEFUN([AG_GST_PARSE_SUBSYSTEM_DISABLE],
[
  grep >/dev/null "#undef GST_DISABLE_$2" $1
  if test $? = 0; then
    GST_DISABLE_[$2]=0
  else
    GST_DISABLE_[$2]=1
  fi
  AC_SUBST(GST_DISABLE_[$2])
])

dnl Parse gstconfig.h and defines add the symbols and substitions
dnl
dnl GST_CONFIGPATH=`$PKG_CONFIG --variable=includedir gstreamer-0.10`"/gst/gstconfig.h"
dnl AG_GST_PARSE_SUBSYSTEM_DISABLES(GST_CONFIGPATH)
dnl
AC_DEFUN([AG_GST_PARSE_SUBSYSTEM_DISABLES],
[
  AG_GST_PARSE_SUBSYSTEM_DISABLE($1,GST_DEBUG)
  AG_GST_PARSE_SUBSYSTEM_DISABLE($1,LOADSAVE)
  AG_GST_PARSE_SUBSYSTEM_DISABLE($1,PARSE)
  AG_GST_PARSE_SUBSYSTEM_DISABLE($1,TRACE)
  AG_GST_PARSE_SUBSYSTEM_DISABLE($1,ALLOC_TRACE)
  AG_GST_PARSE_SUBSYSTEM_DISABLE($1,REGISTRY)
  AG_GST_PARSE_SUBSYSTEM_DISABLE($1,PLUGIN)
  AG_GST_PARSE_SUBSYSTEM_DISABLE($1,XML)
])



252 253
dnl relies on GST_PLUGINS_ALL, GST_PLUGINS_SELECTED, GST_PLUGINS_YES,
dnl GST_PLUGINS_NO, and BUILD_EXTERNAL
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
254
AC_DEFUN([AG_GST_OUTPUT_PLUGINS], [
255

256 257 258
printf "configure: *** Plug-ins without external dependencies that will be built:\n"
( for i in $GST_PLUGINS_SELECTED; do printf '\t'$i'\n'; done ) | sort
printf "\n"
259

260
printf "configure: *** Plug-ins without external dependencies that will NOT be built:\n"
261
( for i in $GST_PLUGINS_ALL; do
262 263
    case " $GST_PLUGINS_SELECTED " in
      *\ $i\ *)
264 265
	;;
      *)
266
	printf '\t'$i'\n'
267 268 269
	;;
    esac
  done ) | sort
270
printf "\n"
271

272
if test "x$BUILD_EXTERNAL" = "xno"; then
273
  printf "configure: *** No plug-ins with external dependencies will be built\n"
274
else
275 276 277 278 279 280
  printf "configure: *** Plug-ins with dependencies that will be built:"
  printf "$GST_PLUGINS_YES\n" | sort
  printf "\n"
  printf "configure: *** Plug-ins with dependencies that will NOT be built:"
  printf "$GST_PLUGINS_NO\n" | sort
  printf "\n"
281 282 283
fi
])