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