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