]> icculus.org git repositories - btb/d2x.git/blob - configure.ac
selectively enable 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],[https://github.com/btb/d2x/issues])
8 AC_PREREQ(2.52)
9
10 m4_include([m4/ax_check_compile_flag.m4])
11
12 AC_CANONICAL_BUILD
13 AC_CANONICAL_HOST
14 AC_CANONICAL_TARGET
15
16 AC_EXEEXT
17 AC_OBJEXT
18
19 AM_INIT_AUTOMAKE([subdir-objects])
20
21 AM_CONFIG_HEADER(conf.h)
22
23 AC_DEFINE_UNQUOTED(D2XMAJOR,D2X_MAJOR,[d2x major version])
24 AC_DEFINE_UNQUOTED(D2XMINOR,D2X_MINOR,[d2x minor version])
25 AC_DEFINE_UNQUOTED(D2XMICRO,D2X_MICRO,[d2x micro version])
26
27 AM_MAINTAINER_MODE
28
29 #kludge to keep autoconf from adding -g -O2
30 CFLAGS=" $CFLAGS"
31
32 AC_PROG_INSTALL
33 AC_PROG_MAKE_SET
34 AC_ISC_POSIX
35 AC_CHECK_TOOL(CC, gcc, :)
36 AC_CHECK_TOOL(RANLIB, ranlib, :)
37 AC_CHECK_TOOL(STRIP, strip, :)
38 AC_CHECK_TOOL(AR, ar, :)
39 AC_PROG_CC
40 AC_PROG_CXX
41 AC_STDC_HEADERS
42 AC_PATH_PROGS(NASM, nasm nasmw, no)
43 AC_C_BIGENDIAN
44 AC_CHECK_SIZEOF(void *)
45
46 case $host_cpu in
47     sparc)
48         AC_DEFINE(WORDS_NEED_ALIGNMENT,,[Define if your processor needs data to be word-aligned])
49     ;;
50 esac
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         CFLAGS="-no-cpp-precomp $CFLAGS"
64         ;;
65     msdos*)
66         MSDOS=yes
67         ;;
68 esac
69
70 AC_CHECK_DECLS(nanosleep,,,[#include <time.h>])
71 AC_CHECK_TYPES([struct timespec, struct timeval],,,[#include <sys/time.h>])
72
73 AM_CONDITIONAL(MINGW32, test x$MINGW32 = xyes)
74
75 AM_CONDITIONAL(MACOSX, test x$MACOSX = xyes)
76
77 AM_CONDITIONAL(MSDOS, test x$MSDOS = xyes)
78
79 dnl Set $prefix and $exec_prefix to $ac_default_prefix if they are not set
80 test "x$prefix" = "xNONE" && prefix=$ac_default_prefix
81 test "x$exec_prefix" = "xNONE" && exec_prefix="${prefix}"
82
83 dnl Set default locations to find data files.
84 default_sharepath="$datadir/games/$PACKAGE"
85
86 CFLAGS="-Wall -Werror -Wno-deprecated-declarations -Wno-int-to-pointer-cast -Wno-unused-value -Wno-address $CFLAGS"
87 AX_CHECK_COMPILE_FLAG([-Wno-ignored-attributes], [CFLAGS="$CFLAGS -Wno-ignored-attributes"])
88 AX_CHECK_COMPILE_FLAG([-Wno-unused-but-set-variable], [CFLAGS="$CFLAGS -Wno-unused-but-set-variable"])
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_FEATURES="editor $D2X_FEATURES"
96 fi
97 AM_CONDITIONAL(USE_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     if test $ac_cv_sizeof_void_p != 4; then
145         AC_MSG_WARN([pointers not 32 bits.  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 AC_ARG_WITH(sharepath,
155     [[  --with-sharepath=DIR    Use DIR for shared game data (unix only) [DATADIR/games/d2x]]],
156     sharepath=$withval, sharepath="auto")
157 if test "x$sharepath" = "xauto" -o "x$sharepath" = "xyes" -o "x$sharepath" = "x"; then
158     sharepath="$default_sharepath"
159 fi
160 AC_SUBST(sharepath)
161 eval sharepath=$sharepath
162 eval sharepath=$sharepath
163 AC_DEFINE_UNQUOTED(SHAREPATH, "$sharepath",[Define this to be the shared game directory root])
164
165 TARGETS=
166
167 # Test for MSDOS
168 if test x$MSDOS = xyes; then
169     TARGETS="d2x $TARGETS"
170 else
171
172     CFLAGS="-pipe $CFLAGS"
173
174     dnl Check for SDL
175     AM_PATH_SDL(1.1.0,
176         :,
177         AC_MSG_ERROR(SDL not found. Make sure sdl-config is in your PATH, or specify with --with-sdl-prefix)
178     )
179
180     TARGETS="d2x-sdl $TARGETS"
181
182     AC_CHECK_HEADERS(netipx/ipx.h)
183
184   # Check for SDL_image
185     AC_CHECK_LIB(SDL_image, IMG_ReadXPMFromArray,
186         SDLIMAGE_LIBS="-lSDL_image"
187         AC_DEFINE(SDL_IMAGE,,[Define if you have the SDL_image library]))
188     AC_SUBST(SDLIMAGE_LIBS)
189
190   # Check for libpng
191     have_libpng=no
192     #PKG_CHECK_MODULES(LIBPNG, libpng,
193     #    AC_DEFINE(HAVE_LIBPNG,,[Define if you have libpng])
194     #    have_libpng=yes
195     #    LIBS="$LIBPNG_LIBS $LIBS",
196     #    AC_MSG_WARN([libpng not found. disabling png replacement texture support])
197     #)
198     AM_CONDITIONAL(USE_LIBPNG, test x$have_libpng = xyes)
199
200   # Check for PhysicsFS
201     AC_CHECK_HEADERS(physfs.h, , [AC_MSG_ERROR([physfs.h required])])
202     AC_CHECK_LIB(physfs, PHYSFS_init, PHYSFS_LIBS="-lphysfs",
203                  [AC_MSG_ERROR([physfs library required])])
204     AC_SUBST(PHYSFS_LIBS)
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         TARGETS="d2x-gl $TARGETS"
211     fi
212
213   # Check for SVGALib
214     AC_ARG_WITH(svga,
215         [  --with-svga             Build SVGALib support ],,)
216     if test x$with_svga = xyes; then
217         TARGETS="d2x-svga $TARGETS"
218     fi
219     AC_SUBST(SVGA_LIBS)
220     AM_CONDITIONAL(USE_SVGALIB, test x$with_svga = xyes)
221 fi
222
223 dnl Check for network
224 AC_ARG_ENABLE(network,
225     [  --disable-network       Do not build network/serial support ],,)
226 if test x$enable_network != xno; then
227     case $host_os in
228         cygwin* | mingw* | msdos* | linux*)
229             enable_native_ipx="yes";
230            ;;
231        *)
232             AC_MSG_WARN([d2x does not support native ipx on this host.  disabling native ipx])
233             enable_native_ipx="no";
234             ;;
235     esac
236     case $host_os in
237         cygwin* | mingw* | msdos*)
238             enable_kalinix="no";
239             ;;
240     esac
241     case $host_os in
242         *solaris*)
243             AC_CHECK_LIB(socket, socket, LIBS="${LIBS} -lsocket",
244                 [AC_MSG_ERROR(socket lib required for net support on solaris not found)])
245             AC_CHECK_LIB(nsl, inet_addr, LIBS="${LIBS} -lnsl",
246                 [AC_MSG_ERROR(nsl lib required for net support on solaris not found)])
247             ;;
248     esac
249 fi
250 AC_ARG_ENABLE(kalinix,
251     [  --disable-kalinix       Disable the KaliNix driver (unix-only)],,)
252 if test x$enable_network != xno; then
253     if test x$enable_native_ipx != xno; then
254         D2X_FEATURES="ipx ${D2X_FEATURES}"
255         AC_DEFINE(NATIVE_IPX,,[Define to use the IPX support of the OS])
256     fi
257     if test x$enable_kalinix != xno; then
258         D2X_FEATURES="kalinix ${D2X_FEATURES}"
259         AC_DEFINE(KALINIX,,[Define to enable use of the KaliNix driver])
260     fi
261     AC_DEFINE(NETWORK,,[Define if you want a network build])
262     D2X_FEATURES="network ${D2X_FEATURES}"
263 fi
264 AM_CONDITIONAL(USE_NETWORK, test x$enable_network != xno)
265 AM_CONDITIONAL(USE_NATIVE_IPX, test x$enable_native_ipx != xno)
266 AM_CONDITIONAL(USE_KALINIX, test x$enable_kalinix != xno)
267
268 dnl Check for assembler
269 AC_ARG_ENABLE(assembler,
270     [  --disable-assembler     Do not use assembler optimization ],,)
271 if test x$enable_assembler != xno; then
272     if test x$NASM = xno; then
273         AC_MSG_WARN([nasm not found. disabling assembler])
274         enable_assembler="no"
275     else
276         NASMFLAGS="-i\$(srcdir)/ $NASMFLAGS"
277         case $host_os in
278             cygwin* | mingw*)
279                 NASMFLAGS="-f win32 $NASMFLAGS"
280                 ;;
281             msdos*)
282                 NASMFLAGS="-f coff $NASMFLAGS"
283                 ;;
284             linux* | freebsd*)
285                 NASMFLAGS="-f elf -d__ELF__ $NASMFLAGS"
286                 ;;
287             *)
288                 AC_MSG_WARN([nasm not supported for this OS. disabling assembler])
289                 enable_assembler="no"
290                 ;;
291         esac
292         case $host_cpu in
293             x86_64)
294                 AC_MSG_WARN([nasm not supported for this cpu. disabling assembler])
295                 enable_assembler="no"
296                 ;;
297         esac
298     fi
299 fi
300 if test x$enable_assembler = xno; then
301     AC_DEFINE(NO_ASM,,[Define if you want an assembler free build])
302     D2X_FEATURES="no_asm ${D2X_FEATURES}"
303 fi
304 AM_CONDITIONAL(USE_ASM, test x$enable_assembler != xno)
305
306 AH_BOTTOM([
307         /* General defines */
308 #ifndef PACKAGE_STRING
309 #define PACKAGE_STRING PACKAGE " " VERSION
310 #endif
311 #define VERSION_NAME PACKAGE_STRING
312 #define NMONO 1
313 #define PIGGY_USE_PAGING 1
314 #define NEWDEMO 1
315
316 #if defined(__APPLE__) && defined(__MACH__)
317 #define __unix__ /* since we're doing a unix-style compilation... */
318 #endif
319
320 #ifdef __unix__
321 #  ifdef SVGA
322 #   define SVGALIB_INPUT 1
323 #   define SVGALIB_VIDEO 1
324 #  else
325 #   define SDL_INPUT 1
326 #   ifdef OGL
327 #    define SDL_GL_VIDEO 1
328 #   else
329 #    define SDL_VIDEO 1
330 #   endif
331 #  endif
332 #endif
333
334 #ifdef _WIN32
335 # define SDL_INPUT 1
336 # ifdef OGL
337 #  define SDL_GL_VIDEO 1
338 # else
339 #  define SDL_VIDEO 1
340 # endif
341 #endif
342         ])
343
344 TARGETS="$TARGETS$ac_cv_exeext"
345
346 AM_PROG_AS
347
348 AC_SUBST(TARGETS)
349
350 AC_SUBST(NASMFLAGS)
351
352 AC_SUBST(CFLAGS)
353
354 AC_OUTPUT(
355     Makefile
356     debian/changelog
357     rpm/d2x.spec
358 )
359
360 AC_MSG_RESULT([
361         d2x has been configured successfully.
362
363         Targets: $TARGETS
364         Features: $D2X_FEATURES
365
366         Shared game data directory (unix only): $sharepath
367         ])