move SDL_LIBS to LIBS, SDL_CFLAGS to CFLAGS
[btb/d2x.git] / configure.in
1 # -*- mode: shell-script -*-
2 AC_INIT(main/inferno.c)
3
4 AC_VALIDATE_CACHED_SYSTEM_TUPLE(
5         rm $cache_file
6         echo restart configure
7         exit 1
8 )
9
10 AM_CONFIG_HEADER(conf.h)
11 AM_INIT_AUTOMAKE(d2x, 0.1.2)
12
13 AM_MAINTAINER_MODE
14
15 #kludge to keep autoconf from adding -g -O2
16 CFLAGS=" $CFLAGS"
17
18 AC_PROG_INSTALL
19 AC_PROG_CC
20 AC_PROG_MAKE_SET
21 AC_ISC_POSIX
22 AC_CHECK_TOOL(RANLIB, ranlib, :)
23 AC_CHECK_TOOL(AR, ar, :)
24 AC_STDC_HEADERS
25
26 AC_CYGWIN
27 AC_MINGW32
28 if test x$CYGWIN = xyes; then
29     AC_MSG_WARN([Cygwin found, setting -mno-cygwin])
30     CFLAGS="-mno-cygwin $CFLAGS"
31     MINGW32=yes
32 fi
33
34 AM_CONDITIONAL(MINGW32, test x$MINGW32 = xyes)
35 if test x$MINGW32 = xyes; then
36     GL_LIBS="opengl32 glu32"
37     NASM_PROG=nasmw
38 else
39     GL_LIBS="GL GLU"
40     NASM_PROG=nasm
41 fi
42
43 CFLAGS="-Wall $CFLAGS"
44
45 dnl Enable editor build?
46 AC_ARG_ENABLE(editor,
47   [  --enable-editor         Build editor? (not functional)],,)
48 if test x$enable_editor = xyes; then
49     AC_DEFINE(EDITOR)
50     D2X_MAIN_SUBDIRS=editor
51 fi
52 AM_CONDITIONAL(EDITOR, test x$enable_editor = xyes)
53
54 dnl Enable shareware build?
55 AC_ARG_ENABLE(shareware,
56   [  --enable-shareware      Build for demo datafiles (not functional)],,)
57 if test x$enable_shareware = xyes; then
58     AC_DEFINE(SHAREWARE)
59 fi
60 AM_CONDITIONAL(SHAREWARE, test x$enable_shareware = xyes)
61
62 dnl Enable NMOVIES?
63 AC_ARG_ENABLE(nmovies,
64   [  --enable-nmovies        Enable rendering of endlevel flythrough],,)
65 if test x$enable_nmovies = xyes; then
66     AC_DEFINE(NMOVIES)
67 fi
68 AM_CONDITIONAL(NMOVIES, test x$enable_nmovies = xyes)
69
70 dnl Enable cross-platform bitmap/palette loader?
71 AC_ARG_ENABLE(xploader,
72   [  --enable-xploader       Enable cross-platform bitmap/palette loader ],,)
73 if test x$enable_xploader = xyes; then
74     AC_DEFINE(PORTABLE_LOADER)
75 fi
76
77 dnl Count warnings as errors?
78 AC_ARG_ENABLE(werror,
79   [  --enable-werror         Count compiler warning as errors ],,)
80 if test x$enable_werror = xyes; then
81     CFLAGS="-Werror $CFLAGS"
82 fi
83
84 dnl Build with NDEBUG?
85 AC_ARG_ENABLE(debug,
86   [  --disable-debug         Take out debug symbols, Asserts, Int3, etc ],,)
87 if test x$enable_debug = xno; then
88     AC_DEFINE(NDEBUG)
89     CFLAGS="-O2 $CFLAGS"
90 else
91     CFLAGS="-g $CFLAGS"
92 fi
93
94 # Test for DJGPP
95 AM_CONDITIONAL(ENV_DJGPP, test "$host_os" = "msdosdjgpp")
96 if test "$host_os" = "msdosdjgpp"; then
97
98   CFLAGS="-I \$(top_srcdir)/arch/dos/include $CFLAGS"
99   AC_PATH_PROG(NASM, nasm, no)
100   TARGETS=d2x
101   D2X_ARCH_SUBDIRS=dos
102 else
103
104   CFLAGS="-pipe $CFLAGS"
105
106   dnl Check for SDL
107   AM_PATH_SDL(1.1.7,
108     :,
109     AC_MSG_ERROR(SDL not found. Make sure sdl-config is in your PATH, or specify with --with-sdl-prefix)
110   )
111   AC_SUBST(SDL_LIBS)
112
113   TARGETS=d2x-sdl
114   D2X_ARCH_SUBDIRS=sdl
115
116   AC_CHECK_HEADERS(netipx/ipx.h)
117
118   # Check for OpenGL
119   AC_ARG_WITH(opengl,
120     [  --with-opengl           Build OpenGL support ],,)
121   if test x$with_opengl = xyes; then
122     for lib in $GL_LIBS; do
123         AC_CHECK_LIB($lib, main,
124             OGL_LIBS="${OGL_LIBS} -l$lib",
125             [AC_MSG_ERROR([$lib not found, --with-opengl cannot be used])
126             opengl=false],
127             ${OGL_LIBS}
128         )
129     done
130     AC_DEFINE(OGL)
131     TARGETS=d2x-ogl
132     D2X_ARCH_SUBDIRS="${D2X_ARCH_SUBDIRS} ogl"
133   fi
134   AC_SUBST(OGL_LIBS)
135   AM_CONDITIONAL(USE_OPENGL, test x$with_opengl = xyes)
136
137   # Check for GGI
138   AC_ARG_WITH(ggi,
139     [  --with-ggi              Build GGI support ],,)
140   if test x$with_ggi = xyes; then
141     AC_CHECK_LIB(ggi, ggiInit,
142       GGI_LIBS="-lggi",
143       [AC_MSG_ERROR([GGI not found, GGI version cannot be built]); ggi=false])
144     AC_CHECK_LIB(gii, giiInit,
145       GGI_LIBS="${GGI_LIBS} -lgii",
146       [AC_MSG_ERROR([GII not found, GGI version cannot be built]); ggi=false])
147     AC_DEFINE(GGI)
148     TARGETS=d2x-ggi
149     D2X_ARCH_SUBDIRS="${D2X_ARCH_SUBDIRS} ggi"
150   fi
151   AC_SUBST(GGI_LIBS)
152   AM_CONDITIONAL(USE_GGI, test x$with_ggi = xyes)
153
154   # Check for SVGALib
155   AC_ARG_WITH(svga,
156     [  --with-svga             Build SVGALib support ],,)
157   if test x$with_svga = xyes; then
158     AC_CHECK_LIB(vga,vga_getmousetype,
159       SVGA_LIBS="-lvga",
160       [AC_MSG_ERROR([vga not found, SVGALib cannot be built])
161        svga=false],
162        )
163     AC_CHECK_LIB(vgagl,gl_getcontext,
164       SVGA_LIBS="${SVGA_LIBS} -lvgagl",
165       [AC_MSG_ERROR([vgagl not found, SVGALib cannot be built])
166        svga=false],
167        -lvga)
168     AC_DEFINE(SVGA)
169     TARGETS=d2x-svga
170     D2X_ARCH_SUBDIRS="${D2X_ARCH_SUBDIRS} svgalib"
171   fi
172   AC_SUBST(SVGA_LIBS)
173   AM_CONDITIONAL(USE_SVGALIB, test x$with_svga = yes)
174
175   if test x$MINGW32 = xyes; then
176     D2X_ARCH_SUBDIRS="${D2X_ARCH_SUBDIRS} win32"
177   else
178     CFLAGS="-I \$(top_srcdir)/arch/linux/include $CFLAGS"
179     D2X_ARCH_SUBDIRS="${D2X_ARCH_SUBDIRS} linux"
180   fi
181
182   AC_PATH_PROG(NASM, $NASM_PROG, no)
183 fi
184
185 dnl Check for network
186 AC_ARG_ENABLE(network,
187   [  --disable-network       Do not build network/serial support ],,)
188 if test x$enable_network != xno; then
189     AC_DEFINE(NETWORK)
190 fi
191 AM_CONDITIONAL(USE_NETWORK, test x$enable_network != xno)
192
193 dnl Check for assembler
194 AC_ARG_ENABLE(assembler,
195   [  --disable-assembler     Do not use assembler optimization ],,)
196 if test x$enable_assembler = xno; then
197     AC_DEFINE(NO_ASM)
198 else
199     if test x$NASM = xno; then
200         AC_MSG_ERROR([$NASM_PROG not found. Install it or use --disable-assembler])
201     else
202         NASMFLAGS="-i\$(srcdir)/ $NASMFLAGS"
203         case $host_os in
204           cygwin)
205               NASMFLAGS="-f win32 $NASMFLAGS"
206               ;;
207           msdosdjgpp)
208               NASMFLAGS="-f coff $NASMFLAGS"
209               ;;
210           linux*)
211               NASMFLAGS="-f elf -d__linux__ $NASMFLAGS"
212               ;;
213           *)
214               AC_MSG_ERROR([Assembler not supported for this OS])
215         esac
216     fi
217 fi
218 AM_CONDITIONAL(USE_ASM, test x$enable_assembler != xno)
219
220 AM_PROG_AS
221
222 AC_SUBST(D2X_ARCH_SUBDIRS)
223
224 AC_SUBST(D2X_MAIN_SUBDIRS)
225
226 AC_SUBST(TARGETS)
227
228 AC_SUBST(NASMFLAGS)
229
230 AC_SUBST(CFLAGS)
231
232 AC_OUTPUT(
233 Makefile
234 2d/Makefile
235 3d/Makefile
236 arch/Makefile
237 arch/dos/Makefile
238 arch/ggi/Makefile
239 arch/linux/Makefile
240 arch/ogl/Makefile
241 arch/sdl/Makefile
242 arch/svgalib/Makefile
243 arch/win32/Makefile
244 cfile/Makefile
245 iff/Makefile
246 main/Makefile
247 main/editor/Makefile
248 maths/Makefile
249 mem/Makefile
250 misc/Makefile
251 texmap/Makefile
252 )