]> icculus.org git repositories - btb/d2x.git/blob - configure.ac
use the orientation parameter of g3_draw_bitmap
[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 AC_CANONICAL_BUILD
11 AC_CANONICAL_HOST
12 AC_CANONICAL_TARGET
13
14 AM_INIT_AUTOMAKE([subdir-objects])
15
16 AC_CONFIG_HEADERS(conf.h)
17
18 AC_DEFINE_UNQUOTED(D2XMAJOR,D2X_MAJOR,[d2x major version])
19 AC_DEFINE_UNQUOTED(D2XMINOR,D2X_MINOR,[d2x minor version])
20 AC_DEFINE_UNQUOTED(D2XMICRO,D2X_MICRO,[d2x micro version])
21
22 AM_MAINTAINER_MODE
23
24 #kludge to keep autoconf from adding -g -O2
25 CFLAGS=" $CFLAGS"
26
27 AC_PROG_INSTALL
28 AC_PROG_MAKE_SET
29 AC_SEARCH_LIBS([strerror],[cposix])
30 AC_CHECK_TOOL(CC, gcc, :)
31 AC_CHECK_TOOL(RANLIB, ranlib, :)
32 AC_CHECK_TOOL(STRIP, strip, :)
33 AC_CHECK_TOOL(AR, ar, :)
34 AC_PROG_CC
35 AC_PATH_PROGS(NASM, nasm nasmw, no)
36 AC_C_BIGENDIAN
37 AC_CHECK_SIZEOF(void *)
38
39 case $host_cpu in
40     sparc)
41         AC_DEFINE(WORDS_NEED_ALIGNMENT,,[Define if your processor needs data to be word-aligned])
42     ;;
43 esac
44
45 case $host_os in
46     cygwin)
47         AC_MSG_WARN([Cygwin found, setting -mno-cygwin])
48         CFLAGS="-mno-cygwin $CFLAGS"
49         MINGW32=yes
50         ;;
51     mingw*)
52         MINGW32=yes
53         ;;
54     darwin*)
55         MACOSX=yes
56         AX_CHECK_COMPILE_FLAG([-no-cpp-precomp], [CFLAGS="$CFLAGS -no-cpp-precomp"])
57         ;;
58     msdos*)
59         MSDOS=yes
60         ;;
61 esac
62
63 AC_CHECK_DECLS(nanosleep,,,[#include <time.h>])
64 AC_CHECK_TYPES([struct timespec, struct timeval],,,[#include <sys/time.h>])
65
66 AM_CONDITIONAL(MINGW32, test x$MINGW32 = xyes)
67
68 AM_CONDITIONAL(MACOSX, test x$MACOSX = xyes)
69
70 AM_CONDITIONAL(MSDOS, test x$MSDOS = xyes)
71
72 dnl Set $prefix and $exec_prefix to $ac_default_prefix if they are not set
73 test "x$prefix" = "xNONE" && prefix=$ac_default_prefix
74 test "x$exec_prefix" = "xNONE" && exec_prefix="${prefix}"
75
76 dnl Set default locations to find data files.
77 default_sharepath="$datadir/games/$PACKAGE"
78
79 CFLAGS="-Wall -Werror -Wno-deprecated-declarations -Wno-int-to-pointer-cast -Wno-pointer-to-int-cast -Wno-unused-value -Wno-address $CFLAGS"
80 AX_CHECK_COMPILE_FLAG([-Wno-ignored-attributes], [CFLAGS="$CFLAGS -Wno-ignored-attributes"])
81 AX_CHECK_COMPILE_FLAG([-Wno-unused-but-set-variable], [CFLAGS="$CFLAGS -Wno-unused-but-set-variable"])
82 AX_CHECK_COMPILE_FLAG([-Wno-address-of-packed-member], [CFLAGS="$CFLAGS -Wno-address-of-packed-member"])
83 AX_CHECK_COMPILE_FLAG([-Wno-stringop-truncation], [CFLAGS="$CFLAGS -Wno-stringop-truncation"])
84 AX_CHECK_COMPILE_FLAG([-Wno-format-truncation], [CFLAGS="$CFLAGS -Wno-format-truncation"])
85
86 dnl Enable editor build?
87 AC_ARG_ENABLE(editor,
88     [  --enable-editor         Build editor? (not functional)],,)
89
90 dnl Enable macdata build?
91 AC_ARG_ENABLE(macdata,
92     [  --enable-macdata        Build for mac datafiles],,)
93 if test x$enable_macdata = xyes; then
94     AC_DEFINE(MACDATA,,[Define if you want to build for mac datafiles])
95     D2X_FEATURES="macdata ${D2X_FEATURES}"
96 fi
97 AM_CONDITIONAL(MACDATA, test x$enable_macdata = xyes)
98
99 dnl Build with NDEBUG?
100 AC_ARG_ENABLE(debug,
101     [  --disable-debug         Take out debug symbols, Asserts, Int3, etc ],,)
102 if test x$enable_debug = xno; then
103     AC_DEFINE(NDEBUG,,[Define to disable asserts, int3, etc.])
104     CFLAGS="-O2 $CFLAGS"
105 else
106     CFLAGS="-g $CFLAGS"
107     D2X_FEATURES="debug ${D2X_FEATURES}"
108 fi
109
110 dnl Build with RELEASE?
111 AC_ARG_ENABLE(release,
112     [  --enable-release        Release build.  Removes debug/editor things ],,)
113 if test x$enable_release = xyes; then
114     AC_DEFINE(RELEASE,,[Define for a "release" build])
115     D2X_FEATURES="release ${D2X_FEATURES}"
116 fi
117
118 dnl Build without using sdl-joystick ?
119 AC_ARG_ENABLE(linuxjoy,
120     [  --enable-linuxjoy       do not use the SDL Joystick. (eg for MS Sidewinder)],,)
121 if test x$enable_linuxjoy = xyes; then
122     AC_DEFINE(USE_LINUX_JOY,,[define to not use the SDL_Joystick routines.])
123     D2X_FEATURES="linuxjoy ${D2X_FEATURES}"
124 fi
125 AM_CONDITIONAL(USE_LINUX_JOY, test x$enable_linuxjoy = xyes)
126
127 dnl Build with FAST_FILE_IO?
128 AC_ARG_ENABLE(fastfileio,
129     [  --disable-fastfileio    Disable fast file i/o. ],,)
130 if test x$enable_fastfileio != xno; then
131     if test x$ac_cv_c_bigendian = xyes; then
132         AC_MSG_WARN([big-endian cpu detected.  disabling fastfileio])
133         enable_fastfileio="no";
134     fi
135     if test $ac_cv_sizeof_void_p != 4; then
136         AC_MSG_WARN([pointers not 32 bits.  disabling fastfileio])
137         enable_fastfileio="no";
138     fi
139 fi
140 if test x$enable_fastfileio != xno; then
141     AC_DEFINE(FAST_FILE_IO,,[Define for faster i/o on little-endian cpus])
142     D2X_FEATURES="fastfileio ${D2X_FEATURES}"
143 fi
144
145 AC_ARG_WITH(sharepath,
146     [[  --with-sharepath=DIR    Use DIR for shared game data (unix only) [DATADIR/games/d2x]]],
147     sharepath=$withval, sharepath="auto")
148 if test "x$sharepath" = "xauto" -o "x$sharepath" = "xyes" -o "x$sharepath" = "x"; then
149     sharepath="$default_sharepath"
150 fi
151 AC_SUBST(sharepath)
152 eval sharepath=$sharepath
153 eval sharepath=$sharepath
154 AC_DEFINE_UNQUOTED(SHAREPATH, "$sharepath",[Define this to be the shared game directory root])
155
156 TARGETS=
157
158 # Test for MSDOS
159 if test x$MSDOS = xyes; then
160     TARGETS="d2x$ac_cv_exeext $TARGETS"
161         if test x$enable_editor = xyes; then
162                 TARGETS="miner$ac_cv_exeext $TARGETS"
163         fi
164 else
165
166     CFLAGS="-pipe $CFLAGS"
167
168     dnl Check for SDL
169     AM_PATH_SDL(1.1.0,
170         :,
171         AC_MSG_ERROR(SDL not found. Make sure sdl-config is in your PATH, or specify with --with-sdl-prefix)
172     )
173
174     TARGETS="d2x-sdl$ac_cv_exeext $TARGETS"
175         if test x$enable_editor = xyes; then
176                 TARGETS="miner-sdl$ac_cv_exeext $TARGETS"
177         fi
178
179     AC_CHECK_HEADERS(netipx/ipx.h)
180
181   # Check for SDL_image
182     AC_CHECK_LIB(SDL_image, IMG_ReadXPMFromArray,
183         SDLIMAGE_LIBS="-lSDL_image"
184         AC_DEFINE(SDL_IMAGE,,[Define if you have the SDL_image library]))
185     AC_SUBST(SDLIMAGE_LIBS)
186
187   # Check for SDL_mixer
188     PKG_CHECK_MODULES(SDLMIXER, SDL_mixer)
189     AC_SUBST(SDLMIXER_CFLAGS)
190     AC_SUBST(SDLMIXER_LIBS)
191
192   # Check for libpng
193     have_libpng=no
194     #PKG_CHECK_MODULES(LIBPNG, libpng,
195     #    AC_DEFINE(HAVE_LIBPNG,,[Define if you have libpng])
196     #    have_libpng=yes
197     #    LIBS="$LIBPNG_LIBS $LIBS",
198     #    AC_MSG_WARN([libpng not found. disabling png replacement texture support])
199     #)
200     AM_CONDITIONAL(USE_LIBPNG, test x$have_libpng = xyes)
201
202   # Check for PhysicsFS
203     PKG_CHECK_MODULES(PHYSFS, physfs, CFLAGS="$CFLAGS -D__EXPORT__=PHYSFS_DECL",
204     AC_CHECK_HEADERS(physfs.h, , [AC_MSG_ERROR([physfs.h required])])
205     AC_CHECK_LIB(physfs, PHYSFS_init, PHYSFS_LIBS="-lphysfs",
206                  [AC_MSG_ERROR([physfs library required])])
207     )
208     AC_SUBST(PHYSFS_CFLAGS)
209     AC_SUBST(PHYSFS_LIBS)
210
211   # Check for OpenGL
212     AC_ARG_WITH(opengl,
213         [  --with-opengl           Build OpenGL support ],,)
214     if test x$with_opengl = xyes; then
215         TARGETS="d2x-gl$ac_cv_exeext $TARGETS"
216                 if test x$enable_editor = xyes; then
217                         TARGETS="miner-gl$ac_cv_exeext $TARGETS"
218                 fi
219     fi
220
221   # Check for SVGALib
222     AC_ARG_WITH(svga,
223         [  --with-svga             Build SVGALib support ],,)
224     if test x$with_svga = xyes; then
225         TARGETS="d2x-svga$ac_cv_exeext $TARGETS"
226                 if test x$enable_editor = xyes; then
227                         TARGETS="miner-svga$ac_cv_exeext $TARGETS"
228                 fi
229     fi
230     AC_SUBST(SVGA_LIBS)
231 fi
232
233 dnl Check for network
234 AC_ARG_ENABLE(network,
235     [  --disable-network       Do not build network/serial support ],,)
236 if test x$enable_network != xno; then
237     case $host_os in
238         cygwin* | mingw* | msdos* | linux*)
239             enable_native_ipx="yes";
240            ;;
241        *)
242             AC_MSG_WARN([d2x does not support native ipx on this host.  disabling native ipx])
243             enable_native_ipx="no";
244             ;;
245     esac
246     case $host_os in
247         cygwin* | mingw* | msdos*)
248             enable_kalinix="no";
249             ;;
250     esac
251     case $host_os in
252         *solaris*)
253             AC_CHECK_LIB(socket, socket, LIBS="${LIBS} -lsocket",
254                 [AC_MSG_ERROR(socket lib required for net support on solaris not found)])
255             AC_CHECK_LIB(nsl, inet_addr, LIBS="${LIBS} -lnsl",
256                 [AC_MSG_ERROR(nsl lib required for net support on solaris not found)])
257             ;;
258     esac
259 fi
260 AC_ARG_ENABLE(kalinix,
261     [  --disable-kalinix       Disable the KaliNix driver (unix-only)],,)
262 if test x$enable_network != xno; then
263     if test x$enable_native_ipx != xno; then
264         D2X_FEATURES="ipx ${D2X_FEATURES}"
265         AC_DEFINE(NATIVE_IPX,,[Define to use the IPX support of the OS])
266     fi
267     if test x$enable_kalinix != xno; then
268         D2X_FEATURES="kalinix ${D2X_FEATURES}"
269         AC_DEFINE(KALINIX,,[Define to enable use of the KaliNix driver])
270     fi
271     AC_DEFINE(NETWORK,,[Define if you want a network build])
272     D2X_FEATURES="network ${D2X_FEATURES}"
273 fi
274 AM_CONDITIONAL(USE_NETWORK, test x$enable_network != xno)
275 AM_CONDITIONAL(USE_NATIVE_IPX, test x$enable_native_ipx != xno)
276 AM_CONDITIONAL(USE_KALINIX, test x$enable_kalinix != xno)
277
278 dnl Check for assembler
279 AC_ARG_ENABLE(assembler,
280     [  --disable-assembler     Do not use assembler optimization ],,)
281 if test x$enable_assembler != xno; then
282     if test x$NASM = xno; then
283         AC_MSG_WARN([nasm not found. disabling assembler])
284         enable_assembler="no"
285     else
286         NASMFLAGS="-i\$(srcdir)/ $NASMFLAGS"
287         case $host_os in
288             cygwin* | mingw*)
289                 NASMFLAGS="-f win32 $NASMFLAGS"
290                 ;;
291             msdos*)
292                 NASMFLAGS="-f coff $NASMFLAGS"
293                 ;;
294             linux* | freebsd*)
295                 NASMFLAGS="-f elf -d__ELF__ $NASMFLAGS"
296                 ;;
297             *)
298                 AC_MSG_WARN([nasm not supported for this OS. disabling assembler])
299                 enable_assembler="no"
300                 ;;
301         esac
302         case $host_cpu in
303             x86_64)
304                 AC_MSG_WARN([nasm not supported for this cpu. disabling assembler])
305                 enable_assembler="no"
306                 ;;
307         esac
308     fi
309 fi
310 if test x$enable_assembler = xno; then
311     AC_DEFINE(NO_ASM,,[Define if you want an assembler free build])
312     D2X_FEATURES="no_asm ${D2X_FEATURES}"
313 fi
314 AM_CONDITIONAL(USE_ASM, test x$enable_assembler != xno)
315
316 AH_BOTTOM([
317         /* General defines */
318 #ifndef PACKAGE_STRING
319 #define PACKAGE_STRING PACKAGE " " VERSION
320 #endif
321 #define VERSION_NAME PACKAGE_STRING
322 #define NMONO 1
323 #define PIGGY_USE_PAGING 1
324 #define NEWDEMO 1
325
326 #if defined(__APPLE__) && defined(__MACH__)
327 #define __unix__ /* since we're doing a unix-style compilation... */
328 #endif
329         ])
330
331 AM_PROG_AS
332
333 AC_SUBST(TARGETS)
334
335 AC_SUBST(NASMFLAGS)
336
337 AC_SUBST(CFLAGS)
338
339 AC_CONFIG_FILES([Makefile
340     debian/changelog
341     rpm/d2x.spec
342 ])
343 AC_OUTPUT
344
345 AC_MSG_RESULT([
346         d2x has been configured successfully.
347
348         Targets: $TARGETS
349         Features: $D2X_FEATURES
350
351         Shared game data directory (unix only): $sharepath
352         ])