Fix sdl joystick axis problem, all arch use global variable joy_num_axes
[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 dnl Enable editor build?
91 AC_ARG_ENABLE(editor,
92     [  --enable-editor         Build editor? (not functional)],,)
93 if test x$enable_editor = xyes; then
94     AC_DEFINE(EDITOR,,[Define if you want to build the editor])
95     D2X_MAIN_SUBDIRS=editor
96 fi
97 AM_CONDITIONAL(EDITOR, test x$enable_editor = xyes)
98
99 dnl Enable macdata build?
100 AC_ARG_ENABLE(macdata,
101     [  --enable-macdata        Build for mac datafiles],,)
102 if test x$enable_macdata = xyes; then
103     AC_DEFINE(MACDATA,,[Define if you want to build for mac datafiles])
104     D2X_FEATURES="macdata ${D2X_FEATURES}"
105 fi
106 AM_CONDITIONAL(MACDATA, test x$enable_macdata = xyes)
107
108 dnl Build with NDEBUG?
109 AC_ARG_ENABLE(debug,
110     [  --disable-debug         Take out debug symbols, Asserts, Int3, etc ],,)
111 if test x$enable_debug = xno; then
112     AC_DEFINE(NDEBUG,,[Define to disable asserts, int3, etc.])
113     CFLAGS="-O2 $CFLAGS"
114 else
115     CFLAGS="-g $CFLAGS"
116     D2X_FEATURES="debug ${D2X_FEATURES}"
117 fi
118
119 dnl Build with RELEASE?
120 AC_ARG_ENABLE(release,
121     [  --enable-release        Release build.  Removes debug/editor things ],,)
122 if test x$enable_release = xyes; then
123     AC_DEFINE(RELEASE,,[Define for a "release" build])
124     D2X_FEATURES="release ${D2X_FEATURES}"
125 fi
126
127 dnl Build without using sdl-joystick ?
128 AC_ARG_ENABLE(linuxjoy,
129     [  --enable-linuxjoy       do not use the SDL Joystick. (eg for MS Sidewinder)],,)
130 if test x$enable_linuxjoy = xyes; then
131     AC_DEFINE(USE_LINUX_JOY,,[define to not use the SDL_Joystick routines.])
132     D2X_FEATURES="linuxjoy ${D2X_FEATURES}"
133 fi
134 AM_CONDITIONAL(USE_LINUX_JOY, test x$enable_linuxjoy = xyes)
135
136 dnl Build with FAST_FILE_IO?
137 AC_ARG_ENABLE(fastfileio,
138     [  --disable-fastfileio    Disable fast file i/o. ],,)
139 if test x$enable_fastfileio != xno; then
140         if test x$ac_cv_c_bigendian = xyes; then
141                 AC_MSG_WARN([big-endian cpu detected.  disabling fastfileio])
142                 enable_fastfileio="no";
143         fi
144 fi
145 if test x$enable_fastfileio != xno; then
146     AC_DEFINE(FAST_FILE_IO,,[Define for faster i/o on little-endian cpus])
147     D2X_FEATURES="fastfileio ${D2X_FEATURES}"
148 fi
149
150 dnl Build with CONSOLE?
151 AC_ARG_ENABLE(console,
152     [  --enable-console        Enable console (experimental) ],,)
153 if test x$enable_console = xyes; then
154     AC_DEFINE(CONSOLE,,[Define to enable console])
155     D2X_SUBDIRS=console
156 fi
157 AM_CONDITIONAL(CONSOLE, test x$enable_console = xyes)
158
159 AC_ARG_WITH(sharepath,
160     [[  --with-sharepath=DIR    Use DIR for shared game data (unix only) [DATADIR/games/d2x]]],
161     sharepath=$withval, sharepath="auto")
162 if test "x$sharepath" = "xauto" -o "x$sharepath" = "xyes" -o "x$sharepath" = "x"; then
163     sharepath="$default_sharepath"
164 fi
165 AC_SUBST(sharepath)
166 eval sharepath=$sharepath
167 AC_DEFINE_UNQUOTED(SHAREPATH, "$sharepath",[Define this to be the shared game directory root])
168
169 # Test for MSDOS
170 if test x$MSDOS = xyes; then
171     CFLAGS="-I \$(top_srcdir)/arch/dos/include $CFLAGS"
172     TARGETS=d2x
173     D2X_ARCH_SUBDIRS=dos
174 else
175
176     CFLAGS="-pipe $CFLAGS"
177
178     dnl Check for SDL
179     AM_PATH_SDL(1.1.0,
180         :,
181         AC_MSG_ERROR(SDL not found. Make sure sdl-config is in your PATH, or specify with --with-sdl-prefix)
182     )
183     CFLAGS="$SDL_CFLAGS $CFLAGS"
184     LIBS="$SDL_LIBS $LIBS"
185
186     TARGETS=d2x-sdl
187     D2X_ARCH_SUBDIRS=sdl
188
189     AC_CHECK_HEADERS(netipx/ipx.h)
190
191   # Check for SDL_image
192         AC_CHECK_LIB(SDL_image, IMG_ReadXPMFromArray,
193                 LIBS="-lSDL_image $LIBS"
194                 AC_DEFINE(SDL_IMAGE,,[Define if you have the SDL_image library]))
195
196   # Check for libpng
197         have_libpng=no
198         #PKG_CHECK_MODULES(LIBPNG, libpng,
199         #       AC_DEFINE(HAVE_LIBPNG,,[Define if you have libpng])
200         #       have_libpng=yes
201         #       LIBS="$LIBPNG_LIBS $LIBS",
202         #       AC_MSG_WARN([libpng not found. disabling png replacement texture support])
203 #)
204         AM_CONDITIONAL(USE_LIBPNG, test x$have_libpng = xyes)
205
206   # Check for OpenGL
207     AC_ARG_WITH(opengl,
208         [  --with-opengl           Build OpenGL support ],,)
209     if test x$with_opengl = xyes; then
210         for lib in $GL_LIBS; do
211             AC_CHECK_LIB($lib, main,
212                 OGL_LIBS="${OGL_LIBS} -l$lib",
213                 [AC_MSG_ERROR([$lib not found, --with-opengl cannot be used])
214                     opengl=false],
215                 ${OGL_LIBS}
216             )
217         done
218         AC_DEFINE(OGL,,[Define if you want an OpenGL build])
219         TARGETS=d2x-gl
220         D2X_ARCH_SUBDIRS="ogl ${D2X_ARCH_SUBDIRS}"
221     fi
222     AC_SUBST(OGL_LIBS)
223     AM_CONDITIONAL(USE_OPENGL, test x$with_opengl = xyes)
224
225   # Check for GGI
226     AC_ARG_WITH(ggi,
227         [  --with-ggi              Build GGI support ],,)
228     if test x$with_ggi = xyes; then
229         AC_CHECK_LIB(ggi, ggiInit,
230             GGI_LIBS="-lggi",
231             [AC_MSG_ERROR([GGI not found, GGI version cannot be built]); ggi=false])
232         AC_CHECK_LIB(gii, giiInit,
233             GGI_LIBS="${GGI_LIBS} -lgii",
234             [AC_MSG_ERROR([GII not found, GGI version cannot be built]); ggi=false])
235         AC_DEFINE(GGI,,[Define if you want a GGI build])
236         TARGETS=d2x-ggi
237         D2X_ARCH_SUBDIRS="ggi ${D2X_ARCH_SUBDIRS}"
238     fi
239     AC_SUBST(GGI_LIBS)
240     AM_CONDITIONAL(USE_GGI, test x$with_ggi = xyes)
241
242   # Check for SVGALib
243     AC_ARG_WITH(svga,
244         [  --with-svga             Build SVGALib support ],,)
245     if test x$with_svga = xyes; then
246         AC_CHECK_LIB(vga,vga_getmousetype,
247             SVGA_LIBS="-lvga",
248             [AC_MSG_ERROR([vga not found, SVGALib cannot be built])
249                 svga=false],
250         )
251         AC_CHECK_LIB(vgagl,gl_getcontext,
252             SVGA_LIBS="${SVGA_LIBS} -lvgagl",
253             [AC_MSG_ERROR([vgagl not found, SVGALib cannot be built])
254                 svga=false],
255             -lvga)
256         AC_DEFINE(SVGA,,[Define if you want an SVGALib build])
257         TARGETS=d2x-svga
258         D2X_ARCH_SUBDIRS="svgalib ${D2X_ARCH_SUBDIRS}"
259     fi
260     AC_SUBST(SVGA_LIBS)
261     AM_CONDITIONAL(USE_SVGALIB, test x$with_svga = xyes)
262
263     if test x$MINGW32 = xyes; then
264         D2X_ARCH_SUBDIRS="win32 ${D2X_ARCH_SUBDIRS}"
265     else
266         CFLAGS="-I \$(top_srcdir)/arch/linux/include $CFLAGS"
267         D2X_ARCH_SUBDIRS="linux ${D2X_ARCH_SUBDIRS}"
268     fi
269 fi
270
271 dnl Check for network
272 AC_ARG_ENABLE(network,
273     [  --disable-network       Do not build network/serial support ],,)
274 if test x$enable_network != xno; then
275     case $host_os in
276         cygwin* | mingw* | msdos* | linux*)
277             enable_native_ipx="yes";
278            ;;
279        *)
280             AC_MSG_WARN([d2x does not support native ipx on this host.  disabling native ipx])
281             enable_native_ipx="no";
282             ;;
283     esac
284         case $host_os in
285                 cygwin* | mingw* | msdos*)
286                         enable_kalinix="no";
287                         ;;
288         esac
289     case $host_os in
290         *solaris*)
291             AC_CHECK_LIB(socket, socket, LIBS="${LIBS} -lsocket",
292                 [AC_MSG_ERROR(socket lib required for net support on solaris not found)])
293             AC_CHECK_LIB(nsl, inet_addr, LIBS="${LIBS} -lnsl",
294                 [AC_MSG_ERROR(nsl lib required for net support on solaris not found)])          
295            ;;
296     esac
297 fi
298 AC_ARG_ENABLE(kalinix,
299     [  --disable-kalinix       Disable the KaliNix driver (unix-only)],,)
300 if test x$enable_network != xno; then
301     if test x$enable_native_ipx != xno; then
302         D2X_FEATURES="ipx ${D2X_FEATURES}"
303         AC_DEFINE(NATIVE_IPX,,[Define to use the IPX support of the OS])
304     fi
305     if test x$enable_kalinix != xno; then
306         D2X_FEATURES="kalinix ${D2X_FEATURES}"
307         AC_DEFINE(KALINIX,,[Define to enable use of the KaliNix driver])
308     fi
309     AC_DEFINE(NETWORK,,[Define if you want a network build])
310     D2X_FEATURES="network ${D2X_FEATURES}"
311 fi
312 AM_CONDITIONAL(USE_NETWORK, test x$enable_network != xno)
313 AM_CONDITIONAL(USE_NATIVE_IPX, test x$enable_native_ipx != xno)
314 AM_CONDITIONAL(USE_KALINIX, test x$enable_kalinix != xno)
315
316 dnl Check for assembler
317 AC_ARG_ENABLE(assembler,
318     [  --disable-assembler     Do not use assembler optimization ],,)
319 if test x$enable_assembler != xno; then
320     if test x$NASM = xno; then
321         AC_MSG_WARN([nasm not found. disabling assembler])
322         enable_assembler="no"
323     else
324         NASMFLAGS="-i\$(srcdir)/ $NASMFLAGS"
325         case $host_os in
326             cygwin* | mingw*)
327                 NASMFLAGS="-f win32 $NASMFLAGS"
328                 ;;
329             msdos*)
330                 NASMFLAGS="-f coff $NASMFLAGS"
331                 ;;
332                         linux* | freebsd*)
333                                 NASMFLAGS="-f elf -d__ELF__ $NASMFLAGS"
334                 ;;
335             *)
336                 AC_MSG_WARN([nasm not supported for this OS. disabling assembler])
337                 enable_assembler="no"
338                 ;;
339         esac
340     fi
341 fi
342 if test x$enable_assembler = xno; then
343     AC_DEFINE(NO_ASM,,[Define if you want an assembler free build])
344     D2X_FEATURES="no_asm ${D2X_FEATURES}"
345 fi
346 AM_CONDITIONAL(USE_ASM, test x$enable_assembler != xno)
347
348 AH_BOTTOM([
349         /* General defines */
350 #ifndef PACKAGE_STRING
351 #define PACKAGE_STRING PACKAGE " " VERSION
352 #endif
353 #define VERSION_NAME PACKAGE_STRING
354 #define NMONO 1
355 #define PIGGY_USE_PAGING 1
356 #define NEWDEMO 1
357
358 #if defined(__APPLE__) && defined(__MACH__)
359 #define __unix__ /* since we're doing a unix-style compilation... */
360 #endif
361
362 #ifdef __unix__
363 # ifdef GGI
364 #  define GII_INPUT 1
365 #  define GGI_VIDEO 1
366 # else
367 #  ifdef SVGA
368 #   define SVGALIB_INPUT 1
369 #   define SVGALIB_VIDEO 1
370 #  else
371 #   define SDL_INPUT 1
372 #   ifdef OGL
373 #    define SDL_GL_VIDEO 1
374 #   else
375 #    define SDL_VIDEO 1
376 #   endif
377 #  endif
378 # endif
379 #endif
380
381 #ifdef __MINGW32__
382 # define SDL_INPUT 1
383 # ifdef OGL
384 #  define SDL_GL_VIDEO 1
385 # else
386 #  define SDL_VIDEO 1
387 # endif
388 #endif
389         ])
390
391 TARGETS="$TARGETS$ac_cv_exeext"
392
393 AM_PROG_AS
394
395 AC_SUBST(D2X_SUBDIRS)
396
397 AC_SUBST(D2X_ARCH_SUBDIRS)
398
399 AC_SUBST(D2X_MAIN_SUBDIRS)
400
401 AC_SUBST(TARGETS)
402
403 AC_SUBST(NASMFLAGS)
404
405 AC_SUBST(CFLAGS)
406
407 AC_OUTPUT(
408     Makefile
409     2d/Makefile
410     3d/Makefile
411     arch/Makefile
412     arch/dos/Makefile
413     arch/ggi/Makefile
414     arch/linux/Makefile
415     arch/ogl/Makefile
416     arch/sdl/Makefile
417     arch/svgalib/Makefile
418     arch/win32/Makefile
419     cfile/Makefile
420     console/Makefile
421     iff/Makefile
422     libmve/Makefile
423     main/Makefile
424     main/editor/Makefile
425     maths/Makefile
426     mem/Makefile
427     misc/Makefile
428     texmap/Makefile
429     utilities/Makefile
430     debian/changelog
431     rpm/d2x.spec
432 )
433
434 AC_MSG_RESULT([
435         d2x has been configured successfully.
436
437         Platform(s): $D2X_ARCH_SUBDIRS
438         Features   : $D2X_FEATURES $D2X_SUBDIRS $D2X_MAIN_SUBDIRS
439
440         Shared game data directory (unix only): $sharepath
441         ])