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