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