make new multi epg bouquet handling optional via usage config "Multi-EPG bouquet...
[enigma2.git] / acinclude.m4
index 074e1a0..6f1cb0a 100644 (file)
@@ -1,6 +1,6 @@
-AC_DEFUN(TUXBOX_APPS,[
-AM_CONFIG_HEADER(config.h)
-AM_MAINTAINER_MODE
+AC_DEFUN([TUXBOX_APPS],[
+
+INSTALL="$INSTALL -p"
 
 AC_GNU_SOURCE
 AC_SYS_LARGEFILE
@@ -10,7 +10,7 @@ AC_ARG_WITH(target,
        [TARGET="$withval"],[TARGET="native"])
 
 AC_ARG_WITH(targetprefix,
-       [  --with-targetprefix=PATH  prefix relative to target root [[PREFIX[for native], /[for cdk]]]],
+       [  --with-targetprefix=PATH  prefix relative to target root (only applicable in cdk mode)],
        [targetprefix="$withval"],[targetprefix="NONE"])
 
 AC_ARG_WITH(debug,
@@ -22,7 +22,11 @@ if test "$DEBUG" = "yes"; then
        AC_DEFINE(DEBUG,1,[Enable debug messages])
 fi
 
+AC_MSG_CHECKING(target)
+
 if test "$TARGET" = "native"; then
+       AC_MSG_RESULT(native)
+
        if test "$CFLAGS" = "" -a "$CXXFLAGS" = ""; then
                CFLAGS="-Wall -O2 -pipe $DEBUG_CFLAGS"
                CXXFLAGS="-Wall -O2 -pipe $DEBUG_CFLAGS"
@@ -30,13 +34,10 @@ if test "$TARGET" = "native"; then
        if test "$prefix" = "NONE"; then
                prefix=/usr/local
        fi
-       if test "$targetprefix" = "NONE"; then
-               targetprefix="\${prefix}"
-               _targetprefix="${prefix}"
-       else
-               _targetprefix="$targetprefix"
-       fi
+       targetprefix=$prefix
 elif test "$TARGET" = "cdk"; then
+       AC_MSG_RESULT(cdk)
+
        if test "$CC" = "" -a "$CXX" = ""; then
                CC=powerpc-tuxbox-linux-gnu-gcc CXX=powerpc-tuxbox-linux-gnu-g++
        fi
@@ -45,101 +46,88 @@ elif test "$TARGET" = "cdk"; then
                CXXFLAGS="-Wall -Os -mcpu=823 -pipe $DEBUG_CFLAGS"
        fi
        if test "$prefix" = "NONE"; then
-               prefix=/dbox2/cdkroot
+               AC_MSG_ERROR(invalid prefix, you need to specify one in cdk mode)
        fi
        if test "$targetprefix" = "NONE"; then
                targetprefix=""
-               _targetprefix=""
-       else
-               _targetprefix="$targetprefix"
        fi
        if test "$host_alias" = ""; then
                cross_compiling=yes
                host_alias=powerpc-tuxbox-linux-gnu
        fi
 else
+       AC_MSG_RESULT(none)
        AC_MSG_ERROR([invalid target $TARGET, choose on from native,cdk]);
 fi
 
 AC_CANONICAL_BUILD
 AC_CANONICAL_HOST
 
-targetdatadir="\${targetprefix}/share"
-_targetdatadir="${_targetprefix}/share"
-targetsysconfdir="\${targetprefix}/etc"
-_targetsysconfdir="${_targetprefix}/etc"
-targetlocalstatedir="\${targetprefix}/var"
-_targetlocalstatedir="${_targetprefix}/var"
-targetlibdir="\${targetprefix}/lib"
-_targetlibdir="${_targetprefix}/lib"
-AC_SUBST(targetprefix)
-AC_SUBST(targetdatadir)
-AC_SUBST(targetsysconfdir)
-AC_SUBST(targetlocalstatedir)
-
 check_path () {
        return $(perl -e "if(\"$1\"=~m#^/usr/(local/)?bin#){print \"0\"}else{print \"1\";}")
 }
 
 ])
 
-AC_DEFUN(TUXBOX_APPS_DIRECTORY,[
-AC_REQUIRE([TUXBOX_APPS])
-
-CONFIGDIR="\${localstatedir}/tuxbox/config"
-_CONFIGDIR="${_targetlocalstatedir}/tuxbox/config"
-AC_SUBST(CONFIGDIR)
-AC_DEFINE_UNQUOTED(CONFIGDIR,"$_CONFIGDIR",[where to find the config files])
+AC_DEFUN([TUXBOX_APPS_DIRECTORY_ONE],[
+AC_ARG_WITH($1,[  $6$7 [[PREFIX$4$5]]],[
+       _$2=$withval
+       if test "$TARGET" = "cdk"; then
+               $2=`eval echo "${targetprefix}$withval"`
+       else
+               $2=$withval
+       fi
+],[
+       $2="\${$3}$5"
+       if test "$TARGET" = "cdk"; then
+               _$2=`eval echo "${target$3}$5"`
+       else
+               _$2=`eval echo "${$3}$5"`
+       fi
+])
 
-DATADIR="\${datadir}/tuxbox"
-_DATADIR="${_targetdatadir}/tuxbox"
-AC_SUBST(DATADIR)
-AC_DEFINE_UNQUOTED(DATADIR,"$_DATADIR",[where to find data like icons])
+dnl automake <= 1.6 don't support this
+dnl AC_SUBST($2)
+AC_DEFINE_UNQUOTED($2,"$_$2",$7)
+])
 
-FONTDIR="\${datadir}/fonts"
-_FONTDIR="${_targetdatadir}/fonts"
-AC_SUBST(FONTDIR)
-AC_DEFINE_UNQUOTED(FONTDIR,"$_FONTDIR",[where to find the fonts])
+AC_DEFUN([TUXBOX_APPS_DIRECTORY],[
+AC_REQUIRE([TUXBOX_APPS])
 
-GAMESDIR="\${localstatedir}/tuxbox/games"
-_GAMESDIR="${_targetlocalstatedir}/tuxbox/games"
-AC_SUBST(GAMESDIR)
-AC_DEFINE_UNQUOTED(GAMESDIR,"$_GAMESDIR",[where games data is stored])
+if test "$TARGET" = "cdk"; then
+       datadir="\${prefix}/share"
+       tuxboxdatadir="\${prefix}/share/tuxbox"
+       zoneinfodir="\${datadir}/zoneinfo"
+       sysconfdir="\${prefix}/etc"
+       localstatedir="\${prefix}/var"
+       localedir="\${prefix}/var"
+       libdir="\${prefix}/lib"
+       targetdatadir="\${targetprefix}/share"
+       targetsysconfdir="\${targetprefix}/etc"
+       targetlocalstatedir="\${targetprefix}/var"
+       targetlibdir="\${targetprefix}/lib"
+fi
 
-LIBDIR="\${libdir}/tuxbox"
-_LIBDIR="${_targetlibdir}/tuxbox"
-AC_SUBST(LIBDIR)
-AC_SUBST(_LIBDIR)
-AC_DEFINE_UNQUOTED(LIBDIR,"$_LIBDIR",[where to find the internal libs])
-
-PLUGINDIR="\${libdir}/tuxbox/plugins"
-_PLUGINDIR="${_targetlibdir}/tuxbox/plugins"
-AC_SUBST(PLUGINDIR)
-AC_DEFINE_UNQUOTED(PLUGINDIR,"$_PLUGINDIR",[where to find the plugins])
-
-UCODEDIR="\${localstatedir}/tuxbox/ucodes"
-_UCODEDIR="${_targetlocalstatedir}/tuxbox/ucodes"
-AC_SUBST(UCODEDIR)
-AC_DEFINE_UNQUOTED(UCODEDIR,"$_UCODEDIR",[where to find the ucodes (firmware)])
-])
+TUXBOX_APPS_DIRECTORY_ONE(configdir,CONFIGDIR,sysconfdir,/etc,,
+       [--with-configdir=PATH   ],[where to find the config files])
 
-AC_DEFUN(TUXBOX_APPS_ENDIAN,[
-AC_CHECK_HEADERS(endian.h)
-AC_C_BIGENDIAN
-])
+TUXBOX_APPS_DIRECTORY_ONE(datadir,DATADIR,datadir,/share,,
+       [--with-datadir=PATH     ],[where to find data])
 
-AC_DEFUN(TUXBOX_APPS_DRIVER,[
-AC_ARG_WITH(driver,
-       [  --with-driver=PATH      path for driver sources[[NONE]]],
-       [DRIVER="$withval"],[DRIVER=""])
+TUXBOX_APPS_DIRECTORY_ONE(fontdir,FONTDIR,datadir,/share,/fonts,
+       [--with-fontdir=PATH     ],[where to find the fonts])
 
-if test -z "$DRIVER"; then
-       AC_MSG_ERROR([can't find driver sources])
-fi
-CPPFLAGS="$CPPFLAGS -I$DRIVER/include"
-AC_SUBST(DRIVER)
+TUXBOX_APPS_DIRECTORY_ONE(libdir,LIBDIR,libdir,/lib,,
+       [--with-libdir=PATH      ],[where to find the internal libs])
 ])
 
+dnl automake <= 1.6 needs this specifications
+AC_SUBST(CONFIGDIR)
+AC_SUBST(DATADIR)
+AC_SUBST(FONTDIR)
+AC_SUBST(LIBDIR)
+dnl end workaround
+
 AC_DEFUN([TUXBOX_APPS_DVB],[
 AC_ARG_WITH(dvbincludes,
        [  --with-dvbincludes=PATH  path for dvb includes [[NONE]]],
@@ -177,8 +165,7 @@ else
 fi
 ])
 
-
-AC_DEFUN(_TUXBOX_APPS_LIB_CONFIG,[
+AC_DEFUN([_TUXBOX_APPS_LIB_CONFIG],[
 AC_PATH_PROG($1_CONFIG,$2,no)
 if test "$$1_CONFIG" != "no"; then
        if test "$TARGET" = "cdk" && check_path "$$1_CONFIG"; then
@@ -193,51 +180,54 @@ AC_SUBST($1_CFLAGS)
 AC_SUBST($1_LIBS)
 ])
 
-AC_DEFUN(TUXBOX_APPS_LIB_CONFIG,[
+AC_DEFUN([TUXBOX_APPS_LIB_CONFIG],[
 _TUXBOX_APPS_LIB_CONFIG($1,$2,ERROR)
 if test "$$1_CONFIG" = "no"; then
        AC_MSG_ERROR([could not find $2]);
 fi
 ])
 
-AC_DEFUN(TUXBOX_APPS_LIB_CONFIG_CHECK,[
+AC_DEFUN([TUXBOX_APPS_LIB_CONFIG_CHECK],[
 _TUXBOX_APPS_LIB_CONFIG($1,$2,WARN)
 ])
 
-AC_DEFUN(TUXBOX_APPS_PKGCONFIG,[
+AC_DEFUN([TUXBOX_APPS_PKGCONFIG],[
 AC_PATH_PROG(PKG_CONFIG, pkg-config,no)
 if test "$PKG_CONFIG" = "no" ; then
        AC_MSG_ERROR([could not find pkg-config]);
 fi
 ])
 
-AC_DEFUN(_TUXBOX_APPS_LIB_PKGCONFIG,[
-AC_REQUIRE([TUXBOX_APPS_PKGCONFIG])
-AC_MSG_CHECKING(for package $2)
-if PKG_CONFIG_PATH="${prefix}/lib/pkgconfig" $PKG_CONFIG --exists "$2" ; then
-       AC_MSG_RESULT(yes)
-       $1_CFLAGS=$(PKG_CONFIG_PATH="${prefix}/lib/pkgconfig" $PKG_CONFIG --cflags "$2")
-       $1_LIBS=$(PKG_CONFIG_PATH="${prefix}/lib/pkgconfig" $PKG_CONFIG --libs "$2")
+AC_DEFUN([_TUXBOX_APPS_LIB_PKGCONFIG],[
+PKG_CHECK_MODULES($1,$2)
+AC_SUBST($1_CFLAGS)
+AC_SUBST($1_LIBS)
+])
+
+AC_DEFUN([_TUXBOX_APPS_LIB_PKGCONFIG_OPTIONAL],[
+PKG_CHECK_MODULES($1,$2,$3="yes",$3="no")
+if test "$$3" = "yes"; then
+       AC_DEFINE($3, 1, [$2 available])
 else
-       AC_MSG_RESULT(no)
+       $1_CFLAGS=""
+       $1_LIBS=""
 fi
-
 AC_SUBST($1_CFLAGS)
 AC_SUBST($1_LIBS)
 ])
 
-AC_DEFUN(TUXBOX_APPS_LIB_PKGCONFIG,[
+AC_DEFUN([TUXBOX_APPS_LIB_PKGCONFIG],[
 _TUXBOX_APPS_LIB_PKGCONFIG($1,$2)
 if test -z "$$1_CFLAGS" ; then
        AC_MSG_ERROR([could not find package $2]);
 fi
 ])
 
-AC_DEFUN(TUXBOX_APPS_LIB_PKGCONFIG_CHECK,[
+AC_DEFUN([TUXBOX_APPS_LIB_PKGCONFIG_CHECK],[
 _TUXBOX_APPS_LIB_PKGCONFIG($1,$2)
 ])
 
-AC_DEFUN(_TUXBOX_APPS_LIB_SYMBOL,[
+AC_DEFUN([_TUXBOX_APPS_LIB_SYMBOL],[
 AC_CHECK_LIB($2,$3,HAVE_$1="yes",HAVE_$1="no")
 if test "$HAVE_$1" = "yes"; then
        $1_LIBS=-l$2
@@ -246,18 +236,18 @@ fi
 AC_SUBST($1_LIBS)
 ])
 
-AC_DEFUN(TUXBOX_APPS_LIB_SYMBOL,[
+AC_DEFUN([TUXBOX_APPS_LIB_SYMBOL],[
 _TUXBOX_APPS_LIB_SYMBOL($1,$2,$3,ERROR)
 if test "$HAVE_$1" = "no"; then
        AC_MSG_ERROR([could not find $2]);
 fi
 ])
 
-AC_DEFUN(TUXBOX_APPS_LIB_CONFIG_SYMBOL,[
+AC_DEFUN([TUXBOX_APPS_LIB_CONFIG_SYMBOL],[
 _TUXBOX_APPS_LIB_SYMBOL($1,$2,$3,WARN)
 ])
 
-AC_DEFUN(TUXBOX_APPS_GETTEXT,[
+AC_DEFUN([TUXBOX_APPS_GETTEXT],[
 AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
        [$ac_dir/$ac_word --statistics /dev/null >/dev/null 2>&1 &&
        (if $ac_dir/$ac_word --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)],
@@ -348,8 +338,7 @@ AC_SUBST(DUMMYPOFILES)
 AC_SUBST(CATALOGS)
 ])
 
-
-
+dnl backward compatiblity
 AC_DEFUN([AC_GNU_SOURCE],
 [AH_VERBATIM([_GNU_SOURCE],
 [/* Enable GNU extensions on systems that have them.  */
@@ -361,3 +350,96 @@ AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
 AC_DEFINE([_GNU_SOURCE])
 ])
 
+AC_DEFUN([AC_PROG_EGREP],
+[AC_CACHE_CHECK([for egrep], [ac_cv_prog_egrep],
+   [if echo a | (grep -E '(a|b)') >/dev/null 2>&1
+    then ac_cv_prog_egrep='grep -E'
+    else ac_cv_prog_egrep='egrep'
+    fi])
+ EGREP=$ac_cv_prog_egrep
+ AC_SUBST([EGREP])
+])
+
+AC_DEFUN([AC_PYTHON_DEVEL],[
+       #
+       # should allow for checking of python version here...
+       #
+       if test $cross_compiling = "yes"; then
+               # Check for Python include path
+               AC_MSG_CHECKING([for Python include path])
+               
+               # FIXME: yes, this is wrong. sorry about that. (tmbinc)
+               cross_PYTHON_VERSION=$PYTHON_VERSION
+               python_path=
+               for i in $CPPFLAGS ; do
+                       p=`echo $i | sed "s,^-I,,"`
+                       p=`echo $p | sed "s,^-isystem,,"`
+                       if test -f "$p/python$cross_PYTHON_VERSION/Python.h"; then
+                               python_path="$p/python$cross_PYTHON_VERSION"
+                               break
+                       fi
+               done
+               AC_MSG_RESULT([$python_path])
+               if test -z "$python_path" ; then
+                                               AC_MSG_ERROR([cannot find Python include path])
+               fi
+               AC_SUBST([PYTHON_CPPFLAGS],[-I$python_path])
+
+               # Check for Python library path
+               AC_MSG_CHECKING([for Python library path])
+               python_path=
+               for i in $LDFLAGS; do
+                       l=`echo $i | sed "s,^-L,,"`
+                       python_path=`find $l -type f -name libpython$cross_PYTHON_VERSION.* -print | sed "1q"`
+                       if test -n "$python_path" ; then
+                               break
+                       fi
+               done
+               python_path=`echo $python_path | sed "s,/libpython.*$,,"`
+               AC_MSG_RESULT([$python_path])
+               if test -z "$python_path" ; then
+                                               AC_MSG_ERROR([cannot find Python library path])
+               fi
+               AC_SUBST([PYTHON_LDFLAGS],["-L$python_path -lpython$cross_PYTHON_VERSION"])
+               #
+               python_site=`echo $python_path | sed "s/config/site-packages/"`
+               AC_SUBST([PYTHON_SITE_PKG],[$python_site])
+       else
+               AC_REQUIRE([AM_PATH_PYTHON])
+
+               # Check for Python include path
+               AC_MSG_CHECKING([for Python include path])
+               python_path=`echo $PYTHON | sed "s,/bin.*$,,"`
+               for i in "$python_path/include/python$PYTHON_VERSION/" "$python_path/include/python/" "$python_path/" ; do
+                       python_path=`find $i -type f -name Python.h -print | sed "1q"`
+                       if test -n "$python_path" ; then
+                               break
+                       fi
+               done
+               python_path=`echo $python_path | sed "s,/Python.h$,,"`
+               AC_MSG_RESULT([$python_path])
+               if test -z "$python_path" ; then
+                       AC_MSG_ERROR([cannot find Python include path])
+               fi
+               AC_SUBST([PYTHON_CPPFLAGS],[-I$python_path])
+
+               # Check for Python library path
+               AC_MSG_CHECKING([for Python library path])
+               python_path=`echo $PYTHON | sed "s,/bin.*$,,"`
+               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
+                       python_path=`find $i -type f -name libpython$PYTHON_VERSION.* -print | sed "1q"`
+                       if test -n "$python_path" ; then
+                               break
+                       fi
+               done
+               python_path=`echo $python_path | sed "s,/libpython.*$,,"`
+               AC_MSG_RESULT([$python_path])
+               if test -z "$python_path" ; then
+                       AC_MSG_ERROR([cannot find Python library path])
+               fi
+               AC_SUBST([PYTHON_LDFLAGS],["-L$python_path -lpython$PYTHON_VERSION"])
+               #
+               python_site=`echo $python_path | sed "s/config/site-packages/"`
+               AC_SUBST([PYTHON_SITE_PKG],[$python_site])
+       fi
+])