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