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