dnl configuration script for gerbv
dnl
dnl  gEDA - GNU Electronic Design Automation
dnl  This file is part of gerbv.
dnl
dnl    Copyright (C) 2000-2001 Stefan Petersen (spe@stacken.kth.se)
dnl
dnl  $Id: configure.in,v 1.10 2002/02/10 13:40:49 spetm Exp $
dnl
dnl  This program is free software; you can redistribute it and/or modify
dnl  it under the terms of the GNU General Public License as published by
dnl  the Free Software Foundation; either version 2 of the License, or
dnl  (at your option) any later version.
dnl
dnl  This program 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
dnl  GNU General Public License for more details.
dnl
dnl  You should have received a copy of the GNU General Public License
dnl  along with this program; if not, write to the Free Software
dnl  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA


AC_INIT(src/gerbv.c)

dnl variables
PACKAGE=gerbv
VERSION=0.0.7

dnl --disable-batch : turn off guile/batch support
AC_ARG_ENABLE(batch,
    [  --disable-batch        Disable batch support (ie no Guile).],
    [
        if test $enableval = "no"; then
                no_guile=yes
		AC_DEFINE(NO_GUILE)
        fi
    ])

dnl --with-backend-dir : tells where to store global backends if != default
AC_ARG_WITH(backend-dir,
    [  --with-backend-dir     Where to store backends if != default.],
	opt_backend_dir=$withval)

dnl Initialize automake stuff (?)
AM_INIT_AUTOMAKE($PACKAGE, $VERSION, no-define)

dnl Create a configuration header 
AM_CONFIG_HEADER(config.h)

dnl Build time sanity check... (?)
AM_SANITY_CHECK

dnl Initialize maintainer mode (?)
AM_MAINTAINER_MODE

dnl Checks for programs.
AC_PROG_CC
AC_PROG_MAKE_SET
AC_PROG_INSTALL
AC_ARG_PROGRAM

dnl Guile stuff
if test "$no_guile" = "yes" ; then
	echo Disabling Guile
	GUILE_CFLAGS=
	GUILE_LDFLAGS=
else
	GUILE_FLAGS

	dnl Check that scm_make_real exist
	AC_CHECK_LIB(guile, scm_make_real,,
        AC_MSG_ERROR(**Upgrade Guile**  At least version >= 1.4), 
	$GUILE_LDFLAGS)
	
	dnl Restore LIBS. Apperantly AC_CHECK_LIB destroys it.
	LIBS="$ac_save_LIBS"
fi

dnl GTK+ stuff
AM_PATH_GTK(1.2.3, ,AC_MSG_ERROR([*** GTK+ >= 1.2.3 not installed - please install first ***]))

dnl Why do I have to set prefix?
if eval "test x$prefix = xNONE"; then
	prefix=$ac_default_prefix
fi

dnl This is because I can unquote only once. Should be $datadir/gerbv/scheme
if test -z "$opt_backend_dir"; then
    if eval "test $datadir = '${prefix}/share'"; then
       opt_backend_dir="$prefix/share/gerbv/scheme"
    else
       opt_backend_dir="$datadir/gerbv/scheme"
    fi
fi

AC_DEFINE_UNQUOTED(BACKEND_DIR, "$opt_backend_dir")
BACKEND_DIR="$opt_backend_dir"

AC_DEFINE_UNQUOTED(VERSION, "$VERSION")

AC_CHECK_HEADERS(unistd.h getopt.h string.h)

AC_CHECK_FUNCS(getopt_long)

AC_SUBST(CC)
AC_SUBST(VERSION)

AC_SUBST(GTK_CFLAGS)
AC_SUBST(GTK_CONFIG)
AC_SUBST(GTK_LIBS)

AC_SUBST(GUILE_CFLAGS)
AC_SUBST(GUILE_LDFLAGS)

AC_SUBST(BACKEND_DIR)

AC_OUTPUT(	Makefile \
		src/Makefile \
		man/Makefile \
		scheme/Makefile)

