f7b075e6db3587738306f15783b974110be1177d
[platform/upstream/gst-common.git] / m4 / gst-args.m4
1 dnl configure-time options shared among gstreamer modules
2
3 dnl GST_ARG_DEBUG
4 dnl GST_ARG_PROFILING
5 dnl GST_ARG_VALGRIND
6 dnl GST_ARG_GCOV
7
8 dnl GST_ARG_EXAMPLES
9
10 dnl GST_ARG_WITH_PKG_CONFIG_PATH
11 dnl GST_ARG_PACKAGE_NAME
12 dnl GST_ARG_PACKAGE_ORIGIN
13
14 dnl GST_ARG_WITH_PLUGINS
15
16 dnl GST_ARG_ENABLE_EXTERNAL
17 dnl GST_ARG_ENABLE_EXPERIMENTAL
18 dnl GST_ARG_ENABLE_BROKEN
19
20 AC_DEFUN([GST_ARG_DEBUG],
21 [
22   dnl debugging stuff
23   AC_ARG_ENABLE(debug,
24     AC_HELP_STRING([--disable-debug],[disable addition of -g debugging info]),
25     [
26       case "${enableval}" in
27         yes) USE_DEBUG=yes ;;
28         no)  USE_DEBUG=no ;;
29         *)   AC_MSG_ERROR(bad value ${enableval} for --enable-debug) ;;
30       esac
31     ],
32     [USE_DEBUG=yes]) dnl Default value
33 ])
34
35 AC_DEFUN([GST_ARG_PROFILING],
36 [
37   AC_ARG_ENABLE(profiling,
38     AC_HELP_STRING([--enable-profiling],
39       [adds -pg to compiler commandline, for profiling]),
40     [
41       case "${enableval}" in
42         yes) USE_PROFILING=yes ;;
43         no)  USE_PROFILING=no ;;
44         *)   AC_MSG_ERROR(bad value ${enableval} for --enable-profiling) ;;
45       esac
46     ], 
47     [USE_PROFILING=no]) dnl Default value
48 ])
49
50 AC_DEFUN([GST_ARG_VALGRIND],
51 [
52   dnl valgrind inclusion
53   AC_ARG_ENABLE(valgrind,
54     AC_HELP_STRING([--disable-valgrind],[disable run-time valgrind detection]),
55     [
56       case "${enableval}" in
57         yes) USE_VALGRIND="$USE_DEBUG" ;;
58         no)  USE_VALGRIND=no ;;
59         *)   AC_MSG_ERROR(bad value ${enableval} for --enable-valgrind) ;;
60       esac
61     ],
62     [USE_VALGRIND="$USE_DEBUG"]) dnl Default value
63   VALGRIND_REQ="2.1"
64   if test "x$USE_VALGRIND" = xyes; then
65     PKG_CHECK_MODULES(VALGRIND, valgrind > $VALGRIND_REQ,
66       USE_VALGRIND="yes",
67       [
68         USE_VALGRIND="no"
69         AC_MSG_RESULT([no])
70       ])
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([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="-O0"
115       AC_SUBST(CFLAGS)
116       CXXFLAGS="-O0"
117       AC_SUBST(CXXFLAGS)
118       FFLAGS="-O0"
119       AC_SUBST(FFLAGS)
120       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([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([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 AC_DEFUN([GST_ARG_WITH_PACKAGE_NAME],
157 [
158   dnl package name in plugins
159   AC_ARG_WITH(package-name,
160     AC_HELP_STRING([--with-package-name],
161       [specify package name to use in plugins]),
162     [
163       case "${withval}" in
164         yes) AC_MSG_ERROR(bad value ${withval} for --with-package-name) ;;
165         no)  AC_MSG_ERROR(bad value ${withval} for --with-package-name) ;;
166         *)   GST_PACKAGE_NAME="${withval}" ;;
167       esac
168     ], 
169     [
170       P=$1
171       if test "x$P" = "x"
172       then
173         P=$PACKAGE_NAME
174       fi
175       
176       dnl default value
177       if test "x$GST_CVS" = "xyes"
178       then
179         dnl nano >= 1
180         GST_PACKAGE_NAME="$P CVS/prerelease"
181       else
182         GST_PACKAGE_NAME="$P source release"
183       fi
184     ]
185   )
186   AC_MSG_NOTICE(Using $GST_PACKAGE_NAME as package name)
187   AC_DEFINE_UNQUOTED(GST_PACKAGE_NAME, "$GST_PACKAGE_NAME",
188       [package name in plugins])
189   AC_SUBST(GST_PACKAGE_NAME)
190 ])
191
192 AC_DEFUN([GST_ARG_WITH_PACKAGE_ORIGIN],
193 [
194   dnl package origin URL
195   AC_ARG_WITH(package-origin,
196     AC_HELP_STRING([--with-package-origin],
197       [specify package origin URL to use in plugins]),
198     [
199       case "${withval}" in
200         yes) AC_MSG_ERROR(bad value ${withval} for --with-package-origin) ;;
201         no)  AC_MSG_ERROR(bad value ${withval} for --with-package-origin) ;;
202         *)   GST_PACKAGE_ORIGIN="${withval}" ;;
203       esac
204     ], 
205     [GST_PACKAGE_ORIGIN="[Unknown package origin]"] dnl Default value
206   )
207   AC_MSG_NOTICE(Using $GST_PACKAGE_ORIGIN as package origin)
208   AC_DEFINE_UNQUOTED(GST_PACKAGE_ORIGIN, "$GST_PACKAGE_ORIGIN",
209       [package origin])
210   AC_SUBST(GST_PACKAGE_ORIGIN)
211 ])
212
213 dnl sets GST_PLUGINS_SELECTED to the list given as an argument, or to
214 dnl GST_PLUGINS_ALL
215 AC_DEFUN([GST_ARG_WITH_PLUGINS],
216 [
217   AC_ARG_WITH(plugins,
218     AC_HELP_STRING([--with-plugins],
219       [comma-separated list of dependencyless plug-ins to compile]),
220     [
221       for i in `echo $withval | tr , ' '`; do
222         if echo $GST_PLUGINS_ALL | grep $i > /dev/null
223         then
224             GST_PLUGINS_SELECTED="$GST_PLUGINS_SELECTED $i"
225         else
226             echo "plug-in $i not recognized, ignoring..."
227         fi
228     done],
229     [GST_PLUGINS_SELECTED=$GST_PLUGINS_ALL])
230 ])
231
232 AC_DEFUN([GST_ARG_ENABLE_EXTERNAL],
233 [
234   GST_CHECK_FEATURE(EXTERNAL, [enable building of plug-ins with external deps],,
235     HAVE_EXTERNAL=yes, enabled,
236     [
237       AC_MSG_NOTICE(building external plug-ins)
238       BUILD_EXTERNAL="yes"
239     ],[
240       AC_MSG_WARN(all plug-ins with external dependencies will not be built)
241       BUILD_EXTERNAL="no"
242     ])
243   # make BUILD_EXTERNAL available to Makefile.am
244   AM_CONDITIONAL(BUILD_EXTERNAL, test "x$BUILD_EXTERNAL" = "xyes")
245 ])
246
247 dnl experimental plug-ins; stuff that hasn't had the dust settle yet
248 dnl read 'builds, but might not work'
249 AC_DEFUN([GST_ARG_ENABLE_EXPERIMENTAL],
250 [
251   GST_CHECK_FEATURE(EXPERIMENTAL,
252     [building of experimental plug-ins],,
253     HAVE_EXPERIMENTAL=yes, enabled,
254     [
255       AC_MSG_WARN(building experimental plug-ins)
256       BUILD_EXPERIMENTAL="yes"
257     ],[
258       AC_MSG_NOTICE(not building experimental plug-ins)
259       BUILD_EXPERIMENTAL="no"
260     ])
261   # make BUILD_EXPERIMENTAL available to Makefile.am
262   AM_CONDITIONAL(BUILD_EXPERIMENTAL, test "x$BUILD_EXPERIMENTAL" = "xyes")
263 ])
264
265 dnl broken plug-ins; stuff that doesn't seem to build at the moment
266 AC_DEFUN([GST_ARG_ENABLE_BROKEN],
267 [
268   GST_CHECK_FEATURE(BROKEN, [enable building of broken plug-ins],,
269     HAVE_BROKEN=yes, disabled,
270     [
271       AC_MSG_WARN([building broken plug-ins -- no bug reports on these, only patches ...])
272     ],[
273       AC_MSG_NOTICE([not building broken plug-ins])
274     ])
275 ])