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