1#                                               -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3
4AC_PREREQ(2.57)
5AC_INIT(SDL_console)
6AC_CONFIG_SRCDIR([README])
7AC_CONFIG_HEADER([config.h])
8
9dnl Set various version strings - taken gratefully from the GTk sources
10
11# Making releases:
12#   MICRO_VERSION += 1;
13#   INTERFACE_AGE += 1;
14#   BINARY_AGE += 1;
15# if any functions have been added, set INTERFACE_AGE to 0.
16# if backwards compatibility has been broken,
17# set BINARY_AGE and INTERFACE_AGE to 0.
18
19MAJOR_VERSION=2
20MINOR_VERSION=1
21MICRO_VERSION=0
22INTERFACE_AGE=0
23BINARY_AGE=0
24VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION
25
26AC_SUBST(MAJOR_VERSION)
27AC_SUBST(MINOR_VERSION)
28AC_SUBST(MICRO_VERSION)
29AC_SUBST(INTERFACE_AGE)
30AC_SUBST(BINARY_AGE)
31AC_SUBST(VERSION)
32
33# libtool versioning
34LT_RELEASE=$MAJOR_VERSION.$MINOR_VERSION
35LT_CURRENT=`expr $MICRO_VERSION - $INTERFACE_AGE`
36LT_REVISION=$INTERFACE_AGE
37LT_AGE=`expr $BINARY_AGE - $INTERFACE_AGE`
38
39AC_SUBST(LT_RELEASE)
40AC_SUBST(LT_CURRENT)
41AC_SUBST(LT_REVISION)
42AC_SUBST(LT_AGE)
43
44dnl Detect the canonical host and target build environment
45AC_CANONICAL_HOST
46AC_CANONICAL_TARGET
47
48dnl Setup for automake
49AM_INIT_AUTOMAKE(SDL_console, $VERSION)
50AM_MAINTAINER_MODE
51
52dnl Check for tools
53
54AC_LIBTOOL_WIN32_DLL
55AM_PROG_LIBTOOL
56AC_PROG_MAKE_SET
57AC_PROG_CC
58AC_C_INLINE
59AC_PROG_INSTALL
60AC_PROG_LN_S
61
62# Check for SDL
63SDL_VERSION=1.2.4
64AM_PATH_SDL($SDL_VERSION,
65		  :,
66	AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!])
67)
68CFLAGS="$CFLAGS $SDL_CFLAGS"
69LIBS="$LIBS $SDL_LIBS"
70
71# Check command-line options
72AC_ARG_ENABLE(sdlimage,
73AC_HELP_STRING(--enable-sdlimage,support SDL_image (default=yes)),
74,
75enable_sdlimage=yes)
76if test x$enable_sdlimage = xyes; then
77	AC_CHECK_LIB([SDL_image], [IMG_Load],have_sdlimage=yes)
78	if test x$have_sdlimage = xyes; then
79	  CFLAGS="$CFLAGS -DHAVE_SDLIMAGE"
80	  CON_LIBS="$CON_LIBS -lSDL_image"
81	  LIBS="$LIBS $CON_LIBS"
82	else
83	  enable_sdlimage=no
84	fi
85fi
86AC_SUBST(CON_LIBS)
87
88
89AC_ARG_ENABLE(gldemo,
90AC_HELP_STRING(--enable-opengl,enable OpenGL support for the example (default=yes)),
91,
92enable_gldemo=yes)
93if test x$enable_gldemo = xyes; then
94	have_opengl=yes
95	AC_CHECK_LIB([GL], [glLoadIdentity],have_gl=yes,have_opengl=no)
96	AC_CHECK_LIB([GLU], [gluPerspective],have_glu=yes,have_opengl=no,-lGL)
97	AC_CHECK_LIB([glut], [glutSolidTeapot],have_glut=yes,have_opengl=no,-lGL -lGLU)
98	if test x$have_opengl = xyes; then
99	  EXAMPLE_LIBS="$EXAMPLE_LIBS -lGL -lGLU -lglut"
100	else
101	  enable_gldemo=no
102	fi
103fi
104AC_SUBST(EXAMPLE_LIBS)
105AM_CONDITIONAL(HAVE_OPENGL,test x$enable_gldemo = xyes)
106
107#What is that thing used for anyway???
108# FIXME: Replace `main' with a function in `-lm':
109#AC_CHECK_LIB([m], [main])
110
111# Checks for header files.
112AC_HEADER_STDC
113AC_CHECK_HEADERS([stdlib.h string.h])
114
115# Checks for typedefs, structures, and compiler characteristics.
116AC_C_CONST
117
118# Checks for library functions.
119AC_FUNC_MALLOC
120AC_CHECK_FUNCS([atexit memset strdup])
121
122AC_CONFIG_FILES([Makefile
123                 src/Makefile
124                 include/Makefile
125				 example/Makefile])
126AC_OUTPUT
127
128# Print some useful information
129echo
130echo "Configuration:"
131echo "   Target system type: $target"
132echo "   Build static library: $enable_static"
133echo "   Build shared library: $enable_shared"
134echo "   Build with SDL_image: $enable_sdlimage"
135echo "   Build OpenGL Demos: $enable_gldemo"
136echo
137echo "   Headers will be installed in $prefix/include"
138echo "   Libraries will be installed in $prefix/lib"
139echo
140
141