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