made the configure script more robust.
[neuro.git] / configure.ac
blob95265e829abddeb0c2b832dc9d83770425f10eb6
2 AC_PREREQ(2.59)
4 AC_INIT(README)
7 # NEURO_MICRO_VERSION += 1      when bug fixes were done or small changes
8 # NEURO_MINOR_VERSION += 1      when new functions and or modules were added, anything more than mere bug fixes or small changes
9 # NEURO_MAJOR_VERSION += 1      when set goals for the whole projects are met, example when neuro will be done, we will raise that by 1. After it is 1, it only raise when most(like more than half) of the code was changes.
11 NEURO_MAJOR_VERSION=0
12 NEURO_MINOR_VERSION=46
13 NEURO_MICRO_VERSION=0
14 NEURO_INTERFACE_AGE=1
15 NEURO_REVISION=0
16 NEURO_BINARY_AGE=0
17 NEURO_VERSION=$NEURO_MAJOR_VERSION.$NEURO_MINOR_VERSION.$NEURO_MICRO_VERSION
19 AC_SUBST(NEURO_MAJOR_VERSION)
20 AC_SUBST(NEURO_MINOR_VERSION)
21 AC_SUBST(NEURO_MICRO_VERSION)
22 AC_SUBST(NEURO_INTERFACE_AGE)
23 AC_SUBST(NEURO_BINARY_AGE)
24 AC_SUBST(NEURO_VERSION)
27 # libtool versioning
28 LT_CURRENT=$NEURO_INTERFACE_AGE
29 LT_REVISION=$NEURO_REVISION
30 LT_AGE=$NEURO_BINARY_AGE
32 AC_SUBST(LT_CURRENT)
33 AC_SUBST(LT_REVISION)
34 AC_SUBST(LT_AGE)
36 #AC_INIT(Neuro, $NEURO_VERSION)
37 AC_CONFIG_SRCDIR([src/neuro_main.c])
39 # init automake
40 AM_INIT_AUTOMAKE(neuro, $NEURO_VERSION)
42 # call canonical host to get valuable informations about the current system
43 AC_CANONICAL_HOST
44 AC_DEFINE_UNQUOTED(OS, "${host}", [cpu-machine-OS])
45 AC_MSG_RESULT($host)
47 #dnl ----- set some variables ------
49 # check for programs
50 AC_PROG_CXX
51 AC_PROG_CC
52 AC_PROG_CPP
53 AC_PROG_INSTALL
54 AC_PROG_LN_S
55 AC_PROG_MAKE_SET
57 # check for cygwin stuff
58 AC_LIBTOOL_WIN32_DLL
60 # libtool setup
61 AM_PROG_LIBTOOL
64 # set the flags
65 CFLAGS="$CFLAGS -ansi -Wall -pedantic -I\$(top_srcdir)/src" 
66 NEUROFLAGS="-D__USE_GNU -I\${top_srcdir}/include -I\${top_srcdir}/include/neuro"
67 NEUROLIBFLAGS="--enable-realtime-pseudo-reloc"
68 SDLFLAGS="`sdl-config --libs`" 
70 dnl ------ Configure Arguments ------
72 AC_ARG_ENABLE(libxml2, [  --enable-libxml2      enable the use of libxml2 for use with the xmltools [[default=yes]]], , enable_libxml2=yes)
74 AC_ARG_ENABLE(Debug, [  --enable-Debug  enable the debugging of this program [[default=no]]], , enable_Debug=no)
76 AC_ARG_WITH(lowlib, 
77 [ --with-lowlib=<lowlib>     the low library Neuro will use;]
78 [                          only a single value is valid here;]
79 [                          Default is "sdl";]
80 [                          Possible low libraries are :]
81 [                            dummy, X11, sdl ],
82 lowlib="$withval", lowlib="sdl")
85 # host related checkings
87 AC_MSG_CHECKING([if we need -no-undefined])
88 case $host in
89         *-*-cygwin | *-*-mingw* | *-*-pw32*)
90                 NEUROFLAGS="$NEUROFLAGS -DWIN32"
91                 NEUROLIBFLAGS="$NEUROLIBFLAGS -no-undefined"
92                 need_no_undefined=yes
93                 targ=w32
94                 #LIBS="$LIBS -lc -lgcc_s -ldl"
95                 ;;
96         *)
97                 targ=unix
98                 need_no_undefined=no
99                 ;;
100 esac
101 AC_MSG_RESULT($need_no_undefined)
102 AM_CONDITIONAL(NO_UNDEFINED, test x$need_no_undefined = xyes)
104 case $targ in
105         w32)
106                 AC_CHECK_HEADERS([windows.h], , [AC_MSG_ERROR([the required header windows is missing.])])
107                 #AC_CHECK_FUNCS([GetTickCount], , [AC_MSG_ERROR([a required function is missing.])])
108         
110         ;;
112         unix)
113                 AC_FUNC_REALLOC
114                 AC_CHECK_HEADERS([unistd.h], , [AC_MSG_ERROR([the required header unistd is missing.])])
115                 AC_CHECK_FUNCS([gettimeofday], , [AC_MSG_ERROR([a required function is missing.])])
116         ;;
117 esac
119 dnl --------- Checks -------------
121 dnl ----------------
122 dnl check for header files.
123 dnl ----------------
124 AC_HEADER_STDC
125 AC_CHECK_HEADERS([fcntl.h stdlib.h string.h sys/time.h], , [AC_MSG_ERROR([a required header is missing.])])
127 # Checks for typedefs, structures, and compiler characteristics.
129 AC_C_CONST
130 AC_TYPE_SIZE_T
131 AC_HEADER_TIME
133 # Checks for library functions.
134 AC_FUNC_VPRINTF
135 AC_CHECK_FUNCS([memchr memset strchr], , [AC_MSG_ERROR([a required function is missing.])])
137 dnl ----------------
138 dnl XML check
139 dnl ----------------
140 if test x$enable_libxml2 = xyes; then
141   AC_CHECK_LIB(xml2, 
142                  xmlFreeDoc, 
143                  [NEUROFLAGS="$NEUROFLAGS -I/usr/include/libxml2 -I/usr/local/include/libxml2" NEUROLIBS="$NEUROLIBS -lxml2" LIBS="$LIBS -lxml2"] , 
144                  AC_MSG_ERROR([You must have libxml2])
145                  )
147 AM_CONDITIONAL(USE_XML, test x$enable_libxml2 = xyes)
149 dnl ----------------
150 dnl List of libraries Neuro can use
151 dnl ----------------
152 SELECTED_LOWLIB=`echo $lowlib`
155 dnl ----------------
156 dnl SDL check
157 dnl ----------------
158 AM_CONDITIONAL(USE_SDL, test x$SELECTED_LOWLIB = xsdl)
159 if test $SELECTED_LOWLIB = sdl; then
160         if test $targ = unix; then
161                 AC_CHECK_LIB(SDL, SDL_Init, 
162                      [AC_DEFINE(USE_SDL, 1) LIBS="$LIBS $SDLFLAGS"
163                       NEUROFLAGS="$NEUROFLAGS `sdl-config --cflags`"], 
164                      [AC_MSG_ERROR(You don't have libSDL you can get it from http://www.libsdl.org)
167                 
168         else
169                 AC_CHECK_LIB(SDL, SDL_Init, 
170                      [AC_DEFINE(USE_SDL, 1) LIBS="$LIBS -lSDL"], 
171                      [AC_MSG_ERROR(You don't have libSDL you can get it from http://www.libsdl.org)
174                 
175         fi
177         AC_CHECK_LIB(SDL_ttf, TTF_RenderUNICODE_Solid, ,
178                      [AC_MSG_ERROR(You don't have libSDL_ttf you can get it from http://libsdl.org)])
180         cp include/extlib.h include/neuro
181         cat include/extlib_sdl.h >> include/neuro/extlib.h
183 dnl ----------------
184 dnl Zlib check
185 dnl ----------------
186 AC_CHECK_LIB(z, gzgetc, 
187              [AC_DEFINE(USE_ZLIB, 1) LIBS="$LIBS -lz"], 
188              [AC_MSG_ERROR(You don't have the Z library)])
191 dnl ----------------
192 dnl X11 check
193 dnl ----------------
194 AM_CONDITIONAL(USE_X11, test x$SELECTED_LOWLIB = xX11)
195 if test $SELECTED_LOWLIB = X11; then
196         AC_PATH_X
197         AC_PATH_XTRA
198         LDFLAGS="$CFLAGS $X_LIBS"
199         CFLAGS="$CFLAGS $X_CFLAGS"
200         AC_CHECK_LIB(X11, XCreateGC, 
201                      [AC_DEFINE(USE_X11, 1) LIBS="$LIBS $X_PRE_LIBS $X_LIBS $X_EXTRA_LIBS"], 
202                      [AC_MSG_ERROR(You don't have libX11)])
203 #       LIBS="$LIBS $X_PRE_LIBS $X_LIBS $X_EXTRA_LIBS"
204 #       NEUROFLAGS="$NEUROFLAGS $X_CFLAGS"
205         AC_CHECK_LIB(Xpm, XpmCreatePixmapFromData,
206                      [LIBS="$LIBS -lXpm"],
207                      [AC_MSG_ERROR(You don't have libXpm)])
208         cp include/extlib.h include/neuro
212 dnl ----------------
213 dnl Debug toggle
214 dnl ----------------
215 if test x$enable_Debug = xyes; then
216         NEUROFLAGS="$NEUROFLAGS -g"
217 else
218         NEUROFLAGS="$NEUROFLAGS -O2 -s"
221 AC_SUBST(NEUROFLAGS)
222 AC_SUBST(NEUROLIBFLAGS)
224 # set the installation path for the headers
225 includedir=$includedir/neuro
227 echo 
229 # enumerate the Makefiles to be created
230 AC_CONFIG_FILES([
231 Makefile
232 src/Makefile
233 src/xml/Makefile
234 src/memory/Makefile
235 src/video/Makefile
236 src/events/Makefile
237 src/extlib/Makefile
238 src/misc/Makefile
240 #add those above when they are started
241 #src/gui/Makefile
242 #src/script/Makefile
243 #src/sound/Makefile
244 #src/sound/music/Makefile
248 #AC_MSG_NOTICE([This is the low library Neuro will use : $SELECTED_LOWLIB])
250 AC_OUTPUT
252 echo " "
253 echo "This is the low library Neuro will use : $SELECTED_LOWLIB"
254 echo " "