]> icculus.org git repositories - btb/d2x.git/blob - configure.ac
Updated for autoconf 2.53 (no more acconfig.h)
[btb/d2x.git] / configure.ac
1 # -*- mode: shell-script -*-
2 AC_INIT(main/inferno.c)
3 AC_PREREQ(2.52)
4
5 AC_CANONICAL_BUILD
6 AC_CANONICAL_HOST
7 AC_CANONICAL_TARGET
8
9 AM_CONFIG_HEADER(conf.h)
10
11 D2XMAJOR=0
12 D2XMINOR=1
13 D2XMICRO=3
14
15 AC_DEFINE_UNQUOTED(D2XMAJOR,,[d2x major version])
16 AC_DEFINE_UNQUOTED(D2XMINOR,,[d2x minor version])
17 AC_DEFINE_UNQUOTED(D2XMICRO,,[d2x micro version])
18
19 VERSION=$D2XMAJOR.$D2XMINOR.$D2XMICRO
20
21 AM_INIT_AUTOMAKE(d2x, $VERSION)
22
23 AM_MAINTAINER_MODE
24
25 #kludge to keep autoconf from adding -g -O2
26 CFLAGS=" $CFLAGS"
27
28 AC_PROG_INSTALL
29 AC_PROG_MAKE_SET
30 AC_ISC_POSIX
31 AC_CHECK_TOOL(CC, gcc, :)
32 AC_CHECK_TOOL(RANLIB, ranlib, :)
33 AC_CHECK_TOOL(STRIP, strip, :)
34 AC_CHECK_TOOL(AR, ar, :)
35 AC_PROG_CC
36 AC_PROG_CXX
37 AC_STDC_HEADERS
38 AC_PATH_PROGS(NASM, nasmw nasm, no)
39 AC_C_BIGENDIAN
40
41 AC_CYGWIN
42 AC_MINGW32
43 if test x$CYGWIN = xyes; then
44     AC_MSG_WARN([Cygwin found, setting -mno-cygwin])
45     CFLAGS="-mno-cygwin $CFLAGS"
46     MINGW32=yes
47 fi
48
49 AM_CONDITIONAL(MINGW32, test x$MINGW32 = xyes)
50 if test x$MINGW32 = xyes; then
51     GL_LIBS="opengl32 glu32"
52 else
53     GL_LIBS="GL GLU"
54 fi
55
56 dnl Set $prefix and $exec_prefix to $ac_default_prefix if they are not set
57 test "x$prefix" = "xNONE" && prefix=$ac_default_prefix
58 test "x$exec_prefix" = "xNONE" && exec_prefix="${prefix}"
59
60 dnl Set default locations to find data files.
61 eval foo="$datadir"
62 default_sharepath="$foo/games/$PACKAGE"
63
64 CFLAGS="-Wall $CFLAGS"
65
66 dnl Enable editor build?
67 AC_ARG_ENABLE(editor,
68   [  --enable-editor         Build editor? (not functional)],,)
69 if test x$enable_editor = xyes; then
70     AC_DEFINE(EDITOR,,[Define if you want to build the editor])
71     D2X_MAIN_SUBDIRS=editor
72 fi
73 AM_CONDITIONAL(EDITOR, test x$enable_editor = xyes)
74
75 dnl Enable shareware build?
76 AC_ARG_ENABLE(shareware,
77   [  --enable-shareware      Build for demo datafiles (not functional)],,)
78 if test x$enable_shareware = xyes; then
79     AC_DEFINE(SHAREWARE,,[Define if you want to build the demo version])
80     D2X_FEATURES="shareware ${D2X_FEATURES}"
81 fi
82 AM_CONDITIONAL(SHAREWARE, test x$enable_shareware = xyes)
83
84 dnl Enable movie trick?
85 AC_ARG_ENABLE(movies,
86   [  --enable-movie-trick    Enable trick to show movies],,)
87 if test x$enable_movie_trick = xyes; then
88     AC_DEFINE(MOVIE_TRICK,,[Define to enable trick to show movies])
89     D2X_FEATURES="movie_trick ${D2X_FEATURES}"
90 fi
91 AM_CONDITIONAL(MOVIE_TRICK, test x$enable_movie_trick = xyes)
92
93 dnl Enable NMOVIES?
94 AC_ARG_ENABLE(nmovies,
95   [  --enable-nmovies        Turn off movies (render endlevel flythrough)],,)
96 if test x$enable_nmovies = xyes; then
97     AC_DEFINE(NMOVIES,,[Define to render endlevel flythrough sequences (instead of movies)])
98     D2X_FEATURES="nmovies ${D2X_FEATURES}"
99 fi
100 AM_CONDITIONAL(NMOVIES, test x$enable_nmovies = xyes)
101
102 dnl Count warnings as errors?
103 AC_ARG_ENABLE(werror,
104   [  --enable-werror         Count compiler warning as errors ],,)
105 if test x$enable_werror = xyes; then
106     CFLAGS="-Werror $CFLAGS"
107     D2X_FEATURES="werror ${D2X_FEATURES}"
108 fi
109
110 dnl Build with NDEBUG?
111 AC_ARG_ENABLE(debug,
112   [  --disable-debug         Take out debug symbols, Asserts, Int3, etc ],,)
113 if test x$enable_debug = xno; then
114     AC_DEFINE(NDEBUG,,[Define to disable asserts, int3, etc.])
115     CFLAGS="-O2 $CFLAGS"
116 else
117     CFLAGS="-g $CFLAGS"
118     D2X_FEATURES="debug ${D2X_FEATURES}"
119 fi
120
121 dnl Build with RELEASE?
122 AC_ARG_ENABLE(release,
123   [  --enable-release        Release build.  Removes debug/editor things ],,)
124 if test x$enable_release = xyes; then
125     AC_DEFINE(RELEASE,,[Define for a "release" build])
126     D2X_FEATURES="release ${D2X_FEATURES}"
127 fi
128
129 AC_ARG_WITH(sharepath,
130   [[  --with-sharepath=DIR    Use DIR for shared game data [DATADIR/games/d2x]]],
131   sharepath=$withval, sharepath="auto")
132 if test "x$sharepath" = "xauto" -o "x$sharepath" = "xyes" -o "x$sharepath" = "x"; then
133     sharepath="$default_sharepath"
134 fi
135 AC_DEFINE_UNQUOTED(SHAREPATH, "$sharepath",[Define this to be the shared game directory root])
136
137 # Test for DJGPP
138 AM_CONDITIONAL(DJGPP, test "$host_os" = "msdosdjgpp")
139 if test "$host_os" = "msdosdjgpp"; then
140
141   CFLAGS="-I \$(top_srcdir)/arch/dos/include $CFLAGS"
142   TARGETS=d2x
143   D2X_ARCH_SUBDIRS=dos
144 else
145
146   CFLAGS="-pipe $CFLAGS"
147
148   dnl Check for SDL
149   AM_PATH_SDL(1.0.1,
150     :,
151     AC_MSG_ERROR(SDL not found. Make sure sdl-config is in your PATH, or specify with --with-sdl-prefix)
152   )
153   CFLAGS="$SDL_CFLAGS $CFLAGS"
154   LIBS="$SDL_LIBS $LIBS"
155
156   TARGETS=d2x-sdl
157   D2X_ARCH_SUBDIRS=sdl
158
159   AC_CHECK_HEADERS(netipx/ipx.h)
160
161   # Check for OpenGL
162   AC_ARG_WITH(opengl,
163     [  --with-opengl           Build OpenGL support ],,)
164   if test x$with_opengl = xyes; then
165     for lib in $GL_LIBS; do
166         AC_CHECK_LIB($lib, main,
167             OGL_LIBS="${OGL_LIBS} -l$lib",
168             [AC_MSG_ERROR([$lib not found, --with-opengl cannot be used])
169             opengl=false],
170             ${OGL_LIBS}
171         )
172     done
173     AC_DEFINE(OGL,,[Define if you want an OpenGL build])
174     TARGETS=d2x-ogl
175     D2X_ARCH_SUBDIRS="ogl ${D2X_ARCH_SUBDIRS}"
176   fi
177   AC_SUBST(OGL_LIBS)
178   AM_CONDITIONAL(USE_OPENGL, test x$with_opengl = xyes)
179
180   # Check for GGI
181   AC_ARG_WITH(ggi,
182     [  --with-ggi              Build GGI support ],,)
183   if test x$with_ggi = xyes; then
184     AC_CHECK_LIB(ggi, ggiInit,
185       GGI_LIBS="-lggi",
186       [AC_MSG_ERROR([GGI not found, GGI version cannot be built]); ggi=false])
187     AC_CHECK_LIB(gii, giiInit,
188       GGI_LIBS="${GGI_LIBS} -lgii",
189       [AC_MSG_ERROR([GII not found, GGI version cannot be built]); ggi=false])
190     AC_DEFINE(GGI,,[Define if you want a GGI build])
191     TARGETS=d2x-ggi
192     D2X_ARCH_SUBDIRS="ggi ${D2X_ARCH_SUBDIRS}"
193   fi
194   AC_SUBST(GGI_LIBS)
195   AM_CONDITIONAL(USE_GGI, test x$with_ggi = xyes)
196
197   # Check for SVGALib
198   AC_ARG_WITH(svga,
199     [  --with-svga             Build SVGALib support ],,)
200   if test x$with_svga = xyes; then
201     AC_CHECK_LIB(vga,vga_getmousetype,
202       SVGA_LIBS="-lvga",
203       [AC_MSG_ERROR([vga not found, SVGALib cannot be built])
204        svga=false],
205        )
206     AC_CHECK_LIB(vgagl,gl_getcontext,
207       SVGA_LIBS="${SVGA_LIBS} -lvgagl",
208       [AC_MSG_ERROR([vgagl not found, SVGALib cannot be built])
209        svga=false],
210        -lvga)
211     AC_DEFINE(SVGA,,[Define if you want an SVGALib build])
212     TARGETS=d2x-svga
213     D2X_ARCH_SUBDIRS="svgalib ${D2X_ARCH_SUBDIRS}"
214   fi
215   AC_SUBST(SVGA_LIBS)
216   AM_CONDITIONAL(USE_SVGALIB, test x$with_svga = xyes)
217
218   if test x$MINGW32 = xyes; then
219     D2X_ARCH_SUBDIRS="win32 ${D2X_ARCH_SUBDIRS}"
220   else
221     CFLAGS="-I \$(top_srcdir)/arch/linux/include $CFLAGS"
222     D2X_ARCH_SUBDIRS="linux ${D2X_ARCH_SUBDIRS}"
223   fi
224 fi
225
226 dnl Check for network
227 AC_ARG_ENABLE(network,
228   [  --disable-network       Do not build network/serial support ],,)
229 if test x$enable_network != xno; then
230     AC_DEFINE(NETWORK,,[Define if you want a network build])
231     D2X_FEATURES="network ${D2X_FEATURES}"
232 fi
233 AM_CONDITIONAL(USE_NETWORK, test x$enable_network != xno)
234
235 dnl Check for assembler
236 AC_ARG_ENABLE(assembler,
237   [  --disable-assembler     Do not use assembler optimization ],,)
238 if test x$enable_assembler = xno; then
239     AC_DEFINE(NO_ASM,,[Define if you want an assembler free build])
240     D2X_FEATURES="no_asm ${D2X_FEATURES}"
241 else
242     if test x$NASM = xno; then
243         AC_MSG_ERROR([nasm not found. Install it or use --disable-assembler])
244     else
245         NASMFLAGS="-i\$(srcdir)/ $NASMFLAGS"
246         case $host_os in
247           cygwin)
248               NASMFLAGS="-f win32 $NASMFLAGS"
249               ;;
250           msdosdjgpp)
251               NASMFLAGS="-f coff $NASMFLAGS"
252               ;;
253           linux*)
254               NASMFLAGS="-f elf -d__linux__ $NASMFLAGS"
255               ;;
256           *)
257               AC_MSG_ERROR([Assembler not supported for this OS])
258         esac
259     fi
260 fi
261 AM_CONDITIONAL(USE_ASM, test x$enable_assembler != xno)
262
263 AH_BOTTOM([
264 /* General defines */
265 #define NMONO 1
266 #define PIGGY_USE_PAGING 1
267 #define NEWDEMO 1
268
269 #ifdef __linux__
270 # define __SDL__ 1
271 # define SDL_AUDIO 1
272 # define SDL_JOYSTICK 1
273
274 # ifdef OGL
275 #  define SDL_GL_VIDEO 1
276 #  define SDL_INPUT 1
277 # else
278 #  ifdef GGI
279 #   define GGI_VIDEO 1
280 #   define GII_INPUT 1
281 #  else
282 #   ifdef SVGA
283 #    define SVGALIB_VIDEO 1
284 #    define SVGALIB_INPUT 1
285 #   else
286 #    define SDL_VIDEO 1
287 #    define SDL_INPUT 1
288 #   endif
289 #  endif
290 # endif
291 #endif
292
293 #ifdef __MINGW32__
294 # define __SDL__ 1
295 # define SDL_AUDIO 1
296 # define SDL_INPUT 1
297 # define SDL_JOYSTICK 1
298 # ifdef OGL
299 #  define SDL_GL_VIDEO 1
300 # else
301 #  define SDL_VIDEO 1
302 # endif
303 #endif
304 ])
305
306 AM_PROG_AS
307
308 AC_SUBST(D2X_ARCH_SUBDIRS)
309
310 AC_SUBST(D2X_MAIN_SUBDIRS)
311
312 AC_SUBST(TARGETS)
313
314 AC_SUBST(NASMFLAGS)
315
316 AC_SUBST(CFLAGS)
317
318 AC_OUTPUT(
319 Makefile
320 2d/Makefile
321 3d/Makefile
322 arch/Makefile
323 arch/dos/Makefile
324 arch/ggi/Makefile
325 arch/linux/Makefile
326 arch/ogl/Makefile
327 arch/sdl/Makefile
328 arch/svgalib/Makefile
329 arch/win32/Makefile
330 cfile/Makefile
331 iff/Makefile
332 main/Makefile
333 main/editor/Makefile
334 maths/Makefile
335 mem/Makefile
336 misc/Makefile
337 texmap/Makefile
338 debian/changelog
339 rpm/d2x.spec
340 )
341
342 AC_MSG_RESULT([
343     d2x has been configured successfully.
344
345     Platform(s): $D2X_ARCH_SUBDIRS
346     Features   : $D2X_FEATURES $D2X_MAIN_SUBDIRS
347
348     Shared game data directory: $sharepath
349 ])