- add more python stuff
[enigma2.git] / acinclude.m4
1 AC_DEFUN(TUXBOX_APPS,[
2 AM_CONFIG_HEADER(config.h)
3 AM_MAINTAINER_MODE
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 [[PREFIX[for native], /[for cdk]]]],
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 if test "$TARGET" = "native"; then
26         if test "$CFLAGS" = "" -a "$CXXFLAGS" = ""; then
27                 CFLAGS="-Wall -O2 -pipe $DEBUG_CFLAGS"
28                 CXXFLAGS="-Wall -O2 -pipe $DEBUG_CFLAGS"
29         fi
30         if test "$prefix" = "NONE"; then
31                 prefix=/usr/local
32         fi
33         if test "$targetprefix" = "NONE"; then
34                 targetprefix="\${prefix}"
35                 _targetprefix="${prefix}"
36         else
37                 _targetprefix="$targetprefix"
38         fi
39 elif test "$TARGET" = "cdk"; then
40         if test "$CC" = "" -a "$CXX" = ""; then
41                 CC=powerpc-tuxbox-linux-gnu-gcc CXX=powerpc-tuxbox-linux-gnu-g++
42         fi
43         if test "$CFLAGS" = "" -a "$CXXFLAGS" = ""; then
44                 CFLAGS="-Wall -Os -mcpu=823 -pipe $DEBUG_CFLAGS"
45                 CXXFLAGS="-Wall -Os -mcpu=823 -pipe $DEBUG_CFLAGS"
46         fi
47         if test "$prefix" = "NONE"; then
48                 prefix=/dbox2/cdkroot
49         fi
50         if test "$targetprefix" = "NONE"; then
51                 targetprefix=""
52                 _targetprefix=""
53         else
54                 _targetprefix="$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_ERROR([invalid target $TARGET, choose on from native,cdk]);
62 fi
63
64 AC_CANONICAL_BUILD
65 AC_CANONICAL_HOST
66
67 targetdatadir="\${targetprefix}/share"
68 _targetdatadir="${_targetprefix}/share"
69 targetsysconfdir="\${targetprefix}/etc"
70 _targetsysconfdir="${_targetprefix}/etc"
71 targetlocalstatedir="\${targetprefix}/var"
72 _targetlocalstatedir="${_targetprefix}/var"
73 targetlibdir="\${targetprefix}/lib"
74 _targetlibdir="${_targetprefix}/lib"
75 AC_SUBST(targetprefix)
76 AC_SUBST(targetdatadir)
77 AC_SUBST(targetsysconfdir)
78 AC_SUBST(targetlocalstatedir)
79
80 check_path () {
81         return $(perl -e "if(\"$1\"=~m#^/usr/(local/)?bin#){print \"0\"}else{print \"1\";}")
82 }
83
84 ])
85
86 AC_DEFUN(TUXBOX_APPS_DIRECTORY,[
87 AC_REQUIRE([TUXBOX_APPS])
88
89 CONFIGDIR="\${localstatedir}/tuxbox/config"
90 _CONFIGDIR="${_targetlocalstatedir}/tuxbox/config"
91 AC_SUBST(CONFIGDIR)
92 AC_DEFINE_UNQUOTED(CONFIGDIR,"$_CONFIGDIR",[where to find the config files])
93
94 DATADIR="\${datadir}/tuxbox"
95 _DATADIR="${_targetdatadir}/tuxbox"
96 AC_SUBST(DATADIR)
97 AC_DEFINE_UNQUOTED(DATADIR,"$_DATADIR",[where to find data like icons])
98
99 FONTDIR="\${datadir}/fonts"
100 _FONTDIR="${_targetdatadir}/fonts"
101 AC_SUBST(FONTDIR)
102 AC_DEFINE_UNQUOTED(FONTDIR,"$_FONTDIR",[where to find the fonts])
103
104 GAMESDIR="\${localstatedir}/tuxbox/games"
105 _GAMESDIR="${_targetlocalstatedir}/tuxbox/games"
106 AC_SUBST(GAMESDIR)
107 AC_DEFINE_UNQUOTED(GAMESDIR,"$_GAMESDIR",[where games data is stored])
108
109 LIBDIR="\${libdir}/tuxbox"
110 _LIBDIR="${_targetlibdir}/tuxbox"
111 AC_SUBST(LIBDIR)
112 AC_SUBST(_LIBDIR)
113 AC_DEFINE_UNQUOTED(LIBDIR,"$_LIBDIR",[where to find the internal libs])
114
115 PLUGINDIR="\${libdir}/tuxbox/plugins"
116 _PLUGINDIR="${_targetlibdir}/tuxbox/plugins"
117 AC_SUBST(PLUGINDIR)
118 AC_DEFINE_UNQUOTED(PLUGINDIR,"$_PLUGINDIR",[where to find the plugins])
119
120 UCODEDIR="\${localstatedir}/tuxbox/ucodes"
121 _UCODEDIR="${_targetlocalstatedir}/tuxbox/ucodes"
122 AC_SUBST(UCODEDIR)
123 AC_DEFINE_UNQUOTED(UCODEDIR,"$_UCODEDIR",[where to find the ucodes (firmware)])
124 ])
125
126 AC_DEFUN(TUXBOX_APPS_ENDIAN,[
127 AC_CHECK_HEADERS(endian.h)
128 AC_C_BIGENDIAN
129 ])
130
131 AC_DEFUN(TUXBOX_APPS_DRIVER,[
132 AC_ARG_WITH(driver,
133         [  --with-driver=PATH      path for driver sources[[NONE]]],
134         [DRIVER="$withval"],[DRIVER=""])
135
136 if test -z "$DRIVER"; then
137         AC_MSG_ERROR([can't find driver sources])
138 fi
139 CPPFLAGS="$CPPFLAGS -I$DRIVER/include"
140 AC_SUBST(DRIVER)
141 ])
142
143 AC_DEFUN([TUXBOX_APPS_DVB],[
144 AC_ARG_WITH(dvbincludes,
145         [  --with-dvbincludes=PATH  path for dvb includes[[NONE]]],
146         [DVBINCLUDES="$withval"],[DVBINCLUDES=""])
147
148 orig_CPPFLAGS=$CPPFLAGS
149 if test "$DVBINCLUDES"; then
150         CPPFLAGS="-I$DVBINCLUDES"
151 else
152         CPPFLAGS=""
153 fi
154 AC_CHECK_HEADERS(linux/dvb/version.h,[DVB_VERSION_H="yes"])
155 AC_CHECK_HEADERS(ost/dmx.h,[OST_DMX_H="yes"])
156 if test "$DVB_VERSION_H"; then
157         AC_MSG_NOTICE([found dvb version 2 or later])
158 elif test "$OST_DMX_H"; then
159         AC_MSG_NOTICE([found dvb version 1])
160 else
161         AC_MSG_ERROR([can't find dvb headers])
162 fi
163 DVB_VERSION_H=
164 OST_DMX_H=
165 CPPFLAGS="$orig_CPPFLAGS -I$DVBINCLUDES"
166 ])
167
168 AC_DEFUN(_TUXBOX_APPS_LIB_CONFIG,[
169 AC_PATH_PROG($1_CONFIG,$2,no)
170 if test "$$1_CONFIG" != "no"; then
171         if test "$TARGET" = "cdk" && check_path "$$1_CONFIG"; then
172                 AC_MSG_$3([could not find a suitable version of $2]);
173         else
174                 $1_CFLAGS=$($$1_CONFIG --cflags)
175                 $1_LIBS=$($$1_CONFIG --libs)
176         fi
177 fi
178
179 AC_SUBST($1_CFLAGS)
180 AC_SUBST($1_LIBS)
181 ])
182
183 AC_DEFUN(TUXBOX_APPS_LIB_CONFIG,[
184 _TUXBOX_APPS_LIB_CONFIG($1,$2,ERROR)
185 if test "$$1_CONFIG" = "no"; then
186         AC_MSG_ERROR([could not find $2]);
187 fi
188 ])
189
190 AC_DEFUN(TUXBOX_APPS_LIB_CONFIG_CHECK,[
191 _TUXBOX_APPS_LIB_CONFIG($1,$2,WARN)
192 ])
193
194 AC_DEFUN(TUXBOX_APPS_PKGCONFIG,[
195 AC_PATH_PROG(PKG_CONFIG, pkg-config,no)
196 if test "$PKG_CONFIG" = "no" ; then
197         AC_MSG_ERROR([could not find pkg-config]);
198 fi
199 ])
200
201 AC_DEFUN(_TUXBOX_APPS_LIB_PKGCONFIG,[
202 AC_REQUIRE([TUXBOX_APPS_PKGCONFIG])
203 AC_MSG_CHECKING(for package $2)
204 if PKG_CONFIG_PATH="${prefix}/lib/pkgconfig" $PKG_CONFIG --exists "$2" ; then
205         AC_MSG_RESULT(yes)
206         $1_CFLAGS=$(PKG_CONFIG_PATH="${prefix}/lib/pkgconfig" $PKG_CONFIG --cflags "$2")
207         $1_LIBS=$(PKG_CONFIG_PATH="${prefix}/lib/pkgconfig" $PKG_CONFIG --libs "$2")
208 else
209         AC_MSG_RESULT(no)
210 fi
211
212 AC_SUBST($1_CFLAGS)
213 AC_SUBST($1_LIBS)
214 ])
215
216 AC_DEFUN(TUXBOX_APPS_LIB_PKGCONFIG,[
217 _TUXBOX_APPS_LIB_PKGCONFIG($1,$2)
218 if test -z "$$1_CFLAGS" ; then
219         AC_MSG_ERROR([could not find package $2]);
220 fi
221 ])
222
223 AC_DEFUN(TUXBOX_APPS_LIB_PKGCONFIG_CHECK,[
224 _TUXBOX_APPS_LIB_PKGCONFIG($1,$2)
225 ])
226
227 AC_DEFUN(_TUXBOX_APPS_LIB_SYMBOL,[
228 AC_CHECK_LIB($2,$3,HAVE_$1="yes",HAVE_$1="no")
229 if test "$HAVE_$1" = "yes"; then
230         $1_LIBS=-l$2
231 fi
232
233 AC_SUBST($1_LIBS)
234 ])
235
236 AC_DEFUN(TUXBOX_APPS_LIB_SYMBOL,[
237 _TUXBOX_APPS_LIB_SYMBOL($1,$2,$3,ERROR)
238 if test "$HAVE_$1" = "no"; then
239         AC_MSG_ERROR([could not find $2]);
240 fi
241 ])
242
243 AC_DEFUN(TUXBOX_APPS_LIB_CONFIG_SYMBOL,[
244 _TUXBOX_APPS_LIB_SYMBOL($1,$2,$3,WARN)
245 ])
246
247 AC_DEFUN(TUXBOX_APPS_GETTEXT,[
248 AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
249         [$ac_dir/$ac_word --statistics /dev/null >/dev/null 2>&1 &&
250         (if $ac_dir/$ac_word --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)],
251         :)
252 AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
253
254 AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
255         [$ac_dir/$ac_word --omit-header --copyright-holder= /dev/null >/dev/null 2>&1 &&
256         (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)],
257         :)
258
259 AM_PATH_PROG_WITH_TEST(MSGMERGE, msgmerge,[$ac_dir/$ac_word --update -q /dev/null /dev/null >/dev/null 2>&1],:)
260
261 AC_MSG_CHECKING([whether NLS is requested])
262 AC_ARG_ENABLE(nls,
263         [  --disable-nls           do not use Native Language Support],
264         USE_NLS=$enableval, USE_NLS=yes)
265 AC_MSG_RESULT($USE_NLS)
266 AC_SUBST(USE_NLS)
267
268 if test "$USE_NLS" = "yes"; then
269         AC_CACHE_CHECK([for GNU gettext in libc], gt_cv_func_gnugettext_libc,[
270                 AC_TRY_LINK([
271                         #include <libintl.h>
272                         #ifndef __GNU_GETTEXT_SUPPORTED_REVISION
273                         #define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1)
274                         #endif
275                         extern int _nl_msg_cat_cntr;
276                         extern int *_nl_domain_bindings;
277                         ],[
278                         bindtextdomain ("", "");
279                         return (int) gettext ("") + _nl_msg_cat_cntr + *_nl_domain_bindings;
280                         ], gt_cv_func_gnugettext_libc=yes, gt_cv_func_gnugettext_libc=no
281                 )]
282         )
283
284         if test "$gt_cv_func_gnugettext_libc" = "yes"; then
285                 AC_DEFINE(ENABLE_NLS, 1, [Define to 1 if translation of program messages to the user's native language is requested.])
286                 gt_use_preinstalled_gnugettext=yes
287         else
288                 USE_NLS=no
289         fi
290 fi
291
292 if test -f "$srcdir/po/LINGUAS"; then
293         ALL_LINGUAS=$(sed -e "/^#/d" "$srcdir/po/LINGUAS")
294 fi
295
296 POFILES=
297 GMOFILES=
298 UPDATEPOFILES=
299 DUMMYPOFILES=
300 for lang in $ALL_LINGUAS; do
301         POFILES="$POFILES $srcdirpre$lang.po"
302         GMOFILES="$GMOFILES $srcdirpre$lang.gmo"
303         UPDATEPOFILES="$UPDATEPOFILES $lang.po-update"
304         DUMMYPOFILES="$DUMMYPOFILES $lang.nop"
305 done
306 INST_LINGUAS=
307 if test -n "$ALL_LINGUAS"; then
308         for presentlang in $ALL_LINGUAS; do
309                 useit=no
310                 if test -n "$LINGUAS"; then
311                         desiredlanguages="$LINGUAS"
312                 else
313                         desiredlanguages="$ALL_LINGUAS"
314                 fi
315                 for desiredlang in $desiredlanguages; do
316                         case "$desiredlang" in
317                                 "$presentlang"*) useit=yes;;
318                         esac
319                 done
320                 if test $useit = yes; then
321                         INST_LINGUAS="$INST_LINGUAS $presentlang"
322                 fi
323         done
324 fi
325 CATALOGS=
326 if test -n "$INST_LINGUAS"; then
327         for lang in $INST_LINGUAS; do
328                 CATALOGS="$CATALOGS $lang.gmo"
329         done
330 fi
331 AC_SUBST(POFILES)
332 AC_SUBST(GMOFILES)
333 AC_SUBST(UPDATEPOFILES)
334 AC_SUBST(DUMMYPOFILES)
335 AC_SUBST(CATALOGS)
336 ])
337
338
339
340 AC_DEFUN([AC_GNU_SOURCE],
341 [AH_VERBATIM([_GNU_SOURCE],
342 [/* Enable GNU extensions on systems that have them.  */
343 #ifndef _GNU_SOURCE
344 # undef _GNU_SOURCE
345 #endif])dnl
346 AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl
347 AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
348 AC_DEFINE([_GNU_SOURCE])
349 ])
350