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