1 dnl Perform a check for a feature for GStreamer
2 dnl Richard Boulton <richard-alsa@tartarus.org>
3 dnl Thomas Vander Stichele <thomas@apestaart.org> added useful stuff
4 dnl Last modification: 25/06/2001
6 dnl AG_GST_CHECK_FEATURE(FEATURE-NAME, FEATURE-DESCRIPTION,
7 dnl DEPENDENT-PLUGINS, TEST-FOR-FEATURE,
8 dnl DISABLE-BY-DEFAULT, ACTION-IF-USE, ACTION-IF-NOTUSE)
10 dnl This macro adds a command line argument to allow the user to enable
11 dnl or disable a feature, and if the feature is enabled, performs a supplied
12 dnl test to check if the feature is available.
14 dnl The test should define HAVE_<FEATURE-NAME> to "yes" or "no" depending
15 dnl on whether the feature is available.
17 dnl The macro will set USE_<FEATURE-NAME> to "yes" or "no" depending on
18 dnl whether the feature is to be used.
19 dnl Thomas changed this, so that when USE_<FEATURE-NAME> was already set
20 dnl to no, then it stays that way.
22 dnl The macro will call AM_CONDITIONAL(USE_<FEATURE-NAME>, ...) to allow
23 dnl the feature to control what is built in Makefile.ams. If you want
24 dnl additional actions resulting from the test, you can add them with the
25 dnl ACTION-IF-USE and ACTION-IF-NOTUSE parameters.
27 dnl FEATURE-NAME is the name of the feature, and should be in
28 dnl purely upper case characters.
29 dnl FEATURE-DESCRIPTION is used to describe the feature in help text for
30 dnl the command line argument.
31 dnl DEPENDENT-PLUGINS lists any plug-ins which depend on this feature.
32 dnl TEST-FOR-FEATURE is a test which sets HAVE_<FEATURE-NAME> to "yes"
33 dnl or "no" depending on whether the feature is
35 dnl DISABLE-BY-DEFAULT if "disabled", the feature is disabled by default,
36 dnl if any other value, the feature is enabled by default.
37 dnl ACTION-IF-USE any extra actions to perform if the feature is to be
39 dnl ACTION-IF-NOTUSE any extra actions to perform if the feature is not to
44 dnl we also added a history.
45 dnl GST_PLUGINS_YES will contain all plugins to be built
46 dnl that were checked through AG_GST_CHECK_FEATURE
47 dnl GST_PLUGINS_NO will contain those that won't be built
49 AC_DEFUN([AG_GST_CHECK_FEATURE],
51 AC_MSG_NOTICE(*** checking feature: [$2] ***)
52 if test "x[$3]" != "x"
54 AC_MSG_NOTICE(*** for plug-ins: [$3] ***)
57 builtin(define, [gst_endisable], ifelse($5, [disabled], [enable], [disable]))dnl
58 dnl if it is set to NO, then don't even consider it for building
60 if test "x$USE_[$1]" = "xno"; then
63 AC_ARG_ENABLE(translit([$1], A-Z, a-z),
64 [ ]builtin(format, --%-26s gst_endisable %s, gst_endisable-translit([$1], A-Z, a-z), [$2]ifelse([$3],,,: [$3])),
65 [ case "${enableval}" in
68 *) AC_MSG_ERROR(bad value ${enableval} for --enable-translit([$1], A-Z, a-z)) ;;
70 [ USE_$1=]ifelse($5, [disabled], [no], [yes])) dnl DEFAULT
72 dnl *** set it back to no if it was preset to no
73 if test "x$NOUSE" = "xyes"; then
75 AC_MSG_WARN(*** $3 pre-configured not to be built)
79 dnl *** If it's enabled
81 if test x$USE_[$1] = xyes; then
82 dnl save compile variables before the test
84 gst_check_save_LIBS=$LIBS
85 gst_check_save_LDFLAGS=$LDFLAGS
86 gst_check_save_CFLAGS=$CFLAGS
87 gst_check_save_CPPFLAGS=$CPPFLAGS
88 gst_check_save_CXXFLAGS=$CXXFLAGS
94 LIBS=$gst_check_save_LIBS
95 LDFLAGS=$gst_check_save_LDFLAGS
96 CFLAGS=$gst_check_save_CFLAGS
97 CPPFLAGS=$gst_check_save_CPPFLAGS
98 CXXFLAGS=$gst_check_save_CXXFLAGS
100 dnl If it isn't found, unset USE_[$1]
101 if test x$HAVE_[$1] = xno; then
104 ifelse([$3], , :, [AC_MSG_NOTICE(*** These plugins will be built: [$3])])
107 dnl *** Warn if it's disabled or not found
108 if test x$USE_[$1] = xyes; then
109 ifelse([$6], , :, [$6])
110 if test "x$3" != "x"; then
111 GST_PLUGINS_YES="\t[$3]\n$GST_PLUGINS_YES"
113 AC_DEFINE(HAVE_[$1], , [Define to enable $2]ifelse($3,,, [ (used by $3)]).)
115 ifelse([$3], , :, [AC_MSG_NOTICE(*** These plugins will not be built: [$3])])
116 if test "x$3" != "x"; then
117 GST_PLUGINS_NO="\t[$3]\n$GST_PLUGINS_NO"
119 ifelse([$7], , :, [$7])
121 dnl *** Define the conditional as appropriate
122 AM_CONDITIONAL(USE_[$1], test x$USE_[$1] = xyes)
125 dnl Use a -config program which accepts --cflags and --libs parameters
126 dnl to set *_CFLAGS and *_LIBS and check existence of a feature.
127 dnl Richard Boulton <richard-alsa@tartarus.org>
128 dnl Last modification: 26/06/2001
129 dnl AG_GST_CHECK_CONFIGPROG(FEATURE-NAME, CONFIG-PROG-FILENAME, MODULES)
131 dnl This check was written for GStreamer: it should be renamed and checked
132 dnl for portability if you decide to use it elsewhere.
134 AC_DEFUN([AG_GST_CHECK_CONFIGPROG],
136 AC_PATH_PROG([$1]_CONFIG, [$2], no)
137 if test x$[$1]_CONFIG = xno; then
142 if [$2] --plugin-libs [$3] &> /dev/null; then
143 [$1]_LIBS=`[$2] --plugin-libs [$3]`
145 [$1]_LIBS=`[$2] --libs [$3]`
147 [$1]_CFLAGS=`[$2] --cflags [$3]`
151 AC_SUBST([$1]_CFLAGS)
154 dnl Use AC_CHECK_LIB and AC_CHECK_HEADER to do both tests at once
155 dnl sets HAVE_module if we have it
156 dnl Richard Boulton <richard-alsa@tartarus.org>
157 dnl Last modification: 26/06/2001
158 dnl AG_GST_CHECK_LIBHEADER(FEATURE-NAME, LIB NAME, LIB FUNCTION, EXTRA LD FLAGS,
159 dnl HEADER NAME, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
161 dnl This check was written for GStreamer: it should be renamed and checked
162 dnl for portability if you decide to use it elsewhere.
164 AC_DEFUN([AG_GST_CHECK_LIBHEADER],
166 AC_CHECK_LIB([$2], [$3], HAVE_[$1]=yes, HAVE_[$1]=no,[$4])
167 if test "x$HAVE_[$1]" = "xyes"; then
168 AC_CHECK_HEADER([$5], :, HAVE_[$1]=no)
169 if test "x$HAVE_[$1]" = "xyes"; then
170 dnl execute what needs to be
171 ifelse([$6], , :, [$6])
173 ifelse([$7], , :, [$7])
176 ifelse([$7], , :, [$7])
182 dnl 2004-02-14 Thomas - changed to get set properly and use proper output
183 dnl 2003-06-27 Benjamin Otte - changed to make this work with gstconfig.h
185 dnl Add a subsystem --disable flag and all the necessary symbols and substitions
187 dnl AG_GST_CHECK_SUBSYSTEM_DISABLE(SYSNAME, [subsystem name])
189 AC_DEFUN([AG_GST_CHECK_SUBSYSTEM_DISABLE],
191 dnl this define will replace each literal subsys_def occurrence with
192 dnl the lowercase hyphen-separated subsystem
193 dnl e.g. if $1 is GST_DEBUG then subsys_def will be a macro with gst-debug
194 define([subsys_def],translit([$1], _A-Z, -a-z))
196 AC_ARG_ENABLE(subsys_def,
197 AC_HELP_STRING(--disable-subsys_def, [disable $2]),
199 case "${enableval}" in
200 yes) GST_DISABLE_[$1]=no ;;
201 no) GST_DISABLE_[$1]=yes ;;
202 *) AC_MSG_ERROR([bad value ${enableval} for --enable-subsys_def]) ;;
205 [GST_DISABLE_[$1]=no]) dnl Default value
207 if test x$GST_DISABLE_[$1] = xyes; then
208 AC_MSG_NOTICE([disabled subsystem [$2]])
209 GST_DISABLE_[$1]_DEFINE="#define GST_DISABLE_$1 1"
211 GST_DISABLE_[$1]_DEFINE="/* #undef GST_DISABLE_$1 */"
213 AC_SUBST(GST_DISABLE_[$1]_DEFINE)
214 undefine([subsys_def])
218 dnl Parse gstconfig.h for feature and defines add the symbols and substitions
220 dnl AG_GST_PARSE_SUBSYSTEM_DISABLE(GST_CONFIGPATH, FEATURE)
222 AC_DEFUN([AG_GST_PARSE_SUBSYSTEM_DISABLE],
224 grep >/dev/null "#undef GST_DISABLE_$2" $1
230 AC_SUBST(GST_DISABLE_[$2])
233 dnl Parse gstconfig.h and defines add the symbols and substitions
235 dnl GST_CONFIGPATH=`$PKG_CONFIG --variable=includedir gstreamer-0.10`"/gst/gstconfig.h"
236 dnl AG_GST_PARSE_SUBSYSTEM_DISABLES(GST_CONFIGPATH)
238 AC_DEFUN([AG_GST_PARSE_SUBSYSTEM_DISABLES],
240 AG_GST_PARSE_SUBSYSTEM_DISABLE($1,GST_DEBUG)
241 AG_GST_PARSE_SUBSYSTEM_DISABLE($1,LOADSAVE)
242 AG_GST_PARSE_SUBSYSTEM_DISABLE($1,PARSE)
243 AG_GST_PARSE_SUBSYSTEM_DISABLE($1,TRACE)
244 AG_GST_PARSE_SUBSYSTEM_DISABLE($1,ALLOC_TRACE)
245 AG_GST_PARSE_SUBSYSTEM_DISABLE($1,REGISTRY)
246 AG_GST_PARSE_SUBSYSTEM_DISABLE($1,ENUMTYPES)
247 AG_GST_PARSE_SUBSYSTEM_DISABLE($1,INDEX)
248 AG_GST_PARSE_SUBSYSTEM_DISABLE($1,PLUGIN)
249 AG_GST_PARSE_SUBSYSTEM_DISABLE($1,URI)
250 AG_GST_PARSE_SUBSYSTEM_DISABLE($1,XML)
255 dnl relies on GST_PLUGINS_ALL, GST_PLUGINS_SELECTED, GST_PLUGINS_YES,
256 dnl GST_PLUGINS_NO, and BUILD_EXTERNAL
257 AC_DEFUN([AG_GST_OUTPUT_PLUGINS], [
259 printf "configure: *** Plug-ins without external dependencies that will be built:\n"
260 ( for i in $GST_PLUGINS_SELECTED; do printf '\t'$i'\n'; done ) | sort
263 printf "configure: *** Plug-ins without external dependencies that will NOT be built:\n"
264 ( for i in $GST_PLUGINS_ALL; do
265 case $GST_PLUGINS_SELECTED in
275 if test "x$BUILD_EXTERNAL" = "xno"; then
276 printf "configure: *** No plug-ins with external dependencies will be built\n"
278 printf "configure: *** Plug-ins with dependencies that will be built:"
279 printf "$GST_PLUGINS_YES\n" | sort
281 printf "configure: *** Plug-ins with dependencies that will NOT be built:"
282 printf "$GST_PLUGINS_NO\n" | sort