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