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