Add service flags and pid cache to recordings meta file. This adds possibility to...
[enigma2.git] / acinclude.m4
1 AC_DEFUN([TUXBOX_APPS],[
2
3 INSTALL="$INSTALL -p"
4
5 AC_GNU_SOURCE
6 AC_SYS_LARGEFILE
7
8 AC_ARG_WITH(target,
9         [  --with-target=TARGET    target for compilation [[native,cdk]]],
10         [TARGET="$withval"],[TARGET="native"])
11
12 AC_ARG_WITH(targetprefix,
13         [  --with-targetprefix=PATH  prefix relative to target root (only applicable in cdk mode)],
14         [targetprefix="$withval"],[targetprefix="NONE"])
15
16 AC_ARG_WITH(debug,
17         [  --without-debug         disable debugging code],
18         [DEBUG="$withval"],[DEBUG="yes"])
19
20 if test "$DEBUG" = "yes"; then
21         DEBUG_CFLAGS="-g3 -ggdb"
22         AC_DEFINE(DEBUG,1,[Enable debug messages])
23 fi
24
25 AC_MSG_CHECKING(target)
26
27 if test "$TARGET" = "native"; then
28         AC_MSG_RESULT(native)
29
30         if test "$CFLAGS" = "" -a "$CXXFLAGS" = ""; then
31                 CFLAGS="-Wall -O2 -pipe $DEBUG_CFLAGS"
32                 CXXFLAGS="-Wall -O2 -pipe $DEBUG_CFLAGS"
33         fi
34         if test "$prefix" = "NONE"; then
35                 prefix=/usr/local
36         fi
37         targetprefix=$prefix
38 elif test "$TARGET" = "cdk"; then
39         AC_MSG_RESULT(cdk)
40
41         if test "$CC" = "" -a "$CXX" = ""; then
42                 CC=powerpc-tuxbox-linux-gnu-gcc CXX=powerpc-tuxbox-linux-gnu-g++
43         fi
44         if test "$CFLAGS" = "" -a "$CXXFLAGS" = ""; then
45                 CFLAGS="-Wall -Os -mcpu=823 -pipe $DEBUG_CFLAGS"
46                 CXXFLAGS="-Wall -Os -mcpu=823 -pipe $DEBUG_CFLAGS"
47         fi
48         if test "$prefix" = "NONE"; then
49                 AC_MSG_ERROR(invalid prefix, you need to specify one in cdk mode)
50         fi
51         if test "$targetprefix" = "NONE"; then
52                 targetprefix=""
53         fi
54         if test "$host_alias" = ""; then
55                 cross_compiling=yes
56                 host_alias=powerpc-tuxbox-linux-gnu
57         fi
58 else
59         AC_MSG_RESULT(none)
60         AC_MSG_ERROR([invalid target $TARGET, choose on from native,cdk]);
61 fi
62
63 AC_CANONICAL_BUILD
64 AC_CANONICAL_HOST
65
66 check_path () {
67         return $(perl -e "if(\"$1\"=~m#^/usr/(local/)?bin#){print \"0\"}else{print \"1\";}")
68 }
69
70 ])
71
72 AC_DEFUN([TUXBOX_APPS_DIRECTORY_ONE],[
73 AC_ARG_WITH($1,[  $6$7 [[PREFIX$4$5]]],[
74         _$2=$withval
75         if test "$TARGET" = "cdk"; then
76                 $2=`eval echo "${targetprefix}$withval"`
77         else
78                 $2=$withval
79         fi
80 ],[
81         $2="\${$3}$5"
82         if test "$TARGET" = "cdk"; then
83                 _$2=`eval echo "${target$3}$5"`
84         else
85                 _$2=`eval echo "${$3}$5"`
86         fi
87 ])
88
89 dnl automake <= 1.6 don't support this
90 dnl AC_SUBST($2)
91 AC_DEFINE_UNQUOTED($2,"$_$2",$7)
92 ])
93
94 AC_DEFUN([TUXBOX_APPS_DIRECTORY],[
95 AC_REQUIRE([TUXBOX_APPS])
96
97 if test "$TARGET" = "cdk"; then
98         datadir="\${prefix}/share"
99         tuxboxdatadir="\${prefix}/share/tuxbox"
100         zoneinfodir="\${datadir}/zoneinfo"
101         sysconfdir="\${prefix}/etc"
102         localstatedir="\${prefix}/var"
103         localedir="\${prefix}/var"
104         libdir="\${prefix}/lib"
105         targetdatadir="\${targetprefix}/share"
106         targetsysconfdir="\${targetprefix}/etc"
107         targetlocalstatedir="\${targetprefix}/var"
108         targetlibdir="\${targetprefix}/lib"
109 fi
110
111 TUXBOX_APPS_DIRECTORY_ONE(configdir,CONFIGDIR,sysconfdir,/etc,,
112         [--with-configdir=PATH   ],[where to find the config files])
113
114 TUXBOX_APPS_DIRECTORY_ONE(datadir,DATADIR,datadir,/share,,
115         [--with-datadir=PATH     ],[where to find data])
116
117 TUXBOX_APPS_DIRECTORY_ONE(localedir,LOCALEDIR,datadir,/share,/locale,
118         [--with-localedir=PATH ],[where to find locales])
119
120 TUXBOX_APPS_DIRECTORY_ONE(fontdir,FONTDIR,datadir,/share,/fonts,
121         [--with-fontdir=PATH     ],[where to find the fonts])
122
123 TUXBOX_APPS_DIRECTORY_ONE(gamesdir,GAMESDIR,localstatedir,/var,/tuxbox/games,
124         [--with-gamesdir=PATH    ],[where games data is stored])
125
126 TUXBOX_APPS_DIRECTORY_ONE(libdir,LIBDIR,libdir,/lib,,
127         [--with-libdir=PATH      ],[where to find the internal libs])
128
129 TUXBOX_APPS_DIRECTORY_ONE(plugindir,PLUGINDIR,libdir,/lib,/tuxbox/plugins,
130         [--with-plugindir=PATH   ],[where to find the plugins])
131
132 TUXBOX_APPS_DIRECTORY_ONE(tuxboxdatadir,TUXBOXDATADIR,datadir,/share,,
133         [--with-tuxboxdatadir=PATH],[where to find tuxbox data])
134
135 TUXBOX_APPS_DIRECTORY_ONE(zoneinfodir,ZONEINFODIR,datadir,/share,/zoneinfo,
136         [--with-zoneinfodir=PATH ],[where to find zoneinfo db])
137 ])
138
139 dnl automake <= 1.6 needs this specifications
140 AC_SUBST(CONFIGDIR)
141 AC_SUBST(DATADIR)
142 AC_SUBST(ZONEINFODIR)
143 AC_SUBST(FONTDIR)
144 AC_SUBST(GAMESDIR)
145 AC_SUBST(LIBDIR)
146 AC_SUBST(LOCALEDIR)
147 AC_SUBST(PLUGINDIR)
148 AC_SUBST(TUXBOXDATADIR)
149 dnl end workaround
150
151 AC_DEFUN([TUXBOX_APPS_ENDIAN],[
152 AC_CHECK_HEADERS(endian.h)
153 AC_C_BIGENDIAN
154 ])
155
156 AC_DEFUN([TUXBOX_APPS_DRIVER],[
157 #AC_ARG_WITH(driver,
158 #       [  --with-driver=PATH      path for driver sources [[NONE]]],
159 #       [DRIVER="$withval"],[DRIVER=""])
160 #
161 #if test -d "$DRIVER/include"; then
162 #       AC_DEFINE(HAVE_DBOX2_DRIVER,1,[Define to 1 if you have the dbox2 driver sources])
163 #else
164 #       AC_MSG_ERROR([can't find driver sources])
165 #fi
166
167 #AC_SUBST(DRIVER)
168
169 #CPPFLAGS="$CPPFLAGS -I$DRIVER/include"
170 ])
171
172 AC_DEFUN([TUXBOX_APPS_DVB],[
173 AC_ARG_WITH(dvbincludes,
174         [  --with-dvbincludes=PATH  path for dvb includes [[NONE]]],
175         [DVBINCLUDES="$withval"],[DVBINCLUDES=""])
176
177 if test "$DVBINCLUDES"; then
178         CPPFLAGS="$CPPFLAGS -I$DVBINCLUDES"
179 fi
180
181 AC_CHECK_HEADERS(ost/dmx.h,[
182         DVB_API_VERSION=1
183         AC_MSG_NOTICE([found dvb version 1])
184 ])
185
186 if test -z "$DVB_API_VERSION"; then
187 AC_CHECK_HEADERS(linux/dvb/version.h,[
188         AC_LANG_PREPROC_REQUIRE()
189         AC_REQUIRE([AC_PROG_EGREP])
190         AC_LANG_CONFTEST([AC_LANG_SOURCE([[
191 #include <linux/dvb/version.h>
192 version DVB_API_VERSION
193         ]])])
194         DVB_API_VERSION=`(eval "$ac_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD | $EGREP "^version" | sed "s,version\ ,,"`
195         rm -f conftest*
196
197         AC_MSG_NOTICE([found dvb version $DVB_API_VERSION])
198 ])
199 fi
200
201 if test "$DVB_API_VERSION"; then
202         AC_DEFINE(HAVE_DVB,1,[Define to 1 if you have the dvb includes])
203         AC_DEFINE_UNQUOTED(HAVE_DVB_API_VERSION,$DVB_API_VERSION,[Define to the version of the dvb api])
204 else
205         AC_MSG_ERROR([can't find dvb headers])
206 fi
207 ])
208
209 AC_DEFUN([_TUXBOX_APPS_LIB_CONFIG],[
210 AC_PATH_PROG($1_CONFIG,$2,no)
211 if test "$$1_CONFIG" != "no"; then
212         if test "$TARGET" = "cdk" && check_path "$$1_CONFIG"; then
213                 AC_MSG_$3([could not find a suitable version of $2]);
214         else
215                 $1_CFLAGS=$($$1_CONFIG --cflags)
216                 $1_LIBS=$($$1_CONFIG --libs)
217         fi
218 fi
219
220 AC_SUBST($1_CFLAGS)
221 AC_SUBST($1_LIBS)
222 ])
223
224 AC_DEFUN([TUXBOX_APPS_LIB_CONFIG],[
225 _TUXBOX_APPS_LIB_CONFIG($1,$2,ERROR)
226 if test "$$1_CONFIG" = "no"; then
227         AC_MSG_ERROR([could not find $2]);
228 fi
229 ])
230
231 AC_DEFUN([TUXBOX_APPS_LIB_CONFIG_CHECK],[
232 _TUXBOX_APPS_LIB_CONFIG($1,$2,WARN)
233 ])
234
235 AC_DEFUN([TUXBOX_APPS_PKGCONFIG],[
236 AC_PATH_PROG(PKG_CONFIG, pkg-config,no)
237 if test "$PKG_CONFIG" = "no" ; then
238         AC_MSG_ERROR([could not find pkg-config]);
239 fi
240 ])
241
242 AC_DEFUN([_TUXBOX_APPS_LIB_PKGCONFIG],[
243 PKG_CHECK_MODULES($1,$2)
244 AC_SUBST($1_CFLAGS)
245 AC_SUBST($1_LIBS)
246 ])
247
248 AC_DEFUN([_TUXBOX_APPS_LIB_PKGCONFIG_OPTIONAL],[
249 PKG_CHECK_MODULES($1,$2,$3="yes",$3="no")
250 if test "$$3" = "yes"; then
251         AC_DEFINE($3, 1, [$2 available])
252 else
253         $1_CFLAGS=""
254         $1_LIBS=""
255 fi
256 AC_SUBST($1_CFLAGS)
257 AC_SUBST($1_LIBS)
258 ])
259
260 AC_DEFUN([TUXBOX_APPS_LIB_PKGCONFIG],[
261 _TUXBOX_APPS_LIB_PKGCONFIG($1,$2)
262 if test -z "$$1_CFLAGS" ; then
263         AC_MSG_ERROR([could not find package $2]);
264 fi
265 ])
266
267 AC_DEFUN([TUXBOX_APPS_LIB_PKGCONFIG_CHECK],[
268 _TUXBOX_APPS_LIB_PKGCONFIG($1,$2)
269 ])
270
271 AC_DEFUN([_TUXBOX_APPS_LIB_SYMBOL],[
272 AC_CHECK_LIB($2,$3,HAVE_$1="yes",HAVE_$1="no")
273 if test "$HAVE_$1" = "yes"; then
274         $1_LIBS=-l$2
275 fi
276
277 AC_SUBST($1_LIBS)
278 ])
279
280 AC_DEFUN([TUXBOX_APPS_LIB_SYMBOL],[
281 _TUXBOX_APPS_LIB_SYMBOL($1,$2,$3,ERROR)
282 if test "$HAVE_$1" = "no"; then
283         AC_MSG_ERROR([could not find $2]);
284 fi
285 ])
286
287 AC_DEFUN([TUXBOX_APPS_LIB_CONFIG_SYMBOL],[
288 _TUXBOX_APPS_LIB_SYMBOL($1,$2,$3,WARN)
289 ])
290
291 AC_DEFUN([TUXBOX_APPS_GETTEXT],[
292 AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
293         [$ac_dir/$ac_word --statistics /dev/null >/dev/null 2>&1 &&
294         (if $ac_dir/$ac_word --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)],
295         :)
296 AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
297
298 AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
299         [$ac_dir/$ac_word --omit-header --copyright-holder= /dev/null >/dev/null 2>&1 &&
300         (if $ac_dir/$ac_word --omit-header --copyright-holder= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)],
301         :)
302
303 AM_PATH_PROG_WITH_TEST(MSGMERGE, msgmerge,[$ac_dir/$ac_word --update -q /dev/null /dev/null >/dev/null 2>&1],:)
304
305 AC_MSG_CHECKING([whether NLS is requested])
306 AC_ARG_ENABLE(nls,
307         [  --disable-nls           do not use Native Language Support],
308         USE_NLS=$enableval, USE_NLS=yes)
309 AC_MSG_RESULT($USE_NLS)
310 AC_SUBST(USE_NLS)
311
312 if test "$USE_NLS" = "yes"; then
313         AC_CACHE_CHECK([for GNU gettext in libc], gt_cv_func_gnugettext_libc,[
314                 AC_TRY_LINK([
315                         #include <libintl.h>
316                         #ifndef __GNU_GETTEXT_SUPPORTED_REVISION
317                         #define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1)
318                         #endif
319                         extern int _nl_msg_cat_cntr;
320                         extern int *_nl_domain_bindings;
321                         ],[
322                         bindtextdomain ("", "");
323                         return (int) gettext ("") + _nl_msg_cat_cntr + *_nl_domain_bindings;
324                         ], gt_cv_func_gnugettext_libc=yes, gt_cv_func_gnugettext_libc=no
325                 )]
326         )
327
328         if test "$gt_cv_func_gnugettext_libc" = "yes"; then
329                 AC_DEFINE(ENABLE_NLS, 1, [Define to 1 if translation of program messages to the user's native language is requested.])
330                 gt_use_preinstalled_gnugettext=yes
331         else
332                 USE_NLS=no
333         fi
334 fi
335
336 if test -f "$srcdir/po/LINGUAS"; then
337         ALL_LINGUAS=$(sed -e "/^#/d" "$srcdir/po/LINGUAS")
338 fi
339
340 POFILES=
341 GMOFILES=
342 UPDATEPOFILES=
343 DUMMYPOFILES=
344 for lang in $ALL_LINGUAS; do
345         POFILES="$POFILES $srcdirpre$lang.po"
346         GMOFILES="$GMOFILES $srcdirpre$lang.gmo"
347         UPDATEPOFILES="$UPDATEPOFILES $lang.po-update"
348         DUMMYPOFILES="$DUMMYPOFILES $lang.nop"
349 done
350 INST_LINGUAS=
351 if test -n "$ALL_LINGUAS"; then
352         for presentlang in $ALL_LINGUAS; do
353                 useit=no
354                 if test -n "$LINGUAS"; then
355                         desiredlanguages="$LINGUAS"
356                 else
357                         desiredlanguages="$ALL_LINGUAS"
358                 fi
359                 for desiredlang in $desiredlanguages; do
360                         case "$desiredlang" in
361                                 "$presentlang"*) useit=yes;;
362                         esac
363                 done
364                 if test $useit = yes; then
365                         INST_LINGUAS="$INST_LINGUAS $presentlang"
366                 fi
367         done
368 fi
369 CATALOGS=
370 if test -n "$INST_LINGUAS"; then
371         for lang in $INST_LINGUAS; do
372                 CATALOGS="$CATALOGS $lang.gmo"
373         done
374 fi
375 AC_SUBST(POFILES)
376 AC_SUBST(GMOFILES)
377 AC_SUBST(UPDATEPOFILES)
378 AC_SUBST(DUMMYPOFILES)
379 AC_SUBST(CATALOGS)
380 ])
381
382 dnl backward compatiblity
383 AC_DEFUN([AC_GNU_SOURCE],
384 [AH_VERBATIM([_GNU_SOURCE],
385 [/* Enable GNU extensions on systems that have them.  */
386 #ifndef _GNU_SOURCE
387 # undef _GNU_SOURCE
388 #endif])dnl
389 AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl
390 AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
391 AC_DEFINE([_GNU_SOURCE])
392 ])
393
394 AC_DEFUN([AC_PROG_EGREP],
395 [AC_CACHE_CHECK([for egrep], [ac_cv_prog_egrep],
396    [if echo a | (grep -E '(a|b)') >/dev/null 2>&1
397     then ac_cv_prog_egrep='grep -E'
398     else ac_cv_prog_egrep='egrep'
399     fi])
400  EGREP=$ac_cv_prog_egrep
401  AC_SUBST([EGREP])
402 ])
403
404 AC_DEFUN([AC_PYTHON_DEVEL],[
405         #
406         # should allow for checking of python version here...
407         #
408         if test $cross_compiling = "yes"; then
409                 # Check for Python include path
410                 AC_MSG_CHECKING([for Python include path])
411                 
412                 # FIXME: yes, this is wrong. sorry about that. (tmbinc)
413                 cross_PYTHON_VERSION=$PYTHON_VERSION
414                 python_path=
415                 for i in $CPPFLAGS ; do
416                         p=`echo $i | sed "s,^-I,,"`
417                         p=`echo $p | sed "s,^-isystem,,"`
418                         if test -f "$p/python$cross_PYTHON_VERSION/Python.h"; then
419                                 python_path="$p/python$cross_PYTHON_VERSION"
420                                 break
421                         fi
422                 done
423                 AC_MSG_RESULT([$python_path])
424                 if test -z "$python_path" ; then
425                                                 AC_MSG_ERROR([cannot find Python include path])
426                 fi
427                 AC_SUBST([PYTHON_CPPFLAGS],[-I$python_path])
428
429                 # Check for Python library path
430                 AC_MSG_CHECKING([for Python library path])
431                 python_path=
432                 for i in $LDFLAGS; do
433                         l=`echo $i | sed "s,^-L,,"`
434                         python_path=`find $l -type f -name libpython$cross_PYTHON_VERSION.* -print | sed "1q"`
435                         if test -n "$python_path" ; then
436                                 break
437                         fi
438                 done
439                 python_path=`echo $python_path | sed "s,/libpython.*$,,"`
440                 AC_MSG_RESULT([$python_path])
441                 if test -z "$python_path" ; then
442                                                 AC_MSG_ERROR([cannot find Python library path])
443                 fi
444                 AC_SUBST([PYTHON_LDFLAGS],["-L$python_path -lpython$cross_PYTHON_VERSION"])
445                 #
446                 python_site=`echo $python_path | sed "s/config/site-packages/"`
447                 AC_SUBST([PYTHON_SITE_PKG],[$python_site])
448         else
449                 AC_REQUIRE([AM_PATH_PYTHON])
450
451                 # Check for Python include path
452                 AC_MSG_CHECKING([for Python include path])
453                 python_path=`echo $PYTHON | sed "s,/bin.*$,,"`
454                 for i in "$python_path/include/python$PYTHON_VERSION/" "$python_path/include/python/" "$python_path/" ; do
455                         python_path=`find $i -type f -name Python.h -print | sed "1q"`
456                         if test -n "$python_path" ; then
457                                 break
458                         fi
459                 done
460                 python_path=`echo $python_path | sed "s,/Python.h$,,"`
461                 AC_MSG_RESULT([$python_path])
462                 if test -z "$python_path" ; then
463                         AC_MSG_ERROR([cannot find Python include path])
464                 fi
465                 AC_SUBST([PYTHON_CPPFLAGS],[-I$python_path])
466
467                 # Check for Python library path
468                 AC_MSG_CHECKING([for Python library path])
469                 python_path=`echo $PYTHON | sed "s,/bin.*$,,"`
470                 for i in "$python_path/lib/python$PYTHON_VERSION/config/" "$python_path/lib/python$PYTHON_VERSION/" "$python_path/lib/python/config/" "$python_path/lib/python/" "$python_path/" ; do
471                         python_path=`find $i -type f -name libpython$PYTHON_VERSION.* -print | sed "1q"`
472                         if test -n "$python_path" ; then
473                                 break
474                         fi
475                 done
476                 python_path=`echo $python_path | sed "s,/libpython.*$,,"`
477                 AC_MSG_RESULT([$python_path])
478                 if test -z "$python_path" ; then
479                         AC_MSG_ERROR([cannot find Python library path])
480                 fi
481                 AC_SUBST([PYTHON_LDFLAGS],["-L$python_path -lpython$PYTHON_VERSION"])
482                 #
483                 python_site=`echo $python_path | sed "s/config/site-packages/"`
484                 AC_SUBST([PYTHON_SITE_PKG],[$python_site])
485         fi
486 ])