opendreambox-archive-keyring: update to krogoth key
[opendreambox.git] / meta-opendreambox / recipes-dreambox / tuxtxt / tuxbox-libtuxtxt / 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         sysconfdir="\${prefix}/etc"
102         localstatedir="\${prefix}/var"
103         libdir="\${prefix}/lib"
104         targetdatadir="\${targetprefix}/share"
105         targetsysconfdir="\${targetprefix}/etc"
106         targetlocalstatedir="\${targetprefix}/var"
107         targetlibdir="\${targetprefix}/lib"
108 fi
109
110 TUXBOX_APPS_DIRECTORY_ONE(configdir,CONFIGDIR,sysconfdir,/etc,/tuxbox,
111         [--with-configdir=PATH   ],[where to find the config files])
112
113 TUXBOX_APPS_DIRECTORY_ONE(datadir,DATADIR,datadir,/share,/tuxbox,
114         [--with-datadir=PATH     ],[where to find data])
115
116 TUXBOX_APPS_DIRECTORY_ONE(fontdir,FONTDIR,datadir,/share,/fonts,
117         [--with-fontdir=PATH     ],[where to find the fonts])
118
119 TUXBOX_APPS_DIRECTORY_ONE(gamesdir,GAMESDIR,localstatedir,/etc,/tuxbox/games,
120         [--with-gamesdir=PATH    ],[where games data is stored])
121
122 TUXBOX_APPS_DIRECTORY_ONE(libdir,LIBDIR,libdir,/lib,/tuxbox,
123         [--with-libdir=PATH      ],[where to find the internal libs])
124
125 TUXBOX_APPS_DIRECTORY_ONE(plugindir,PLUGINDIR,libdir,/lib,/tuxbox/plugins,
126         [--with-plugindir=PATH   ],[where to find the plugins])
127
128 TUXBOX_APPS_DIRECTORY_ONE(ucodedir,UCODEDIR,localstatedir,/var,/tuxbox/ucodes,
129         [--with-ucodedir=PATH    ],[where to find the ucodes])
130 ])
131
132 dnl automake <= 1.6 needs this specifications
133 AC_SUBST(CONFIGDIR)
134 AC_SUBST(DATADIR)
135 AC_SUBST(FONTDIR)
136 AC_SUBST(GAMESDIR)
137 AC_SUBST(LIBDIR)
138 AC_SUBST(PLUGINDIR)
139 AC_SUBST(UCODEDIR)
140 dnl end workaround
141
142 AC_DEFUN(TUXBOX_APPS_ENDIAN,[
143 AC_CHECK_HEADERS(endian.h)
144 AC_C_BIGENDIAN
145 ])
146
147 AC_DEFUN(TUXBOX_APPS_DRIVER,[
148 AC_ARG_WITH(driver,
149         [  --with-driver=PATH      path for driver sources [[NONE]]],
150         [DRIVER="$withval"],[DRIVER=""])
151
152 if test "$DRIVER"; then
153         if test -d "$DRIVER/include"; then
154                 AC_DEFINE(HAVE_DBOX2_DRIVER,1,[Define to 1 if you have the dbox2 driver sources])
155         #else
156         #       AC_MSG_ERROR([can't find driver sources])
157         fi
158
159         AC_SUBST(DRIVER)
160
161         CPPFLAGS="$CPPFLAGS -I$DRIVER/include"
162 fi
163 ])
164
165 AC_DEFUN([TUXBOX_APPS_DVB],[
166 AC_ARG_WITH(dvbincludes,
167         [  --with-dvbincludes=PATH  path for dvb includes [[NONE]]],
168         [DVBINCLUDES="$withval"],[DVBINCLUDES=""])
169
170 if test "$DVBINCLUDES"; then
171         CPPFLAGS="$CPPFLAGS -I$DVBINCLUDES"
172 fi
173
174 AC_CHECK_HEADERS(ost/dmx.h,[
175         DVB_API_VERSION=1
176         AC_MSG_NOTICE([found dvb version 1])
177 ])
178
179 if test -z "$DVB_API_VERSION"; then
180 AC_CHECK_HEADERS(linux/dvb/version.h,[
181         AC_LANG_PREPROC_REQUIRE()
182         AC_REQUIRE([AC_PROG_EGREP])
183         AC_LANG_CONFTEST([AC_LANG_SOURCE([[
184 #include <linux/dvb/version.h>
185 version DVB_API_VERSION
186         ]])])
187         DVB_API_VERSION=`(eval "$ac_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD | $EGREP "^version" | sed "s,version\ ,,"`
188         rm -f conftest*
189
190         AC_MSG_NOTICE([found dvb version $DVB_API_VERSION])
191 ])
192 fi
193
194 if test "$DVB_API_VERSION"; then
195         AC_DEFINE(HAVE_DVB,1,[Define to 1 if you have the dvb includes])
196         AC_DEFINE_UNQUOTED(HAVE_DVB_API_VERSION,$DVB_API_VERSION,[Define to the version of the dvb api])
197 else
198         AC_MSG_ERROR([can't find dvb headers])
199 fi
200 ])
201
202 AC_DEFUN(_TUXBOX_APPS_LIB_CONFIG,[
203 AC_PATH_PROG($1_CONFIG,$2,no)
204 if test "$$1_CONFIG" != "no"; then
205         if test "$TARGET" = "cdk" && check_path "$$1_CONFIG"; then
206                 AC_MSG_$3([could not find a suitable version of $2]);
207         else
208                 $1_CFLAGS=$($$1_CONFIG --cflags)
209                 $1_LIBS=$($$1_CONFIG --libs)
210         fi
211 fi
212
213 AC_SUBST($1_CFLAGS)
214 AC_SUBST($1_LIBS)
215 ])
216
217 AC_DEFUN(TUXBOX_APPS_LIB_CONFIG,[
218 _TUXBOX_APPS_LIB_CONFIG($1,$2,ERROR)
219 if test "$$1_CONFIG" = "no"; then
220         AC_MSG_ERROR([could not find $2]);
221 fi
222 ])
223
224 AC_DEFUN(TUXBOX_APPS_LIB_CONFIG_CHECK,[
225 _TUXBOX_APPS_LIB_CONFIG($1,$2,WARN)
226 ])
227
228 AC_DEFUN(TUXBOX_APPS_PKGCONFIG,[
229 AC_PATH_PROG(PKG_CONFIG, pkg-config,no)
230 if test "$PKG_CONFIG" = "no" ; then
231         AC_MSG_ERROR([could not find pkg-config]);
232 fi
233 ])
234
235 AC_DEFUN(_TUXBOX_APPS_LIB_PKGCONFIG,[
236 AC_REQUIRE([TUXBOX_APPS_PKGCONFIG])
237 PKG_CHECK_MODULES($1,$2)
238 AC_SUBST($1_CFLAGS)
239 AC_SUBST($1_LIBS)
240 ])
241
242 AC_DEFUN(TUXBOX_APPS_LIB_PKGCONFIG,[
243 _TUXBOX_APPS_LIB_PKGCONFIG($1,$2)
244 if test -z "$$1_CFLAGS" ; then
245         AC_MSG_ERROR([could not find package $2]);
246 fi
247 ])
248
249 AC_DEFUN(TUXBOX_APPS_LIB_PKGCONFIG_CHECK,[
250 _TUXBOX_APPS_LIB_PKGCONFIG($1,$2)
251 ])
252
253 AC_DEFUN(_TUXBOX_APPS_LIB_SYMBOL,[
254 AC_CHECK_LIB($2,$3,HAVE_$1="yes",HAVE_$1="no")
255 if test "$HAVE_$1" = "yes"; then
256         $1_LIBS=-l$2
257 fi
258
259 AC_SUBST($1_LIBS)
260 ])
261
262 AC_DEFUN(TUXBOX_APPS_LIB_SYMBOL,[
263 _TUXBOX_APPS_LIB_SYMBOL($1,$2,$3,ERROR)
264 if test "$HAVE_$1" = "no"; then
265         AC_MSG_ERROR([could not find $2]);
266 fi
267 ])
268
269 AC_DEFUN(TUXBOX_APPS_LIB_CONFIG_SYMBOL,[
270 _TUXBOX_APPS_LIB_SYMBOL($1,$2,$3,WARN)
271 ])
272
273 AC_DEFUN(TUXBOX_APPS_GETTEXT,[
274 AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
275         [$ac_dir/$ac_word --statistics /dev/null >/dev/null 2>&1 &&
276         (if $ac_dir/$ac_word --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)],
277         :)
278 AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
279
280 AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
281         [$ac_dir/$ac_word --omit-header --copyright-holder= /dev/null >/dev/null 2>&1 &&
282         (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)],
283         :)
284
285 AM_PATH_PROG_WITH_TEST(MSGMERGE, msgmerge,[$ac_dir/$ac_word --update -q /dev/null /dev/null >/dev/null 2>&1],:)
286
287 AC_MSG_CHECKING([whether NLS is requested])
288 AC_ARG_ENABLE(nls,
289         [  --disable-nls           do not use Native Language Support],
290         USE_NLS=$enableval, USE_NLS=yes)
291 AC_MSG_RESULT($USE_NLS)
292 AC_SUBST(USE_NLS)
293
294 if test "$USE_NLS" = "yes"; then
295         AC_CACHE_CHECK([for GNU gettext in libc], gt_cv_func_gnugettext_libc,[
296                 AC_TRY_LINK([
297                         #include <libintl.h>
298                         #ifndef __GNU_GETTEXT_SUPPORTED_REVISION
299                         #define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1)
300                         #endif
301                         extern int _nl_msg_cat_cntr;
302                         extern int *_nl_domain_bindings;
303                         ],[
304                         bindtextdomain ("", "");
305                         return (int) gettext ("") + _nl_msg_cat_cntr + *_nl_domain_bindings;
306                         ], gt_cv_func_gnugettext_libc=yes, gt_cv_func_gnugettext_libc=no
307                 )]
308         )
309
310         if test "$gt_cv_func_gnugettext_libc" = "yes"; then
311                 AC_DEFINE(ENABLE_NLS, 1, [Define to 1 if translation of program messages to the user's native language is requested.])
312                 gt_use_preinstalled_gnugettext=yes
313         else
314                 USE_NLS=no
315         fi
316 fi
317
318 if test -f "$srcdir/po/LINGUAS"; then
319         ALL_LINGUAS=$(sed -e "/^#/d" "$srcdir/po/LINGUAS")
320 fi
321
322 POFILES=
323 GMOFILES=
324 UPDATEPOFILES=
325 DUMMYPOFILES=
326 for lang in $ALL_LINGUAS; do
327         POFILES="$POFILES $srcdirpre$lang.po"
328         GMOFILES="$GMOFILES $srcdirpre$lang.gmo"
329         UPDATEPOFILES="$UPDATEPOFILES $lang.po-update"
330         DUMMYPOFILES="$DUMMYPOFILES $lang.nop"
331 done
332 INST_LINGUAS=
333 if test -n "$ALL_LINGUAS"; then
334         for presentlang in $ALL_LINGUAS; do
335                 useit=no
336                 if test -n "$LINGUAS"; then
337                         desiredlanguages="$LINGUAS"
338                 else
339                         desiredlanguages="$ALL_LINGUAS"
340                 fi
341                 for desiredlang in $desiredlanguages; do
342                         case "$desiredlang" in
343                                 "$presentlang"*) useit=yes;;
344                         esac
345                 done
346                 if test $useit = yes; then
347                         INST_LINGUAS="$INST_LINGUAS $presentlang"
348                 fi
349         done
350 fi
351 CATALOGS=
352 if test -n "$INST_LINGUAS"; then
353         for lang in $INST_LINGUAS; do
354                 CATALOGS="$CATALOGS $lang.gmo"
355         done
356 fi
357 AC_SUBST(POFILES)
358 AC_SUBST(GMOFILES)
359 AC_SUBST(UPDATEPOFILES)
360 AC_SUBST(DUMMYPOFILES)
361 AC_SUBST(CATALOGS)
362 ])
363
364 dnl backward compatiblity
365 AC_DEFUN([AC_GNU_SOURCE],
366 [AH_VERBATIM([_GNU_SOURCE],
367 [/* Enable GNU extensions on systems that have them.  */
368 #ifndef _GNU_SOURCE
369 # undef _GNU_SOURCE
370 #endif])dnl
371 AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl
372 AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
373 AC_DEFINE([_GNU_SOURCE])
374 ])
375
376 AC_DEFUN([AC_PROG_EGREP],
377 [AC_CACHE_CHECK([for egrep], [ac_cv_prog_egrep],
378    [if echo a | (grep -E '(a|b)') >/dev/null 2>&1
379     then ac_cv_prog_egrep='grep -E'
380     else ac_cv_prog_egrep='egrep'
381     fi])
382  EGREP=$ac_cv_prog_egrep
383  AC_SUBST([EGREP])
384 ])
385