move SDL_LIBS to LIBS, SDL_CFLAGS to CFLAGS
[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="${D2X_ARCH_SUBDIRS} ogl"
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="${D2X_ARCH_SUBDIRS} ggi"
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="${D2X_ARCH_SUBDIRS} svgalib"
169   fi
170   AC_SUBST(SVGA_LIBS)
171   AM_CONDITIONAL(USE_SVGALIB, test x$with_svga = yes)
172
173   if test x$MINGW32 = xyes; then
174     D2X_ARCH_SUBDIRS="${D2X_ARCH_SUBDIRS} win32"
175   else
176     CFLAGS="-I \$(top_srcdir)/arch/linux/include $CFLAGS"
177     D2X_ARCH_SUBDIRS="${D2X_ARCH_SUBDIRS} linux"
178   fi
179 fi
180
181 dnl Check for network
182 AC_ARG_ENABLE(network,
183   [  --disable-network       Do not build network/serial support ],,)
184 if test x$enable_network != xno; then
185     AC_DEFINE(NETWORK)
186 fi
187 AM_CONDITIONAL(USE_NETWORK, test x$enable_network != xno)
188
189 dnl Check for assembler
190 AC_ARG_ENABLE(assembler,
191   [  --disable-assembler     Do not use assembler optimization ],,)
192 if test x$enable_assembler = xno; then
193     AC_DEFINE(NO_ASM)
194 else
195     if test x$NASM = xno; then
196         AC_MSG_ERROR([$NASM_PROG not found. Install it or use --disable-assembler])
197     else
198         NASMFLAGS="-i\$(srcdir)/ $NASMFLAGS"
199         case $host_os in
200           cygwin)
201               NASMFLAGS="-f win32 $NASMFLAGS"
202               ;;
203           msdosdjgpp)
204               NASMFLAGS="-f coff $NASMFLAGS"
205               ;;
206           linux*)
207               NASMFLAGS="-f elf -d__linux__ $NASMFLAGS"
208               ;;
209           *)
210               AC_MSG_ERROR([Assembler not supported for this OS])
211         esac
212     fi
213 fi
214 AM_CONDITIONAL(USE_ASM, test x$enable_assembler != xno)
215
216 AM_PROG_AS
217
218 AC_SUBST(D2X_ARCH_SUBDIRS)
219
220 AC_SUBST(D2X_MAIN_SUBDIRS)
221
222 AC_SUBST(TARGETS)
223
224 AC_SUBST(NASMFLAGS)
225
226 AC_SUBST(CFLAGS)
227
228 AC_OUTPUT(
229 Makefile
230 2d/Makefile
231 3d/Makefile
232 arch/Makefile
233 arch/dos/Makefile
234 arch/ggi/Makefile
235 arch/linux/Makefile
236 arch/ogl/Makefile
237 arch/sdl/Makefile
238 arch/svgalib/Makefile
239 arch/win32/Makefile
240 cfile/Makefile
241 iff/Makefile
242 main/Makefile
243 main/editor/Makefile
244 maths/Makefile
245 mem/Makefile
246 misc/Makefile
247 texmap/Makefile
248 )