AC_PREREQ(2.50)

AC_INIT([OGRE], [1.0.5])

AC_CANONICAL_TARGET

# New syntax, but this is still buggy; PACKAGE gets defined as 'ogre' not 'OGRE'
#AM_INIT_AUTOMAKE([1.7.0 foreign no-installinfo no-installman subdir-objects])
AM_INIT_AUTOMAKE([OGRE], [1.0.5])
AC_CONFIG_HEADERS([OgreMain/include/config.h])

dnl Check for programs
AC_PROG_CC
AC_PROG_CXX
AM_PROG_CC_C_O
AC_PROG_INSTALL
AC_PROG_YACC
AM_PROG_LEX

dnl Setup target-specific parameters
OGRE_SETUP_FOR_TARGET

AC_DISABLE_STATIC
AC_PROG_LIBTOOL

dnl GCC version check
if test x$GCC = xyes; then
    AC_MSG_CHECKING([version 3.1 or above of gcc])
    if test -n "`$CC --version 2>&1|grep ' [[34]].'`"; then
        AC_DEFINE(EXT_HASH,, Use old STL hash options)
        AC_SUBST(OGRE_CFLAGS, "-DEXT_HASH")
        AC_MSG_RESULT(yes);
    else
        AC_MSG_RESULT(no)
    fi
fi

dnl Other stuff we need
OGRE_USE_STLPORT
#AM_PATH_SDL(1.2.0)
AC_CHECK_FT2(9.0.0)

AC_CHECK_LIB(dl, dlopen)
AC_CHECK_LIB(m, pow)
AC_CHECK_LIB(z, gzopen)
AC_CHECK_LIB(pthread, pthread_create)
AC_CHECK_FUNC(snprintf, AC_DEFINE(HAVE_SNPRINTF,,snprintf))
AC_CHECK_FUNC(vsnprintf, AC_DEFINE(HAVE_VSNPRINTF,,vsnprintf))

OGRE_CHECK_CPPUNIT

PKG_CHECK_MODULES(ZZIPLIB, zziplib)
AC_SUBST(ZZIPLIB_CFLAGS)
AC_SUBST(ZZIPLIB_LIBS)

OGRE_GET_CONFIG_TOOLKIT
OGRE_GET_PLATFORM
OGRE_GET_GLSUPPORT

dnl Find the optional components we should build
OGRE_CHECK_DOUBLE
OGRE_CHECK_THREADING
OGRE_CHECK_DEVIL
OGRE_CHECK_CG
OGRE_CHECK_OPENEXR
OGRE_CHECK_DX9

dnl Detect endianness
OGRE_DETECT_ENDIAN

dnl Check to see if -fPIC is required.
OGRE_CHECK_PIC

dnl Check to see if CEGUI is installed.
OGRE_CHECK_CEGUI

CFLAGS="$CFLAGS $SDL_CFLAGS"
CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
LIBS="$LIBS $SDL_LIBS"

dnl versioning info for libtool
dnl Note this is the ABI version which is not the same as our actual library version
OGREMAIN_CURRENT=9
OGREMAIN_REVISION=0
OGREMAIN_AGE=4
OGREMAIN_VERSION_INFO=$OGREMAIN_CURRENT:$OGREMAIN_REVISION:$OGREMAIN_AGE
AC_SUBST(OGREMAIN_VERSION_INFO)


dnl Create the makefiles
AC_CONFIG_FILES([Makefile \
    OgreMain/Makefile \
    OgreMain/src/Makefile \
    OgreMain/include/Makefile \
    PlatformManagers/Makefile \
    PlatformManagers/SDL/Makefile \
    PlatformManagers/SDL/src/Makefile
    PlatformManagers/SDL/include/Makefile
    PlatformManagers/gtk/Makefile \
    PlatformManagers/gtk/src/Makefile \
    PlatformManagers/gtk/include/Makefile \
    PlatformManagers/GLX/Makefile \
    PlatformManagers/GLX/src/Makefile \
    PlatformManagers/GLX/include/Makefile \
    PlatformManagers/Win32/Makefile \
    PlatformManagers/Win32/src/Makefile \
    PlatformManagers/Win32/include/Makefile \
    PlugIns/Makefile \
    PlugIns/BSPSceneManager/Makefile \
    PlugIns/BSPSceneManager/src/Makefile \
    PlugIns/BSPSceneManager/include/Makefile \
    PlugIns/CgProgramManager/Makefile \
    PlugIns/CgProgramManager/src/Makefile \
    PlugIns/CgProgramManager/include/Makefile \
    PlugIns/OctreeSceneManager/Makefile \
    PlugIns/OctreeSceneManager/src/Makefile \
    PlugIns/OctreeSceneManager/include/Makefile \
    PlugIns/ParticleFX/Makefile \
    PlugIns/ParticleFX/src/Makefile \
    PlugIns/ParticleFX/include/Makefile \
    RenderSystems/Makefile \
    RenderSystems/GL/Makefile \
    RenderSystems/GL/src/Makefile \
    RenderSystems/GL/include/Makefile \
    RenderSystems/GL/src/atifs/Makefile \
    RenderSystems/GL/src/atifs/include/Makefile \
    RenderSystems/GL/src/atifs/src/Makefile \
    RenderSystems/GL/src/GLSL/Makefile \
    RenderSystems/GL/src/GLSL/include/Makefile \
    RenderSystems/GL/src/GLSL/src/Makefile \
    RenderSystems/GL/src/nvparse/Makefile \
    RenderSystems/Direct3D9/Makefile \
    RenderSystems/Direct3D9/src/Makefile \
    RenderSystems/Direct3D9/include/Makefile \
    Samples/Makefile \
    Samples/Common/Makefile \
    Samples/Common/include/Makefile \
    Samples/BezierPatch/Makefile \
    Samples/BezierPatch/src/Makefile \
    Samples/BezierPatch/include/Makefile \
    Samples/CameraTrack/Makefile \
    Samples/CameraTrack/src/Makefile \
    Samples/CelShading/Makefile \
    Samples/CelShading/src/Makefile \
    Samples/CubeMapping/Makefile \
    Samples/CubeMapping/src/Makefile \
    Samples/CubeMapping/include/Makefile \
    Samples/Dot3Bump/Makefile \
    Samples/Dot3Bump/src/Makefile \
    Samples/EnvMapping/Makefile \
    Samples/EnvMapping/src/Makefile \
    Samples/EnvMapping/include/Makefile \
    Samples/Fresnel/Makefile \
    Samples/Fresnel/src/Makefile \
    Samples/Grass/Makefile \
    Samples/Grass/src/Makefile \
    Samples/Transpacency/Makefile \
    Samples/Transpacency/src/Makefile \
    Samples/Transpacency/include/Makefile \
    Samples/Lighting/Makefile \
    Samples/Lighting/src/Makefile \
    Samples/Lighting/include/Makefile \
    Samples/ParticleFX/Makefile \
    Samples/ParticleFX/src/Makefile \
    Samples/ParticleFX/include/Makefile \
    Samples/RenderToTexture/Makefile \
    Samples/RenderToTexture/src/Makefile \
    Samples/TextureFX/Makefile \
    Samples/TextureFX/src/Makefile \
    Samples/TextureFX/include/Makefile \
    Samples/Shadows/Makefile \
    Samples/Shadows/src/Makefile \
    Samples/SkyBox/Makefile \
    Samples/SkyBox/src/Makefile \
    Samples/SkyBox/include/Makefile \
    Samples/SkyDome/Makefile \
    Samples/SkyDome/src/Makefile \
    Samples/SkyDome/include/Makefile \
    Samples/SkyPlane/Makefile \
    Samples/SkyPlane/src/Makefile \
    Samples/SkyPlane/include/Makefile \
    Samples/Smoke/Makefile \
    Samples/Smoke/src/Makefile \
    Samples/Smoke/include/Makefile \
    Samples/BSP/Makefile \
    Samples/BSP/src/Makefile \
    Samples/SkeletalAnimation/Makefile \
    Samples/SkeletalAnimation/src/Makefile \
    Samples/SkeletalAnimation/include/Makefile \
    Samples/Terrain/Makefile \
    Samples/Terrain/src/Makefile \
    Samples/Terrain/include/Makefile \
    Samples/Water/Makefile \
    Samples/Water/src/Makefile \
    Samples/Water/include/Makefile \
	Samples/DynTex/Makefile \
	Samples/DynTex/src/Makefile \
	Samples/DynTex/include/Makefile \
	Samples/VolumeTex/Makefile \
	Samples/VolumeTex/src/Makefile \
	Samples/VolumeTex/include/Makefile \
    Tests/Makefile \
    Tests/src/Makefile \
    Tools/Makefile \
    Tools/MaterialUpgrader/Makefile \
    Tools/MaterialUpgrader/src/Makefile \
    Tools/MaterialUpgrader/include/Makefile \
    Tools/MeshUpgrader/Makefile \
    Tools/MeshUpgrader/src/Makefile \
    Tools/XMLConverter/Makefile \
    Tools/XMLConverter/src/Makefile \
    Tools/XMLConverter/include/Makefile \
    Tools/LightwaveConverter/Makefile \
    Tools/LightwaveConverter/src/Makefile \
    Tools/LightwaveConverter/include/Makefile \
    OGRE.pc
    ])

AC_OUTPUT
