dnl    This file is part of the KDE libraries/packages
dnl    Copyright (C) 2001 Stephan Kulow (coolo@kde.org)
 
dnl    This file is free software; you can redistribute it and/or
dnl    modify it under the terms of the GNU Library General Public
dnl    License as published by the Free Software Foundation; either
dnl    version 2 of the License, or (at your option) any later version.
 
dnl    This library is distributed in the hope that it will be useful,
dnl    but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
dnl    Library General Public License for more details.
 
dnl    You should have received a copy of the GNU Library General Public License
dnl    along with this library; see the file COPYING.LIB.  If not, write to
dnl    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
dnl    Boston, MA 02111-1307, USA.

# Original Author was Kalle@kde.org
# I lifted it in some mater. (Stephan Kulow)
# I used much code from Janos Farkas

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

AC_INIT(acinclude.m4) dnl a source file from your sub dir

dnl This is so we can use kde-common
AC_CONFIG_AUX_DIR(admin)

dnl This ksh/zsh feature conflicts with `cd blah ; pwd`
unset CDPATH

dnl Checking host/target/build systems, for make, install etc.
AC_CANONICAL_SYSTEM 
dnl Perform program name transformation
AC_ARG_PROGRAM

dnl Automake doc recommends to do this only here. (Janos)
AM_INIT_AUTOMAKE(kmusic, "2.91") dnl searches for some needed programs

KDE_SET_PREFIX

dnl generate the config header
AM_CONFIG_HEADER(config.h) dnl at the distribution this done

dnl Checks for programs.
AC_CHECK_COMPILERS
AC_ENABLE_SHARED(yes)
AC_ENABLE_STATIC(no)
KDE_PROG_LIBTOOL

dnl for NLS support. Call them in this order!
dnl WITH_NLS is for the po files
AM_KDE_WITH_NLS

dnl KDE_USE_QT
AC_PATH_KDE
#MIN_CONFIG

DO_NOT_COMPILE="$DO_NOT_COMPILE ksynth mediatool"

dnl Checks for header files.
AC_HEADER_DIRENT
AC_HEADER_STDC
AC_CHECK_HEADERS(fcntl.h sys/time.h unistd.h linux/awe_voice.h awe_voice.h /usr/src/sys/i386/isa/sound/awe_voice.h /usr/src/sys/gnu/i386/isa/sound/awe_voice.h linux/ucdrom.h sys/stdtypes.h sys/filio.h sys/audioio.h Alib.h sys/sem.h string.h getopt.h machine/endian.h sys/awe_voice.h)
AC_CHECK_FUNCS(usleep snprintf)

dnl check whether user wants to use ALSA
AC_ARG_WITH(alsa, [  --with-alsa             use an alternative driver for GUS],
[
   if test $withval = "yes"; then
     kde_with_alsa=yes
   else
     kde_with_alsa=no
  fi
], kde_with_alsa=no)

dnl only use ALSA when sys/soundlib.h is found
if test "$ac_header_sys_soundlib_h" = "no"; then
  kde_with_alsa=no
fi

dnl and libasound is present
if test "$kde_with_alsa" = "yes"; then
  AC_CHECK_LIB(asound,snd_seq_create_simple_port,
               LIBASOUND="-lasound",kde_with_alsa=no)
fi
AC_SUBST(LIBASOUND)

if test "$kde_with_alsa" = "yes"; then
  AC_DEFINE(HAVE_ALSA, 1, [Define if you have Alsa support])
fi

dnl Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_TIME
CXXFLAGS="$CXXFLAGS -DQT_CLEAN_NAMESPACE"

dnl libltdl: we have our own copy in kmusic. To quote Coolo:
dnl
dnl The maintainers of libltdl don't want installed versions of libltdl, to
dnl avoid clashes with system libraries. Besides, the version KDE uses is
dnl practically unreleased.
ac_configure_args="$ac_configure_args --enable-ltdl-convenience"
AC_CONFIG_SUBDIRS(libltdl)
AM_PATH_GLIB(1.2.0)

dnl check whether we have arts/common.h and arts/artsmidi.h installed
AC_DEFUN(AC_CHECK_ARTS_HEADERS,
[
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
ac_cppflags_safe="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS -I$kde_includes"

AC_CHECK_HEADER(arts/common.h, [], [
AC_MSG_ERROR([
aRts development headers not found (missing include file arts/common.h).

Please ensure that the aRts development headers are installed. If you have
installed aRts as binary package, they are usually found in a development
package, which is called arts-dev, libarts-dev or similar.
])
])

AC_CHECK_HEADER(arts/artsmidi.h, [], [
AC_MSG_ERROR([
aRts extra development headers not found (missing include file arts/artsmidi.h).

Please ensure that the aRts extra development headers are installed. If you
installed kdemultimedia as binary package, they are usually found in a
development package called kdemultimedia-dev or similar.
])
])

CPPFLAGS="$ac_cppflags_safe"
AC_LANG_RESTORE
])

dnl check whether we have aRts environments
AC_DEFUN(AC_CHECK_ARTS_ENVIRONMENT,
[
AC_MSG_CHECKING([for Arts::Environment support in aRts])

AC_LANG_SAVE
AC_LANG_CPLUSPLUS
ac_cxxflags_safe="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS -I$kde_includes"

AC_CACHE_VAL(ac_cv_have_arts_environment,
[
AC_TRY_COMPILE([
#include <arts/artsmodules.h>
],
[
Arts::Environment::Container container;
],
ac_cv_have_arts_environment=yes,
ac_cv_have_arts_environment=no)
])

CXXFLAGS="$ac_cxxflags_safe"

AC_MSG_RESULT($ac_cv_have_arts_environment)
if eval "test \"`echo `$ac_cv_have_arts_environment\" = yes"; then
  AC_DEFINE(HAVE_ARTS_ENVIRONMENT,1,
        [Define if your aRts has Arts::Environment support (>= aRts-0.7.0)])
fi
])

AC_CHECK_ARTS_HEADERS
AC_CHECK_ARTS_ENVIRONMENT
KDE_CREATE_SUBDIRSLIST
AC_OUTPUT( \
./Makefile \
brahms/Makefile \
brahms/addons/Makefile \
brahms/addons/Debug/Makefile \
brahms/addons/Dump/Makefile \
brahms/addons/EarTraining/Makefile \
brahms/addons/ExtractLyrics/Makefile \
brahms/addons/FixedLength/Makefile \
brahms/addons/Parallels/Makefile \
brahms/addons/QuantizeAll/Makefile \
brahms/addons/QuantizeLength/Makefile \
brahms/addons/Riemann/Makefile \
brahms/addons/Stretch/Makefile \
brahms/addons/Tex/Makefile \
brahms/arts/Makefile \
brahms/core/Makefile \
brahms/pics/Makefile \
brahms/presentations/Makefile \
brahms/presentations/kde/Makefile \
brahms/presentations/text/Makefile \
doc/Makefile \
doc/brahms/Makefile \
doc/ksynth/Makefile \
doc/ksynth/images/Makefile \
)
