Initial release including wifi display based on gst-rtsp-server-1.4.1
[platform/upstream/gstreamer.git] / common / m4 / gst-args.m4
1 dnl configure-time options shared among gstreamer modules
2
3 dnl AG_GST_ARG_DEBUG
4 dnl AG_GST_ARG_PROFILING
5 dnl AG_GST_ARG_VALGRIND
6 dnl AG_GST_ARG_GCOV
7
8 dnl AG_GST_ARG_EXAMPLES
9
10 dnl AG_GST_ARG_WITH_PKG_CONFIG_PATH
11 dnl AG_GST_ARG_WITH_PACKAGE_NAME
12 dnl AG_GST_ARG_WITH_PACKAGE_ORIGIN
13
14 dnl AG_GST_ARG_WITH_PLUGINS
15 dnl AG_GST_CHECK_PLUGIN
16 dnl AG_GST_DISABLE_PLUGIN
17
18 dnl AG_GST_ARG_ENABLE_EXTERNAL
19 dnl AG_GST_ARG_ENABLE_EXPERIMENTAL
20 dnl AG_GST_ARG_ENABLE_BROKEN
21
22 dnl AG_GST_ARG_DISABLE_FATAL_WARNINGS
23 AC_DEFUN([AG_GST_ARG_DEBUG],
24 [
25   dnl debugging stuff
26   AC_ARG_ENABLE(debug,
27     AC_HELP_STRING([--disable-debug],[disable addition of -g debugging info]),
28     [
29       case "${enableval}" in
30         yes) USE_DEBUG=yes ;;
31         no)  USE_DEBUG=no ;;
32         *)   AC_MSG_ERROR(bad value ${enableval} for --enable-debug) ;;
33       esac
34     ],
35     [USE_DEBUG=yes]) dnl Default value
36 ])
37
38 AC_DEFUN([AG_GST_ARG_PROFILING],
39 [
40   AC_ARG_ENABLE(profiling,
41     AC_HELP_STRING([--enable-profiling],
42       [adds -pg to compiler commandline, for profiling]),
43     [
44       case "${enableval}" in
45         yes) USE_PROFILING=yes ;;
46         no)  USE_PROFILING=no ;;
47         *)   AC_MSG_ERROR(bad value ${enableval} for --enable-profiling) ;;
48       esac
49     ],
50     [USE_PROFILING=no]) dnl Default value
51 ])
52
53 AC_DEFUN([AG_GST_ARG_VALGRIND],
54 [
55   dnl valgrind inclusion
56   AC_ARG_ENABLE(valgrind,
57     AC_HELP_STRING([--disable-valgrind],[disable run-time valgrind detection]),
58     [
59       case "${enableval}" in
60         yes) USE_VALGRIND="$USE_DEBUG" ;;
61         no)  USE_VALGRIND=no ;;
62         *)   AC_MSG_ERROR(bad value ${enableval} for --enable-valgrind) ;;
63       esac
64     ],
65     [USE_VALGRIND="$USE_DEBUG"]) dnl Default value
66   VALGRIND_REQ="3.0"
67   if test "x$USE_VALGRIND" = xyes; then
68     PKG_CHECK_MODULES(VALGRIND, valgrind >= $VALGRIND_REQ,
69       USE_VALGRIND="yes",
70       USE_VALGRIND="no")
71   fi
72   if test "x$USE_VALGRIND" = xyes; then
73     AC_DEFINE(HAVE_VALGRIND, 1, [Define if valgrind should be used])
74     AC_MSG_NOTICE(Using extra code paths for valgrind)
75   fi
76 ])
77
78 AC_DEFUN([AG_GST_ARG_GCOV],
79 [
80   AC_ARG_ENABLE(gcov,
81     AC_HELP_STRING([--enable-gcov],
82       [compile with coverage profiling instrumentation (gcc only)]),
83     enable_gcov=$enableval,
84     enable_gcov=no)
85   if test x$enable_gcov = xyes ; then
86     if test "x$GCC" != "xyes"
87     then
88       AC_MSG_ERROR([gcov only works if gcc is used])
89     fi
90
91     AS_COMPILER_FLAG(["-fprofile-arcs"],
92       [GCOV_CFLAGS="$GCOV_CFLAGS -fprofile-arcs"],
93       true)
94     AS_COMPILER_FLAG(["-ftest-coverage"],
95       [GCOV_CFLAGS="$GCOV_CFLAGS -ftest-coverage"],
96       true)
97     dnl remove any -O flags - FIXME: is this needed ?
98     GCOV_CFLAGS=`echo "$GCOV_CFLAGS" | sed -e 's/-O[[0-9]]*//g'`
99     dnl libtool 1.5.22 and lower strip -fprofile-arcs from the flags
100     dnl passed to the linker, which is a bug; -fprofile-arcs implicitly
101     dnl links in -lgcov, so we do it explicitly here for the same effect
102     GCOV_LIBS=-lgcov
103     AC_SUBST(GCOV_CFLAGS)
104     AC_SUBST(GCOV_LIBS)
105     GCOV=`echo $CC | sed s/gcc/gcov/g`
106     AC_SUBST(GCOV)
107
108     GST_GCOV_ENABLED=yes
109     AC_DEFINE_UNQUOTED(GST_GCOV_ENABLED, 1,
110       [Defined if gcov is enabled to force a rebuild due to config.h changing])
111     dnl if gcov is used, we do not want default -O2 CFLAGS
112     if test "x$GST_GCOV_ENABLED" = "xyes"
113     then
114       CFLAGS="$CFLAGS -O0"
115       AC_SUBST(CFLAGS)
116       CXXFLAGS="$CXXFLAGS -O0"
117       AC_SUBST(CXXFLAGS)
118       FFLAGS="$FFLAGS -O0"
119       AC_SUBST(FFLAGS)
120       CCASFLAGS="$CCASFLAGS -O0"
121       AC_SUBST(CCASFLAGS)
122       AC_MSG_NOTICE([gcov enabled, setting CFLAGS and friends to $CFLAGS])
123     fi
124   fi
125   AM_CONDITIONAL(GST_GCOV_ENABLED, test x$enable_gcov = xyes)
126 ])
127
128 AC_DEFUN([AG_GST_ARG_EXAMPLES],
129 [
130   AC_ARG_ENABLE(examples,
131     AC_HELP_STRING([--disable-examples], [disable building examples]),
132       [
133         case "${enableval}" in
134           yes) BUILD_EXAMPLES=yes ;;
135           no)  BUILD_EXAMPLES=no ;;
136           *)   AC_MSG_ERROR(bad value ${enableval} for --disable-examples) ;;
137         esac
138       ],
139       [BUILD_EXAMPLES=yes]) dnl Default value
140   AM_CONDITIONAL(BUILD_EXAMPLES,      test "x$BUILD_EXAMPLES" = "xyes")
141 ])
142
143 AC_DEFUN([AG_GST_ARG_WITH_PKG_CONFIG_PATH],
144 [
145   dnl possibly modify pkg-config path
146   AC_ARG_WITH(pkg-config-path,
147      AC_HELP_STRING([--with-pkg-config-path],
148                     [colon-separated list of pkg-config(1) dirs]),
149      [
150        export PKG_CONFIG_PATH=${withval}
151        AC_MSG_NOTICE(Set PKG_CONFIG_PATH to $PKG_CONFIG_PATH)
152      ])
153 ])
154
155
156 dnl This macro requires that GST_GIT or GST_CVS is set to yes or no (release)
157 AC_DEFUN([AG_GST_ARG_WITH_PACKAGE_NAME],
158 [
159   dnl package name in plugins
160   AC_ARG_WITH(package-name,
161     AC_HELP_STRING([--with-package-name],
162       [specify package name to use in plugins]),
163     [
164       case "${withval}" in
165         yes) AC_MSG_ERROR(bad value ${withval} for --with-package-name) ;;
166         no)  AC_MSG_ERROR(bad value ${withval} for --with-package-name) ;;
167         *)   GST_PACKAGE_NAME="${withval}" ;;
168       esac
169     ],
170     [
171       P=$1
172       if test "x$P" = "x"
173       then
174         P=$PACKAGE_NAME
175       fi
176
177       if test "x$PACKAGE_VERSION_NANO" = "x0"
178       then
179         GST_PACKAGE_NAME="$P source release"
180       else
181         if test "x$PACKAGE_VERSION_NANO" = "x1"
182         then
183           GST_PACKAGE_NAME="$P git"
184         else
185           GST_PACKAGE_NAME="$P prerelease"
186         fi
187       fi
188     ]
189   )
190   AC_MSG_NOTICE(Using $GST_PACKAGE_NAME as package name)
191   AC_DEFINE_UNQUOTED(GST_PACKAGE_NAME, "$GST_PACKAGE_NAME",
192       [package name in plugins])
193   AC_SUBST(GST_PACKAGE_NAME)
194 ])
195
196 AC_DEFUN([AG_GST_ARG_WITH_PACKAGE_ORIGIN],
197 [
198   dnl package origin URL
199   AC_ARG_WITH(package-origin,
200     AC_HELP_STRING([--with-package-origin],
201       [specify package origin URL to use in plugins]),
202     [
203       case "${withval}" in
204         yes) AC_MSG_ERROR(bad value ${withval} for --with-package-origin) ;;
205         no)  AC_MSG_ERROR(bad value ${withval} for --with-package-origin) ;;
206         *)   GST_PACKAGE_ORIGIN="${withval}" ;;
207       esac
208     ],
209     [GST_PACKAGE_ORIGIN="[Unknown package origin]"] dnl Default value
210   )
211   AC_MSG_NOTICE(Using $GST_PACKAGE_ORIGIN as package origin)
212   AC_DEFINE_UNQUOTED(GST_PACKAGE_ORIGIN, "$GST_PACKAGE_ORIGIN",
213       [package origin])
214   AC_SUBST(GST_PACKAGE_ORIGIN)
215 ])
216
217 dnl sets WITH_PLUGINS to the list of plug-ins given as an argument
218 dnl also clears GST_PLUGINS_ALL and GST_PLUGINS_SELECTED
219 AC_DEFUN([AG_GST_ARG_WITH_PLUGINS],
220 [
221   AC_ARG_WITH(plugins,
222     AC_HELP_STRING([--with-plugins],
223       [comma-separated list of dependencyless plug-ins to compile]),
224     [WITH_PLUGINS=$withval],
225     [WITH_PLUGINS=])
226
227   GST_PLUGINS_ALL=""
228   GST_PLUGINS_SELECTED=""
229   GST_PLUGINS_NONPORTED=""
230
231   AC_SUBST(GST_PLUGINS_ALL)
232   AC_SUBST(GST_PLUGINS_SELECTED)
233   AC_SUBST(GST_PLUGINS_NONPORTED)
234 ])
235
236 dnl AG_GST_CHECK_PLUGIN(PLUGIN-NAME)
237 dnl
238 dnl This macro adds the plug-in <PLUGIN-NAME> to GST_PLUGINS_ALL. Then it
239 dnl checks if WITH_PLUGINS is empty or the plugin is present in WITH_PLUGINS,
240 dnl and if so adds it to GST_PLUGINS_SELECTED. Then it checks if the plugin
241 dnl is present in WITHOUT_PLUGINS (ie. was disabled specifically) and if so
242 dnl removes it from GST_PLUGINS_SELECTED.
243 dnl
244 dnl The macro will call AM_CONDITIONAL(USE_PLUGIN_<PLUGIN-NAME>, ...) to allow
245 dnl control of what is built in Makefile.ams.
246 AC_DEFUN([AG_GST_CHECK_PLUGIN],
247 [
248   GST_PLUGINS_ALL="$GST_PLUGINS_ALL [$1]"
249
250   define([pname_def],translit([$1], -a-z, _a-z))
251
252   AC_ARG_ENABLE([$1],
253     AC_HELP_STRING([--disable-[$1]], [disable dependency-less $1 plugin]),
254     [
255       case "${enableval}" in
256         yes) [gst_use_]pname_def=yes ;;
257         no) [gst_use_]pname_def=no ;;
258         *) AC_MSG_ERROR([bad value ${enableval} for --enable-$1]) ;;
259        esac
260     ],
261     [[gst_use_]pname_def=yes]) dnl Default value
262
263   if test x$[gst_use_]pname_def = xno; then
264     AC_MSG_NOTICE(disabling dependency-less plugin $1)
265     WITHOUT_PLUGINS="$WITHOUT_PLUGINS [$1]"
266   fi
267   undefine([pname_def])
268
269   dnl First check inclusion
270   if [[ -z "$WITH_PLUGINS" ]] || echo " [$WITH_PLUGINS] " | tr , ' ' | grep -i " [$1] " > /dev/null; then
271     GST_PLUGINS_SELECTED="$GST_PLUGINS_SELECTED [$1]"
272   fi
273   dnl Then check exclusion
274   if echo " [$WITHOUT_PLUGINS] " | tr , ' ' | grep -i " [$1] " > /dev/null; then
275     GST_PLUGINS_SELECTED=`echo " $GST_PLUGINS_SELECTED " | $SED -e 's/ [$1] / /'`
276   fi
277   dnl Finally check if the plugin is ported or not
278   if echo " [$GST_PLUGINS_NONPORTED] " | tr , ' ' | grep -i " [$1] " > /dev/null; then
279     GST_PLUGINS_SELECTED=`echo " $GST_PLUGINS_SELECTED " | $SED -e 's/ [$1] / /'`
280   fi
281   AM_CONDITIONAL([USE_PLUGIN_]translit([$1], a-z, A-Z), echo " $GST_PLUGINS_SELECTED " | grep -i " [$1] " > /dev/null)
282 ])
283
284 dnl AG_GST_DISABLE_PLUGIN(PLUGIN-NAME)
285 dnl
286 dnl This macro disables the plug-in <PLUGIN-NAME> by removing it from
287 dnl GST_PLUGINS_SELECTED.
288 AC_DEFUN([AG_GST_DISABLE_PLUGIN],
289 [
290   GST_PLUGINS_SELECTED=`echo " $GST_PLUGINS_SELECTED " | $SED -e 's/ [$1] / /'`
291   AM_CONDITIONAL([USE_PLUGIN_]translit([$1], a-z, A-Z), false)
292 ])
293
294 AC_DEFUN([AG_GST_ARG_ENABLE_EXTERNAL],
295 [
296   AG_GST_CHECK_FEATURE(EXTERNAL, [building of plug-ins with external deps],,
297     HAVE_EXTERNAL=yes, enabled,
298     [
299       AC_MSG_NOTICE(building external plug-ins)
300       BUILD_EXTERNAL="yes"
301     ],[
302       AC_MSG_WARN(all plug-ins with external dependencies will not be built)
303       BUILD_EXTERNAL="no"
304     ])
305   # make BUILD_EXTERNAL available to Makefile.am
306   AM_CONDITIONAL(BUILD_EXTERNAL, test "x$BUILD_EXTERNAL" = "xyes")
307 ])
308
309 dnl experimental plug-ins; stuff that hasn't had the dust settle yet
310 dnl read 'builds, but might not work'
311 AC_DEFUN([AG_GST_ARG_ENABLE_EXPERIMENTAL],
312 [
313   AG_GST_CHECK_FEATURE(EXPERIMENTAL, [building of experimental plug-ins],,
314     HAVE_EXPERIMENTAL=yes, disabled,
315     [
316       AC_MSG_WARN(building experimental plug-ins)
317       BUILD_EXPERIMENTAL="yes"
318     ],[
319       AC_MSG_NOTICE(not building experimental plug-ins)
320       BUILD_EXPERIMENTAL="no"
321     ])
322   # make BUILD_EXPERIMENTAL available to Makefile.am
323   AM_CONDITIONAL(BUILD_EXPERIMENTAL, test "x$BUILD_EXPERIMENTAL" = "xyes")
324 ])
325
326 dnl broken plug-ins; stuff that doesn't seem to build at the moment
327 AC_DEFUN([AG_GST_ARG_ENABLE_BROKEN],
328 [
329   AG_GST_CHECK_FEATURE(BROKEN, [building of broken plug-ins],,
330     HAVE_BROKEN=yes, disabled,
331     [
332       AC_MSG_WARN([building broken plug-ins -- no bug reports on these, only patches ...])
333     ],[
334       AC_MSG_NOTICE([not building broken plug-ins])
335     ])
336 ])
337
338 dnl allow people (or build tools) to override default behaviour
339 dnl for fatal compiler warnings
340 dnl Enable fatal warnings by default only for development versions
341 AC_DEFUN([AG_GST_ARG_DISABLE_FATAL_WARNINGS],
342 [
343   AC_ARG_ENABLE(fatal-warnings,
344     AC_HELP_STRING([--disable-fatal-warnings],
345                    [Don't turn compiler warnings into fatal errors]),
346     [
347       case "${enableval}" in
348         yes) FATAL_WARNINGS=yes ;;
349         no)  FATAL_WARNINGS=no ;;
350         *)   AC_MSG_ERROR(bad value ${enableval} for --disable-fatal-warnings) ;;
351       esac
352     ],
353     [
354       if test "x`expr $PACKAGE_VERSION_MINOR % 2`" = "x1" -a "x`expr $PACKAGE_VERSION_MICRO '<' 90`" = "x1"; then
355         FATAL_WARNINGS=yes
356       else
357         FATAL_WARNINGS=no
358       fi
359     ])
360 ])