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