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