change ENV_DJGPP to DJGPP
[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(AR, ar, :)
21 AC_PROG_CC
22 AC_STDC_HEADERS
23 AC_PATH_PROGS(NASM, nasmw nasm, no)
24
25 AC_CYGWIN
26 AC_MINGW32
27 if test x$CYGWIN = xyes; then
28     AC_MSG_WARN([Cygwin found, setting -mno-cygwin])
29     CFLAGS="-mno-cygwin $CFLAGS"
30     MINGW32=yes
31 fi
32
33 AM_CONDITIONAL(MINGW32, test x$MINGW32 = xyes)
34 if test x$MINGW32 = xyes; then
35     GL_LIBS="opengl32 glu32"
36 else
37     GL_LIBS="GL GLU"
38 fi
39
40 CFLAGS="-Wall $CFLAGS"
41
42 dnl Enable editor build?
43 AC_ARG_ENABLE(editor,
44   [  --enable-editor         Build editor? (not functional)],,)
45 if test x$enable_editor = xyes; then
46     AC_DEFINE(EDITOR)
47     D2X_MAIN_SUBDIRS=editor
48 fi
49 AM_CONDITIONAL(EDITOR, test x$enable_editor = xyes)
50
51 dnl Enable shareware build?
52 AC_ARG_ENABLE(shareware,
53   [  --enable-shareware      Build for demo datafiles (not functional)],,)
54 if test x$enable_shareware = xyes; then
55     AC_DEFINE(SHAREWARE)
56 fi
57 AM_CONDITIONAL(SHAREWARE, test x$enable_shareware = xyes)
58
59 dnl Enable NMOVIES?
60 AC_ARG_ENABLE(nmovies,
61   [  --enable-nmovies        Enable rendering of endlevel flythrough],,)
62 if test x$enable_nmovies = xyes; then
63     AC_DEFINE(NMOVIES)
64 fi
65 AM_CONDITIONAL(NMOVIES, test x$enable_nmovies = xyes)
66
67 dnl Enable cross-platform bitmap/palette loader?
68 AC_ARG_ENABLE(xploader,
69   [  --enable-xploader       Enable cross-platform bitmap/palette loader ],,)
70 if test x$enable_xploader = xyes; then
71     AC_DEFINE(PORTABLE_LOADER)
72 fi
73
74 dnl Count warnings as errors?
75 AC_ARG_ENABLE(werror,
76   [  --enable-werror         Count compiler warning as errors ],,)
77 if test x$enable_werror = xyes; then
78     CFLAGS="-Werror $CFLAGS"
79 fi
80
81 dnl Build with NDEBUG?
82 AC_ARG_ENABLE(debug,
83   [  --disable-debug         Take out debug symbols, Asserts, Int3, etc ],,)
84 if test x$enable_debug = xno; then
85     AC_DEFINE(NDEBUG)
86     CFLAGS="-O2 $CFLAGS"
87 else
88     CFLAGS="-g $CFLAGS"
89 fi
90
91 # Test for DJGPP
92 AM_CONDITIONAL(DJGPP, test "$host_os" = "msdosdjgpp")
93 if test "$host_os" = "msdosdjgpp"; then
94
95   CFLAGS="-I \$(top_srcdir)/arch/dos/include $CFLAGS"
96   TARGETS=d2x
97   D2X_ARCH_SUBDIRS=dos
98 else
99
100   CFLAGS="-pipe $CFLAGS"
101
102   dnl Check for SDL
103   AM_PATH_SDL(1.1.7,
104     :,
105     AC_MSG_ERROR(SDL not found. Make sure sdl-config is in your PATH, or specify with --with-sdl-prefix)
106   )
107   AC_SUBST(SDL_LIBS)
108
109   TARGETS=d2x-sdl
110   D2X_ARCH_SUBDIRS=sdl
111
112   AC_CHECK_HEADERS(netipx/ipx.h)
113
114   # Check for OpenGL
115   AC_ARG_WITH(opengl,
116     [  --with-opengl           Build OpenGL support ],,)
117   if test x$with_opengl = xyes; then
118     for lib in $GL_LIBS; do
119         AC_CHECK_LIB($lib, main,
120             OGL_LIBS="${OGL_LIBS} -l$lib",
121             [AC_MSG_ERROR([$lib not found, --with-opengl cannot be used])
122             opengl=false],
123             ${OGL_LIBS}
124         )
125     done
126     AC_DEFINE(OGL)
127     TARGETS=d2x-ogl
128     D2X_ARCH_SUBDIRS="${D2X_ARCH_SUBDIRS} ogl"
129   fi
130   AC_SUBST(OGL_LIBS)
131   AM_CONDITIONAL(USE_OPENGL, test x$with_opengl = xyes)
132
133   # Check for GGI
134   AC_ARG_WITH(ggi,
135     [  --with-ggi              Build GGI support ],,)
136   if test x$with_ggi = xyes; then
137     AC_CHECK_LIB(ggi, ggiInit,
138       GGI_LIBS="-lggi",
139       [AC_MSG_ERROR([GGI not found, GGI version cannot be built]); ggi=false])
140     AC_CHECK_LIB(gii, giiInit,
141       GGI_LIBS="${GGI_LIBS} -lgii",
142       [AC_MSG_ERROR([GII not found, GGI version cannot be built]); ggi=false])
143     AC_DEFINE(GGI)
144     TARGETS=d2x-ggi
145     D2X_ARCH_SUBDIRS="${D2X_ARCH_SUBDIRS} ggi"
146   fi
147   AC_SUBST(GGI_LIBS)
148   AM_CONDITIONAL(USE_GGI, test x$with_ggi = xyes)
149
150   # Check for SVGALib
151   AC_ARG_WITH(svga,
152     [  --with-svga             Build SVGALib support ],,)
153   if test x$with_svga = xyes; then
154     AC_CHECK_LIB(vga,vga_getmousetype,
155       SVGA_LIBS="-lvga",
156       [AC_MSG_ERROR([vga not found, SVGALib cannot be built])
157        svga=false],
158        )
159     AC_CHECK_LIB(vgagl,gl_getcontext,
160       SVGA_LIBS="${SVGA_LIBS} -lvgagl",
161       [AC_MSG_ERROR([vgagl not found, SVGALib cannot be built])
162        svga=false],
163        -lvga)
164     AC_DEFINE(SVGA)
165     TARGETS=d2x-svga
166     D2X_ARCH_SUBDIRS="${D2X_ARCH_SUBDIRS} svgalib"
167   fi
168   AC_SUBST(SVGA_LIBS)
169   AM_CONDITIONAL(USE_SVGALIB, test x$with_svga = yes)
170
171   if test x$MINGW32 = xyes; then
172     D2X_ARCH_SUBDIRS="${D2X_ARCH_SUBDIRS} win32"
173   else
174     CFLAGS="-I \$(top_srcdir)/arch/linux/include $CFLAGS"
175     D2X_ARCH_SUBDIRS="${D2X_ARCH_SUBDIRS} linux"
176   fi
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_PROG 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 AM_PROG_AS
215
216 AC_SUBST(D2X_ARCH_SUBDIRS)
217
218 AC_SUBST(D2X_MAIN_SUBDIRS)
219
220 AC_SUBST(TARGETS)
221
222 AC_SUBST(NASMFLAGS)
223
224 AC_SUBST(CFLAGS)
225
226 AC_OUTPUT(
227 Makefile
228 2d/Makefile
229 3d/Makefile
230 arch/Makefile
231 arch/dos/Makefile
232 arch/ggi/Makefile
233 arch/linux/Makefile
234 arch/ogl/Makefile
235 arch/sdl/Makefile
236 arch/svgalib/Makefile
237 arch/win32/Makefile
238 cfile/Makefile
239 iff/Makefile
240 main/Makefile
241 main/editor/Makefile
242 maths/Makefile
243 mem/Makefile
244 misc/Makefile
245 texmap/Makefile
246 )