remove generated file "config.h":
[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,[
250 _TUXBOX_APPS_LIB_PKGCONFIG($1,$2)
251 if test -z "$$1_CFLAGS" ; then
252         AC_MSG_ERROR([could not find package $2]);
253 fi
254 ])
255
256 AC_DEFUN(TUXBOX_APPS_LIB_PKGCONFIG_CHECK,[
257 _TUXBOX_APPS_LIB_PKGCONFIG($1,$2)
258 ])
259
260 AC_DEFUN(_TUXBOX_APPS_LIB_SYMBOL,[
261 AC_CHECK_LIB($2,$3,HAVE_$1="yes",HAVE_$1="no")
262 if test "$HAVE_$1" = "yes"; then
263         $1_LIBS=-l$2
264 fi
265
266 AC_SUBST($1_LIBS)
267 ])
268
269 AC_DEFUN(TUXBOX_APPS_LIB_SYMBOL,[
270 _TUXBOX_APPS_LIB_SYMBOL($1,$2,$3,ERROR)
271 if test "$HAVE_$1" = "no"; then
272         AC_MSG_ERROR([could not find $2]);
273 fi
274 ])
275
276 AC_DEFUN(TUXBOX_APPS_LIB_CONFIG_SYMBOL,[
277 _TUXBOX_APPS_LIB_SYMBOL($1,$2,$3,WARN)
278 ])
279
280 AC_DEFUN(TUXBOX_APPS_GETTEXT,[
281 AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
282         [$ac_dir/$ac_word --statistics /dev/null >/dev/null 2>&1 &&
283         (if $ac_dir/$ac_word --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)],
284         :)
285 AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
286
287 AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
288         [$ac_dir/$ac_word --omit-header --copyright-holder= /dev/null >/dev/null 2>&1 &&
289         (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)],
290         :)
291
292 AM_PATH_PROG_WITH_TEST(MSGMERGE, msgmerge,[$ac_dir/$ac_word --update -q /dev/null /dev/null >/dev/null 2>&1],:)
293
294 AC_MSG_CHECKING([whether NLS is requested])
295 AC_ARG_ENABLE(nls,
296         [  --disable-nls           do not use Native Language Support],
297         USE_NLS=$enableval, USE_NLS=yes)
298 AC_MSG_RESULT($USE_NLS)
299 AC_SUBST(USE_NLS)
300
301 if test "$USE_NLS" = "yes"; then
302         AC_CACHE_CHECK([for GNU gettext in libc], gt_cv_func_gnugettext_libc,[
303                 AC_TRY_LINK([
304                         #include <libintl.h>
305                         #ifndef __GNU_GETTEXT_SUPPORTED_REVISION
306                         #define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1)
307                         #endif
308                         extern int _nl_msg_cat_cntr;
309                         extern int *_nl_domain_bindings;
310                         ],[
311                         bindtextdomain ("", "");
312                         return (int) gettext ("") + _nl_msg_cat_cntr + *_nl_domain_bindings;
313                         ], gt_cv_func_gnugettext_libc=yes, gt_cv_func_gnugettext_libc=no
314                 )]
315         )
316
317         if test "$gt_cv_func_gnugettext_libc" = "yes"; then
318                 AC_DEFINE(ENABLE_NLS, 1, [Define to 1 if translation of program messages to the user's native language is requested.])
319                 gt_use_preinstalled_gnugettext=yes
320         else
321                 USE_NLS=no
322         fi
323 fi
324
325 if test -f "$srcdir/po/LINGUAS"; then
326         ALL_LINGUAS=$(sed -e "/^#/d" "$srcdir/po/LINGUAS")
327 fi
328
329 POFILES=
330 GMOFILES=
331 UPDATEPOFILES=
332 DUMMYPOFILES=
333 for lang in $ALL_LINGUAS; do
334         POFILES="$POFILES $srcdirpre$lang.po"
335         GMOFILES="$GMOFILES $srcdirpre$lang.gmo"
336         UPDATEPOFILES="$UPDATEPOFILES $lang.po-update"
337         DUMMYPOFILES="$DUMMYPOFILES $lang.nop"
338 done
339 INST_LINGUAS=
340 if test -n "$ALL_LINGUAS"; then
341         for presentlang in $ALL_LINGUAS; do
342                 useit=no
343                 if test -n "$LINGUAS"; then
344                         desiredlanguages="$LINGUAS"
345                 else
346                         desiredlanguages="$ALL_LINGUAS"
347                 fi
348                 for desiredlang in $desiredlanguages; do
349                         case "$desiredlang" in
350                                 "$presentlang"*) useit=yes;;
351                         esac
352                 done
353                 if test $useit = yes; then
354                         INST_LINGUAS="$INST_LINGUAS $presentlang"
355                 fi
356         done
357 fi
358 CATALOGS=
359 if test -n "$INST_LINGUAS"; then
360         for lang in $INST_LINGUAS; do
361                 CATALOGS="$CATALOGS $lang.gmo"
362         done
363 fi
364 AC_SUBST(POFILES)
365 AC_SUBST(GMOFILES)
366 AC_SUBST(UPDATEPOFILES)
367 AC_SUBST(DUMMYPOFILES)
368 AC_SUBST(CATALOGS)
369 ])
370
371 dnl backward compatiblity
372 AC_DEFUN([AC_GNU_SOURCE],
373 [AH_VERBATIM([_GNU_SOURCE],
374 [/* Enable GNU extensions on systems that have them.  */
375 #ifndef _GNU_SOURCE
376 # undef _GNU_SOURCE
377 #endif])dnl
378 AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl
379 AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
380 AC_DEFINE([_GNU_SOURCE])
381 ])
382
383 AC_DEFUN([AC_PROG_EGREP],
384 [AC_CACHE_CHECK([for egrep], [ac_cv_prog_egrep],
385    [if echo a | (grep -E '(a|b)') >/dev/null 2>&1
386     then ac_cv_prog_egrep='grep -E'
387     else ac_cv_prog_egrep='egrep'
388     fi])
389  EGREP=$ac_cv_prog_egrep
390  AC_SUBST([EGREP])
391 ])
392
393 AC_DEFUN([AC_PYTHON_DEVEL],[
394         #
395         # should allow for checking of python version here...
396         #
397         AC_REQUIRE([AM_PATH_PYTHON])
398
399         # Check for Python include path
400         AC_MSG_CHECKING([for Python include path])
401         python_path=`echo $PYTHON | sed "s,/bin.*$,,"`
402         for i in "$python_path/include/python$PYTHON_VERSION/" "$python_path/include/python/" "$python_path/" ; do
403                 python_path=`find $i -type f -name Python.h -print | sed "1q"`
404                 if test -n "$python_path" ; then
405                         break
406                 fi
407         done
408         python_path=`echo $python_path | sed "s,/Python.h$,,"`
409         AC_MSG_RESULT([$python_path])
410         if test -z "$python_path" ; then
411                 AC_MSG_ERROR([cannot find Python include path])
412         fi
413         AC_SUBST([PYTHON_CPPFLAGS],[-I$python_path])
414
415         # Check for Python library path
416         AC_MSG_CHECKING([for Python library path])
417         python_path=`echo $PYTHON | sed "s,/bin.*$,,"`
418         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
419                 python_path=`find $i -type f -name libpython$PYTHON_VERSION.* -print | sed "1q"`
420                 if test -n "$python_path" ; then
421                         break
422                 fi
423         done
424         python_path=`echo $python_path | sed "s,/libpython.*$,,"`
425         AC_MSG_RESULT([$python_path])
426         if test -z "$python_path" ; then
427                 AC_MSG_ERROR([cannot find Python library path])
428         fi
429         AC_SUBST([PYTHON_LDFLAGS],["-L$python_path -lpython$PYTHON_VERSION"])
430         #
431         python_site=`echo $python_path | sed "s/config/site-packages/"`
432         AC_SUBST([PYTHON_SITE_PKG],[$python_site])
433 ])