undo shitty stuff.. sorry
[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 if test "$DVBINCLUDES"; then
149         CPPFLAGS="$CPPFLAGS -I$DVBINCLUDES"
150 fi
151
152 AC_CHECK_HEADERS(ost/dmx.h,[
153         DVB_API_VERSION=1
154         AC_MSG_NOTICE([found dvb version 1])
155 ])
156
157 if test -z "$DVB_API_VERSION"; then
158 AC_CHECK_HEADERS(linux/dvb/version.h,[
159         AC_LANG_PREPROC_REQUIRE()
160         AC_REQUIRE([AC_PROG_EGREP])
161         AC_LANG_CONFTEST([AC_LANG_SOURCE([[
162 #include <linux/dvb/version.h>
163 version DVB_API_VERSION
164         ]])])
165         DVB_API_VERSION=`(eval "$ac_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD | $EGREP "^version" | sed "s,version\ ,,"`
166         rm -f conftest*
167
168         AC_MSG_NOTICE([found dvb version $DVB_API_VERSION])
169 ])
170 fi
171
172 if test "$DVB_API_VERSION"; then
173         AC_DEFINE(HAVE_DVB,1,[Define to 1 if you have the dvb includes])
174         AC_DEFINE_UNQUOTED(HAVE_DVB_API_VERSION,$DVB_API_VERSION,[Define to the version of the dvb api])
175 else
176         AC_MSG_ERROR([can't find dvb headers])
177 fi
178 ])
179
180
181 AC_DEFUN(_TUXBOX_APPS_LIB_CONFIG,[
182 AC_PATH_PROG($1_CONFIG,$2,no)
183 if test "$$1_CONFIG" != "no"; then
184         if test "$TARGET" = "cdk" && check_path "$$1_CONFIG"; then
185                 AC_MSG_$3([could not find a suitable version of $2]);
186         else
187                 $1_CFLAGS=$($$1_CONFIG --cflags)
188                 $1_LIBS=$($$1_CONFIG --libs)
189         fi
190 fi
191
192 AC_SUBST($1_CFLAGS)
193 AC_SUBST($1_LIBS)
194 ])
195
196 AC_DEFUN(TUXBOX_APPS_LIB_CONFIG,[
197 _TUXBOX_APPS_LIB_CONFIG($1,$2,ERROR)
198 if test "$$1_CONFIG" = "no"; then
199         AC_MSG_ERROR([could not find $2]);
200 fi
201 ])
202
203 AC_DEFUN(TUXBOX_APPS_LIB_CONFIG_CHECK,[
204 _TUXBOX_APPS_LIB_CONFIG($1,$2,WARN)
205 ])
206
207 AC_DEFUN(TUXBOX_APPS_PKGCONFIG,[
208 AC_PATH_PROG(PKG_CONFIG, pkg-config,no)
209 if test "$PKG_CONFIG" = "no" ; then
210         AC_MSG_ERROR([could not find pkg-config]);
211 fi
212 ])
213
214 AC_DEFUN(_TUXBOX_APPS_LIB_PKGCONFIG,[
215 AC_REQUIRE([TUXBOX_APPS_PKGCONFIG])
216 AC_MSG_CHECKING(for package $2)
217 if PKG_CONFIG_PATH="${prefix}/lib/pkgconfig" $PKG_CONFIG --exists "$2" ; then
218         AC_MSG_RESULT(yes)
219         $1_CFLAGS=$(PKG_CONFIG_PATH="${prefix}/lib/pkgconfig" $PKG_CONFIG --cflags "$2")
220         $1_LIBS=$(PKG_CONFIG_PATH="${prefix}/lib/pkgconfig" $PKG_CONFIG --libs "$2")
221 else
222         AC_MSG_RESULT(no)
223 fi
224
225 AC_SUBST($1_CFLAGS)
226 AC_SUBST($1_LIBS)
227 ])
228
229 AC_DEFUN(TUXBOX_APPS_LIB_PKGCONFIG,[
230 _TUXBOX_APPS_LIB_PKGCONFIG($1,$2)
231 if test -z "$$1_CFLAGS" ; then
232         AC_MSG_ERROR([could not find package $2]);
233 fi
234 ])
235
236 AC_DEFUN(TUXBOX_APPS_LIB_PKGCONFIG_CHECK,[
237 _TUXBOX_APPS_LIB_PKGCONFIG($1,$2)
238 ])
239
240 AC_DEFUN(_TUXBOX_APPS_LIB_SYMBOL,[
241 AC_CHECK_LIB($2,$3,HAVE_$1="yes",HAVE_$1="no")
242 if test "$HAVE_$1" = "yes"; then
243         $1_LIBS=-l$2
244 fi
245
246 AC_SUBST($1_LIBS)
247 ])
248
249 AC_DEFUN(TUXBOX_APPS_LIB_SYMBOL,[
250 _TUXBOX_APPS_LIB_SYMBOL($1,$2,$3,ERROR)
251 if test "$HAVE_$1" = "no"; then
252         AC_MSG_ERROR([could not find $2]);
253 fi
254 ])
255
256 AC_DEFUN(TUXBOX_APPS_LIB_CONFIG_SYMBOL,[
257 _TUXBOX_APPS_LIB_SYMBOL($1,$2,$3,WARN)
258 ])
259
260 AC_DEFUN(TUXBOX_APPS_GETTEXT,[
261 AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
262         [$ac_dir/$ac_word --statistics /dev/null >/dev/null 2>&1 &&
263         (if $ac_dir/$ac_word --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)],
264         :)
265 AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
266
267 AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
268         [$ac_dir/$ac_word --omit-header --copyright-holder= /dev/null >/dev/null 2>&1 &&
269         (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)],
270         :)
271
272 AM_PATH_PROG_WITH_TEST(MSGMERGE, msgmerge,[$ac_dir/$ac_word --update -q /dev/null /dev/null >/dev/null 2>&1],:)
273
274 AC_MSG_CHECKING([whether NLS is requested])
275 AC_ARG_ENABLE(nls,
276         [  --disable-nls           do not use Native Language Support],
277         USE_NLS=$enableval, USE_NLS=yes)
278 AC_MSG_RESULT($USE_NLS)
279 AC_SUBST(USE_NLS)
280
281 if test "$USE_NLS" = "yes"; then
282         AC_CACHE_CHECK([for GNU gettext in libc], gt_cv_func_gnugettext_libc,[
283                 AC_TRY_LINK([
284                         #include <libintl.h>
285                         #ifndef __GNU_GETTEXT_SUPPORTED_REVISION
286                         #define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1)
287                         #endif
288                         extern int _nl_msg_cat_cntr;
289                         extern int *_nl_domain_bindings;
290                         ],[
291                         bindtextdomain ("", "");
292                         return (int) gettext ("") + _nl_msg_cat_cntr + *_nl_domain_bindings;
293                         ], gt_cv_func_gnugettext_libc=yes, gt_cv_func_gnugettext_libc=no
294                 )]
295         )
296
297         if test "$gt_cv_func_gnugettext_libc" = "yes"; then
298                 AC_DEFINE(ENABLE_NLS, 1, [Define to 1 if translation of program messages to the user's native language is requested.])
299                 gt_use_preinstalled_gnugettext=yes
300         else
301                 USE_NLS=no
302         fi
303 fi
304
305 if test -f "$srcdir/po/LINGUAS"; then
306         ALL_LINGUAS=$(sed -e "/^#/d" "$srcdir/po/LINGUAS")
307 fi
308
309 POFILES=
310 GMOFILES=
311 UPDATEPOFILES=
312 DUMMYPOFILES=
313 for lang in $ALL_LINGUAS; do
314         POFILES="$POFILES $srcdirpre$lang.po"
315         GMOFILES="$GMOFILES $srcdirpre$lang.gmo"
316         UPDATEPOFILES="$UPDATEPOFILES $lang.po-update"
317         DUMMYPOFILES="$DUMMYPOFILES $lang.nop"
318 done
319 INST_LINGUAS=
320 if test -n "$ALL_LINGUAS"; then
321         for presentlang in $ALL_LINGUAS; do
322                 useit=no
323                 if test -n "$LINGUAS"; then
324                         desiredlanguages="$LINGUAS"
325                 else
326                         desiredlanguages="$ALL_LINGUAS"
327                 fi
328                 for desiredlang in $desiredlanguages; do
329                         case "$desiredlang" in
330                                 "$presentlang"*) useit=yes;;
331                         esac
332                 done
333                 if test $useit = yes; then
334                         INST_LINGUAS="$INST_LINGUAS $presentlang"
335                 fi
336         done
337 fi
338 CATALOGS=
339 if test -n "$INST_LINGUAS"; then
340         for lang in $INST_LINGUAS; do
341                 CATALOGS="$CATALOGS $lang.gmo"
342         done
343 fi
344 AC_SUBST(POFILES)
345 AC_SUBST(GMOFILES)
346 AC_SUBST(UPDATEPOFILES)
347 AC_SUBST(DUMMYPOFILES)
348 AC_SUBST(CATALOGS)
349 ])
350
351
352
353 AC_DEFUN([AC_GNU_SOURCE],
354 [AH_VERBATIM([_GNU_SOURCE],
355 [/* Enable GNU extensions on systems that have them.  */
356 #ifndef _GNU_SOURCE
357 # undef _GNU_SOURCE
358 #endif])dnl
359 AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl
360 AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
361 AC_DEFINE([_GNU_SOURCE])
362 ])
363