Tizen 2.0 Release
[framework/multimedia/gst-plugins-good0.10.git] / common / m4 / gst-feature.m4
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
5 dnl
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)
9 dnl
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.
13 dnl
14 dnl The test should define HAVE_<FEATURE-NAME> to "yes" or "no" depending
15 dnl on whether the feature is available.
16 dnl
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.
21 dnl
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.
26 dnl
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
34 dnl                     available.
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
38 dnl                     used.
39 dnl ACTION-IF-NOTUSE    any extra actions to perform if the feature is not to
40 dnl                     be used.
41 dnl
42 dnl
43 dnl thomas :
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
48
49 AC_DEFUN([AG_GST_CHECK_FEATURE],
50 [echo
51 AC_MSG_NOTICE(*** checking feature: [$2] ***)
52 if test "x[$3]" != "x"
53 then
54   AC_MSG_NOTICE(*** for plug-ins: [$3] ***)
55 fi
56 dnl
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
59 NOUSE=
60 if test "x$USE_[$1]" = "xno"; then
61   NOUSE="yes"
62 fi
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
66       yes) USE_[$1]=yes;;
67       no) USE_[$1]=no;;
68       *) AC_MSG_ERROR(bad value ${enableval} for --enable-translit([$1], A-Z, a-z)) ;;
69     esac],
70   [ USE_$1=]ifelse($5, [disabled], [no], [yes]))           dnl DEFAULT
71
72 dnl *** set it back to no if it was preset to no
73 if test "x$NOUSE" = "xyes"; then
74   USE_[$1]="no"
75   AC_MSG_WARN(*** $3 pre-configured not to be built)
76 fi
77 NOUSE=
78
79 dnl *** If it's enabled
80
81 if test x$USE_[$1] = xyes; then
82   dnl save compile variables before the test
83
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
89
90   HAVE_[$1]=no
91   dnl TEST_FOR_FEATURE
92   $4
93
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
99
100   dnl If it isn't found, unset USE_[$1]
101   if test x$HAVE_[$1] = xno; then
102     USE_[$1]=no
103   else
104     ifelse([$3], , :, [AC_MSG_NOTICE(*** These plugins will be built: [$3])])
105   fi
106 fi
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"
112   fi
113   AC_DEFINE(HAVE_[$1], , [Define to enable $2]ifelse($3,,, [ (used by $3)]).)
114 else
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"
118   fi
119   ifelse([$7], , :, [$7])
120 fi
121 dnl *** Define the conditional as appropriate
122 AM_CONDITIONAL(USE_[$1], test x$USE_[$1] = xyes)
123 ])
124
125 dnl Use AC_CHECK_LIB and AC_CHECK_HEADER to do both tests at once
126 dnl sets HAVE_module if we have it
127 dnl Richard Boulton <richard-alsa@tartarus.org>
128 dnl Last modification: 26/06/2001
129 dnl AG_GST_CHECK_LIBHEADER(FEATURE-NAME, LIB NAME, LIB FUNCTION, EXTRA LD FLAGS,
130 dnl                     HEADER NAME, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
131 dnl
132 dnl This check was written for GStreamer: it should be renamed and checked
133 dnl for portability if you decide to use it elsewhere.
134 dnl
135 AC_DEFUN([AG_GST_CHECK_LIBHEADER],
136 [
137   AC_CHECK_LIB([$2], [$3], HAVE_[$1]=yes, HAVE_[$1]=no,[$4])
138   if test "x$HAVE_[$1]" = "xyes"; then
139     AC_CHECK_HEADER([$5], :, HAVE_[$1]=no)
140     if test "x$HAVE_[$1]" = "xyes"; then
141       dnl execute what needs to be
142       ifelse([$6], , :, [$6])
143     else
144       ifelse([$7], , :, [$7])
145     fi
146   else
147     ifelse([$7], , :, [$7])
148   fi
149   AC_SUBST(HAVE_[$1])
150 ]
151 )
152
153 dnl 2004-02-14 Thomas - changed to get set properly and use proper output
154 dnl 2003-06-27 Benjamin Otte - changed to make this work with gstconfig.h
155 dnl
156 dnl Add a subsystem --disable flag and all the necessary symbols and substitions
157 dnl
158 dnl AG_GST_CHECK_SUBSYSTEM_DISABLE(SYSNAME, [subsystem name])
159 dnl
160 AC_DEFUN([AG_GST_CHECK_SUBSYSTEM_DISABLE],
161 [
162   dnl this define will replace each literal subsys_def occurrence with
163   dnl the lowercase hyphen-separated subsystem
164   dnl e.g. if $1 is GST_DEBUG then subsys_def will be a macro with gst-debug
165   define([subsys_def],translit([$1], _A-Z, -a-z))
166
167   AC_ARG_ENABLE(subsys_def,
168     AC_HELP_STRING(--disable-subsys_def, [disable $2]),
169     [
170       case "${enableval}" in
171         yes) GST_DISABLE_[$1]=no ;;
172         no) GST_DISABLE_[$1]=yes ;;
173         *) AC_MSG_ERROR([bad value ${enableval} for --enable-subsys_def]) ;;
174        esac
175     ],
176     [GST_DISABLE_[$1]=no]) dnl Default value
177
178   if test x$GST_DISABLE_[$1] = xyes; then
179     AC_MSG_NOTICE([disabled subsystem [$2]])
180     GST_DISABLE_[$1]_DEFINE="#define GST_DISABLE_$1 1"
181   else
182     GST_DISABLE_[$1]_DEFINE="/* #undef GST_DISABLE_$1 */"
183   fi
184   AC_SUBST(GST_DISABLE_[$1]_DEFINE)
185   undefine([subsys_def])
186 ])
187
188
189 dnl Parse gstconfig.h for feature and defines add the symbols and substitions
190 dnl
191 dnl AG_GST_PARSE_SUBSYSTEM_DISABLE(GST_CONFIGPATH, FEATURE)
192 dnl
193 AC_DEFUN([AG_GST_PARSE_SUBSYSTEM_DISABLE],
194 [
195   grep >/dev/null "#undef GST_DISABLE_$2" $1
196   if test $? = 0; then
197     GST_DISABLE_[$2]=0
198   else
199     GST_DISABLE_[$2]=1
200   fi
201   AC_SUBST(GST_DISABLE_[$2])
202 ])
203
204 dnl Parse gstconfig.h and defines add the symbols and substitions
205 dnl
206 dnl GST_CONFIGPATH=`$PKG_CONFIG --variable=includedir gstreamer-0.10`"/gst/gstconfig.h"
207 dnl AG_GST_PARSE_SUBSYSTEM_DISABLES(GST_CONFIGPATH)
208 dnl
209 AC_DEFUN([AG_GST_PARSE_SUBSYSTEM_DISABLES],
210 [
211   AG_GST_PARSE_SUBSYSTEM_DISABLE($1,GST_DEBUG)
212   AG_GST_PARSE_SUBSYSTEM_DISABLE($1,LOADSAVE)
213   AG_GST_PARSE_SUBSYSTEM_DISABLE($1,PARSE)
214   AG_GST_PARSE_SUBSYSTEM_DISABLE($1,TRACE)
215   AG_GST_PARSE_SUBSYSTEM_DISABLE($1,ALLOC_TRACE)
216   AG_GST_PARSE_SUBSYSTEM_DISABLE($1,REGISTRY)
217   AG_GST_PARSE_SUBSYSTEM_DISABLE($1,PLUGIN)
218   AG_GST_PARSE_SUBSYSTEM_DISABLE($1,XML)
219 ])
220
221 dnl AG_GST_CHECK_GST_DEBUG_DISABLED(ACTION-IF-DISABLED, ACTION-IF-NOT-DISABLED)
222 dnl
223 dnl Checks if the GStreamer debugging system is disabled in the core version
224 dnl we are compiling against (by checking gstconfig.h)
225 dnl
226 AC_DEFUN([AG_GST_CHECK_GST_DEBUG_DISABLED],
227 [
228   AC_REQUIRE([AG_GST_CHECK_GST])
229
230   AC_MSG_CHECKING([whether the GStreamer debugging system is enabled])
231   AC_LANG_PUSH([C])
232   save_CFLAGS="$CFLAGS"
233   CFLAGS="$GST_CFLAGS $CFLAGS"
234   AC_COMPILE_IFELSE([
235       #include <gst/gstconfig.h>
236       #ifdef GST_DISABLE_GST_DEBUG
237       #error "debugging disabled, make compiler fail"
238       #endif], [ debug_system_enabled=yes], [debug_system_enabled=no])
239   CFLAGS="$save_CFLAGS"
240   AC_LANG_POP([C])
241
242   AC_MSG_RESULT([$debug_system_enabled])
243
244   if test "x$debug_system_enabled" = "xyes" ; then
245     $2
246     true
247   else
248     $1
249     true
250   fi
251 ])
252
253 dnl relies on GST_PLUGINS_ALL, GST_PLUGINS_SELECTED, GST_PLUGINS_YES,
254 dnl GST_PLUGINS_NO, and BUILD_EXTERNAL
255 AC_DEFUN([AG_GST_OUTPUT_PLUGINS], [
256
257 printf "configure: *** Plug-ins without external dependencies that will be built:\n"
258 ( for i in $GST_PLUGINS_SELECTED; do printf '\t'$i'\n'; done ) | sort
259 printf "\n"
260
261 printf "configure: *** Plug-ins without external dependencies that will NOT be built:\n"
262 ( for i in $GST_PLUGINS_ALL; do
263     case " $GST_PLUGINS_SELECTED " in
264       *\ $i\ *)
265         ;;
266       *)
267         printf '\t'$i'\n'
268         ;;
269     esac
270   done ) | sort
271 printf "\n"
272
273 if test "x$BUILD_EXTERNAL" = "xno"; then
274   printf "configure: *** No plug-ins with external dependencies will be built\n"
275 else
276   printf "configure: *** Plug-ins with dependencies that will be built:"
277   printf "$GST_PLUGINS_YES\n" | sort
278   printf "\n"
279   printf "configure: *** Plug-ins with dependencies that will NOT be built:"
280   printf "$GST_PLUGINS_NO\n" | sort
281   printf "\n"
282 fi
283 ])
284