take out -O2 if doing debug build
[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 cross-platform bitmap/palette loader?
55 AC_ARG_ENABLE(xploader,
56   [  --enable-xploader       Enable cross-platform bitmap/palette loader ],,)
57 if test x$enable_xploader = xyes; then
58     AC_DEFINE(PORTABLE_LOADER)
59 fi
60
61 dnl Count warnings as errors?
62 AC_ARG_ENABLE(werror,
63   [  --enable-werror         Count compiler warning as errors ],,)
64 if test x$enable_werror = xyes; then
65     CFLAGS="-Werror $CFLAGS"
66 fi
67
68 dnl Build with NDEBUG?
69 AC_ARG_ENABLE(debug,
70   [  --disable-debug         Take out debug symbols, Asserts, Int3, etc ],,)
71 if test x$enable_debug = xno; then
72     AC_DEFINE(NDEBUG)
73     CFLAGS="-O2 $CFLAGS"
74 else
75     CFLAGS="-g $CFLAGS"
76 fi
77
78 # Test for DJGPP
79 AM_CONDITIONAL(ENV_DJGPP, test "$host_os" = "msdosdjgpp")
80 if test "$host_os" = "msdosdjgpp"; then
81
82   CFLAGS="-I \$(top_srcdir)/arch/dos/include $CFLAGS"
83   AC_PATH_PROG(NASM, nasm, no)
84   TARGETS=d2x
85   D2X_ARCH_SUBDIRS=dos
86 else
87
88   CFLAGS="-pipe $CFLAGS"
89
90   dnl Check for SDL
91   AM_PATH_SDL(1.1.7,
92     :,
93     AC_MSG_ERROR(SDL not found. Make sure sdl-config is in your PATH, or specify with --with-sdl-prefix)
94   )
95   AC_SUBST(SDL_LIBS)
96
97   TARGETS=d2x-sdl
98   D2X_ARCH_SUBDIRS=sdl
99
100   AC_CHECK_HEADERS(netipx/ipx.h)
101
102   # Check for OpenGL
103   AC_ARG_WITH(opengl,
104     [  --with-opengl           Build OpenGL support ],,)
105   if test x$with_opengl = xyes; then
106     for lib in $GL_LIBS; do
107         AC_CHECK_LIB($lib, main,
108             OGL_LIBS="${OGL_LIBS} -l$lib",
109             [AC_MSG_ERROR([$lib not found, --with-opengl cannot be used])
110             opengl=false],
111             ${OGL_LIBS}
112         )
113     done
114     AC_DEFINE(OGL)
115     TARGETS=d2x-ogl
116     D2X_ARCH_SUBDIRS="${D2X_ARCH_SUBDIRS} ogl"
117   fi
118   AC_SUBST(OGL_LIBS)
119   AM_CONDITIONAL(USE_OPENGL, test x$with_opengl = xyes)
120
121   # Check for GGI
122   AC_ARG_WITH(ggi,
123     [  --with-ggi              Build GGI support ],,)
124   if test x$with_ggi = xyes; then
125     AC_CHECK_LIB(ggi, ggiInit,
126       GGI_LIBS="-lggi",
127       [AC_MSG_ERROR([GGI not found, GGI version cannot be built]); ggi=false])
128     AC_CHECK_LIB(gii, giiInit,
129       GGI_LIBS="${GGI_LIBS} -lgii",
130       [AC_MSG_ERROR([GII not found, GGI version cannot be built]); ggi=false])
131     AC_DEFINE(GGI)
132     TARGETS=d2x-ggi
133     D2X_ARCH_SUBDIRS="${D2X_ARCH_SUBDIRS} ggi"
134   fi
135   AC_SUBST(GGI_LIBS)
136   AM_CONDITIONAL(USE_GGI, test x$with_ggi = xyes)
137
138   # Check for SVGALib
139   AC_ARG_WITH(svga,
140     [  --with-svga             Build SVGALib support ],,)
141   if test x$with_svga = xyes; then
142     AC_CHECK_LIB(vga,vga_getmousetype,
143       SVGA_LIBS="-lvga",
144       [AC_MSG_ERROR([vga not found, SVGALib cannot be built])
145        svga=false],
146        )
147     AC_CHECK_LIB(vgagl,gl_getcontext,
148       SVGA_LIBS="${SVGA_LIBS} -lvgagl",
149       [AC_MSG_ERROR([vgagl not found, SVGALib cannot be built])
150        svga=false],
151        -lvga)
152     AC_DEFINE(SVGA)
153     TARGETS=d2x-svga
154     D2X_ARCH_SUBDIRS="${D2X_ARCH_SUBDIRS} svgalib"
155   fi
156   AC_SUBST(SVGA_LIBS)
157   AM_CONDITIONAL(USE_SVGALIB, test x$with_svga = yes)
158
159   if test x$MINGW32 = xyes; then
160     D2X_ARCH_SUBDIRS="${D2X_ARCH_SUBDIRS} win32"
161   else
162     CFLAGS="-I \$(top_srcdir)/arch/linux/include $CFLAGS"
163     D2X_ARCH_SUBDIRS="${D2X_ARCH_SUBDIRS} linux"
164   fi
165
166   AC_PATH_PROG(NASM, $NASM_PROG, no)
167 fi
168
169 dnl Check for network
170 AC_ARG_ENABLE(network,
171   [  --disable-network       Do not build network/serial support ],,)
172 if test x$enable_network != xno; then
173     AC_DEFINE(NETWORK)
174 fi
175 AM_CONDITIONAL(USE_NETWORK, test x$enable_network != xno)
176
177 dnl Check for assembler
178 AC_ARG_ENABLE(assembler,
179   [  --disable-assembler     Do not use assembler optimization ],,)
180 if test x$enable_assembler = xno; then
181     AC_DEFINE(NO_ASM)
182 else
183     if test x$NASM = xno; then
184         AC_MSG_ERROR([$NASM_PROG not found. Install it or use --disable-assembler])
185     else
186         NASMFLAGS="-i\$(srcdir)/ $NASMFLAGS"
187         case $host_os in
188           cygwin)
189               NASMFLAGS="-f win32 $NASMFLAGS"
190               ;;
191           msdosdjgpp)
192               NASMFLAGS="-f coff $NASMFLAGS"
193               ;;
194           linux*)
195               NASMFLAGS="-f elf -d__linux__ $NASMFLAGS"
196               ;;
197           *)
198               AC_MSG_ERROR([Assembler not supported for this OS])
199         esac
200     fi
201 fi
202 AM_CONDITIONAL(USE_ASM, test x$enable_assembler != xno)
203
204 AM_PROG_AS
205
206 AC_SUBST(D2X_ARCH_SUBDIRS)
207
208 AC_SUBST(D2X_MAIN_SUBDIRS)
209
210 AC_SUBST(TARGETS)
211
212 AC_SUBST(NASMFLAGS)
213
214 AC_SUBST(CFLAGS)
215
216 AC_OUTPUT(
217 Makefile
218 2d/Makefile
219 3d/Makefile
220 arch/Makefile
221 arch/dos/Makefile
222 arch/ggi/Makefile
223 arch/linux/Makefile
224 arch/ogl/Makefile
225 arch/sdl/Makefile
226 arch/svgalib/Makefile
227 arch/win32/Makefile
228 cfile/Makefile
229 iff/Makefile
230 main/Makefile
231 main/editor/Makefile
232 maths/Makefile
233 mem/Makefile
234 misc/Makefile
235 texmap/Makefile
236 )