]> git.donarmstrong.com Git - lilypond.git/blobdiff - stepmake/aclocal.m4
* scm/framework-gnome.scm: Add pango decoders.
[lilypond.git] / stepmake / aclocal.m4
index 079bd0e4daea76b330a64532d0ee924f1f0b7692..a592a8ab0d08cd772fcd7369a6b524c053ddbe71 100644 (file)
@@ -11,21 +11,24 @@ AC_DEFUN(STEPMAKE_GET_EXECUTABLE, [
     ## command -v doesn't work in zsh
     ## command -v "$1" 2>&1
     ## this test should work in ash, bash, pdksh (ksh), zsh
-    type -p "$1" 2>/dev/null | tail -1 | awk '{print $NF}'
+    type -p "$1" 2>/dev/null | tail -1 | awk '{print $NF}'
 ])
 
 
 # Get version string from executable ($1)
 AC_DEFUN(STEPMAKE_GET_VERSION, [
-    ## "$1" --version 2>&1 | grep -v '^$' | head -1 | awk '{print $NF}'
+    ## "$1" --version 2>&1 | grep -v '^$' | head -1 | awk '{print $NF}'
     ##
     ## ARG.
     ## Workaround for broken Debian gcc version string:
     ##     gcc (GCC) 3.1.1 20020606 (Debian prerelease)
     ##
+    ## -V: Workaround for python
+    ##
     ## Assume, and hunt for, dotted version multiplet.
+
     changequote(<<, >>)dnl
-    "$1" --version 2>&1 | grep '[0-9]\.[0-9]' | head -1 | \
+    ("$1" --version || "$1" -V) 2>&1 | grep '[0-9]\.[0-9]' | head -n 1 | \
        sed -e 's/.*[^-.0-9]\([0-9][0-9]*\.[0-9][.0-9]*\).*/\1/'
     changequote([, ])dnl
 ])
@@ -94,12 +97,15 @@ AC_DEFUN(STEPMAKE_CHECK_VERSION, [
     if test "$num" -lt "$req"; then
        STEPMAKE_ADD_ENTRY($2, ["$r >= $3 (installed: $ver)"])
     fi
+    vervar="`echo $1 | tr '[a-z]' '[A-Z]'`_VERSION"
+    eval `echo $vervar=$num`
+##    AC_SUBST(`eval echo $vervar`)
 ])
 
 # Check version of program ($1)
-# If version is greater than or equals requested ($3),
+# If version is greater than or equals unsupported ($3),
 # add entry to unsupported list ($2, 'UNSUPPORTED')
-AC_DEFUN(STEPMAKE_CHECK_VERSION_SUPPORT, [
+AC_DEFUN(STEPMAKE_CHECK_VERSION_UNSUPPORTED, [
     r="`eval echo '$'"$1"`"
     AC_MSG_CHECKING([$r version])
     exe=`STEPMAKE_GET_EXECUTABLE($r)`
@@ -149,6 +155,7 @@ AC_DEFUN(STEPMAKE_COMPILE, [
     optimise_b=yes
     profile_b=no
     debug_b=yes
+    pipe_b=yes
 
     AC_ARG_ENABLE(checking,
     [  --enable-checking       set runtime checks (assert calls).  Default: on],
@@ -166,6 +173,9 @@ AC_DEFUN(STEPMAKE_COMPILE, [
     [  --enable-profiling      compile with gprof support.  Default: off],
     [profile_b=$enableval])
     
+    AC_ARG_ENABLE(pipe, 
+    [  --enable-pipe           compile with -pipe.  Default: on],
+    [pipe_b=$enableval])
 
     if test "$checking_b" = no; then
        # ugh
@@ -177,22 +187,35 @@ AC_DEFUN(STEPMAKE_COMPILE, [
        OPTIMIZE="-O2 -finline-functions"
     fi
 
-
     if test $profile_b = yes; then
        EXTRA_LIBES="-pg"
        OPTIMIZE="$OPTIMIZE -pg"
     fi
 
-    if test $debug_b = yes; then       
+    if test $debug_b = yes; then
        OPTIMIZE="$OPTIMIZE -g"
     fi
-
-
     AC_PROG_CC
     STEPMAKE_OPTIONAL_REQUIRED(CC, cc, $1)
     LD='$(CC)'
     AC_SUBST(LD)
 
+    # If -pipe requested, test if it works and add to CFLAGS.
+    if test "$pipe_b" = yes; then
+       save_cflags="$CFLAGS"
+       CFLAGS="-pipe $CFLAGS";
+       AC_CACHE_CHECK([whether compiler understands -pipe],
+           [stepmake_cflags_pipe],
+           AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[/* -pipe test */]])],
+               [stepmake_cflags_pipe=yes],
+               [stepmake_cflags_pipe=no]))
+       CFLAGS=$save_cflags
+       if test $stepmake_cflags_pipe = yes; then
+           OPTIMIZE="$OPTIMIZE -pipe"
+       fi
+    fi
+
     CFLAGS="$CFLAGS $OPTIMIZE"
     CPPFLAGS=${CPPFLAGS-""}
 
@@ -208,6 +231,7 @@ AC_DEFUN(STEPMAKE_COMPILE, [
            AC_MSG_RESULT([none])
            ;;
     esac
+
     AC_SUBST(cross_compiling)
     AC_SUBST(CFLAGS)
     AC_SUBST(CPPFLAGS)
@@ -308,13 +332,15 @@ AC_DEFUN(STEPMAKE_END, [
         echo "ERROR: Please use older version of programs: $UNSUPPORTED"
     fi
     
-    if test -n "$OPTIONAL$REQUIRED"; then
+    if test -n "$OPTIONAL$REQUIRED$UNSUPPORTED"; then
        echo
        echo "See INSTALL.txt for more information on how to build $PACKAGE_NAME"
-       echo "Remove config.cache before rerunning ./configure"
+       if test -f config.cache ; then
+           echo "Remove config.cache before rerunning ./configure"
+       fi 
     fi
     
-    if test -n "$REQUIRED"; then
+    if test -n "$REQUIRED$UNSUPPORTED"; then
        rm -f $srcdir/GNUmakefile
         exit 1
     fi
@@ -386,7 +412,6 @@ AC_DEFUN(STEPMAKE_GCC, [
     fi
 ])
 
-
 AC_DEFUN(STEPMAKE_GETTEXT, [
     presome=${prefix}
     if test "$prefix" = "NONE"; then
@@ -403,10 +428,10 @@ AC_DEFUN(STEPMAKE_GETTEXT, [
     # Use a workaround until this is resolved:
     # for g++ >= 3.3, select C language.
     GCC_UNSUPPORTED=
-    STEPMAKE_CHECK_VERSION_SUPPORT(CXX, GCC_UNSUPPORTED, 3.3)
+    STEPMAKE_CHECK_VERSION_UNSUPPORTED(CXX, GCC_UNSUPPORTED, 3.3)
     if test -n "$GCC_UNSUPPORTED"; then
-       AC_MSG_WARN([autoconf <= 2.57 with g++ >= 3.3 gettext test broken.])
-       AC_MSG_WARN([Trying gcc, cross thumbs.])
+       AC_MSG_WARN([autoconf <= 2.59 with g++ >= 3.3 gettext test broken.])
+       AC_MSG_WARN([Trying gcc, cross fingers.])
        AC_LANG_PUSH(C)
     fi
     AC_CHECK_LIB(intl, gettext)
@@ -640,8 +665,8 @@ AC_DEFUN(STEPMAKE_INIT, [
        AC_PATH_PROG(BASH, bash, $SHELL)
     fi
     AC_SUBST(SHELL)
-    
-    STEPMAKE_PATH_PROG(PYTHON, python, REQUIRED)
+
+    STEPMAKE_PYTHON(REQUIRED, 1.5)
 
     if expr "$MAKE" : '.*\(echo\)' >/dev/null; then
        $MAKE -v 2> /dev/null | grep GNU > /dev/null
@@ -878,10 +903,51 @@ AC_DEFUN(STEPMAKE_PERL, [
 ])
 
 
+AC_DEFUN(STEPMAKE_PYTHON, [
+    unset pv
+    AC_MSG_CHECKING([for python])
+    for python in $PYTHON python python2 python2.3 python2.2 python2.1 python2.0; do
+       AC_MSG_RESULT([$python])
+       if ! $python -V > /dev/null 2>&1 ; then
+           #AC_MSG_WARN([cannot execute $python])
+           PYTHON='echo no python'
+       else
+           unset pv
+           STEPMAKE_CHECK_VERSION(python, pv, $2)
+           if test -z "$pv"; then
+               PYTHON=$python
+               break
+           fi
+       fi
+    done
+    if test -n "$pv"; then
+       STEPMAKE_ADD_ENTRY($1, $pv)
+    fi
+    AC_PATH_PROG(PYTHON, $PYTHON)
+    AC_SUBST(PYTHON)
+])
+
 AC_DEFUN(STEPMAKE_PYTHON_DEVEL, [
-    AC_CHECK_HEADERS([python2.2/Python.h python2.1/Python.h python2.0/Python.h python2/Python.h python/Python.h python1.5/Python.h Python.h],[PYTHON_HEADER=yes])
+    unset PYTHON_HEADER PYTHON_INCLUDE
+    if test -n "$PYTHON"; then
+       changequote(<<, >>)dnl
+       # alternatively, for python >= 2.0
+       # 'import sys, distutils.sysconfig; sys.stdout.write (distutils.sysconfig.get_python_inc ())'
+       PYTHON_INCLUDE=`$PYTHON -c 'import sys; sys.stdout.write ("%s/include/python%s" % (sys.prefix, sys.version[:3]))'`
+       changequote([, ])dnl
+    fi
+    
+    ##AC_CHECK_HEADERS([Python.h],[PYTHON_HEADER=yes])
     if test -z "$PYTHON_HEADER"; then
-       warn='python.h (python-devel, python-dev or libpython-dev package)'
+       #URG -- how to extend include path?
+       ac_compile="$ac_compile -I$PYTHON_INCLUDE"
+       ac_cpp="$ac_cpp -I$PYTHON_INCLUDE"
+       CPPFLAGS="$CPPFLAGS -I$PYTHON_INCLUDE"
+       AC_CHECK_HEADERS([Python.h],[PYTHON_HEADER=yes])
+    fi
+    
+    if test -z "$PYTHON_HEADER"; then
+       warn="$PYTHON_INCLUDE/Python.h (python-devel, python-dev or libpython-dev package)"
        STEPMAKE_ADD_ENTRY($1, $warn)
     fi
 ])
@@ -948,3 +1014,91 @@ AC_DEFUN(STEPMAKE_WARN, [
 ])
 
 
+dnl PKG_CHECK_MODULES(GSTUFF, gtk+-2.0 >= 1.3 glib = 1.3.4, action-if, action-not)
+dnl defines GSTUFF_LIBS, GSTUFF_CFLAGS, see pkg-config man page
+dnl also defines GSTUFF_PKG_ERRORS on error
+AC_DEFUN(PKG_CHECK_MODULES, [
+  succeeded=no
+
+  if test -z "$PKG_CONFIG"; then
+    AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
+  fi
+
+  if test "$PKG_CONFIG" = "no" ; then
+     echo "*** The pkg-config script could not be found. Make sure it is"
+     echo "*** in your path, or set the PKG_CONFIG environment variable"
+     echo "*** to the full path to pkg-config."
+     echo "*** Or see http://www.freedesktop.org/software/pkgconfig to get pkg-config."
+  else
+     PKG_CONFIG_MIN_VERSION=0.9.0
+     if $PKG_CONFIG --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
+        AC_MSG_CHECKING(for $2)
+
+        if $PKG_CONFIG --exists "$2" ; then
+            AC_MSG_RESULT(yes)
+            succeeded=yes
+
+            AC_MSG_CHECKING($1_CFLAGS)
+            $1_CFLAGS=`$PKG_CONFIG --cflags "$2"`
+            AC_MSG_RESULT($$1_CFLAGS)
+
+            AC_MSG_CHECKING($1_LIBS)
+            $1_LIBS=`$PKG_CONFIG --libs "$2"`
+            AC_MSG_RESULT($$1_LIBS)
+        else
+            $1_CFLAGS=""
+            $1_LIBS=""
+            ## If we have a custom action on failure, don't print errors, but 
+            ## do set a variable so people can do so.
+            $1_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"`
+            ifelse([$4], ,echo $$1_PKG_ERRORS,)
+        fi
+
+        AC_SUBST($1_CFLAGS)
+        AC_SUBST($1_LIBS)
+     else
+        echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
+        echo "*** See http://www.freedesktop.org/software/pkgconfig"
+     fi
+  fi
+
+  if test $succeeded = yes; then
+     ifelse([$3], , :, [$3])
+  else
+     ifelse([$4], , AC_MSG_ERROR([Library requirements ($2) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them.]), [$4])
+  fi
+])
+
+
+AC_DEFUN(STEPMAKE_FREETYPE2, [
+    PKG_CHECK_MODULES(FREETYPE2, freetype2 >= 0, have_freetype2=true, true)
+    if $have_freetype2 ; then
+       AC_DEFINE(HAVE_FREETYPE2)
+       AC_SUBST(FREETYPE2_CFLAGS)
+       AC_SUBST(FREETYPE2_LIBS)
+    fi
+])
+
+AC_DEFUN(STEPMAKE_GTK2, [
+    PKG_CHECK_MODULES(GTK2, gtk+-2.0 >= 2.4.0, have_gtk2=true, true)
+    if $have_gtk2 ; then
+       AC_DEFINE(HAVE_GTK2)
+       AC_SUBST(GTK2_CFLAGS)
+       AC_SUBST(GTK2_LIBS)
+    fi
+])
+
+AC_DEFUN(STEPMAKE_PANGO, [
+    PKG_CHECK_MODULES(PANGO, pango >= 1.5.0, have_pango_cvs=true, true)
+    if $have_pango_cvs ; then
+       AC_DEFINE(HAVE_PANGO_CVS)
+       PANGO_CFLAGS="$PANGO_CFLAGS $GTK2_CFLAGS"
+       PANGO_LIBS="$PANGO_LIBS $GTK2_LIBS"
+       CPPFLAGS="$PANGO_CFLAGS $CPPFLAGS"
+       LIBS="$PANGO_LIBS $LIBS"
+       AC_CHECK_HEADERS([pango/pangofc-fontmap.h])
+       AC_CHECK_FUNCS([pango_fc_font_map_add_decoder_find_func])
+       AC_SUBST(PANGO_CFLAGS)
+       AC_SUBST(PANGO_LIBS)
+fi
+])