dnl Process this file with autoconf to produce a configure script.
#
# THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY
# PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
# TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX
# INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 
# DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 
# THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 
# EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A
# FULL TEXT OF THE NON-WARRANTY PROVISIONS.  
#
# USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
# RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
# TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013,
# AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
# SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
# THE UNITED STATES.  
#
# COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
#
# $Revision$
# $Date$
#
AC_INIT(h5/glide3/src/glfb.c)
AM_INIT_AUTOMAKE(glide, 3.0)
AM_CONFIG_HEADER(swlibs/include/config.h)
AC_PREFIX_DEFAULT([/usr])
includedir='${prefix}/include/glide3'
#
# Variables local to the build.
#
FX_HW_PROJECTS=glide3
AC_SUBST(FX_HW_PROJECTS)
#
# --enable-fx-glide-hw chooses which ASIC to build for.
#
AC_ARG_ENABLE([fx-glide-hw],
              [dnl
  --enable-fx-glide-hw=ASIC   Build for the given ASIC
                                h5: VoodooV
                                h3: Voodoo3
                                cvg: Voodoo2
                                [default=h5]],
            [case ${enableval} in
             h3|h5|cvg)
                 FX_GLIDE_HW="${enableval}"
                 ;;
            *)
                 AC_MSG_ERROR([Illegal value ($enable_fx_glide_hw) for --enable-fx-glide-hw])
                 ;;
            esac],[FX_GLIDE_HW=h5])
AC_SUBST(FX_GLIDE_HW)
#
# --enable-fx-dri-build chooses to build with or without DRI.
#
AC_ARG_ENABLE([fx-dri-build],
              [dnl
  --enable-fx-build-dri       Build for DRI. [default=yes]],
              [case ${enableval} in
               true|yes)
                   DRI_BUILD=true
                   ;;
               false|no)
                   DRI_BUILD=false
                   ;;
               *)
                   AC_MSG_ERROR([Illegal value (${enableval}) for --enable-fx-build-dri])
                   ;;
               esac],[DRI_BUILD=true])
AM_CONDITIONAL(DRI_BUILD,test x$DRI_BUILD = xtrue)
AC_SUBST(DRI_BUILD)
#
# This is makefile.linux behavior.  I don't know exactly
# what this does.
#
AM_CONDITIONAL(HAL_HW, test "$FX_GLIDE_HW"=cvg && test ! -z "$HAL_HW")
#
# Define debugging
#
AC_ARG_ENABLE([fx-debug],
              [dnl
  --enable-fx-debug           Enable a debugging glide build [default=no]],
              [case ${enableval} in
               true|yes)
                   GLIDE_DEBUG=true
                   ;;
               false|no)
                   GLIDE_DEBUG=false
                   ;;
               *)
                   AC_MSG_ERROR([Illegal value (${enableval}) for --enable-fx-debug])
                   ;;
               esac],[GLIDE_DEBUG=false])
AM_CONDITIONAL(GLIDE_DEBUG,test x$GLIDE_DEBUG = xtrue)
AC_SUBST(GLIDE_DEBUG)
#
# Define --enable-amd3d
#
AC_ARG_ENABLE([amd3d],
              [dnl
  --enable-amd3d              Enable AMD 3DNow instructions [default=no]],
              [case ${enableval} in
               true|yes)
                   enable_amd3d=true
                   ;;
               false|no)
                   enable_amd3d=false
                   ;;
               *)
                   AC_MSG_ERROR([Illegal value (${enableval}) for --enable-amd3d])
                   ;;
               esac],[enable_amd3d=false])
AM_CONDITIONAL(GL_AMD3D,     test x$enable_amd3d = xtrue)
#
# --enable-fx-texlib=texus2 enables new texus library.
#
AC_ARG_ENABLE([fx-texlib],
              [dnl
  --enable-fx-tex=dir         Enable enhanced texture utilities library
                                texus  - original library
                                texus2 - library for compressed textures
                                [default=texus2]],
              [case ${enableval} in
               texus|texus2)
                   TEXTURE_UTILITIES_DIR=${enableval}
                   ;;
               *)
                   AC_MSG_ERROR([Illegal value (${enableval}) for --enable-fx-texus])
                   ;;
               esac],[TEXTURE_UTILITIES_DIR=texus2])
AC_SUBST(TEXTURE_UTILITIES_DIR)
#
# These are conditional variables whose value is set by
# one of the other enable macros.
#
AM_CONDITIONAL(FX_GLIDE_H3,  test x$FX_GLIDE_HW = xh3)
AM_CONDITIONAL(FX_GLIDE_H5,  test x$FX_GLIDE_HW = xh5)
AM_CONDITIONAL(FX_GLIDE_CVG, test x$FX_GLIDE_HW = xcvg)
#
# Architecture
#
AC_ARG_ENABLE([build-architecture],
              [dnl
  --enable-build-architecture Enable AMD 3DNow instructions [default=current]],
              [case ${enableval} in
               i[3456]86|alpha)
                   FX_GLIDE_BUILD_ARCHITECTURE=${enableval}
                   ;;
               *)
                   AC_MSG_ERROR([Illegal value (${enableval}) for --enable-build-architecture])
                   ;;
               esac],[FX_GLIDE_BUILD_ARCHITECTURE=`uname -m`])
AC_SUBST(FX_GLIDE_BUILD_ARCHITECTURE)
#
# Various tests needed at points in the build
# First, we set defaults.
#
FX_GLIDE_PACKET_FIFO=true
FX_GLIDE3=true
FX_GLIDE_PACKET_FIFO=true
FX_GLIDE_SW_SETUP=false
FX_CHRIS_DENIS_ANTHONY_HACK=false
FX_GLIDE_ALT_TAB=false
FX_GLIDE_DIRECT_WRITE=false
HAL_CSIM=false
FX_GLIDE_NO_FIFO=false
FX_GLIDE_DEBUG_FIFO=false
FX_GLIDE_NO_PLUG=false
FX_GLIDE_NO_SPLASH=false
GLIDE_SANITY_ALL=false
GLIDE_SANITY_SIZE=false
FX_DLL_BUILD=false
FX_GLIDE_HW_CULL=false
FX_GLIDE_CTRISETUP=false
# Next, we read some configuration options
# statically.  This is to avoid creating a bunch of
# not-terribly-useful --enable options.
#
if test -f $srcdir/swlibs/include/make/3dfx.config.sh  ; then
    . $srcdir/swlibs/include/make/3dfx.config.sh
fi
AM_CONDITIONAL(FX_GLIDE3,
               test x$FX_GLIDE3 = xtrue)
AM_CONDITIONAL(FX_CHRIS_DENIS_ANTHONY_HACK,dnl
               test x$FX_CHRIS_DENIS_ANTHONY_HACK = xtrue)
AM_CONDITIONAL(FX_GLIDE_ALT_TAB,dnl
               test x$FX_GLIDE_ALT_TAB = xtrue)
AM_CONDITIONAL(FX_GLIDE_DIRECT_WRITE,dnl
               test x$FX_GLIDE_DIRECT_WRITE = xtrue)
AM_CONDITIONAL(HAL_CSIM,dnl
               test x$HAL_CSIM = xtrue)
AM_CONDITIONAL(FX_GLIDE_SW_SETUP,dnl
               test x$FX_GLIDE_SW_SETUP = xtrue)
AM_CONDITIONAL(FX_GLIDE_NO_FIFO,dnl
               test x$FX_GLIDE_NO_FIFO = xtrue)
AM_CONDITIONAL(FX_GLIDE_DEBUG_FIFO,dnl
               test x$FX_GLIDE_DEBUG_FIFO = xtrue)
AM_CONDITIONAL(FX_GLIDE_NO_PLUG,dnl
               test x$FX_GLIDE_NO_PLUG = xtrue)
AM_CONDITIONAL(FX_GLIDE_NO_SPLASH,dnl
               test x$FX_GLIDE_NO_SPLASH = xtrue)
AM_CONDITIONAL(GLIDE_SANITY_ALL,dnl
               test x$GLIDE_SANITY_ALL = xtrue)
AM_CONDITIONAL(GLIDE_SANITY_SIZE,dnl
               test x$GLIDE_SANITY_SIZE = xtrue)
AM_CONDITIONAL(FX_DLL_BUILD,dnl
               test x$FX_DLL_BUILD = xtrue)
AM_CONDITIONAL(FX_GLIDE_HW_CULL,dnl
               test x$FX_GLIDE_HW_CULL = xtrue)
AM_CONDITIONAL(FX_GLIDE_CTRISETUP,dnl
               test x$FX_GLIDE_CTRISETUP = xtrue)
AM_CONDITIONAL(FX_GLIDE_PACKET_FIFO,dnl
               test x$FX_GLIDE_PACKET_FIFO = xtrue)
AM_CONDITIONAL(FX_GLIDE_VERTEX_TABLE,dnl
               test x$FX_GLIDE_VERTEX_TABLE = xtrue)
AM_CONDITIONAL(FX_HOOPTI_TRI_SETUP_COMPARE,dnl
               test x$FX_HOOPTI_TRI_SETUP_COMPARE = xtrue)

dnl Checks for programs.
AC_PROG_CC
AC_PROG_CPP
AC_CHECK_TOOL(AS, as, false)
AC_CHECK_TOOL(OBJDUMP, objdump, false)
AC_CHECK_TOOL(DLLTOOL, dlltool, false)
AC_CHECK_TOOL(CP, cp, false)
AC_PROG_INSTALL
AM_PROG_LIBTOOL
MAKE="make -f makefile.autoconf"
AC_SUBST(MAKE)
dnl Checks for libraries.

dnl Checks for header files.
AC_PATH_X
AC_HEADER_DIRENT
AC_HEADER_STDC
AC_CHECK_HEADERS(fcntl.h limits.h malloc.h sys/ioctl.h sys/time.h unistd.h)

dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_INLINE
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_HEADER_TIME
AC_STRUCT_TM

dnl Checks for library functions.
AC_PROG_GCC_TRADITIONAL
AC_FUNC_MEMCMP
AC_FUNC_MMAP
AC_FUNC_VPRINTF
AC_CHECK_FUNCS(ftime gethostname select strcspn strdup strstr strtoul)

dnl
dnl This is complicated perhaps.  We create a makefile by concatenating
dnl the two files:
dnl     o $makefile.in
dnl     o swlibs/include/make/makefile.autoconf.bottom
dnl where $makefile is the makefile name.
dnl
AC_OUTPUT(build.3dfx
          makefile.autoconf:makefile.autoconf.in:swlibs/include/make/makefile.autoconf.bottom
          cvg/makefile.autoconf:cvg/makefile.autoconf.in:swlibs/include/make/makefile.autoconf.bottom
          cvg/incsrc/makefile.autoconf:cvg/incsrc/makefile.autoconf.in:swlibs/include/make/makefile.autoconf.bottom
          cvg/init/makefile.autoconf:cvg/init/makefile.autoconf.in:swlibs/include/make/makefile.autoconf.bottom
          cvg/glide3/makefile.autoconf:cvg/glide3/makefile.autoconf.in:swlibs/include/make/makefile.autoconf.bottom
          cvg/glide3/src/makefile.autoconf:cvg/glide3/src/makefile.autoconf.in:swlibs/include/make/makefile.autoconf.bottom
          h3/makefile.autoconf:h3/makefile.autoconf.in:swlibs/include/make/makefile.autoconf.bottom
          h3/incsrc/makefile.autoconf:h3/incsrc/makefile.autoconf.in:swlibs/include/make/makefile.autoconf.bottom
          h3/minihwc/makefile.autoconf:h3/minihwc/makefile.autoconf.in:swlibs/include/make/makefile.autoconf.bottom
          h3/glide3/makefile.autoconf:h3/glide3/makefile.autoconf.in:swlibs/include/make/makefile.autoconf.bottom
          h3/glide3/src/makefile.autoconf:h3/glide3/src/makefile.autoconf.in:swlibs/include/make/makefile.autoconf.bottom
          h5/makefile.autoconf:h5/makefile.autoconf.in:swlibs/include/make/makefile.autoconf.bottom
          h5/glide3/makefile.autoconf:h5/glide3/makefile.autoconf.in:swlibs/include/make/makefile.autoconf.bottom
          h5/glide3/src/makefile.autoconf:h5/glide3/src/makefile.autoconf.in:swlibs/include/make/makefile.autoconf.bottom
          h5/incsrc/makefile.autoconf:h5/incsrc/makefile.autoconf.in:swlibs/include/make/makefile.autoconf.bottom
          h5/minihwc/makefile.autoconf:h5/minihwc/makefile.autoconf.in:swlibs/include/make/makefile.autoconf.bottom
          swlibs/makefile.autoconf:swlibs/makefile.autoconf.in:swlibs/include/make/makefile.autoconf.bottom
          swlibs/fxmisc/makefile.autoconf:swlibs/fxmisc/makefile.autoconf.in:swlibs/include/make/makefile.autoconf.bottom
          swlibs/newpci/makefile.autoconf:swlibs/newpci/makefile.autoconf.in:swlibs/include/make/makefile.autoconf.bottom
          swlibs/newpci/pcilib/makefile.autoconf:swlibs/newpci/pcilib/makefile.autoconf.in:swlibs/include/make/makefile.autoconf.bottom
          swlibs/texus/makefile.autoconf:swlibs/texus/makefile.autoconf.in:swlibs/include/make/makefile.autoconf.bottom
          swlibs/texus/lib/makefile.autoconf:swlibs/texus/lib/makefile.autoconf.in:swlibs/include/make/makefile.autoconf.bottom
          swlibs/texus2/makefile.autoconf:swlibs/texus2/makefile.autoconf.in:swlibs/include/make/makefile.autoconf.bottom
          swlibs/texus2/lib/makefile.autoconf:swlibs/texus2/lib/makefile.autoconf.in:swlibs/include/make/makefile.autoconf.bottom
          swlibs/texus2/cmd/makefile.autoconf:swlibs/texus2/cmd/makefile.autoconf.in:swlibs/include/make/makefile.autoconf.bottom
          )
AC_OUTPUT_COMMANDS([chmod +x build.3dfx])

