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