1dnl Process this file with autoconf to produce a configure script.
2AC_INIT(Makefile.am)
3
4AM_CONFIG_HEADER(config.h)
5
6AM_INIT_AUTOMAKE(lbreakout,010315)
7
8dnl Checks for programs.
9AC_PROG_CC
10AC_PROG_CXX
11AC_PROG_RANLIB
12
13dnl Checks for libraries.
14AC_CHECK_LIB(m, main,, AC_MSG_ERROR(lib math is needed))
15
16dnl check SDL version
17sdl_flag=""
18AM_PATH_SDL(1.0.0,, AC_MSG_ERROR(lib SDL is needed))
19CFLAGS="$CFLAGS $SDL_CFLAGS"
20CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
21LIBS="$LIBS $SDL_LIBS"
22AM_PATH_SDL(1.1.5, sdl_flag="-DSDL_1_1_5",)
23dnl AM_PATH_SDL(1.1.7, sdl_flag="",)
24CFLAGS="$CFLAGS $sdl_flag"
25
26dnl check for pthread
27ac_save_LIBS="$LIBS"
28thread_flag=""
29dnl first look for -pthread
30LIBS="$LIBS -pthread"
31AC_TRY_LINK(
32        [#include <pthread.h>],
33        [ pthread_create((pthread_t*) 0,(pthread_attr_t*) 0, 0, 0); ],
34        AC_MSG_RESULT("-pthread used...")
35        thread_flag="-pthread",
36        dnl now look for -lpthread
37        AC_MSG_RESULT("checking for -lpthread...")
38        LIBS="$ac_save_LIBS"
39        AC_CHECK_LIB(
40                pthread,
41                pthread_create,
42                thread_flag="-lpthread"
43		AC_MSG_RESULT(yes),
44                AC_MSG_ERROR([lib pthread is needed])
45        )
46)
47LIBS="$ac_save_LIBS"
48AC_SUBST(thread_flag)
49
50dnl check sound
51sound_flag="-DSOUND"
52AC_ARG_ENABLE( sound,
53[  --disable-sound         Disables sound], sound_flag="")
54AC_SUBST(sound_flag)
55
56dnl installation path
57sdir=$datadir/games/lbreakout
58hdir=/var/lib/games
59inst_flag="-DSRC_DIR=\\\"$sdir/\\\""
60hi_inst_flag="-DHI_DIR=\\\"$hdir/\\\""
61
62AC_ARG_ENABLE( install,
63[  --disable-install       No installation. Played from the source directory.],
64sdir=./ hdir=./ inst_flag="-DSRC_DIR=\\\"./\\\"" hi_inst_flag="-DHI_DIR=\\\"./\\\"")
65
66AC_SUBST(inst_flag)
67AC_SUBST(hi_inst_flag)
68AC_SUBST(sdir)
69AC_SUBST(hdir)
70
71AC_OUTPUT(Makefile lbreakout/Makefile)
72