# GNU Solfege - ear training for GNOME
# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005  Tom Cato Amundsen
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

# Process this file with autoconf to produce a configure script.

AC_INIT([GNU Solfege],[2.2.0],[bug-solfege@gnu.org])
AC_CONFIG_HEADER(config.h)

PACKAGE=solfege
AC_SUBST(PACKAGE)

MAJOR_VERSION=2
MINOR_VERSION=2
PATCH_LEVEL=0
VERSION=2.2.0

AC_SUBST(MAJOR_VERSION)
AC_SUBST(MINOR_VERSION)
AC_SUBST(PATCH_LEVEL)
AC_SUBST(VERSION)

AC_PROG_CC

AC_ARG_WITH(local-xmlcatalog, AC_HELP_STRING([--with-local-xmlcatalog],
  [Use the xml catalog file supplied with Solfege. Use this option if there
   are no catalog file on you system and you have no network while building.
   You might have to edit online-docs/stupid_catalog_file.cat to make it fit you system.]),
   [WITH_LOCAL_XMLCATALOG=$withval],
   [WITH_LOCAL_XMLCATALOG=no])
AC_SUBST(WITH_LOCAL_XMLCATALOG)

AM_PATH_PYTHON(2.3)
AM_CHECK_PYTHON_HEADERS(HAVE_PYTHON_H="yes", HAVE_PYTHON_H="no")

AC_PROG_INSTALL
AC_PROG_MAKE_SET

dnl Check for programs

MY_PATH_PROG(M4, m4, [You need to install m4.])
MY_PATH_PROG(XGETTEXT, xgettext, [You need to install the gettext.])
MY_PATH_PROG(MSGFMT, msgfmt, [You need to install the gettext.])
MY_PATH_PROG(MSGMERGE, msgmerge, [You need to install the gettext.])
MY_PATH_PROG(MAKEINFO, makeinfo [You need to install the texinfo.])
MY_PATH_PROG(SED, sed)
MY_PATH_PROG(CAT, cat)

AC_ARG_ENABLE(pygtk-test, AC_HELP_STRING([--disable-pygtk-test],
    [Don't test for PyGTK, assume it is installed]),
    run_pygtk_test=$enableval,
    run_pygtk_test=yes)

if test x"$run_pygtk_test" = xyes; then
  PKG_CHECK_MODULES(PYGTK, pygtk-2.0 >= 2.0.0)
fi

AC_ARG_WITH(gnome, AC_HELP_STRING([--without-gnome],
    [build Solfege without GNOME support]),
    WITH_GNOME=$withval,
    WITH_GNOME=yes)
AC_SUBST(WITH_GNOME)

AC_ARG_ENABLE(pygnome-test, AC_HELP_STRING([--disable-pygnome-test],
    [Don't test for gnome-python, assume it is installed]),
    run_pygnome_test=$enableval,
    run_pygnome_test=yes)

if test x"$run_pygnome_test" = xyes; then
 if test x"$WITH_GNOME" = xyes; then
 PKG_CHECK_MODULES(GNOMEPYTHON, gnxome-python-2.0 >= 2.0.0,
     have_gnomepython=yes, 
     have_gnomepython=no)
 fi
else
 have_gnomepython=yes
fi

AC_ARG_ENABLE(oss-sound, AC_HELP_STRING([--disable-oss-sound],
    [Do not build module for OSS sound. Use this if you OS don't support OSS]),
    [ENABLE_OSS_SOUND=$enableval],
    [ENABLE_OSS_SOUND=yes])
AC_SUBST(ENABLE_OSS_SOUND)

AC_ARG_ENABLE(tuner, AC_HELP_STRING([--enable-tuner],
    [the microphone experiment (default: disable). This code is dead, it
     does not work.]),
    [ENABLE_TUNER=$enableval],
    [ENABLE_TUNER=no])
AC_SUBST(ENABLE_TUNER)

dnl Checks for libraries.
if test x"$ENABLE_TUNER" = x"yes"; then
    AC_DEFINE(ENABLE_TUNER)
    AC_CHECK_LIB(rfftw, rfftw, [
        AC_DEFINE(HAVE_FFTW)
        LIBS="$LIBS -lfftw -lrfftw"], ,-lfftw)
fi

AC_ARG_WITH(gtkhtml, AC_HELP_STRING([--without-gtkhtml],
    [build the application to run without gtkhtml2.]),
    WITH_GTKHTML=$withval,
    WITH_GTKHTML=yes)
AC_SUBST(WITH_GTKHTML)

if test x"$WITH_GTKHTML" = x"yes"; then
  PKG_CHECK_MODULES(GTKHTML2, libgtkhtml-2.0 >= 1.99.9,
      HAVE_GTKHTML="yes",
      HAVE_GTKHTML="no")
  if test x"$HAVE_GTKHTML" = x"no"; then
   AC_MSG_ERROR([
**** You said --with-gtkhtml, but configure cannot find gtkhtml-2
**** Run ./configure with --without-gtkhtml if you don't have gtkhtml2
**** and its devel files installed.
   ])
  fi
  AC_SUBST(HAVE_GTKHTML)
fi

dnl  If we use --without-gnome, we cannot use gtkhtml, even if it is installed.
dnl if test x"$WITH_GNOME" = x"no"; then
dnl         WITH_GTKHTML=no
dnl fi

dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS(fcntl.h sys/ioctl.h unistd.h)

if test x$ENABLE_OSS_SOUND = "xyes"; then
  if test x$HAVE_PYTHON_H = "xno"; then      
        AC_MSG_ERROR([
*** We need the python header files to build the OSS sound module.
*** The debian package is called python-dev, other distributions
*** probably have a similar name.])
  fi
fi
AC_CHECK_HEADERS(linux/awe_voice.h, [HAVE_LINUX_AWE_VOICE_H="yes"])
AC_SUBST(HAVE_LINUX_AWE_VOICE_H)


dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST

dnl Checks for library functions.
AC_PROG_GCC_TRADITIONAL
#AC_CONFIG_FILES

$CAT run-solfege.py.in | $SED "s/@VERSION@//" > debian-solfege.py.in

AC_CONFIG_FILES([
	 run-solfege.py debian-solfege.py src/configureoutput.py
         topdocs/defs.texi
         online-docs/texidefinitions.m4
         windowsinstaller.iss
         Makefile
         lessonfile_editor.py
         solfege.redhat8.spec solfege.redhat9.spec solfege.suse82.spec
         solfege.suse9.spec])
AC_OUTPUT

