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