Stuff
[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.1)
12
13 AM_MAINTAINER_MODE
14
15 AC_PROG_INSTALL
16 AC_CHECK_TOOL(CC, gcc, :)
17 AC_ISC_POSIX
18 AC_CHECK_TOOL(RANLIB, ranlib, :)
19 AC_CHECK_TOOL(AR, ar, :)
20 AC_STDC_HEADERS
21
22 NO_ASM=0
23 NO_NETWORK=0
24 GL_LIBS="GL GLU"
25 NASM_PROG=nasm
26
27 AC_CYGWIN
28 if test x$CYGWIN = xyes; then
29     AC_MSG_WARN([Cygwin found, setting -mno-cygwin])
30     CFLAGS="$CFLAGS -mno-cygwin"
31 fi
32
33 AC_MINGW32
34 AM_CONDITIONAL(MINGW32, test x$MINGW32 = xyes)
35 if test x$MINGW32 = xyes; then
36     AC_MSG_WARN([mingw32 found, disabling network])
37     NO_NETWORK=1
38     GL_LIBS="opengl32 glu32"
39     NASM_PROG=nasmw
40 fi
41
42 CFLAGS="$CFLAGS -g -O2 -Wall"
43
44 dnl Count warnings as errors?
45 AC_ARG_WITH(werror,
46   [  --with-werror                Count compiler warning as errors ],
47   [case "${withval}" in
48     yes) CFLAGS="-Werror $CFLAGS" ;;
49     no)  ;;
50     *) AC_MSG_ERROR(bad value ${withval} for --with-werror) ;;
51   esac],)
52
53 dnl Build with NDEBUG?
54 AC_ARG_WITH(ndebug,
55   [  --with-ndebug                Take out extra Asserts, Int3, etc ],
56   [case "${withval}" in
57     yes) AC_DEFINE(NDEBUG) ;;
58     no)  ;;
59     *) AC_MSG_ERROR(bad value ${withval} for --with-ndebug) ;;
60   esac],)
61
62 # Test for DJGPP
63 AM_CONDITIONAL(ENV_DJGPP, test "$host_os" = "msdosdjgpp")
64 if test "$host_os" = "msdosdjgpp"; then
65
66   CFLAGS="-I \$(top_srcdir)/arch/dos/include $CFLAGS"
67   AC_PATH_PROG(NASM, nasm, no)
68   TARGETS=d2x
69
70 else
71   CFLAGS="-pipe $CFLAGS"
72
73   case "$host_os" in
74     *linux*) AC_DEFINE(__ENV_LINUX__) ;;
75   esac
76
77   dnl Check for SDL
78   AM_PATH_SDL(1.1.7,
79     :,
80     AC_MSG_ERROR(SDL not found. Make sure sdl-config is in your PATH, or specify with --with-sdl-prefix)
81   )
82   AC_SUBST(SDL_LIBS)
83
84   AC_CHECK_HEADERS(netipx/ipx.h)
85
86   # Check for OpenGL
87   AC_ARG_WITH(opengl,
88     [  --with-opengl                Build OpenGL support ],
89     [case "${withval}" in
90       yes) opengl=true ;;
91       no)  opengl=false ;;
92       *) AC_MSG_ERROR(bad value ${withval} for --with-opengl) ;;
93     esac],[opengl=false])
94
95   if test x$opengl = xtrue; then
96     for lib in $GL_LIBS; do
97         AC_CHECK_LIB($lib, main,
98             OGL_LIBS="${OGL_LIBS} -l$lib",
99             [AC_MSG_ERROR([$lib not found, --with-opengl cannot be used])
100             opengl=false],
101             ${OGL_LIBS}
102         )
103     done
104   fi
105   AC_SUBST(OGL_LIBS)
106   AM_CONDITIONAL(USE_OPENGL, test x$opengl = xtrue)
107
108   CFLAGS="$SDL_CFLAGS $CFLAGS"
109
110   # Check for GGI
111   AC_ARG_WITH(ggi,
112     [  --with-ggi                   Build GGI support ],
113     [case "${withval}" in
114       yes) ggi=true ;;
115       no)  ggi=false ;;
116       *)   AC_MSG_ERROR(bad value ${withval} for --with-ggi) ;;
117     esac],[ggi=false])
118
119   if test x$ggi = xtrue; then
120     AC_CHECK_LIB(ggi, ggiInit,
121       GGI_LIBS="-lggi",
122       [AC_MSG_ERROR([GGI not found, GGI version cannot be built]); ggi=false])
123     AC_CHECK_LIB(gii, giiInit,
124       GGI_LIBS="${GGI_LIBS} -lgii",
125       [AC_MSG_ERROR([GII not found, GGI version cannot be built]); ggi=false])
126   fi
127   AC_SUBST(GGI_LIBS)
128   AM_CONDITIONAL(USE_GGI, test x$ggi = xtrue)
129
130   # Check for SVGALib
131   AC_ARG_WITH(svga,
132     [  --with-svga                  Build SVGALib support ],
133     [case "${withval}" in
134       yes) svga=true ;;
135       no)  svga=false ;;
136       *) AC_MSG_ERROR(bad value ${withval} for --with-svga) ;;
137     esac],[svga=false])
138
139   if test x$svga = xtrue; then
140     AC_CHECK_LIB(vga, vga_getmousetype,
141       SVGA_LIBS="-lvga",
142       [AC_MSG_ERROR([vga not found, SVGALib cannot be built])
143        svga=false],
144        )
145     AC_CHECK_LIB(vgagl,gl_getcontext,
146       SVGA_LIBS="${SVGA_LIBS} -lvgagl",
147       [AC_MSG_ERROR([vgagl not found, SVGALib cannot be built])
148        svga=false],
149        -lvga)
150   fi
151   AC_SUBST(SVGA_LIBS)
152   AM_CONDITIONAL(USE_SVGALIB, test x$svga = xtrue)
153
154   if test x$opengl = xtrue; then
155     AC_DEFINE(OGL)
156     TARGETS=d2x-ogl
157   else
158     if test x$svga = xtrue; then
159       AC_DEFINE(SVGA)
160       TARGETS=d2x-svga
161     else
162       if test x$ggi = xtrue; then
163         AC_DEFINE(GGI)
164         TARGETS=d2x-ggi
165       else
166         TARGETS=d2x-sdl
167       fi
168     fi
169   fi
170
171   AC_PATH_PROG(NASM, $NASM_PROG, no)
172   CFLAGS="-I\$(top_srcdir)/input/linux/include -I\$(top_srcdir)/arch/linux/include $CFLAGS"
173
174 fi
175
176 # Check for NASM and network
177 AC_ARG_WITH(assembler,
178   [  --without-assembler          Do not use assembler optimization ],
179       if test x$withval = xno; then
180         NO_ASM=1
181       fi)
182 AC_ARG_WITH(network,
183   [  --without-network            Do not build network/serial support ],
184       if test x$withval = xno; then
185         NO_NETWORK=1
186       fi)
187       
188 if test "$NASM" = "no"; then
189         NO_ASM=1 
190 fi
191 if test "$NO_ASM" = 1; then
192         AC_DEFINE(NO_ASM)
193         NASMFLAGS="-i\$(srcdir)/ $NASMFLAGS"
194 else
195         case $host_os in
196           cygwin)
197               NASMFLAGS="-f win32 $NASMFLAGS"
198               ;;
199           msdosdjgpp)
200               NASMFLAGS="-f coff -i\$(srcdir)/"
201               ;;
202           linux*)
203               NASMFLAGS="-f elf -d__ENV_LINUX__ -i\$(srcdir)/"
204               ;;
205           *)
206               AC_MSG_ERROR([Assembler not supported for this OS])
207         esac
208 fi  
209 if test "$NO_NETWORK" = 0; then
210         AC_DEFINE(NETWORK)
211 fi
212 AM_CONDITIONAL(USE_ASM, test "$NO_ASM" != 1)
213 AM_CONDITIONAL(USE_NETWORK, test "$NO_NETWORK" != 1)
214
215 AC_SUBST(NASMFLAGS)
216
217 AC_SUBST(CFLAGS)
218
219 AC_SUBST(TARGETS)
220
221 AC_ARG_PROGRAM
222
223 #libdir='$(shell pwd)/${top_srcdir}/main'
224 AC_OUTPUT(
225 Makefile
226 2d/Makefile
227 3d/Makefile
228 arch/Makefile
229 arch/dos/Makefile
230 arch/dos/allg_snd/Makefile
231 arch/dos/allg_snd/sound/Makefile
232 arch/dos/allg_snd/sound/drv/Makefile
233 arch/dos/bak/Makefile
234 arch/dos/comm/Makefile
235 arch/dos/comm/include/Makefile
236 arch/dos/include/Makefile
237 arch/dos/mm_snd/Makefile
238 arch/dos/mm_snd/include/Makefile
239 arch/include/Makefile
240 arch/linux/Makefile
241 arch/linux/include/Makefile
242 arch/win32/Makefile
243 arch/win32/d3dframe/Makefile
244 arch/win32/include/Makefile
245 cfile/Makefile
246 iff/Makefile
247 iff/archive/Makefile
248 includes/Makefile
249 input/Makefile
250 input/linux/Makefile
251 input/linux/include/Makefile
252 main/Makefile
253 main/editor/Makefile
254 main/old/Makefile
255 maths/Makefile
256 mem/Makefile
257 misc/Makefile
258 sound/Makefile
259 texmap/Makefile
260 unused/Makefile
261 unused/bios/Makefile
262 unused/lib/Makefile
263 unused/novga/Makefile
264 unused/pa_null/Makefile
265 unused/ui/Makefile
266 unused/vga/Makefile
267 unused/vga/new/Makefile
268 unused/win95/Makefile
269 video/Makefile
270 tools/Makefile
271 tools/cvs2cl/Makefile
272 )