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