]> git.donarmstrong.com Git - lilypond.git/blobdiff - aclocal.m4
Update d/copyright
[lilypond.git] / aclocal.m4
index 8fe2dddb728027d6ea956c7c65655923d673924d..c9f0093381604ad131867608ef50e772de949f45 100644 (file)
@@ -1,5 +1,5 @@
 dnl aclocal.m4   -*-shell-script-*-
-dnl StepMake subroutines for configure.in
+dnl StepMake subroutines for configure.ac
 
 
 ### mostly interal macros
@@ -140,7 +140,7 @@ AC_DEFUN(STEPMAKE_CHECK_VERSION_UNSUPPORTED, [
     fi
 ])
 
-### Macros to build configure.in
+### Macros to build configure.ac
 
 
 AC_DEFUN(STEPMAKE_BIBTEX2HTML, [
@@ -286,11 +286,24 @@ AC_DEFUN(STEPMAKE_CXXTEMPLATE, [
     fi
 ])
 
+AC_DEFUN(STEPMAKE_GXXCODEGENBUG, [
+    AC_MSG_CHECKING([options for known g++ bugs])
+    case "$GXX:$CXX_VERSION" in
+       yes:400600[[0-2]])
+           AC_MSG_RESULT([-fno-optimize-sibling-calls (tail call bug)])
+           CXXFLAGS="$CXXFLAGS -fno-optimize-sibling-calls"
+           ;;
+       yes:400700?)
+           AC_MSG_RESULT([-fno-tree-vrp (comparison bug)])
+           CXXFLAGS="$CXXFLAGS -fno-tree-vrp"
+           ;;
+       *) AC_MSG_RESULT([none])
+    esac
+    AC_SUBST(CXXFLAGS)
+])
+
 
 AC_DEFUN(STEPMAKE_DATADIR, [
-    if test "$datadir" = "\${prefix}/share"; then
-           datadir='${prefix}/share'
-    fi
     presome=${prefix}
     if test "$prefix" = "NONE"; then
        presome=${ac_default_prefix}
@@ -298,7 +311,7 @@ AC_DEFUN(STEPMAKE_DATADIR, [
     
     build_package_datadir=$ugh_ugh_autoconf250_builddir/out$CONFIGSUFFIX/share/$package
     
-    DATADIR=`echo ${datadir} | sed "s!\\\${datarootdir}!${prefix}/share!"`
+    DATADIR=`echo ${datadir} | sed "s!\\\${datarootdir}!${presome}/share!"`
     DATADIR=`echo ${DATADIR} | sed "s!\\\${prefix}!$presome!"`
     BUILD_PACKAGE_DATADIR=`echo ${build_package_datadir} | sed "s!\\\${prefix}!$presome!"`
     
@@ -311,11 +324,14 @@ AC_DEFUN(STEPMAKE_DATADIR, [
 
 ## ugh: cut & paste programming from datadir. 
 AC_DEFUN(STEPMAKE_LIBDIR, [
-
-    if test "$libdir" = "\${exec_prefix}/lib"; then
-       libdir='${exec_prefix}/lib'
+    presome=${exec_prefix}
+    if test "$presome" = "NONE"; then
+           presome=${prefix}
+    fi
+    if test "$presome" = "NONE"; then
+           presome=${ac_default_prefix}
     fi
-    presome=$exec_prefix
+
     build_package_libdir=$ugh_ugh_autoconf250_builddir/out$CONFIGSUFFIX/lib/$package
     
     LIBDIR=`echo ${libdir} | sed "s!\\\${exec_prefix}!$presome!"`
@@ -361,7 +377,7 @@ AC_DEFUN(STEPMAKE_END, [
     
     if test -n "$OPTIONAL"; then
        echo
-        echo "WARNING: Please consider installing optional programs: $OPTIONAL"
+        echo "WARNING: Please consider installing optional programs or files: $OPTIONAL"
     fi
 
     if test -n "$REQUIRED"; then
@@ -405,9 +421,22 @@ EOF
            exit 2
        fi
 
-       for d in 2 3 4 ; do
+       abssrcdir="`cd $srcdir; pwd`"
+       absbuilddir="`pwd`"
+       for d in 2 3 4 5 ; do
            for mf in `cd $srcdir ; find . -maxdepth $d -mindepth $d -name GNUmakefile`; do
-               mkdir -p $(dirname $mf)
+               case "$abssrcdir" in
+                   "$absbuilddir"/*)
+# source is below build directory, always copy
+                       ;;
+                   *)
+                       case "$abssrcdir/${mf#./}" in
+                           "$absbuilddir"/*)
+# find descended into build directory, don't copy
+                               continue
+                       esac
+               esac
+               mkdir -p ${mf%/*}
                cat <<EOF | $PYTHON -  > $mf
 print 'depth=' + ('../' * ( $d-1 ) )
 print 'include \$(depth)/config\$(if \$(conf),-\$(conf),).make'
@@ -416,7 +445,18 @@ print 'MODULE_INCLUDES += \$(src-dir)/\$(outbase)'
 EOF
            done
            for mf in `cd $srcdir ; find . -maxdepth $d -mindepth $d -name '*.make' | grep -v config.make `; do
-               mkdir -p $(dirname $mf)
+               case "$abssrcdir" in
+                   "$absbuilddir"/*)
+# source is below build directory, always copy
+                       ;;
+                   *)
+                       case "$abssrcdir/${mf#./}" in
+                           "$absbuilddir"/*)
+# find descended into build directory, don't copy
+                               continue
+                       esac
+               esac
+               mkdir -p ${mf%/*}
                cat <<EOF | $PYTHON -  > $mf
 print 'include \$(depth)/config\$(if \$(conf),-\$(conf),).make'
 print 'include \$(configure-srcdir)/$mf'
@@ -424,12 +464,13 @@ EOF
            done
        done
 
-       
+       rm -f GNUmakefile
        cat <<EOF > GNUmakefile
 depth = .
 include config\$(if \$(conf),-\$(conf),).make
 include \$(configure-srcdir)/GNUmakefile.in
 EOF
+       chmod 444 GNUmakefile
        AC_SUBST(VPATH)
     fi
 ])
@@ -494,13 +535,17 @@ EOF
         AC_MSG_RESULT($FLEXLEXER_FILE)
 ])
 
-AC_DEFUN(STEPMAKE_GCC, [
-    if test "$GCC" = "yes"; then
-        STEPMAKE_CHECK_VERSION(CC, $1, $2)
-    else
-       warn="$CC (Please install *GNU* cc)"
-       STEPMAKE_ADD_ENTRY($1, $warn)
+AC_DEFUN(STEPMAKE_GCC_OR_CLANG, [
+    STEPMAKE_HAS_CLANG()
+    if test "$HAS_CLANG" = "no"; then
+        if test "$GCC" = "yes"; then
+            STEPMAKE_CHECK_VERSION(CC, $1, $2)
+        else
+           warn="$CC (Please install *GNU* cc)"
+           STEPMAKE_ADD_ENTRY($1, $warn)
+        fi
     fi
+    # no else, we're fine with any clang
 ])
 
 AC_DEFUN(STEPMAKE_GETTEXT, [
@@ -517,8 +562,44 @@ AC_DEFUN(STEPMAKE_GETTEXT, [
 ])
 
 
+# Check for guile, between minimum ($2) and maximum version ($3).
+# If missing, add entry to missing-list ($1, one of 'OPTIONAL', 'REQUIRED')
 AC_DEFUN(STEPMAKE_GUILE, [
-    STEPMAKE_PATH_PROG(GUILE, guile, $1)
+    AC_MSG_CHECKING([for guile])
+    guile="guile"
+    found="no"
+    for r in $GUILE guile guile2 guile2.0 guile-2.0 guile1 guile1.9 guile1.8 guile-1 guile-1.9 guile-1.8; do
+       exe=`STEPMAKE_GET_EXECUTABLE($r)`
+       if ! $exe --version > /dev/null 2>&1 ; then
+           continue
+       fi
+       ver=`STEPMAKE_GET_VERSION($exe)`
+       num=`STEPMAKE_NUMERIC_VERSION($ver)`
+       req=`STEPMAKE_NUMERIC_VERSION($2)`
+       sup=`STEPMAKE_NUMERIC_VERSION($3)`
+       if test -n "$2" && test "$num" -lt "$req"; then
+           guile=["$r >= $2 (installed: $ver)"]
+           continue
+       else
+           if test -n "$3" && test "$num" -ge "$sup"; then
+               guile=["$r < $3 (installed: $ver)"]
+               continue
+           else
+               guile=$r
+               found=$r
+               break
+           fi
+       fi
+    done
+    AC_MSG_RESULT([$found])
+    if test "$found" != "no"; then
+       AC_MSG_CHECKING([$guile version])
+       AC_MSG_RESULT([$ver])
+       GUILE=$found
+    else
+       STEPMAKE_ADD_ENTRY($1, $guile)
+    fi
+    STEPMAKE_PATH_PROG(GUILE, $GUILE)
 ])
 
 
@@ -555,31 +636,45 @@ AC_DEFUN([STEPMAKE_GUILE_FLAGS], [
 ])
 
 
+# Check for guile-config, between minimum ($2) and maximum version ($3).
+# If missing, add entry to missing-list ($1, one of 'OPTIONAL', 'REQUIRED')
 AC_DEFUN(STEPMAKE_GUILE_DEVEL, [
     ## First, let's just see if we can find Guile at all.
     test -n "$target_alias" && target_guile_config=$target_alias-guile-config
     test -n "$host_alias" && host_guile_config=$host_alias-guile-config
     AC_MSG_CHECKING([for guile-config])
-    for guile_config in $GUILE_CONFIG $target_guile_config $host_guile_config $build_guile_config guile-config; do
-       AC_MSG_RESULT([$guile_config])
-       if ! $guile_config --version > /dev/null 2>&1 ; then
-           AC_MSG_WARN([cannot execute $guile_config])
-           AC_MSG_CHECKING([if we are cross compiling])
-           GUILE_CONFIG='echo no guile-config'
+    guile_config="guile-config"
+    found="no"
+    for r in $GUILE_CONFIG $target_guile_config $host_guile_config $build_guile_config guile-config guile2-config guile2.0-config guile-2.0-config guile1-config guile1.9-config guile1.8-config guile-1-config guile-1.9-config guile-1.8-config; do
+       exe=`STEPMAKE_GET_EXECUTABLE($r)`
+       if ! $exe --version > /dev/null 2>&1 ; then
+           continue
+       fi
+       ver=`STEPMAKE_GET_VERSION($exe)`
+       num=`STEPMAKE_NUMERIC_VERSION($ver)`
+       req=`STEPMAKE_NUMERIC_VERSION($2)`
+       sup=`STEPMAKE_NUMERIC_VERSION($3)`
+       if test -n "$2" -a "$num" -lt "$req"; then
+           guile_config=["$r >= $2 (installed: $ver)"]
+           continue
        else
-           GUILE_CONFIG=$guile_config
-           break
+           if test -n "$3" -a "$num" -ge "$sup"; then
+               guile_config=["$r < $3 (installed: $ver)"]
+               continue
+           else
+               guile_config=$r
+               found=$r
+               break
+           fi
        fi
     done
-    STEPMAKE_OPTIONAL_REQUIRED(GUILE_CONFIG, $guile_config, $1)
-    if test $? -ne 0; then
-        STEPMAKE_ADD_ENTRY($1, 'guile-config (guile-devel, guile-dev or libguile-dev package)')
-    fi 
-
-    STEPMAKE_CHECK_SEARCH_RESULT(GUILE_CONFIG)
-    # urg.  should test functionality rather than version.
-    if test $? -eq 0 -a -n "$2"; then
-       STEPMAKE_CHECK_VERSION(GUILE_CONFIG, $1, $2)
+    AC_MSG_RESULT([$found])
+    if test "$found" != "no"; then
+       AC_MSG_CHECKING([$guile_config version])
+       AC_MSG_RESULT([$ver])
+       GUILE_CONFIG=$found
+    else
+       STEPMAKE_ADD_ENTRY($1, "$guile_config (guile-devel, guile-dev or libguile-dev package) or guile1-config (guile1-devel package)")
     fi
 
     AC_SUBST(GUILE_CONFIG)
@@ -616,13 +711,25 @@ AC_DEFUN(STEPMAKE_DLOPEN, [
     AC_CHECK_FUNCS(dlopen)
 ])
 
-AC_DEFUN(STEPMAKE_GXX, [
-    if test "$GXX" = "yes"; then
-        STEPMAKE_CHECK_VERSION(CXX, $1, $2)
-    else
-       warn="$CXX (Please install *GNU* c++)"
-       STEPMAKE_ADD_ENTRY($1, $warn)
+AC_DEFUN(STEPMAKE_HAS_CLANG, [
+    AC_EGREP_CPP(yes,
+      [#ifdef __clang__
+       yes
+       #endif
+      ], HAS_CLANG=yes, HAS_CLANG=no)
+])
+
+AC_DEFUN(STEPMAKE_GXX_OR_CLANG, [
+    STEPMAKE_HAS_CLANG()
+    if test "$HAS_CLANG" = "no"; then
+        if test "$GXX" = "yes"; then
+            STEPMAKE_CHECK_VERSION(CXX, $1, $2)
+        else
+           warn="$CXX (Please install *GNU* c++)"
+           STEPMAKE_ADD_ENTRY($1, $warn)
+        fi
     fi
+    # no else, we're fine with any clang
 ])
 
 
@@ -778,7 +885,7 @@ AC_DEFUN(STEPMAKE_INIT, [
     fi
     AC_SUBST(SHELL)
 
-    STEPMAKE_PYTHON(REQUIRED, 1.5)
+    STEPMAKE_PYTHON(REQUIRED, 1.5, 3.0)
 
     if expr "$MAKE" : '.*\(echo\)' >/dev/null; then
        $MAKE -v 2> /dev/null | grep GNU > /dev/null
@@ -899,7 +1006,7 @@ AC_DEFUN(STEPMAKE_PATH_PROG, [
     AC_CHECK_PROGS($1, $2, no)
     STEPMAKE_OPTIONAL_REQUIRED($1, $2, $3)
     if test $? -eq 0; then
-       AC_PATH_PROG($1, $2)
+       AC_PATH_PROGS($1, $2)
        if test -n "$4"; then
            STEPMAKE_CHECK_VERSION($1, $3, $4)
        fi
@@ -924,33 +1031,49 @@ AC_DEFUN(STEPMAKE_PERL, [
 ])
 
 
+# Check for python, between minimum ($2) and maximum version ($3).
+# If missing, add entry to missing-list ($1, one of 'OPTIONAL', 'REQUIRED')
 AC_DEFUN(STEPMAKE_PYTHON, [
-    unset pv
     AC_MSG_CHECKING([for python])
-    for python in $PYTHON python python2 python2.4 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'
+    python="python"
+    found="no"
+    for r in $PYTHON python python3 python3.3 python3.2 python3.1 python3.0 python2 python2.7 python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0; do
+       exe=`STEPMAKE_GET_EXECUTABLE($r)`
+       if ! $exe -V > /dev/null 2>&1 ; then
+           continue
+       fi
+       ver=`STEPMAKE_GET_VERSION($exe)`
+       num=`STEPMAKE_NUMERIC_VERSION($ver)`
+       req=`STEPMAKE_NUMERIC_VERSION($2)`
+       sup=`STEPMAKE_NUMERIC_VERSION($3)`
+       if test -n "$2" && test "$num" -lt "$req"; then
+           python=["$r >= $2 (installed: $ver)"]
+           continue
        else
-           unset pv
-           STEPMAKE_CHECK_VERSION(python, pv, $2)
-           if test -z "$pv"; then
-               PYTHON=$python
+           if test -n "$3" && test "$num" -ge "$sup"; then
+               python=["$r < $3 (installed: $ver)"]
+               continue
+           else
+               python=$r
+               found=$r
                break
            fi
        fi
     done
-    if test -n "$pv"; then
-       STEPMAKE_ADD_ENTRY($1, $pv)
+    AC_MSG_RESULT([$found])
+    if test "$found" != "no"; then
+       AC_MSG_CHECKING([$python version])
+       AC_MSG_RESULT([$ver])
+       PYTHON=$found
+    else
+       STEPMAKE_ADD_ENTRY($1, $python)
     fi
-    # clear cached value since arg 2 might point us to a new binary
-    unset ac_cv_path_PYTHON
-
     AC_PATH_PROG(PYTHON, $PYTHON)
     AC_SUBST(PYTHON)
 ])
 
+# Check for python-config, between minimum ($2) and maximum version ($3).
+# If missing, add entry to missing-list ($1, one of 'OPTIONAL', 'REQUIRED')
 AC_DEFUN(STEPMAKE_PYTHON_DEVEL, [
     AC_ARG_WITH(python-include,
        [AS_HELP_STRING([--with-python-include=DIR],
@@ -971,14 +1094,19 @@ AC_DEFUN(STEPMAKE_PYTHON_DEVEL, [
            LDFLAGS="$LDFLAGS -l${withval}"
        fi
     ])
-    
-    AC_CHECK_PROGS(PYTHON_CONFIG, python-config, no)
+
+    STEPMAKE_PYTHON($1, $2, $3)
+    AC_CHECK_PROGS(PYTHON_CONFIG, `basename $PYTHON`-config, no)
 
     if test -z "$PYTHON_CFLAGS" -a "$PYTHON_CONFIG" != "no"; then
         # Clean out junk: http://bugs.python.org/issue3290
        # Python headers may need some -f* flags, leave them in.
        # We want the sed commands to look like 's/-[WDOm][[:alnum:][:punct:]][[:alnum:][:punct:]]*//g' and 's/-arch [^[:space:]]*//g', but automake eats brackets.
-       PYTHON_CFLAGS=`$PYTHON_CONFIG --cflags | sed -e 's/-[[WDOm]][[[:alnum:][:punct:]]][[[:alnum:][:punct:]]]*//g' | sed -e 's/-arch @<:@^@<:@:space:@:>@@:>@*//g'`
+        #PYTHON_CFLAGS=`$PYTHON_CONFIG --cflags | sed -e 's/-[[WDOm]][[[:alnum:][:punct:]]][[[:alnum:][:punct:]]]*//g' | sed -e 's/-arch @<:@^@<:@:space:@:>@@:>@*//g'`
+        # The above sed BRE matches parts of legal options, stipping down part of that option, resulting in invalid gcc arguments. Gentoo Bug #415793
+        # For instance, '-floop-stip-mime' becomes '-floop-strip', and '-fvect-cost-model' becomes '-fvect-cost'.
+        # Tentative fix to require a non alphanumeric character before the initial hyphen of the BRE or the hyphen being the first character in the string.
+        PYTHON_CFLAGS=`$PYTHON_CONFIG --cflags | sed -e 's/\(^\|[[^[:alnum:]]]\)-[[WDOm]][[[:alnum:][:punct:]]][[[:alnum:][:punct:]]]*//g' | sed -e 's/-arch @<:@^@<:@:space:@:>@@:>@*//g'`
        PYTHON_LDFLAGS=`$PYTHON_CONFIG --ldflags`
     fi
     
@@ -1022,13 +1150,31 @@ void *p = v.data ();
 
 
 AC_DEFUN(STEPMAKE_TEXMF_DIRS, [
-    # ugh
-    STEPMAKE_PROGS(KPSEWHICH, kpsewhich, OPTIONAL)
+    STEPMAKE_PROGS(KPSEWHICH, kpsewhich, $1)
+
+    AC_MSG_CHECKING(for metapost required files)
+    if test "$MFPLAIN_MP" = ""; then
+        MFPLAIN_MP=`kpsewhich -format=mp mfplain`
+    fi
+    if test "$MFPLAIN_MP" = ""; then
+        AC_MSG_RESULT(no)
+        STEPMAKE_ADD_ENTRY($1,['metapost CTAN package (texlive-metapost)'])
+    else
+        AC_MSG_RESULT(yes)
+    fi
 ])
 
 AC_DEFUN(STEPMAKE_TEXMF, [
     STEPMAKE_PROGS(METAFONT, mf-nowin mf mfw mfont, $1)
     STEPMAKE_PROGS(METAPOST, mpost, $1)
+    if test "$METAPOST" != ""; then
+       ver=`STEPMAKE_GET_VERSION($METAPOST)`
+       num=`STEPMAKE_NUMERIC_VERSION($ver)`
+       # Avoid buggy metapost versions: 1.600 <= x < 1.803
+       if test "$num" -ge "1600000" -a "$num" -lt "1803000"; then
+            STEPMAKE_ADD_ENTRY($1, ["mpost (due to a bug in metapost, versions 1.600 <= x < 1.803 are not supported; installed: $ver)"])
+       fi
+    fi
 
     AC_MSG_CHECKING(for working metafont mode)
     modelist='ljfour lj4 lj3 lj2 ljet laserjet'