Support for cross-compiling, and cygwin fixes
[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.0.9)
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
25 CFLAGS="-g -O2 -Wall"
26
27 dnl Count warnings as errors?
28 AC_ARG_WITH(werror,
29   [  --with-werror                Count compiler warning as errors ],
30   [case "${withval}" in
31     yes) CFLAGS="-Werror $CFLAGS" ;;
32     no)  ;;
33     *) AC_MSG_ERROR(bad value ${withval} for --with-werror) ;;
34   esac],)
35
36 dnl Build with NDEBUG?
37 AC_ARG_WITH(ndebug,
38   [  --with-ndebug                Take out extra Asserts, Int3, etc ],
39   [case "${withval}" in
40     yes) AC_DEFINE(NDEBUG) ;;
41     no)  ;;
42     *) AC_MSG_ERROR(bad value ${withval} for --with-ndebug) ;;
43   esac],)
44
45 # Test for DJGPP
46 AM_CONDITIONAL(ENV_DJGPP, test "$host_os" = "msdosdjgpp")
47 if test "$host_os" = "msdosdjgpp"; then
48
49   CFLAGS="-I \$(top_srcdir)/arch/dos/include $CFLAGS"
50   AC_DEFINE(__ENV_DJGPP__)
51   AC_PATH_PROG(NASM, nasm, no)
52   TARGETS=d2x
53
54 else
55   CFLAGS="-D_REENTRANT -pipe $CFLAGS"
56   AM_CONDITIONAL(ENV_CYGWIN, test "$host_os" = "cygwin")
57
58   AC_DEFINE(__ENV_LINUX__)
59
60   if test "$host_os" = "cygwin"; then
61     AC_CHECK_LIB(SDL, SDL_Init, SDL_LIBS="-lSDL", AC_MSG_ERROR(The SDL which is required not found.))
62   else
63     AC_CHECK_LIB(SDL, SDL_Init, SDL_LIBS="-lSDL", AC_MSG_ERROR(The SDL which is required not found.),-ldl -lpthread)
64   fi
65   AC_CHECK_HEADERS(netipx/ipx.h)
66   AC_SUBST(SDL_LIBS)
67
68   # Check for OpenGL
69   AC_ARG_WITH(opengl,
70     [  --with-opengl                Build OpenGL support ],
71     [case "${withval}" in
72       yes) opengl=true ;;
73       no)  opengl=false ;;
74       *) AC_MSG_ERROR(bad value ${withval} for --with-opengl) ;;
75     esac],[opengl=false])
76   
77   if test x$opengl = xtrue; then
78     AC_CHECK_LIB(GL, main,
79       OGL_LIBS="-lGL", 
80       [AC_MSG_ERROR([GL not found, OpenGL cannot be built])
81        opengl=false],
82        )
83     AC_CHECK_LIB(GLU,main,
84       OGL_LIBS="${OGL_LIBS} -lGLU",
85       [AC_MSG_ERROR([GLU not found, OpenGL cannot be built])
86        opengl=false],
87        -lGL)
88   fi
89   AC_SUBST(OGL_LIBS)
90   AM_CONDITIONAL(USE_OPENGL, test x$opengl = xtrue)
91
92   # Check for GGI
93   AC_ARG_WITH(ggi,
94     [  --with-ggi                   Build GGI support ],
95     [case "${withval}" in
96       yes) ggi=true ;;
97       no)  ggi=false ;;
98       *)   AC_MSG_ERROR(bad value ${withval} for --with-ggi) ;;
99     esac],[ggi=false])
100
101   if test x$ggi = xtrue; then
102     AC_CHECK_LIB(ggi, ggiInit,
103       GGI_LIBS="-lggi",
104       [AC_MSG_ERROR([GGI not found, GGI version cannot be built]); ggi=false])
105     AC_CHECK_LIB(gii, giiInit,
106       GGI_LIBS="${GGI_LIBS} -lgii",
107       [AC_MSG_ERROR([GII not found, GGI version cannot be built]); ggi=false])
108   fi
109   AC_SUBST(GGI_LIBS)
110   AM_CONDITIONAL(USE_GGI, test x$ggi = xtrue)
111
112   # Check for SVGALib
113   AC_ARG_WITH(svga,
114     [  --with-svga                  Build SVGALib support ],
115     [case "${withval}" in
116       yes) svga=true ;;
117       no)  svga=false ;;
118       *) AC_MSG_ERROR(bad value ${withval} for --with-svga) ;;
119     esac],[svga=false])
120
121   if test x$svga = xtrue; then
122     AC_CHECK_LIB(vga, vga_getmousetype,
123       SVGA_LIBS="-lvga",
124       [AC_MSG_ERROR([vga not found, SVGALib cannot be built])
125        svga=false],
126        )
127     AC_CHECK_LIB(vgagl,gl_getcontext,
128       SVGA_LIBS="${SVGA_LIBS} -lvgagl",
129       [AC_MSG_ERROR([vgagl not found, SVGALib cannot be built])
130        svga=false],
131        -lvga)
132   fi
133   AC_SUBST(SVGA_LIBS)
134   AM_CONDITIONAL(USE_SVGALIB, test x$svga = xtrue)
135
136   if test x$opengl = xtrue; then
137     AC_DEFINE(OGL)
138     TARGETS=d2x-ogl
139   else
140     if test x$svga = xtrue; then
141       AC_DEFINE(SVGA)
142       TARGETS=d2x-svga
143     else
144       if test x$ggi = xtrue; then
145         AC_DEFINE(GGI)
146         TARGETS=d2x-ggi
147       else
148         TARGETS=d2x-sdl
149       fi
150     fi
151   fi
152
153   AC_PATH_PROG(NASM, nasm, no)
154   CFLAGS="-I\$(top_srcdir)/input/linux/include -I\$(top_srcdir)/arch/linux/include $CFLAGS"
155
156 fi
157
158 # Check for NASM and network
159 NO_ASM=0
160 NO_NETWORK=0
161 AC_ARG_WITH(assembler,
162   [  --without-assembler          Do not use assembler optimization ],
163       if test x$withval = xno; then
164         NO_ASM=1
165       fi)
166 AC_ARG_WITH(network,
167   [  --without-network            Do not build network/serial support ],
168       if test x$withval = xno; then
169         NO_NETWORK=1
170       fi)
171       
172 if test "$NASM" = "no"; then
173         NO_ASM=1 
174 fi
175 if test "$NO_ASM" = 1; then
176         AC_DEFINE(NO_ASM)
177         NASMFLAGS=""
178 else
179         case $host_os in
180           cygwin)
181               NASMFLAGS="-f win32 -i\$(srcdir)/"
182               ;;
183           msdosdjgpp)
184               NASMFLAGS="-f coff -i\$(srcdir)/"
185               ;;
186           linux*)
187               NASMFLAGS="-f elf -d__ENV_LINUX__ -i\$(srcdir)/"
188               ;;
189           *)
190               AC_MSG_ERROR([Assembler not supported for this OS])
191         esac
192 fi  
193 if test "$NO_NETWORK" = 0; then
194         AC_DEFINE(NETWORK)
195 fi
196 AM_CONDITIONAL(USE_ASM, test "$NO_ASM" != 1)
197 AM_CONDITIONAL(USE_NETWORK, test "$NO_NETWORK" != 1)
198
199 AC_SUBST(NASMFLAGS)
200
201 AC_SUBST(CFLAGS)
202
203 AC_SUBST(TARGETS)
204
205 AC_ARG_PROGRAM
206
207 #libdir='$(shell pwd)/${top_srcdir}/main'
208 AC_OUTPUT(
209 Makefile
210 2d/Makefile
211 3d/Makefile
212 arch/Makefile
213 arch/dos/Makefile
214 arch/dos/allg_snd/Makefile
215 arch/dos/allg_snd/sound/Makefile
216 arch/dos/allg_snd/sound/drv/Makefile
217 arch/dos/bak/Makefile
218 arch/dos/comm/Makefile
219 arch/dos/comm/include/Makefile
220 arch/dos/include/Makefile
221 arch/dos/mm_snd/Makefile
222 arch/dos/mm_snd/include/Makefile
223 arch/include/Makefile
224 arch/ogl/Makefile
225 arch/ogl/include/Makefile
226 arch/linux/Makefile
227 arch/linux/include/Makefile
228 arch/win32/Makefile
229 arch/win32/d3dframe/Makefile
230 arch/win32/include/Makefile
231 cfile/Makefile
232 iff/Makefile
233 iff/archive/Makefile
234 includes/Makefile
235 input/Makefile
236 input/linux/Makefile
237 input/linux/include/Makefile
238 main/Makefile
239 main/editor/Makefile
240 main/old/Makefile
241 maths/Makefile
242 mem/Makefile
243 misc/Makefile
244 sound/Makefile
245 texmap/Makefile
246 unused/Makefile
247 unused/bios/Makefile
248 unused/lib/Makefile
249 unused/novga/Makefile
250 unused/pa_null/Makefile
251 unused/ui/Makefile
252 unused/vga/Makefile
253 unused/vga/new/Makefile
254 unused/win95/Makefile
255 video/Makefile
256 tools/Makefile
257 tools/cvs2cl/Makefile
258 )