]> icculus.org git repositories - btb/d2x.git/blob - configure.ac
This commit was manufactured by cvs2svn to create tag 'd2x-0_1_2'.
[btb/d2x.git] / configure.ac
1 # -*- mode: shell-script -*-
2 AC_INIT(main/inferno.c)
3 AC_PREREQ(2.52)
4
5 AC_CANONICAL_BUILD
6 AC_CANONICAL_HOST
7 AC_CANONICAL_TARGET
8
9 AM_CONFIG_HEADER(conf.h)
10 AM_INIT_AUTOMAKE(d2x, 0.1.2)
11
12 AM_MAINTAINER_MODE
13
14 #kludge to keep autoconf from adding -g -O2
15 CFLAGS=" $CFLAGS"
16
17 AC_PROG_INSTALL
18 AC_PROG_MAKE_SET
19 AC_ISC_POSIX
20 AC_CHECK_TOOL(CC, gcc, :)
21 AC_CHECK_TOOL(RANLIB, ranlib, :)
22 AC_CHECK_TOOL(STRIP, strip, :)
23 AC_CHECK_TOOL(AR, ar, :)
24 AC_PROG_CC
25 AC_STDC_HEADERS
26 AC_PATH_PROGS(NASM, nasmw nasm, no)
27
28 AC_CYGWIN
29 AC_MINGW32
30 if test x$CYGWIN = xyes; then
31     AC_MSG_WARN([Cygwin found, setting -mno-cygwin])
32     CFLAGS="-mno-cygwin $CFLAGS"
33     MINGW32=yes
34 fi
35
36 AM_CONDITIONAL(MINGW32, test x$MINGW32 = xyes)
37 if test x$MINGW32 = xyes; then
38     GL_LIBS="opengl32 glu32"
39 else
40     GL_LIBS="GL GLU"
41 fi
42
43 dnl Set $prefix and $exec_prefix to $ac_default_prefix if they are not set
44 test "x$prefix" = "xNONE" && prefix=$ac_default_prefix
45 test "x$exec_prefix" = "xNONE" && exec_prefix="${prefix}"
46
47 dnl Set default locations to find data files.
48 eval foo="$datadir"
49 default_sharepath="$foo/games/$PACKAGE"
50
51 CFLAGS="-Wall $CFLAGS"
52
53 dnl Enable editor build?
54 AC_ARG_ENABLE(editor,
55   [  --enable-editor         Build editor? (not functional)],,)
56 if test x$enable_editor = xyes; then
57     AC_DEFINE(EDITOR)
58     D2X_MAIN_SUBDIRS=editor
59 fi
60 AM_CONDITIONAL(EDITOR, test x$enable_editor = xyes)
61
62 dnl Enable shareware build?
63 AC_ARG_ENABLE(shareware,
64   [  --enable-shareware      Build for demo datafiles (not functional)],,)
65 if test x$enable_shareware = xyes; then
66     AC_DEFINE(SHAREWARE)
67     D2X_FEATURES="shareware ${D2X_FEATURES}"
68 fi
69 AM_CONDITIONAL(SHAREWARE, test x$enable_shareware = xyes)
70
71 dnl Enable movie trick?
72 AC_ARG_ENABLE(movies,
73   [  --enable-movie-trick    Enable trick to show movies],,)
74 if test x$enable_movie_trick = xyes; then
75     AC_DEFINE(MOVIE_TRICK)
76     D2X_FEATURES="movie_trick ${D2X_FEATURES}"
77 fi
78 AM_CONDITIONAL(MOVIE_TRICK, test x$enable_movie_trick = xyes)
79
80 dnl Enable NMOVIES?
81 AC_ARG_ENABLE(nmovies,
82   [  --enable-nmovies        Turn off movies (render endlevel flythrough)],,)
83 if test x$enable_nmovies = xyes; then
84     AC_DEFINE(NMOVIES)
85     D2X_FEATURES="nmovies ${D2X_FEATURES}"
86 fi
87 AM_CONDITIONAL(NMOVIES, test x$enable_nmovies = xyes)
88
89 dnl Enable cross-platform bitmap/palette loader?
90 AC_ARG_ENABLE(xploader,
91   [  --enable-xploader       Enable cross-platform bitmap/palette loader ],,)
92 if test x$enable_xploader = xyes; then
93     AC_DEFINE(PORTABLE_LOADER)
94     D2X_FEATURES="xploader ${D2X_FEATURES}"
95 fi
96
97 dnl Count warnings as errors?
98 AC_ARG_ENABLE(werror,
99   [  --enable-werror         Count compiler warning as errors ],,)
100 if test x$enable_werror = xyes; then
101     CFLAGS="-Werror $CFLAGS"
102     D2X_FEATURES="werror ${D2X_FEATURES}"
103 fi
104
105 dnl Build with NDEBUG?
106 AC_ARG_ENABLE(debug,
107   [  --disable-debug         Take out debug symbols, Asserts, Int3, etc ],,)
108 if test x$enable_debug = xno; then
109     AC_DEFINE(NDEBUG)
110     CFLAGS="-O2 $CFLAGS"
111 else
112     CFLAGS="-g $CFLAGS"
113     D2X_FEATURES="debug ${D2X_FEATURES}"
114 fi
115
116 dnl Build with RELEASE?
117 AC_ARG_ENABLE(release,
118   [  --enable-release        Release build.  Removes debug/editor things ],,)
119 if test x$enable_release = xyes; then
120     AC_DEFINE(RELEASE)
121     D2X_FEATURES="release ${D2X_FEATURES}"
122 fi
123
124 AC_ARG_WITH(sharepath,
125   [[  --with-sharepath=DIR    Use DIR for shared game data [DATADIR/games/d2x]]],
126   sharepath=$withval, sharepath="auto")
127 if test "x$sharepath" = "xauto" -o "x$sharepath" = "xyes" -o "x$sharepath" = "x"; then
128     sharepath="$default_sharepath"
129 fi
130 AC_DEFINE_UNQUOTED(SHAREPATH, "$sharepath")
131
132 # Test for DJGPP
133 AM_CONDITIONAL(DJGPP, test "$host_os" = "msdosdjgpp")
134 if test "$host_os" = "msdosdjgpp"; then
135
136   CFLAGS="-I \$(top_srcdir)/arch/dos/include $CFLAGS"
137   TARGETS=d2x
138   D2X_ARCH_SUBDIRS=dos
139 else
140
141   CFLAGS="-pipe $CFLAGS"
142
143   dnl Check for SDL
144   AM_PATH_SDL(1.1.7,
145     :,
146     AC_MSG_ERROR(SDL not found. Make sure sdl-config is in your PATH, or specify with --with-sdl-prefix)
147   )
148   CFLAGS="$SDL_CFLAGS $CFLAGS"
149   LIBS="$SDL_LIBS $LIBS"
150
151   TARGETS=d2x-sdl
152   D2X_ARCH_SUBDIRS=sdl
153
154   AC_CHECK_HEADERS(netipx/ipx.h)
155
156   # Check for OpenGL
157   AC_ARG_WITH(opengl,
158     [  --with-opengl           Build OpenGL support ],,)
159   if test x$with_opengl = xyes; then
160     for lib in $GL_LIBS; do
161         AC_CHECK_LIB($lib, main,
162             OGL_LIBS="${OGL_LIBS} -l$lib",
163             [AC_MSG_ERROR([$lib not found, --with-opengl cannot be used])
164             opengl=false],
165             ${OGL_LIBS}
166         )
167     done
168     AC_DEFINE(OGL)
169     TARGETS=d2x-ogl
170     D2X_ARCH_SUBDIRS="ogl ${D2X_ARCH_SUBDIRS}"
171   fi
172   AC_SUBST(OGL_LIBS)
173   AM_CONDITIONAL(USE_OPENGL, test x$with_opengl = xyes)
174
175   # Check for GGI
176   AC_ARG_WITH(ggi,
177     [  --with-ggi              Build GGI support ],,)
178   if test x$with_ggi = xyes; then
179     AC_CHECK_LIB(ggi, ggiInit,
180       GGI_LIBS="-lggi",
181       [AC_MSG_ERROR([GGI not found, GGI version cannot be built]); ggi=false])
182     AC_CHECK_LIB(gii, giiInit,
183       GGI_LIBS="${GGI_LIBS} -lgii",
184       [AC_MSG_ERROR([GII not found, GGI version cannot be built]); ggi=false])
185     AC_DEFINE(GGI)
186     TARGETS=d2x-ggi
187     D2X_ARCH_SUBDIRS="ggi ${D2X_ARCH_SUBDIRS}"
188   fi
189   AC_SUBST(GGI_LIBS)
190   AM_CONDITIONAL(USE_GGI, test x$with_ggi = xyes)
191
192   # Check for SVGALib
193   AC_ARG_WITH(svga,
194     [  --with-svga             Build SVGALib support ],,)
195   if test x$with_svga = xyes; then
196     AC_CHECK_LIB(vga,vga_getmousetype,
197       SVGA_LIBS="-lvga",
198       [AC_MSG_ERROR([vga not found, SVGALib cannot be built])
199        svga=false],
200        )
201     AC_CHECK_LIB(vgagl,gl_getcontext,
202       SVGA_LIBS="${SVGA_LIBS} -lvgagl",
203       [AC_MSG_ERROR([vgagl not found, SVGALib cannot be built])
204        svga=false],
205        -lvga)
206     AC_DEFINE(SVGA)
207     TARGETS=d2x-svga
208     D2X_ARCH_SUBDIRS="svgalib ${D2X_ARCH_SUBDIRS}"
209   fi
210   AC_SUBST(SVGA_LIBS)
211   AM_CONDITIONAL(USE_SVGALIB, test x$with_svga = xyes)
212
213   if test x$MINGW32 = xyes; then
214     D2X_ARCH_SUBDIRS="win32 ${D2X_ARCH_SUBDIRS}"
215     AC_DEFINE(SDL_JOYSTICK)
216   else
217     CFLAGS="-I \$(top_srcdir)/arch/linux/include $CFLAGS"
218     D2X_ARCH_SUBDIRS="linux ${D2X_ARCH_SUBDIRS}"
219
220     dnl Check for SDL joystick
221     AC_ARG_ENABLE(sdl-joystick,
222       [  --enable-sdl-joystick   Use SDL joystick (required for mingw) ],,)
223     if test x$enable_sdl_joystick = xyes; then
224         AC_DEFINE(SDL_JOYSTICK)
225         D2X_FEATURES="sdl_joystick ${D2X_FEATURES}"
226     fi
227     AM_CONDITIONAL(SDL_JOYSTICK, test x$enable_sdl_joystick = xyes)
228   fi
229 fi
230
231 dnl Check for network
232 AC_ARG_ENABLE(network,
233   [  --disable-network       Do not build network/serial support ],,)
234 if test x$enable_network != xno; then
235     AC_DEFINE(NETWORK)
236     D2X_FEATURES="network ${D2X_FEATURES}"
237 fi
238 AM_CONDITIONAL(USE_NETWORK, test x$enable_network != xno)
239
240 dnl Check for assembler
241 AC_ARG_ENABLE(assembler,
242   [  --disable-assembler     Do not use assembler optimization ],,)
243 if test x$enable_assembler = xno; then
244     AC_DEFINE(NO_ASM)
245     D2X_FEATURES="no_asm ${D2X_FEATURES}"
246 else
247     if test x$NASM = xno; then
248         AC_MSG_ERROR([nasm not found. Install it or use --disable-assembler])
249     else
250         NASMFLAGS="-i\$(srcdir)/ $NASMFLAGS"
251         case $host_os in
252           cygwin)
253               NASMFLAGS="-f win32 $NASMFLAGS"
254               ;;
255           msdosdjgpp)
256               NASMFLAGS="-f coff $NASMFLAGS"
257               ;;
258           linux*)
259               NASMFLAGS="-f elf -d__linux__ $NASMFLAGS"
260               ;;
261           *)
262               AC_MSG_ERROR([Assembler not supported for this OS])
263         esac
264     fi
265 fi
266 AM_CONDITIONAL(USE_ASM, test x$enable_assembler != xno)
267
268 AM_PROG_AS
269
270 AC_SUBST(D2X_ARCH_SUBDIRS)
271
272 AC_SUBST(D2X_MAIN_SUBDIRS)
273
274 AC_SUBST(TARGETS)
275
276 AC_SUBST(NASMFLAGS)
277
278 AC_SUBST(CFLAGS)
279
280 AC_OUTPUT(
281 Makefile
282 2d/Makefile
283 3d/Makefile
284 arch/Makefile
285 arch/dos/Makefile
286 arch/ggi/Makefile
287 arch/linux/Makefile
288 arch/ogl/Makefile
289 arch/sdl/Makefile
290 arch/svgalib/Makefile
291 arch/win32/Makefile
292 cfile/Makefile
293 iff/Makefile
294 main/Makefile
295 main/editor/Makefile
296 maths/Makefile
297 mem/Makefile
298 misc/Makefile
299 texmap/Makefile
300 )
301
302 AC_MSG_RESULT([
303     d2x has been configured successfully.
304
305     Platform(s): $D2X_ARCH_SUBDIRS
306     Features   : $D2X_FEATURES $D2X_MAIN_SUBDIRS
307
308     Shared game data directory: $sharepath
309 ])