get rid of compiler warnings
[btb/d2x.git] / configure.ac
1 # -*- mode: shell-script -*-
2
3 define([D2X_MAJOR],0)
4 define([D2X_MINOR],2)
5 define([D2X_MICRO],6)
6
7 AC_INIT(d2x,[D2X_MAJOR.D2X_MINOR.D2X_MICRO],[descent-source@warpcore.org])
8 AC_PREREQ(2.52)
9
10 AC_CANONICAL_BUILD
11 AC_CANONICAL_HOST
12 AC_CANONICAL_TARGET
13
14 AC_EXEEXT
15 AC_OBJEXT
16
17 AM_INIT_AUTOMAKE([1.6])
18
19 AM_CONFIG_HEADER(conf.h)
20
21 AC_DEFINE_UNQUOTED(D2XMAJOR,D2X_MAJOR,[d2x major version])
22 AC_DEFINE_UNQUOTED(D2XMINOR,D2X_MINOR,[d2x minor version])
23 AC_DEFINE_UNQUOTED(D2XMICRO,D2X_MICRO,[d2x micro version])
24
25 AM_MAINTAINER_MODE
26
27 #kludge to keep autoconf from adding -g -O2
28 CFLAGS=" $CFLAGS"
29
30 AC_PROG_INSTALL
31 AC_PROG_MAKE_SET
32 AC_ISC_POSIX
33 AC_CHECK_TOOL(CC, gcc, :)
34 AC_CHECK_TOOL(RANLIB, ranlib, :)
35 AC_CHECK_TOOL(STRIP, strip, :)
36 AC_CHECK_TOOL(AR, ar, :)
37 AC_PROG_CC
38 AC_PROG_CXX
39 AC_STDC_HEADERS
40 AC_PATH_PROGS(NASM, nasm nasmw, no)
41 AC_C_BIGENDIAN
42
43 case $host_cpu in
44         sparc)
45                 AC_DEFINE(WORDS_NEED_ALIGNMENT,,[Define if your processor needs data to be word-aligned])
46         ;;
47 esac
48
49 case $host_os in
50     cygwin)
51         AC_MSG_WARN([Cygwin found, setting -mno-cygwin])
52         CFLAGS="-mno-cygwin $CFLAGS"
53         MINGW32=yes
54         ;;
55     mingw*)
56         MINGW32=yes
57         ;;
58     darwin*)
59         MACOSX=yes
60         CFLAGS="-no-cpp-precomp $CFLAGS"
61         ;;
62     msdos*)
63         MSDOS=yes
64         ;;
65 esac
66
67 AC_CHECK_DECLS(nanosleep,,,[#include <time.h>])
68 AC_CHECK_TYPES([struct timespec, struct timeval],,,[#include <sys/time.h>])
69
70 AM_CONDITIONAL(MINGW32, test x$MINGW32 = xyes)
71 if test x$MINGW32 = xyes; then
72     GL_LIBS="opengl32 glu32"
73 elif test x$MACOSX = xyes; then
74     GL_LIBS=""
75 else
76     GL_LIBS="GL GLU"
77 fi
78
79 AM_CONDITIONAL(MACOSX, test x$MACOSX = xyes)
80
81 dnl Set $prefix and $exec_prefix to $ac_default_prefix if they are not set
82 test "x$prefix" = "xNONE" && prefix=$ac_default_prefix
83 test "x$exec_prefix" = "xNONE" && exec_prefix="${prefix}"
84
85 dnl Set default locations to find data files.
86 default_sharepath="$datadir/games/$PACKAGE"
87
88 CFLAGS="-Wall -Wno-char-subscripts $CFLAGS"
89
90 D2X_SUBDIRS=""
91 D2X_MAIN_SUBDIRS=""
92
93 dnl Enable editor build?
94 AC_ARG_ENABLE(editor,
95     [  --enable-editor         Build editor? (not functional)],,)
96 if test x$enable_editor = xyes; then
97     AC_DEFINE(EDITOR,,[Define if you want to build the editor])
98     D2X_SUBDIRS="ui ${D2X_SUBDIRS}"
99     D2X_MAIN_SUBDIRS="editor ${D2X_MAIN_SUBDIRS}"
100 fi
101 AM_CONDITIONAL(EDITOR, test x$enable_editor = xyes)
102
103 dnl Enable macdata build?
104 AC_ARG_ENABLE(macdata,
105     [  --enable-macdata        Build for mac datafiles],,)
106 if test x$enable_macdata = xyes; then
107     AC_DEFINE(MACDATA,,[Define if you want to build for mac datafiles])
108     D2X_FEATURES="macdata ${D2X_FEATURES}"
109 fi
110 AM_CONDITIONAL(MACDATA, test x$enable_macdata = xyes)
111
112 dnl Build with NDEBUG?
113 AC_ARG_ENABLE(debug,
114     [  --disable-debug         Take out debug symbols, Asserts, Int3, etc ],,)
115 if test x$enable_debug = xno; then
116     AC_DEFINE(NDEBUG,,[Define to disable asserts, int3, etc.])
117     CFLAGS="-O2 $CFLAGS"
118 else
119     CFLAGS="-g $CFLAGS"
120     D2X_FEATURES="debug ${D2X_FEATURES}"
121 fi
122
123 dnl Build with RELEASE?
124 AC_ARG_ENABLE(release,
125     [  --enable-release        Release build.  Removes debug/editor things ],,)
126 if test x$enable_release = xyes; then
127     AC_DEFINE(RELEASE,,[Define for a "release" build])
128     D2X_FEATURES="release ${D2X_FEATURES}"
129 fi
130
131 dnl Build without using sdl-joystick ?
132 AC_ARG_ENABLE(linuxjoy,
133     [  --enable-linuxjoy       do not use the SDL Joystick. (eg for MS Sidewinder)],,)
134 if test x$enable_linuxjoy = xyes; then
135     AC_DEFINE(USE_LINUX_JOY,,[define to not use the SDL_Joystick routines.])
136     D2X_FEATURES="linuxjoy ${D2X_FEATURES}"
137 fi
138 AM_CONDITIONAL(USE_LINUX_JOY, test x$enable_linuxjoy = xyes)
139
140 dnl Build with FAST_FILE_IO?
141 AC_ARG_ENABLE(fastfileio,
142     [  --disable-fastfileio    Disable fast file i/o. ],,)
143 if test x$enable_fastfileio != xno; then
144         if test x$ac_cv_c_bigendian = xyes; then
145                 AC_MSG_WARN([big-endian cpu detected.  disabling fastfileio])
146                 enable_fastfileio="no";
147         fi
148 fi
149 if test x$enable_fastfileio != xno; then
150     AC_DEFINE(FAST_FILE_IO,,[Define for faster i/o on little-endian cpus])
151     D2X_FEATURES="fastfileio ${D2X_FEATURES}"
152 fi
153
154 dnl Build with CONSOLE?
155 AC_ARG_ENABLE(console,
156     [  --enable-console        Enable console (experimental) ],,)
157 if test x$enable_console = xyes; then
158     AC_DEFINE(CONSOLE,,[Define to enable console])
159     D2X_SUBDIRS="console ${D2X_SUBDIRS}"
160 fi
161 AM_CONDITIONAL(CONSOLE, test x$enable_console = xyes)
162
163 AC_ARG_WITH(sharepath,
164     [[  --with-sharepath=DIR    Use DIR for shared game data (unix only) [DATADIR/games/d2x]]],
165     sharepath=$withval, sharepath="auto")
166 if test "x$sharepath" = "xauto" -o "x$sharepath" = "xyes" -o "x$sharepath" = "x"; then
167     sharepath="$default_sharepath"
168 fi
169 AC_SUBST(sharepath)
170 eval sharepath=$sharepath
171 AC_DEFINE_UNQUOTED(SHAREPATH, "$sharepath",[Define this to be the shared game directory root])
172
173 # Test for MSDOS
174 if test x$MSDOS = xyes; then
175     CFLAGS="-I \$(top_srcdir)/arch/dos/include $CFLAGS"
176     TARGETS=d2x
177     D2X_ARCH_SUBDIRS=dos
178 else
179
180     CFLAGS="-pipe $CFLAGS"
181
182     dnl Check for SDL
183     AM_PATH_SDL(1.1.0,
184         :,
185         AC_MSG_ERROR(SDL not found. Make sure sdl-config is in your PATH, or specify with --with-sdl-prefix)
186     )
187     CFLAGS="$SDL_CFLAGS $CFLAGS"
188     LIBS="$SDL_LIBS $LIBS"
189
190     TARGETS=d2x-sdl
191     D2X_ARCH_SUBDIRS=sdl
192
193     AC_CHECK_HEADERS(netipx/ipx.h)
194
195   # Check for SDL_image
196     AC_CHECK_LIB(SDL_image, IMG_ReadXPMFromArray,
197         LIBS="-lSDL_image $LIBS"
198         AC_DEFINE(SDL_IMAGE,,[Define if you have the SDL_image library]))
199
200   # Check for libpng
201     have_libpng=no
202     #PKG_CHECK_MODULES(LIBPNG, libpng,
203     #   AC_DEFINE(HAVE_LIBPNG,,[Define if you have libpng])
204     #   have_libpng=yes
205     #   LIBS="$LIBPNG_LIBS $LIBS",
206     #   AC_MSG_WARN([libpng not found. disabling png replacement texture support])
207 #)
208     AM_CONDITIONAL(USE_LIBPNG, test x$have_libpng = xyes)
209
210   # Check for PhysicsFS
211     AC_CHECK_HEADERS(physfs.h, , [AC_MSG_ERROR([physfs.h required])])
212     AC_CHECK_LIB(physfs, PHYSFS_init, LIBS="-lphysfs $LIBS",
213                  [AC_MSG_ERROR([physfs library required])])
214
215   # Check for OpenGL
216     AC_ARG_WITH(opengl,
217         [  --with-opengl           Build OpenGL support ],,)
218     if test x$with_opengl = xyes; then
219         for lib in $GL_LIBS; do
220             AC_CHECK_LIB($lib, main,
221                 OGL_LIBS="${OGL_LIBS} -l$lib",
222                 [AC_MSG_ERROR([$lib not found, --with-opengl cannot be used])
223                     opengl=false],
224                 ${OGL_LIBS}
225             )
226         done
227         AC_DEFINE(OGL,,[Define if you want an OpenGL build])
228         TARGETS=d2x-gl
229         D2X_ARCH_SUBDIRS="ogl ${D2X_ARCH_SUBDIRS}"
230     fi
231     AC_SUBST(OGL_LIBS)
232     AM_CONDITIONAL(USE_OPENGL, test x$with_opengl = xyes)
233
234   # Check for GGI
235     AC_ARG_WITH(ggi,
236         [  --with-ggi              Build GGI support ],,)
237     if test x$with_ggi = xyes; then
238         AC_CHECK_LIB(ggi, ggiInit,
239             GGI_LIBS="-lggi",
240             [AC_MSG_ERROR([GGI not found, GGI version cannot be built]); ggi=false])
241         AC_CHECK_LIB(gii, giiInit,
242             GGI_LIBS="${GGI_LIBS} -lgii",
243             [AC_MSG_ERROR([GII not found, GGI version cannot be built]); ggi=false])
244         AC_DEFINE(GGI,,[Define if you want a GGI build])
245         TARGETS=d2x-ggi
246         D2X_ARCH_SUBDIRS="ggi ${D2X_ARCH_SUBDIRS}"
247     fi
248     AC_SUBST(GGI_LIBS)
249     AM_CONDITIONAL(USE_GGI, test x$with_ggi = xyes)
250
251   # Check for SVGALib
252     AC_ARG_WITH(svga,
253         [  --with-svga             Build SVGALib support ],,)
254     if test x$with_svga = xyes; then
255         AC_CHECK_LIB(vga,vga_getmousetype,
256             SVGA_LIBS="-lvga",
257             [AC_MSG_ERROR([vga not found, SVGALib cannot be built])
258                 svga=false],
259         )
260         AC_CHECK_LIB(vgagl,gl_getcontext,
261             SVGA_LIBS="${SVGA_LIBS} -lvgagl",
262             [AC_MSG_ERROR([vgagl not found, SVGALib cannot be built])
263                 svga=false],
264             -lvga)
265         AC_DEFINE(SVGA,,[Define if you want an SVGALib build])
266         TARGETS=d2x-svga
267         D2X_ARCH_SUBDIRS="svgalib ${D2X_ARCH_SUBDIRS}"
268     fi
269     AC_SUBST(SVGA_LIBS)
270     AM_CONDITIONAL(USE_SVGALIB, test x$with_svga = xyes)
271
272     if test x$MINGW32 = xyes; then
273         D2X_ARCH_SUBDIRS="win32 ${D2X_ARCH_SUBDIRS}"
274     else
275         CFLAGS="-I \$(top_srcdir)/arch/linux/include $CFLAGS"
276         D2X_ARCH_SUBDIRS="linux ${D2X_ARCH_SUBDIRS}"
277     fi
278 fi
279
280 dnl Check for network
281 AC_ARG_ENABLE(network,
282     [  --disable-network       Do not build network/serial support ],,)
283 if test x$enable_network != xno; then
284     case $host_os in
285         cygwin* | mingw* | msdos* | linux*)
286             enable_native_ipx="yes";
287            ;;
288        *)
289             AC_MSG_WARN([d2x does not support native ipx on this host.  disabling native ipx])
290             enable_native_ipx="no";
291             ;;
292     esac
293         case $host_os in
294                 cygwin* | mingw* | msdos*)
295                         enable_kalinix="no";
296                         ;;
297         esac
298     case $host_os in
299         *solaris*)
300             AC_CHECK_LIB(socket, socket, LIBS="${LIBS} -lsocket",
301                 [AC_MSG_ERROR(socket lib required for net support on solaris not found)])
302             AC_CHECK_LIB(nsl, inet_addr, LIBS="${LIBS} -lnsl",
303                 [AC_MSG_ERROR(nsl lib required for net support on solaris not found)])          
304            ;;
305     esac
306 fi
307 AC_ARG_ENABLE(kalinix,
308     [  --disable-kalinix       Disable the KaliNix driver (unix-only)],,)
309 if test x$enable_network != xno; then
310     if test x$enable_native_ipx != xno; then
311         D2X_FEATURES="ipx ${D2X_FEATURES}"
312         AC_DEFINE(NATIVE_IPX,,[Define to use the IPX support of the OS])
313     fi
314     if test x$enable_kalinix != xno; then
315         D2X_FEATURES="kalinix ${D2X_FEATURES}"
316         AC_DEFINE(KALINIX,,[Define to enable use of the KaliNix driver])
317     fi
318     AC_DEFINE(NETWORK,,[Define if you want a network build])
319     D2X_FEATURES="network ${D2X_FEATURES}"
320 fi
321 AM_CONDITIONAL(USE_NETWORK, test x$enable_network != xno)
322 AM_CONDITIONAL(USE_NATIVE_IPX, test x$enable_native_ipx != xno)
323 AM_CONDITIONAL(USE_KALINIX, test x$enable_kalinix != xno)
324
325 dnl Check for assembler
326 AC_ARG_ENABLE(assembler,
327     [  --disable-assembler     Do not use assembler optimization ],,)
328 if test x$enable_assembler != xno; then
329     if test x$NASM = xno; then
330         AC_MSG_WARN([nasm not found. disabling assembler])
331         enable_assembler="no"
332     else
333         NASMFLAGS="-i\$(srcdir)/ $NASMFLAGS"
334         case $host_os in
335             cygwin* | mingw*)
336                 NASMFLAGS="-f win32 $NASMFLAGS"
337                 ;;
338             msdos*)
339                 NASMFLAGS="-f coff $NASMFLAGS"
340                 ;;
341                         linux* | freebsd*)
342                                 NASMFLAGS="-f elf -d__ELF__ $NASMFLAGS"
343                 ;;
344             *)
345                 AC_MSG_WARN([nasm not supported for this OS. disabling assembler])
346                 enable_assembler="no"
347                 ;;
348         esac
349     fi
350 fi
351 if test x$enable_assembler = xno; then
352     AC_DEFINE(NO_ASM,,[Define if you want an assembler free build])
353     D2X_FEATURES="no_asm ${D2X_FEATURES}"
354 fi
355 AM_CONDITIONAL(USE_ASM, test x$enable_assembler != xno)
356
357 AH_BOTTOM([
358         /* General defines */
359 #ifndef PACKAGE_STRING
360 #define PACKAGE_STRING PACKAGE " " VERSION
361 #endif
362 #define VERSION_NAME PACKAGE_STRING
363 #define NMONO 1
364 #define PIGGY_USE_PAGING 1
365 #define NEWDEMO 1
366
367 #if defined(__APPLE__) && defined(__MACH__)
368 #define __unix__ /* since we're doing a unix-style compilation... */
369 #endif
370
371 #ifdef __unix__
372 # ifdef GGI
373 #  define GII_INPUT 1
374 #  define GGI_VIDEO 1
375 # else
376 #  ifdef SVGA
377 #   define SVGALIB_INPUT 1
378 #   define SVGALIB_VIDEO 1
379 #  else
380 #   define SDL_INPUT 1
381 #   ifdef OGL
382 #    define SDL_GL_VIDEO 1
383 #   else
384 #    define SDL_VIDEO 1
385 #   endif
386 #  endif
387 # endif
388 #endif
389
390 #ifdef _WIN32
391 # define SDL_INPUT 1
392 # ifdef OGL
393 #  define SDL_GL_VIDEO 1
394 # else
395 #  define SDL_VIDEO 1
396 # endif
397 #endif
398         ])
399
400 TARGETS="$TARGETS$ac_cv_exeext"
401
402 AM_PROG_AS
403
404 AC_SUBST(D2X_SUBDIRS)
405
406 AC_SUBST(D2X_ARCH_SUBDIRS)
407
408 AC_SUBST(D2X_MAIN_SUBDIRS)
409
410 AC_SUBST(TARGETS)
411
412 AC_SUBST(NASMFLAGS)
413
414 AC_SUBST(CFLAGS)
415
416 AC_OUTPUT(
417     Makefile
418     2d/Makefile
419     3d/Makefile
420     arch/Makefile
421     arch/dos/Makefile
422     arch/ggi/Makefile
423     arch/linux/Makefile
424     arch/ogl/Makefile
425     arch/sdl/Makefile
426     arch/svgalib/Makefile
427     arch/win32/Makefile
428     console/Makefile
429     iff/Makefile
430     libmve/Makefile
431     main/Makefile
432     main/editor/Makefile
433     maths/Makefile
434     mem/Makefile
435     misc/Makefile
436     texmap/Makefile
437     ui/Makefile
438     utilities/Makefile
439     debian/changelog
440     rpm/d2x.spec
441 )
442
443 AC_MSG_RESULT([
444         d2x has been configured successfully.
445
446         Platform(s): $D2X_ARCH_SUBDIRS
447         Features   : $D2X_FEATURES $D2X_SUBDIRS $D2X_MAIN_SUBDIRS
448
449         Shared game data directory (unix only): $sharepath
450         ])