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