]> icculus.org git repositories - btb/d2x.git/blob - configure.ac
Data files now go in DATADIR/games/d2x, user files now go in ~/.d2x
[btb/d2x.git] / configure.ac
1 # -*- mode: shell-script -*-
2 AC_INIT(main/inferno.c)
3
4 AC_CANONICAL_BUILD
5 AC_CANONICAL_HOST
6
7 AM_CONFIG_HEADER(conf.h)
8 AM_INIT_AUTOMAKE(d2x, 0.1.2)
9
10 AM_MAINTAINER_MODE
11
12 #kludge to keep autoconf from adding -g -O2
13 CFLAGS=" $CFLAGS"
14
15 AC_PROG_INSTALL
16 AC_PROG_MAKE_SET
17 AC_ISC_POSIX
18 AC_CHECK_TOOL(CC, gcc, :)
19 AC_CHECK_TOOL(RANLIB, ranlib, :)
20 AC_CHECK_TOOL(STRIP, strip, :)
21 AC_CHECK_TOOL(AR, ar, :)
22 AC_PROG_CC
23 AC_STDC_HEADERS
24 AC_PATH_PROGS(NASM, nasmw nasm, no)
25
26 AC_CYGWIN
27 AC_MINGW32
28 if test x$CYGWIN = xyes; then
29     AC_MSG_WARN([Cygwin found, setting -mno-cygwin])
30     CFLAGS="-mno-cygwin $CFLAGS"
31     MINGW32=yes
32 fi
33
34 AM_CONDITIONAL(MINGW32, test x$MINGW32 = xyes)
35 if test x$MINGW32 = xyes; then
36     GL_LIBS="opengl32 glu32"
37 else
38     GL_LIBS="GL GLU"
39 fi
40
41 dnl Set $prefix and $exec_prefix to $ac_default_prefix if they are not set
42 test "x$prefix" = "xNONE" && prefix=$ac_default_prefix
43 test "x$exec_prefix" = "xNONE" && exec_prefix="${prefix}"
44
45 dnl Set default locations to find data files.
46 eval foo="$datadir"
47 default_sharepath="$foo/games/$PACKAGE"
48
49 CFLAGS="-Wall $CFLAGS"
50
51 dnl Enable editor build?
52 AC_ARG_ENABLE(editor,
53   [  --enable-editor         Build editor? (not functional)],,)
54 if test x$enable_editor = xyes; then
55     AC_DEFINE(EDITOR)
56     D2X_MAIN_SUBDIRS=editor
57 fi
58 AM_CONDITIONAL(EDITOR, test x$enable_editor = xyes)
59
60 dnl Enable shareware build?
61 AC_ARG_ENABLE(shareware,
62   [  --enable-shareware      Build for demo datafiles (not functional)],,)
63 if test x$enable_shareware = xyes; then
64     AC_DEFINE(SHAREWARE)
65 fi
66 AM_CONDITIONAL(SHAREWARE, test x$enable_shareware = xyes)
67
68 dnl Enable movie trick?
69 AC_ARG_ENABLE(movies,
70   [  --enable-movie-trick    Enable trick to show movies],,)
71 if test x$enable_movie_trick = xyes; then
72     AC_DEFINE(MOVIE_TRICK)
73 fi
74 AM_CONDITIONAL(MOVIE_TRICK, test x$enable_movie_trick = xyes)
75
76 dnl Enable NMOVIES?
77 AC_ARG_ENABLE(nmovies,
78   [  --enable-nmovies        Turn off movies (render endlevel flythrough)],,)
79 if test x$enable_nmovies = xyes; then
80     AC_DEFINE(NMOVIES)
81 fi
82 AM_CONDITIONAL(NMOVIES, test x$enable_nmovies = xyes)
83
84 dnl Enable cross-platform bitmap/palette loader?
85 AC_ARG_ENABLE(xploader,
86   [  --enable-xploader       Enable cross-platform bitmap/palette loader ],,)
87 if test x$enable_xploader = xyes; then
88     AC_DEFINE(PORTABLE_LOADER)
89 fi
90
91 dnl Count warnings as errors?
92 AC_ARG_ENABLE(werror,
93   [  --enable-werror         Count compiler warning as errors ],,)
94 if test x$enable_werror = xyes; then
95     CFLAGS="-Werror $CFLAGS"
96 fi
97
98 dnl Build with NDEBUG?
99 AC_ARG_ENABLE(debug,
100   [  --disable-debug         Take out debug symbols, Asserts, Int3, etc ],,)
101 if test x$enable_debug = xno; then
102     AC_DEFINE(NDEBUG)
103     CFLAGS="-O2 $CFLAGS"
104 else
105     CFLAGS="-g $CFLAGS"
106 fi
107
108 AC_ARG_WITH(sharepath,
109   [[  --with-sharepath=DIR    Use DIR for shared game data [DATADIR/games/d2x]]],
110   sharepath=$withval, sharepath="auto")
111 if test "x$sharepath" = "xauto" -o "x$sharepath" = "xyes" -o "x$sharepath" = "x"; then
112     sharepath="$default_sharepath"
113 fi
114 AC_DEFINE_UNQUOTED(SHAREPATH, "$sharepath")
115
116 # Test for DJGPP
117 AM_CONDITIONAL(DJGPP, test "$host_os" = "msdosdjgpp")
118 if test "$host_os" = "msdosdjgpp"; then
119
120   CFLAGS="-I \$(top_srcdir)/arch/dos/include $CFLAGS"
121   TARGETS=d2x
122   D2X_ARCH_SUBDIRS=dos
123 else
124
125   CFLAGS="-pipe $CFLAGS"
126
127   dnl Check for SDL
128   AM_PATH_SDL(1.1.7,
129     :,
130     AC_MSG_ERROR(SDL not found. Make sure sdl-config is in your PATH, or specify with --with-sdl-prefix)
131   )
132   CFLAGS="$SDL_CFLAGS $CFLAGS"
133   LIBS="$SDL_LIBS $LIBS"
134
135   TARGETS=d2x-sdl
136   D2X_ARCH_SUBDIRS=sdl
137
138   AC_CHECK_HEADERS(netipx/ipx.h)
139
140   # Check for OpenGL
141   AC_ARG_WITH(opengl,
142     [  --with-opengl           Build OpenGL support ],,)
143   if test x$with_opengl = xyes; then
144     for lib in $GL_LIBS; do
145         AC_CHECK_LIB($lib, main,
146             OGL_LIBS="${OGL_LIBS} -l$lib",
147             [AC_MSG_ERROR([$lib not found, --with-opengl cannot be used])
148             opengl=false],
149             ${OGL_LIBS}
150         )
151     done
152     AC_DEFINE(OGL)
153     TARGETS=d2x-ogl
154     D2X_ARCH_SUBDIRS="ogl ${D2X_ARCH_SUBDIRS}"
155   fi
156   AC_SUBST(OGL_LIBS)
157   AM_CONDITIONAL(USE_OPENGL, test x$with_opengl = xyes)
158
159   # Check for GGI
160   AC_ARG_WITH(ggi,
161     [  --with-ggi              Build GGI support ],,)
162   if test x$with_ggi = xyes; then
163     AC_CHECK_LIB(ggi, ggiInit,
164       GGI_LIBS="-lggi",
165       [AC_MSG_ERROR([GGI not found, GGI version cannot be built]); ggi=false])
166     AC_CHECK_LIB(gii, giiInit,
167       GGI_LIBS="${GGI_LIBS} -lgii",
168       [AC_MSG_ERROR([GII not found, GGI version cannot be built]); ggi=false])
169     AC_DEFINE(GGI)
170     TARGETS=d2x-ggi
171     D2X_ARCH_SUBDIRS="ggi ${D2X_ARCH_SUBDIRS}"
172   fi
173   AC_SUBST(GGI_LIBS)
174   AM_CONDITIONAL(USE_GGI, test x$with_ggi = xyes)
175
176   # Check for SVGALib
177   AC_ARG_WITH(svga,
178     [  --with-svga             Build SVGALib support ],,)
179   if test x$with_svga = xyes; then
180     AC_CHECK_LIB(vga,vga_getmousetype,
181       SVGA_LIBS="-lvga",
182       [AC_MSG_ERROR([vga not found, SVGALib cannot be built])
183        svga=false],
184        )
185     AC_CHECK_LIB(vgagl,gl_getcontext,
186       SVGA_LIBS="${SVGA_LIBS} -lvgagl",
187       [AC_MSG_ERROR([vgagl not found, SVGALib cannot be built])
188        svga=false],
189        -lvga)
190     AC_DEFINE(SVGA)
191     TARGETS=d2x-svga
192     D2X_ARCH_SUBDIRS="svgalib ${D2X_ARCH_SUBDIRS}"
193   fi
194   AC_SUBST(SVGA_LIBS)
195   AM_CONDITIONAL(USE_SVGALIB, test x$with_svga = xyes)
196
197   if test x$MINGW32 = xyes; then
198     D2X_ARCH_SUBDIRS="win32 ${D2X_ARCH_SUBDIRS}"
199     AC_DEFINE(SDL_JOYSTICK)
200   else
201     CFLAGS="-I \$(top_srcdir)/arch/linux/include $CFLAGS"
202     D2X_ARCH_SUBDIRS="linux ${D2X_ARCH_SUBDIRS}"
203
204     dnl Check for SDL joystick
205     AC_ARG_ENABLE(sdl-joystick,
206       [  --enable-sdl-joystick   Use SDL joystick (required for mingw) ],,)
207     if test x$enable_sdl_joystick = xyes; then
208         AC_DEFINE(SDL_JOYSTICK)
209     fi
210     AM_CONDITIONAL(SDL_JOYSTICK, test x$enable_sdl_joystick = xyes)
211   fi
212 fi
213
214 dnl Check for network
215 AC_ARG_ENABLE(network,
216   [  --disable-network       Do not build network/serial support ],,)
217 if test x$enable_network != xno; then
218     AC_DEFINE(NETWORK)
219 fi
220 AM_CONDITIONAL(USE_NETWORK, test x$enable_network != xno)
221
222 dnl Check for assembler
223 AC_ARG_ENABLE(assembler,
224   [  --disable-assembler     Do not use assembler optimization ],,)
225 if test x$enable_assembler = xno; then
226     AC_DEFINE(NO_ASM)
227 else
228     if test x$NASM = xno; then
229         AC_MSG_ERROR([nasm not found. Install it or use --disable-assembler])
230     else
231         NASMFLAGS="-i\$(srcdir)/ $NASMFLAGS"
232         case $host_os in
233           cygwin)
234               NASMFLAGS="-f win32 $NASMFLAGS"
235               ;;
236           msdosdjgpp)
237               NASMFLAGS="-f coff $NASMFLAGS"
238               ;;
239           linux*)
240               NASMFLAGS="-f elf -d__linux__ $NASMFLAGS"
241               ;;
242           *)
243               AC_MSG_ERROR([Assembler not supported for this OS])
244         esac
245     fi
246 fi
247 AM_CONDITIONAL(USE_ASM, test x$enable_assembler != xno)
248
249 AM_PROG_AS
250
251 AC_SUBST(D2X_ARCH_SUBDIRS)
252
253 AC_SUBST(D2X_MAIN_SUBDIRS)
254
255 AC_SUBST(TARGETS)
256
257 AC_SUBST(NASMFLAGS)
258
259 AC_SUBST(CFLAGS)
260
261 AC_OUTPUT(
262 Makefile
263 2d/Makefile
264 3d/Makefile
265 arch/Makefile
266 arch/dos/Makefile
267 arch/ggi/Makefile
268 arch/linux/Makefile
269 arch/ogl/Makefile
270 arch/sdl/Makefile
271 arch/svgalib/Makefile
272 arch/win32/Makefile
273 cfile/Makefile
274 iff/Makefile
275 main/Makefile
276 main/editor/Makefile
277 maths/Makefile
278 mem/Makefile
279 misc/Makefile
280 texmap/Makefile
281 )