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