specify prerequisite versions of autoconf and automake
[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 AC_ARG_WITH(sharepath,
117   [[  --with-sharepath=DIR    Use DIR for shared game data [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")
123
124 # Test for DJGPP
125 AM_CONDITIONAL(DJGPP, test "$host_os" = "msdosdjgpp")
126 if test "$host_os" = "msdosdjgpp"; then
127
128   CFLAGS="-I \$(top_srcdir)/arch/dos/include $CFLAGS"
129   TARGETS=d2x
130   D2X_ARCH_SUBDIRS=dos
131 else
132
133   CFLAGS="-pipe $CFLAGS"
134
135   dnl Check for SDL
136   AM_PATH_SDL(1.1.7,
137     :,
138     AC_MSG_ERROR(SDL not found. Make sure sdl-config is in your PATH, or specify with --with-sdl-prefix)
139   )
140   CFLAGS="$SDL_CFLAGS $CFLAGS"
141   LIBS="$SDL_LIBS $LIBS"
142
143   TARGETS=d2x-sdl
144   D2X_ARCH_SUBDIRS=sdl
145
146   AC_CHECK_HEADERS(netipx/ipx.h)
147
148   # Check for OpenGL
149   AC_ARG_WITH(opengl,
150     [  --with-opengl           Build OpenGL support ],,)
151   if test x$with_opengl = xyes; then
152     for lib in $GL_LIBS; do
153         AC_CHECK_LIB($lib, main,
154             OGL_LIBS="${OGL_LIBS} -l$lib",
155             [AC_MSG_ERROR([$lib not found, --with-opengl cannot be used])
156             opengl=false],
157             ${OGL_LIBS}
158         )
159     done
160     AC_DEFINE(OGL)
161     TARGETS=d2x-ogl
162     D2X_ARCH_SUBDIRS="ogl ${D2X_ARCH_SUBDIRS}"
163   fi
164   AC_SUBST(OGL_LIBS)
165   AM_CONDITIONAL(USE_OPENGL, test x$with_opengl = xyes)
166
167   # Check for GGI
168   AC_ARG_WITH(ggi,
169     [  --with-ggi              Build GGI support ],,)
170   if test x$with_ggi = xyes; then
171     AC_CHECK_LIB(ggi, ggiInit,
172       GGI_LIBS="-lggi",
173       [AC_MSG_ERROR([GGI not found, GGI version cannot be built]); ggi=false])
174     AC_CHECK_LIB(gii, giiInit,
175       GGI_LIBS="${GGI_LIBS} -lgii",
176       [AC_MSG_ERROR([GII not found, GGI version cannot be built]); ggi=false])
177     AC_DEFINE(GGI)
178     TARGETS=d2x-ggi
179     D2X_ARCH_SUBDIRS="ggi ${D2X_ARCH_SUBDIRS}"
180   fi
181   AC_SUBST(GGI_LIBS)
182   AM_CONDITIONAL(USE_GGI, test x$with_ggi = xyes)
183
184   # Check for SVGALib
185   AC_ARG_WITH(svga,
186     [  --with-svga             Build SVGALib support ],,)
187   if test x$with_svga = xyes; then
188     AC_CHECK_LIB(vga,vga_getmousetype,
189       SVGA_LIBS="-lvga",
190       [AC_MSG_ERROR([vga not found, SVGALib cannot be built])
191        svga=false],
192        )
193     AC_CHECK_LIB(vgagl,gl_getcontext,
194       SVGA_LIBS="${SVGA_LIBS} -lvgagl",
195       [AC_MSG_ERROR([vgagl not found, SVGALib cannot be built])
196        svga=false],
197        -lvga)
198     AC_DEFINE(SVGA)
199     TARGETS=d2x-svga
200     D2X_ARCH_SUBDIRS="svgalib ${D2X_ARCH_SUBDIRS}"
201   fi
202   AC_SUBST(SVGA_LIBS)
203   AM_CONDITIONAL(USE_SVGALIB, test x$with_svga = xyes)
204
205   if test x$MINGW32 = xyes; then
206     D2X_ARCH_SUBDIRS="win32 ${D2X_ARCH_SUBDIRS}"
207     AC_DEFINE(SDL_JOYSTICK)
208   else
209     CFLAGS="-I \$(top_srcdir)/arch/linux/include $CFLAGS"
210     D2X_ARCH_SUBDIRS="linux ${D2X_ARCH_SUBDIRS}"
211
212     dnl Check for SDL joystick
213     AC_ARG_ENABLE(sdl-joystick,
214       [  --enable-sdl-joystick   Use SDL joystick (required for mingw) ],,)
215     if test x$enable_sdl_joystick = xyes; then
216         AC_DEFINE(SDL_JOYSTICK)
217         D2X_FEATURES="sdl_joystick ${D2X_FEATURES}"
218     fi
219     AM_CONDITIONAL(SDL_JOYSTICK, test x$enable_sdl_joystick = xyes)
220   fi
221 fi
222
223 dnl Check for network
224 AC_ARG_ENABLE(network,
225   [  --disable-network       Do not build network/serial support ],,)
226 if test x$enable_network != xno; then
227     AC_DEFINE(NETWORK)
228     D2X_FEATURES="network ${D2X_FEATURES}"
229 fi
230 AM_CONDITIONAL(USE_NETWORK, test x$enable_network != xno)
231
232 dnl Check for assembler
233 AC_ARG_ENABLE(assembler,
234   [  --disable-assembler     Do not use assembler optimization ],,)
235 if test x$enable_assembler = xno; then
236     AC_DEFINE(NO_ASM)
237     D2X_FEATURES="no_asm ${D2X_FEATURES}"
238 else
239     if test x$NASM = xno; then
240         AC_MSG_ERROR([nasm not found. Install it or use --disable-assembler])
241     else
242         NASMFLAGS="-i\$(srcdir)/ $NASMFLAGS"
243         case $host_os in
244           cygwin)
245               NASMFLAGS="-f win32 $NASMFLAGS"
246               ;;
247           msdosdjgpp)
248               NASMFLAGS="-f coff $NASMFLAGS"
249               ;;
250           linux*)
251               NASMFLAGS="-f elf -d__linux__ $NASMFLAGS"
252               ;;
253           *)
254               AC_MSG_ERROR([Assembler not supported for this OS])
255         esac
256     fi
257 fi
258 AM_CONDITIONAL(USE_ASM, test x$enable_assembler != xno)
259
260 AM_PROG_AS
261
262 AC_SUBST(D2X_ARCH_SUBDIRS)
263
264 AC_SUBST(D2X_MAIN_SUBDIRS)
265
266 AC_SUBST(TARGETS)
267
268 AC_SUBST(NASMFLAGS)
269
270 AC_SUBST(CFLAGS)
271
272 AC_OUTPUT(
273 Makefile
274 2d/Makefile
275 3d/Makefile
276 arch/Makefile
277 arch/dos/Makefile
278 arch/ggi/Makefile
279 arch/linux/Makefile
280 arch/ogl/Makefile
281 arch/sdl/Makefile
282 arch/svgalib/Makefile
283 arch/win32/Makefile
284 cfile/Makefile
285 iff/Makefile
286 main/Makefile
287 main/editor/Makefile
288 maths/Makefile
289 mem/Makefile
290 misc/Makefile
291 texmap/Makefile
292 )
293
294 AC_MSG_RESULT([
295     d2x has been configured successfully.
296
297     Platform(s): $D2X_ARCH_SUBDIRS
298     Features   : $D2X_FEATURES $D2X_MAIN_SUBDIRS
299
300     Shared game data directory: $sharepath
301 ])