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