]> icculus.org git repositories - btb/d2x.git/blob - configure.ac
make FAST_FILE_IO the default on little-endian machines
[btb/d2x.git] / configure.ac
1 # -*- mode: shell-script -*-
2
3 define([D2X_MAJOR],0)
4 define([D2X_MINOR],1)
5 define([D2X_MICRO],4)
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 AM_INIT_AUTOMAKE([1.6])
15
16 AM_CONFIG_HEADER(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_ISC_POSIX
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_PROG_CXX
36 AC_STDC_HEADERS
37 AC_PATH_PROGS(NASM, nasm nasmw, no)
38 AC_C_BIGENDIAN
39
40 case $host_os in
41     cygwin)
42         AC_MSG_WARN([Cygwin found, setting -mno-cygwin])
43         CFLAGS="-mno-cygwin $CFLAGS"
44         MINGW32=yes
45         ;;
46     mingw*)
47         MINGW32=yes
48         ;;
49     darwin*)
50         MACOSX=yes
51         ;;
52     msdos*)
53         MSDOS=yes
54         ;;
55 esac
56
57 AM_CONDITIONAL(MINGW32, test x$MINGW32 = xyes)
58 if test x$MINGW32 = xyes; then
59     GL_LIBS="opengl32 glu32"
60 elif test x$MACOSX = xyes; then
61     GL_LIBS=""
62 else
63     GL_LIBS="GL GLU"
64 fi
65
66 if test x$MACOSX = xyes; then
67     AC_DEFINE(__MACOSX__,,[Define if building on MAC OS X])
68 fi
69 AM_CONDITIONAL(MACOSX, test x$MACOSX = xyes)
70
71 dnl Set $prefix and $exec_prefix to $ac_default_prefix if they are not set
72 test "x$prefix" = "xNONE" && prefix=$ac_default_prefix
73 test "x$exec_prefix" = "xNONE" && exec_prefix="${prefix}"
74
75 dnl Set default locations to find data files.
76 eval foo="$datadir"
77 default_sharepath="$foo/games/$PACKAGE"
78
79 CFLAGS="-Wall $CFLAGS"
80
81 dnl Enable editor build?
82 AC_ARG_ENABLE(editor,
83     [  --enable-editor         Build editor? (not functional)],,)
84 if test x$enable_editor = xyes; then
85     AC_DEFINE(EDITOR,,[Define if you want to build the editor])
86     D2X_MAIN_SUBDIRS=editor
87 fi
88 AM_CONDITIONAL(EDITOR, test x$enable_editor = xyes)
89
90 dnl Enable shareware build?
91 AC_ARG_ENABLE(shareware,
92     [  --enable-shareware      Build for demo datafiles (not functional)],,)
93 if test x$enable_shareware = xyes; then
94     AC_DEFINE(SHAREWARE,,[Define if you want to build the demo version])
95     D2X_FEATURES="shareware ${D2X_FEATURES}"
96 fi
97 AM_CONDITIONAL(SHAREWARE, test x$enable_shareware = 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 with FAST_FILE_IO?
119 AC_ARG_ENABLE(fastfileio,
120     [  --disable-fastfileio    Disable fast file i/o. ],,)
121 if test x$enable_fastfileio != xno; then
122         if test x$ac_cv_c_bigendian = xyes; then
123                 AC_MSG_WARN([big-endian cpu detected.  disabling fastfileio])
124                 enable_fastfileio="no";
125         fi
126 fi
127 if test x$enable_fastfileio != xno; then
128     AC_DEFINE(FAST_FILE_IO,,[Define for faster i/o on little-endian cpus])
129     D2X_FEATURES="fastfileio ${D2X_FEATURES}"
130 fi
131
132 AC_ARG_WITH(sharepath,
133     [[  --with-sharepath=DIR    Use DIR for shared game data (unix only) [DATADIR/games/d2x]]],
134     sharepath=$withval, sharepath="auto")
135 if test "x$sharepath" = "xauto" -o "x$sharepath" = "xyes" -o "x$sharepath" = "x"; then
136     sharepath="$default_sharepath"
137 fi
138 AC_DEFINE_UNQUOTED(SHAREPATH, "$sharepath",[Define this to be the shared game directory root])
139
140 # Test for MSDOS
141 if test x$MSDOS = xyes; then
142     CFLAGS="-I \$(top_srcdir)/arch/dos/include $CFLAGS"
143     TARGETS=d2x
144     D2X_ARCH_SUBDIRS=dos
145 else
146
147     CFLAGS="-pipe $CFLAGS"
148
149     dnl Check for SDL
150     AM_PATH_SDL(1.1.0,
151         :,
152         AC_MSG_ERROR(SDL not found. Make sure sdl-config is in your PATH, or specify with --with-sdl-prefix)
153     )
154     CFLAGS="$SDL_CFLAGS $CFLAGS"
155     LIBS="$SDL_LIBS $LIBS"
156
157     TARGETS=d2x-sdl
158     D2X_ARCH_SUBDIRS=sdl
159
160     AC_CHECK_HEADERS(netipx/ipx.h)
161
162   # Check for OpenGL
163     AC_ARG_WITH(opengl,
164         [  --with-opengl           Build OpenGL support ],,)
165     if test x$with_opengl = xyes; then
166         for lib in $GL_LIBS; do
167             AC_CHECK_LIB($lib, main,
168                 OGL_LIBS="${OGL_LIBS} -l$lib",
169                 [AC_MSG_ERROR([$lib not found, --with-opengl cannot be used])
170                     opengl=false],
171                 ${OGL_LIBS}
172             )
173         done
174         AC_DEFINE(OGL,,[Define if you want an OpenGL build])
175         TARGETS=d2x-gl
176         D2X_ARCH_SUBDIRS="ogl ${D2X_ARCH_SUBDIRS}"
177     fi
178     AC_SUBST(OGL_LIBS)
179     AM_CONDITIONAL(USE_OPENGL, test x$with_opengl = xyes)
180
181   # Check for GGI
182     AC_ARG_WITH(ggi,
183         [  --with-ggi              Build GGI support ],,)
184     if test x$with_ggi = xyes; then
185         AC_CHECK_LIB(ggi, ggiInit,
186             GGI_LIBS="-lggi",
187             [AC_MSG_ERROR([GGI not found, GGI version cannot be built]); ggi=false])
188         AC_CHECK_LIB(gii, giiInit,
189             GGI_LIBS="${GGI_LIBS} -lgii",
190             [AC_MSG_ERROR([GII not found, GGI version cannot be built]); ggi=false])
191         AC_DEFINE(GGI,,[Define if you want a GGI build])
192         TARGETS=d2x-ggi
193         D2X_ARCH_SUBDIRS="ggi ${D2X_ARCH_SUBDIRS}"
194     fi
195     AC_SUBST(GGI_LIBS)
196     AM_CONDITIONAL(USE_GGI, test x$with_ggi = xyes)
197
198   # Check for SVGALib
199     AC_ARG_WITH(svga,
200         [  --with-svga             Build SVGALib support ],,)
201     if test x$with_svga = xyes; then
202         AC_CHECK_LIB(vga,vga_getmousetype,
203             SVGA_LIBS="-lvga",
204             [AC_MSG_ERROR([vga not found, SVGALib cannot be built])
205                 svga=false],
206         )
207         AC_CHECK_LIB(vgagl,gl_getcontext,
208             SVGA_LIBS="${SVGA_LIBS} -lvgagl",
209             [AC_MSG_ERROR([vgagl not found, SVGALib cannot be built])
210                 svga=false],
211             -lvga)
212         AC_DEFINE(SVGA,,[Define if you want an SVGALib build])
213         TARGETS=d2x-svga
214         D2X_ARCH_SUBDIRS="svgalib ${D2X_ARCH_SUBDIRS}"
215     fi
216     AC_SUBST(SVGA_LIBS)
217     AM_CONDITIONAL(USE_SVGALIB, test x$with_svga = xyes)
218
219     if test x$MINGW32 = xyes; then
220         D2X_ARCH_SUBDIRS="win32 ${D2X_ARCH_SUBDIRS}"
221     else
222         CFLAGS="-I \$(top_srcdir)/arch/linux/include $CFLAGS"
223         D2X_ARCH_SUBDIRS="linux ${D2X_ARCH_SUBDIRS}"
224     fi
225 fi
226
227 dnl Check for network
228 AC_ARG_ENABLE(network,
229     [  --disable-network       Do not build network/serial support ],,)
230 if test x$enable_network != xno; then
231     AC_DEFINE(NETWORK,,[Define if you want a network build])
232     D2X_FEATURES="network ${D2X_FEATURES}"
233 fi
234 AM_CONDITIONAL(USE_NETWORK, test x$enable_network != xno)
235
236 dnl Check for assembler
237 AC_ARG_ENABLE(assembler,
238     [  --disable-assembler     Do not use assembler optimization ],,)
239 if test x$enable_assembler != xno; then
240     if test x$NASM = xno; then
241         AC_MSG_WARN([nasm not found. disabling assembler])
242         enable_assembler="no"
243     else
244         NASMFLAGS="-i\$(srcdir)/ $NASMFLAGS"
245         case $host_os in
246             cygwin*)
247                 NASMFLAGS="-f win32 $NASMFLAGS"
248                 ;;
249             msdos*)
250                 NASMFLAGS="-f coff $NASMFLAGS"
251                 ;;
252             linux*)
253                 NASMFLAGS="-f elf -d__linux__ $NASMFLAGS"
254                 ;;
255             *)
256                 AC_MSG_WARN([nasm not supported for this OS. disabling assembler])
257                 enable_assembler="no"
258                 ;;
259         esac
260     fi
261 fi
262 if test x$enable_assembler = xno; then
263     AC_DEFINE(NO_ASM,,[Define if you want an assembler free build])
264     D2X_FEATURES="no_asm ${D2X_FEATURES}"
265 fi
266 AM_CONDITIONAL(USE_ASM, test x$enable_assembler != xno)
267
268 AH_BOTTOM([
269         /* General defines */
270 #define NMONO 1
271 #define PIGGY_USE_PAGING 1
272 #define NEWDEMO 1
273
274 #ifdef __MACOSX__
275 #define __unix__
276 #endif
277
278 #ifdef __unix__
279 # ifdef GGI
280 #  define GII_INPUT 1
281 #  define GGI_VIDEO 1
282 # else
283 #  ifdef SVGA
284 #   define SVGALIB_INPUT 1
285 #   define SVGALIB_VIDEO 1
286 #  else
287 #   define SDL_INPUT 1
288 #   ifdef OGL
289 #    define SDL_GL_VIDEO 1
290 #   else
291 #    define SDL_VIDEO 1
292 #   endif
293 #  endif
294 # endif
295 #endif
296
297 #ifdef __MINGW32__
298 # define SDL_INPUT 1
299 # ifdef OGL
300 #  define SDL_GL_VIDEO 1
301 # else
302 #  define SDL_VIDEO 1
303 # endif
304 #endif
305         ])
306
307 AM_PROG_AS
308
309 AC_SUBST(D2X_ARCH_SUBDIRS)
310
311 AC_SUBST(D2X_MAIN_SUBDIRS)
312
313 AC_SUBST(TARGETS)
314
315 AC_SUBST(NASMFLAGS)
316
317 AC_SUBST(CFLAGS)
318
319 AC_OUTPUT(
320     Makefile
321     2d/Makefile
322     3d/Makefile
323     arch/Makefile
324     arch/dos/Makefile
325     arch/ggi/Makefile
326     arch/linux/Makefile
327     arch/ogl/Makefile
328     arch/sdl/Makefile
329     arch/svgalib/Makefile
330     arch/win32/Makefile
331     cfile/Makefile
332     iff/Makefile
333     main/Makefile
334     main/editor/Makefile
335     maths/Makefile
336     mem/Makefile
337     misc/Makefile
338     texmap/Makefile
339     utilities/Makefile
340     debian/changelog
341     rpm/d2x.spec
342 )
343
344 AC_MSG_RESULT([
345         d2x has been configured successfully.
346
347         Platform(s): $D2X_ARCH_SUBDIRS
348         Features   : $D2X_FEATURES $D2X_MAIN_SUBDIRS
349
350         Shared game data directory (unix only): $sharepath
351         ])