Initial release including wifi display based on gst-rtsp-server-1.4.1
[platform/upstream/gstreamer.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 *** Check if it is ported or not
80 if echo " [$GST_PLUGINS_NONPORTED] " | tr , ' ' | grep -i " [$1] " > /dev/null; then
81   USE_[$1]="no"
82   AC_MSG_WARN(*** $3 not ported)
83 fi
84
85 dnl *** If it's enabled
86
87 if test x$USE_[$1] = xyes; then
88   dnl save compile variables before the test
89
90   gst_check_save_LIBS=$LIBS
91   gst_check_save_LDFLAGS=$LDFLAGS
92   gst_check_save_CFLAGS=$CFLAGS
93   gst_check_save_CPPFLAGS=$CPPFLAGS
94   gst_check_save_CXXFLAGS=$CXXFLAGS
95
96   HAVE_[$1]=no
97   dnl TEST_FOR_FEATURE
98   $4
99
100   LIBS=$gst_check_save_LIBS
101   LDFLAGS=$gst_check_save_LDFLAGS
102   CFLAGS=$gst_check_save_CFLAGS
103   CPPFLAGS=$gst_check_save_CPPFLAGS
104   CXXFLAGS=$gst_check_save_CXXFLAGS
105
106   dnl If it isn't found, unset USE_[$1]
107   if test x$HAVE_[$1] = xno; then
108     USE_[$1]=no
109   else
110     ifelse([$3], , :, [AC_MSG_NOTICE(*** These plugins will be built: [$3])])
111   fi
112 fi
113 dnl *** Warn if it's disabled or not found
114 if test x$USE_[$1] = xyes; then
115   ifelse([$6], , :, [$6])
116   if test "x$3" != "x"; then
117     GST_PLUGINS_YES="\t[$3]\n$GST_PLUGINS_YES"
118   fi
119   AC_DEFINE(HAVE_[$1], , [Define to enable $2]ifelse($3,,, [ (used by $3)]).)
120 else
121   ifelse([$3], , :, [AC_MSG_NOTICE(*** These plugins will not be built: [$3])])
122   if test "x$3" != "x"; then
123     GST_PLUGINS_NO="\t[$3]\n$GST_PLUGINS_NO"
124   fi
125   ifelse([$7], , :, [$7])
126 fi
127 dnl *** Define the conditional as appropriate
128 AM_CONDITIONAL(USE_[$1], test x$USE_[$1] = xyes)
129 ])
130
131 dnl Use AC_CHECK_LIB and AC_CHECK_HEADER to do both tests at once
132 dnl sets HAVE_module if we have it
133 dnl Richard Boulton <richard-alsa@tartarus.org>
134 dnl Last modification: 26/06/2001
135 dnl AG_GST_CHECK_LIBHEADER(FEATURE-NAME, LIB NAME, LIB FUNCTION, EXTRA LD FLAGS,
136 dnl                     HEADER NAME, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
137 dnl
138 dnl This check was written for GStreamer: it should be renamed and checked
139 dnl for portability if you decide to use it elsewhere.
140 dnl
141 AC_DEFUN([AG_GST_CHECK_LIBHEADER],
142 [
143   AC_CHECK_LIB([$2], [$3], HAVE_[$1]=yes, HAVE_[$1]=no,[$4])
144   if test "x$HAVE_[$1]" = "xyes"; then
145     AC_CHECK_HEADER([$5], :, HAVE_[$1]=no)
146     if test "x$HAVE_[$1]" = "xyes"; then
147       dnl execute what needs to be
148       ifelse([$6], , :, [$6])
149     else
150       ifelse([$7], , :, [$7])
151     fi
152   else
153     ifelse([$7], , :, [$7])
154   fi
155   AC_SUBST(HAVE_[$1])
156 ]
157 )
158
159 dnl 2004-02-14 Thomas - changed to get set properly and use proper output
160 dnl 2003-06-27 Benjamin Otte - changed to make this work with gstconfig.h
161 dnl
162 dnl Add a subsystem --disable flag and all the necessary symbols and substitions
163 dnl
164 dnl AG_GST_CHECK_SUBSYSTEM_DISABLE(SYSNAME, [subsystem name])
165 dnl
166 AC_DEFUN([AG_GST_CHECK_SUBSYSTEM_DISABLE],
167 [
168   dnl this define will replace each literal subsys_def occurrence with
169   dnl the lowercase hyphen-separated subsystem
170   dnl e.g. if $1 is GST_DEBUG then subsys_def will be a macro with gst-debug
171   define([subsys_def],translit([$1], _A-Z, -a-z))
172
173   AC_ARG_ENABLE(subsys_def,
174     AC_HELP_STRING(--disable-subsys_def, [disable $2]),
175     [
176       case "${enableval}" in
177         yes) GST_DISABLE_[$1]=no ;;
178         no) GST_DISABLE_[$1]=yes ;;
179         *) AC_MSG_ERROR([bad value ${enableval} for --enable-subsys_def]) ;;
180        esac
181     ],
182     [GST_DISABLE_[$1]=no]) dnl Default value
183
184   if test x$GST_DISABLE_[$1] = xyes; then
185     AC_MSG_NOTICE([disabled subsystem [$2]])
186     GST_DISABLE_[$1]_DEFINE="#define GST_DISABLE_$1 1"
187   else
188     GST_DISABLE_[$1]_DEFINE="/* #undef GST_DISABLE_$1 */"
189   fi
190   AC_SUBST(GST_DISABLE_[$1]_DEFINE)
191   undefine([subsys_def])
192 ])
193
194
195 dnl Parse gstconfig.h for feature and defines add the symbols and substitions
196 dnl
197 dnl AG_GST_PARSE_SUBSYSTEM_DISABLE(GST_CONFIGPATH, FEATURE)
198 dnl
199 AC_DEFUN([AG_GST_PARSE_SUBSYSTEM_DISABLE],
200 [
201   grep >/dev/null "#undef GST_DISABLE_$2" $1
202   if test $? = 0; then
203     GST_DISABLE_[$2]=0
204   else
205     GST_DISABLE_[$2]=1
206   fi
207   AC_SUBST(GST_DISABLE_[$2])
208 ])
209
210 dnl Parse gstconfig.h and defines add the symbols and substitions
211 dnl
212 dnl GST_CONFIGPATH=`$PKG_CONFIG --variable=includedir gstreamer-1.0`"/gst/gstconfig.h"
213 dnl AG_GST_PARSE_SUBSYSTEM_DISABLES(GST_CONFIGPATH)
214 dnl
215 AC_DEFUN([AG_GST_PARSE_SUBSYSTEM_DISABLES],
216 [
217   AG_GST_PARSE_SUBSYSTEM_DISABLE($1,GST_DEBUG)
218   AG_GST_PARSE_SUBSYSTEM_DISABLE($1,LOADSAVE)
219   AG_GST_PARSE_SUBSYSTEM_DISABLE($1,PARSE)
220   AG_GST_PARSE_SUBSYSTEM_DISABLE($1,TRACE)
221   AG_GST_PARSE_SUBSYSTEM_DISABLE($1,ALLOC_TRACE)
222   AG_GST_PARSE_SUBSYSTEM_DISABLE($1,REGISTRY)
223   AG_GST_PARSE_SUBSYSTEM_DISABLE($1,PLUGIN)
224   AG_GST_PARSE_SUBSYSTEM_DISABLE($1,XML)
225 ])
226
227 dnl AG_GST_CHECK_GST_DEBUG_DISABLED(ACTION-IF-DISABLED, ACTION-IF-NOT-DISABLED)
228 dnl
229 dnl Checks if the GStreamer debugging system is disabled in the core version
230 dnl we are compiling against (by checking gstconfig.h)
231 dnl
232 AC_DEFUN([AG_GST_CHECK_GST_DEBUG_DISABLED],
233 [
234   AC_REQUIRE([AG_GST_CHECK_GST])
235
236   AC_MSG_CHECKING([whether the GStreamer debugging system is enabled])
237   AC_LANG_PUSH([C])
238   save_CFLAGS="$CFLAGS"
239   CFLAGS="$GST_CFLAGS $CFLAGS"
240   AC_COMPILE_IFELSE([
241     AC_LANG_SOURCE([[
242       #include <gst/gstconfig.h>
243       #ifdef GST_DISABLE_GST_DEBUG
244       #error "debugging disabled, make compiler fail"
245       #endif]])], [ debug_system_enabled=yes], [debug_system_enabled=no])
246   CFLAGS="$save_CFLAGS"
247   AC_LANG_POP([C])
248
249   AC_MSG_RESULT([$debug_system_enabled])
250
251   if test "x$debug_system_enabled" = "xyes" ; then
252     $2
253     true
254   else
255     $1
256     true
257   fi
258 ])
259
260 dnl relies on GST_PLUGINS_ALL, GST_PLUGINS_SELECTED, GST_PLUGINS_YES,
261 dnl GST_PLUGINS_NO, and BUILD_EXTERNAL
262 AC_DEFUN([AG_GST_OUTPUT_PLUGINS], [
263
264 printf "configure: *** Plug-ins without external dependencies that will be built:\n"
265 ( for i in $GST_PLUGINS_SELECTED; do printf '\t'$i'\n'; done ) | sort
266 printf "\n"
267
268 printf "configure: *** Plug-ins without external dependencies that will NOT be built:\n"
269 ( for i in $GST_PLUGINS_ALL; do
270     case " $GST_PLUGINS_SELECTED " in
271       *\ $i\ *)
272         ;;
273       *)
274         printf '\t'$i'\n'
275         ;;
276     esac
277   done ) | sort
278 printf "\n"
279
280 printf "configure: *** Plug-ins that have NOT been ported:\n"
281 ( for i in $GST_PLUGINS_NONPORTED; do
282         printf '\t'$i'\n'
283   done ) | sort
284 printf "\n"
285
286 if test "x$BUILD_EXTERNAL" = "xno"; then
287   printf "configure: *** No plug-ins with external dependencies will be built\n"
288 else
289   printf "configure: *** Plug-ins with dependencies that will be built:"
290   printf "$GST_PLUGINS_YES\n" | sort
291   printf "\n"
292   printf "configure: *** Plug-ins with dependencies that will NOT be built:"
293   printf "$GST_PLUGINS_NO\n" | sort
294   printf "\n"
295 fi
296 ])
297