source: abuse/trunk/configure.ac @ 543

Last change on this file since 543 was 537, checked in by Sam Hocevar, 12 years ago

build: try to autodetect SDL_Mixer upon build.

File size: 3.4 KB
Line 
1dnl Process this file with autoconf to produce a configure script.
2AC_INIT(abuse, 0.7.1)
3AC_CONFIG_AUX_DIR(.auto)
4AM_INIT_AUTOMAKE
5AM_CONFIG_HEADER(config.h)
6
7dnl Checks for programs.
8AC_PROG_LIBTOOL
9AC_ISC_POSIX
10AC_PROG_CC
11AC_PROG_CPP
12AC_PROG_CXX
13AC_PROG_INSTALL
14AC_C_BIGENDIAN
15
16dnl Check for X
17AC_PATH_X
18if [ "x$x_libraries" != "x" ]; then
19  X_LIBS="-L$x_libraries"
20fi
21
22dnl Figure out where the datafiles will be
23EXPDATADIR="-DEXPDATADIR=\\\"$datadir/games/abuse\\\""
24AC_SUBST(EXPDATADIR)
25
26AC_ARG_ENABLE(debug,
27  [  --enable-debug          build debug versions of the game (default no)])
28AC_ARG_ENABLE(release,
29  [  --enable-release        build final release of the game (default no)])
30
31dnl Checks for libraries
32dnl Do we need to link against something for X shared memory support?
33AC_CHECK_LIB(Xext,XShmAttach,:,[
34AC_CHECK_LIB(XextSam,XShmAttach,LIBS="$LIBS -lXextSam",,$X_LIBS -lX11 -lXext)
35],$X_LIBS -lX11)
36
37dnl Checks for Solaris compatibility
38AC_CHECK_LIB(m,pow,LIBS="$LIBS -lm")
39AC_CHECK_LIB(socket,socket,LIBS="$LIBS -lsocket")
40AC_CHECK_LIB(nsl,gethostbyname,LIBS="$LIBS -lnsl")
41
42dnl Check for SDL
43SDL_VERSION=1.1.6
44AM_PATH_SDL($SDL_VERSION, :,
45    AC_MSG_ERROR([*** SDL version $SDL_VERSION or above not found!]))
46CFLAGS="$CFLAGS $SDL_CFLAGS"
47LIBS="$LIBS $SDL_LIBS $X_LIBS"
48
49dnl Check for SDL mixer
50ac_cv_my_have_sdl_mixer="no"
51save_CPPFLAGS="${CPPFLAGS}"
52CPPFLAGS="${CPPFLAGS} ${SDL_CFLAGS}"
53AC_CHECK_HEADERS(SDL/SDL_mixer.h, [ac_cv_my_have_sdl="yes"])
54CPPFLAGS="${save_CPPFLAGS}"
55if test "${ac_cv_my_have_sdl}" != "no"; then
56  AC_DEFINE(USE_SDL_MIXER, 1, Define to 1 to use SDL_Mixer)
57  LIBS="$LIBS -lSDL_mixer"
58fi
59
60if test "${enable_debug}" = "yes"; then
61  AC_DEFINE(HAVE_DEBUG, 1, Define to 1 to activate debug)
62  OPT="-O0"
63else
64  OPT="-O2 -fno-strength-reduce -fomit-frame-pointer"
65fi
66
67if test "${enable_release}" = "yes"; then
68  AC_DEFINE(HAVE_RELEASE, 1, Define to 1 to activate final release)
69  REL=""
70else
71  REL="-g"
72fi
73
74# Optimizations
75CXXFLAGS="${CXXFLAGS} ${OPT} ${REL}"
76# Code qui fait des warnings == code de porc == deux baffes dans ta gueule
77CXXFLAGS="${CXXFLAGS} -Wall -Wpointer-arith -Wcast-align -Wcast-qual -Wsign-compare"
78
79dnl Checks for header files
80AC_HEADER_DIRENT
81AC_HEADER_STDC
82AC_CHECK_HEADERS(fcntl.h malloc.h string.h sys/ioctl.h sys/time.h unistd.h)
83
84dnl Checks for functions
85AC_FUNC_MEMCMP
86AC_CHECK_FUNCS(atexit on_exit strstr gettimeofday)
87
88dnl Check for OpenGL
89dnl Should this be more thorough?
90dnl For OpenGL support on OSX it's better to use Project Builder as -lGL
91dnl doesn't seem to work this way.
92AC_MSG_CHECKING(for OpenGL support)
93have_opengl=no
94AC_TRY_COMPILE([
95    #ifdef WIN32
96    #include <windows.h>
97    #elif defined(__APPLE__) && defined(__MACH__)
98/*    #include <OpenGL/gl.h>*/
99    #error      /* Error so the compile fails on OSX */
100    #else
101    #include <GL/gl.h>
102    #endif
103],[
104],[
105have_opengl=yes
106])
107AC_MSG_RESULT($have_opengl)
108if test x$have_opengl = xyes; then
109    CFLAGS="$CFLAGS -DHAVE_OPENGL"
110    CXXFLAGS="$CXXFLAGS -DHAVE_OPENGL"
111    LIBS="$LIBS -lGL -lpthread"
112fi
113
114AC_OUTPUT([
115    Makefile
116    abuse.6
117    src/Makefile
118    src/lisp/Makefile
119    src/net/Makefile
120    src/imlib/Makefile
121    src/sdlport/Makefile])
122
123echo "
124------ Configuration for $PACKAGE $VERSION ------
125    Compiler:         ${CC} (version `${CC} --version`)
126    Install prefix:   $prefix
127    SDL version:      `sdl-config --version`
128    OpenGL support:   $have_opengl
129
130Now type 'make' to build $PACKAGE.
131"
Note: See TracBrowser for help on using the repository browser.