]> icculus.org git repositories - btb/d2x.git/blob - configure.ac
flatten Makefile
[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([subdir-objects])
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 AC_CHECK_SIZEOF(void *)
43
44 case $host_cpu in
45     sparc)
46         AC_DEFINE(WORDS_NEED_ALIGNMENT,,[Define if your processor needs data to be word-aligned])
47     ;;
48 esac
49
50 case $host_os in
51     cygwin)
52         AC_MSG_WARN([Cygwin found, setting -mno-cygwin])
53         CFLAGS="-mno-cygwin $CFLAGS"
54         MINGW32=yes
55         ;;
56     mingw*)
57         MINGW32=yes
58         ;;
59     darwin*)
60         MACOSX=yes
61         CFLAGS="-no-cpp-precomp $CFLAGS"
62         ;;
63     msdos*)
64         MSDOS=yes
65         ;;
66 esac
67
68 AC_CHECK_DECLS(nanosleep,,,[#include <time.h>])
69 AC_CHECK_TYPES([struct timespec, struct timeval],,,[#include <sys/time.h>])
70
71 AM_CONDITIONAL(MINGW32, test x$MINGW32 = xyes)
72
73 AM_CONDITIONAL(MACOSX, test x$MACOSX = xyes)
74
75 AM_CONDITIONAL(MSDOS, test x$MSDOS = xyes)
76
77 dnl Set $prefix and $exec_prefix to $ac_default_prefix if they are not set
78 test "x$prefix" = "xNONE" && prefix=$ac_default_prefix
79 test "x$exec_prefix" = "xNONE" && exec_prefix="${prefix}"
80
81 dnl Set default locations to find data files.
82 default_sharepath="$datadir/games/$PACKAGE"
83
84 CFLAGS="-Wall -Wno-char-subscripts $CFLAGS"
85
86 dnl Enable editor build?
87 AC_ARG_ENABLE(editor,
88     [  --enable-editor         Build editor? (not functional)],,)
89 if test x$enable_editor = xyes; then
90     AC_DEFINE(EDITOR,,[Define if you want to build the editor])
91     D2X_FEATURES="editor $D2X_FEATURES"
92 fi
93 AM_CONDITIONAL(USE_EDITOR, test x$enable_editor = xyes)
94
95 dnl Enable macdata build?
96 AC_ARG_ENABLE(macdata,
97     [  --enable-macdata        Build for mac datafiles],,)
98 if test x$enable_macdata = xyes; then
99     AC_DEFINE(MACDATA,,[Define if you want to build for mac datafiles])
100     D2X_FEATURES="macdata ${D2X_FEATURES}"
101 fi
102 AM_CONDITIONAL(MACDATA, test x$enable_macdata = xyes)
103
104 dnl Build with NDEBUG?
105 AC_ARG_ENABLE(debug,
106     [  --disable-debug         Take out debug symbols, Asserts, Int3, etc ],,)
107 if test x$enable_debug = xno; then
108     AC_DEFINE(NDEBUG,,[Define to disable asserts, int3, etc.])
109     CFLAGS="-O2 $CFLAGS"
110 else
111     CFLAGS="-g $CFLAGS"
112     D2X_FEATURES="debug ${D2X_FEATURES}"
113 fi
114
115 dnl Build with RELEASE?
116 AC_ARG_ENABLE(release,
117     [  --enable-release        Release build.  Removes debug/editor things ],,)
118 if test x$enable_release = xyes; then
119     AC_DEFINE(RELEASE,,[Define for a "release" build])
120     D2X_FEATURES="release ${D2X_FEATURES}"
121 fi
122
123 dnl Build without using sdl-joystick ?
124 AC_ARG_ENABLE(linuxjoy,
125     [  --enable-linuxjoy       do not use the SDL Joystick. (eg for MS Sidewinder)],,)
126 if test x$enable_linuxjoy = xyes; then
127     AC_DEFINE(USE_LINUX_JOY,,[define to not use the SDL_Joystick routines.])
128     D2X_FEATURES="linuxjoy ${D2X_FEATURES}"
129 fi
130 AM_CONDITIONAL(USE_LINUX_JOY, test x$enable_linuxjoy = xyes)
131
132 dnl Build with FAST_FILE_IO?
133 AC_ARG_ENABLE(fastfileio,
134     [  --disable-fastfileio    Disable fast file i/o. ],,)
135 if test x$enable_fastfileio != xno; then
136     if test x$ac_cv_c_bigendian = xyes; then
137         AC_MSG_WARN([big-endian cpu detected.  disabling fastfileio])
138         enable_fastfileio="no";
139     fi
140     if test $ac_cv_sizeof_void_p != 4; then
141         AC_MSG_WARN([pointers not 32 bits.  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     [  --disable-console        Disable graphical console ],,)
153 if test x$enable_console != xno; then
154     AC_DEFINE(CONSOLE,,[Define to enable console])
155     D2X_FEATURES="console ${D2X_FEATURES}"
156
157 fi
158 AM_CONDITIONAL(USE_CONSOLE, test x$enable_console != xno)
159
160 AC_ARG_WITH(sharepath,
161     [[  --with-sharepath=DIR    Use DIR for shared game data (unix only) [DATADIR/games/d2x]]],
162     sharepath=$withval, sharepath="auto")
163 if test "x$sharepath" = "xauto" -o "x$sharepath" = "xyes" -o "x$sharepath" = "x"; then
164     sharepath="$default_sharepath"
165 fi
166 AC_SUBST(sharepath)
167 eval sharepath=$sharepath
168 eval sharepath=$sharepath
169 AC_DEFINE_UNQUOTED(SHAREPATH, "$sharepath",[Define this to be the shared game directory root])
170
171 TARGETS=
172
173 # Test for MSDOS
174 if test x$MSDOS = xyes; then
175     TARGETS="d2x $TARGETS"
176 else
177
178     CFLAGS="-pipe $CFLAGS"
179
180     dnl Check for SDL
181     AM_PATH_SDL(1.1.0,
182         :,
183         AC_MSG_ERROR(SDL not found. Make sure sdl-config is in your PATH, or specify with --with-sdl-prefix)
184     )
185
186     TARGETS="d2x-sdl $TARGETS"
187
188     AC_CHECK_HEADERS(netipx/ipx.h)
189
190   # Check for SDL_image
191     AC_CHECK_LIB(SDL_image, IMG_ReadXPMFromArray,
192         SDLIMAGE_LIBS="-lSDL_image"
193         AC_DEFINE(SDL_IMAGE,,[Define if you have the SDL_image library]))
194     AC_SUBST(SDLIMAGE_LIBS)
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 PhysicsFS
207     AC_CHECK_HEADERS(physfs.h, , [AC_MSG_ERROR([physfs.h required])])
208     AC_CHECK_LIB(physfs, PHYSFS_init, PHYSFS_LIBS="-lphysfs",
209                  [AC_MSG_ERROR([physfs library required])])
210     AC_SUBST(PHYSFS_LIBS)
211
212   # Check for OpenGL
213     AC_ARG_WITH(opengl,
214         [  --with-opengl           Build OpenGL support ],,)
215     if test x$with_opengl = xyes; then
216         TARGETS="d2x-gl $TARGETS"
217     fi
218
219   # Check for GGI
220     AC_ARG_WITH(ggi,
221         [  --with-ggi              Build GGI support ],,)
222     if test x$with_ggi = xyes; then
223         TARGETS="d2x-ggi $TARGETS"
224     fi
225     AC_SUBST(GGI_LIBS)
226     AM_CONDITIONAL(USE_GGI, test x$with_ggi = xyes)
227
228   # Check for SVGALib
229     AC_ARG_WITH(svga,
230         [  --with-svga             Build SVGALib support ],,)
231     if test x$with_svga = xyes; then
232         TARGETS="d2x-svga $TARGETS"
233     fi
234     AC_SUBST(SVGA_LIBS)
235     AM_CONDITIONAL(USE_SVGALIB, test x$with_svga = xyes)
236 fi
237
238 dnl Check for network
239 AC_ARG_ENABLE(network,
240     [  --disable-network       Do not build network/serial support ],,)
241 if test x$enable_network != xno; then
242     case $host_os in
243         cygwin* | mingw* | msdos* | linux*)
244             enable_native_ipx="yes";
245            ;;
246        *)
247             AC_MSG_WARN([d2x does not support native ipx on this host.  disabling native ipx])
248             enable_native_ipx="no";
249             ;;
250     esac
251     case $host_os in
252         cygwin* | mingw* | msdos*)
253             enable_kalinix="no";
254             ;;
255     esac
256     case $host_os in
257         *solaris*)
258             AC_CHECK_LIB(socket, socket, LIBS="${LIBS} -lsocket",
259                 [AC_MSG_ERROR(socket lib required for net support on solaris not found)])
260             AC_CHECK_LIB(nsl, inet_addr, LIBS="${LIBS} -lnsl",
261                 [AC_MSG_ERROR(nsl lib required for net support on solaris not found)])
262             ;;
263     esac
264 fi
265 AC_ARG_ENABLE(kalinix,
266     [  --disable-kalinix       Disable the KaliNix driver (unix-only)],,)
267 if test x$enable_network != xno; then
268     if test x$enable_native_ipx != xno; then
269         D2X_FEATURES="ipx ${D2X_FEATURES}"
270         AC_DEFINE(NATIVE_IPX,,[Define to use the IPX support of the OS])
271     fi
272     if test x$enable_kalinix != xno; then
273         D2X_FEATURES="kalinix ${D2X_FEATURES}"
274         AC_DEFINE(KALINIX,,[Define to enable use of the KaliNix driver])
275     fi
276     AC_DEFINE(NETWORK,,[Define if you want a network build])
277     D2X_FEATURES="network ${D2X_FEATURES}"
278 fi
279 AM_CONDITIONAL(USE_NETWORK, test x$enable_network != xno)
280 AM_CONDITIONAL(USE_NATIVE_IPX, test x$enable_native_ipx != xno)
281 AM_CONDITIONAL(USE_KALINIX, test x$enable_kalinix != xno)
282
283 dnl Check for assembler
284 AC_ARG_ENABLE(assembler,
285     [  --disable-assembler     Do not use assembler optimization ],,)
286 if test x$enable_assembler != xno; then
287     if test x$NASM = xno; then
288         AC_MSG_WARN([nasm not found. disabling assembler])
289         enable_assembler="no"
290     else
291         NASMFLAGS="-i\$(srcdir)/ $NASMFLAGS"
292         case $host_os in
293             cygwin* | mingw*)
294                 NASMFLAGS="-f win32 $NASMFLAGS"
295                 ;;
296             msdos*)
297                 NASMFLAGS="-f coff $NASMFLAGS"
298                 ;;
299             linux* | freebsd*)
300                 NASMFLAGS="-f elf -d__ELF__ $NASMFLAGS"
301                 ;;
302             *)
303                 AC_MSG_WARN([nasm not supported for this OS. disabling assembler])
304                 enable_assembler="no"
305                 ;;
306         esac
307         case $host_cpu in
308             x86_64)
309                 AC_MSG_WARN([nasm not supported for this cpu. disabling assembler])
310                 enable_assembler="no"
311                 ;;
312         esac
313     fi
314 fi
315 if test x$enable_assembler = xno; then
316     AC_DEFINE(NO_ASM,,[Define if you want an assembler free build])
317     D2X_FEATURES="no_asm ${D2X_FEATURES}"
318 fi
319 AM_CONDITIONAL(USE_ASM, test x$enable_assembler != xno)
320
321 AH_BOTTOM([
322         /* General defines */
323 #ifndef PACKAGE_STRING
324 #define PACKAGE_STRING PACKAGE " " VERSION
325 #endif
326 #define VERSION_NAME PACKAGE_STRING
327 #define NMONO 1
328 #define PIGGY_USE_PAGING 1
329 #define NEWDEMO 1
330
331 #if defined(__APPLE__) && defined(__MACH__)
332 #define __unix__ /* since we're doing a unix-style compilation... */
333 #endif
334
335 #ifdef __unix__
336 # ifdef GGI
337 #  define GII_INPUT 1
338 #  define GGI_VIDEO 1
339 # else
340 #  ifdef SVGA
341 #   define SVGALIB_INPUT 1
342 #   define SVGALIB_VIDEO 1
343 #  else
344 #   define SDL_INPUT 1
345 #   ifdef OGL
346 #    define SDL_GL_VIDEO 1
347 #   else
348 #    define SDL_VIDEO 1
349 #   endif
350 #  endif
351 # endif
352 #endif
353
354 #ifdef _WIN32
355 # define SDL_INPUT 1
356 # ifdef OGL
357 #  define SDL_GL_VIDEO 1
358 # else
359 #  define SDL_VIDEO 1
360 # endif
361 #endif
362         ])
363
364 TARGETS="$TARGETS$ac_cv_exeext"
365
366 AM_PROG_AS
367
368 AC_SUBST(TARGETS)
369
370 AC_SUBST(NASMFLAGS)
371
372 AC_SUBST(CFLAGS)
373
374 AC_OUTPUT(
375     Makefile
376     utilities/Makefile
377     debian/changelog
378     rpm/d2x.spec
379 )
380
381 AC_MSG_RESULT([
382         d2x has been configured successfully.
383
384         Targets: $TARGETS
385         Features: $D2X_FEATURES
386
387         Shared game data directory (unix only): $sharepath
388         ])