Revert bin_programs to earlier style until i understand automake 1.5 better.
[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_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 if test x$CYGWIN = xyes; then
25     AC_MSG_WARN([Cygwin found, setting -mno-cygwin])
26     CFLAGS="$CFLAGS -mno-cygwin"
27     MINGW32=yes
28 fi
29
30 AM_CONDITIONAL(MINGW32, test x$MINGW32 = xyes)
31 if test x$MINGW32 = xyes; then
32     GL_LIBS="opengl32 glu32"
33     NASM_PROG=nasmw
34 else
35     GL_LIBS="GL GLU"
36     NASM_PROG=nasm
37 fi
38
39 CFLAGS="$CFLAGS -O2 -Wall"
40
41 dnl Enable editor build?
42 AC_ARG_ENABLE(editor,
43   [  --enable-editor         Build editor? (not functional)],,)
44 if test x$enable_editor = xyes; then
45     AC_DEFINE(EDITOR)
46 fi
47 AM_CONDITIONAL(EDITOR, test x$enable_editor = xyes)
48
49 dnl Enable cross-platform bitmap/palette loader?
50 AC_ARG_ENABLE(xploader,
51   [  --enable-xploader       Enable cross-platform bitmap/palette loader ],,)
52 if test x$enable_xploader = xyes; then
53     AC_DEFINE(PORTABLE_LOADER)
54 fi
55
56 dnl Count warnings as errors?
57 AC_ARG_ENABLE(werror,
58   [  --enable-werror         Count compiler warning as errors ],,)
59 if test x$enable_werror = xyes; then
60     CFLAGS="-Werror $CFLAGS"
61 fi
62
63 dnl Build with NDEBUG?
64 AC_ARG_ENABLE(debug,
65   [  --disable-debug         Take out debug symbols, Asserts, Int3, etc ],,)
66 if test x$enable_debug = xno; then
67     AC_DEFINE(NDEBUG)
68 else
69     CFLAGS="-g $CFLAGS"
70 fi
71
72 # Test for DJGPP
73 AM_CONDITIONAL(ENV_DJGPP, test "$host_os" = "msdosdjgpp")
74 if test "$host_os" = "msdosdjgpp"; then
75
76   CFLAGS="-I \$(top_srcdir)/arch/dos/include $CFLAGS"
77   AC_PATH_PROG(NASM, nasm, no)
78   TARGETS=d2x
79   D2X_ARCH_SUBDIRS=dos
80 else
81
82   CFLAGS="-pipe $CFLAGS"
83
84   dnl Check for SDL
85   AM_PATH_SDL(1.1.7,
86     :,
87     AC_MSG_ERROR(SDL not found. Make sure sdl-config is in your PATH, or specify with --with-sdl-prefix)
88   )
89   AC_SUBST(SDL_LIBS)
90
91   CFLAGS="$SDL_CFLAGS $CFLAGS"
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   fi
113   AC_SUBST(OGL_LIBS)
114   AM_CONDITIONAL(USE_OPENGL, test x$with_opengl = xyes)
115
116   # Check for GGI
117   AC_ARG_WITH(ggi,
118     [  --with-ggi              Build GGI support ],,)
119   if test x$with_ggi = xyes; then
120     AC_CHECK_LIB(ggi, ggiInit,
121       GGI_LIBS="-lggi",
122       [AC_MSG_ERROR([GGI not found, GGI version cannot be built]); ggi=false])
123     AC_CHECK_LIB(gii, giiInit,
124       GGI_LIBS="${GGI_LIBS} -lgii",
125       [AC_MSG_ERROR([GII not found, GGI version cannot be built]); ggi=false])
126     AC_DEFINE(GGI)
127     TARGETS=d2x-ggi
128     D2X_ARCH_SUBDIRS = "${D2X_ARCH_SUBDIRS} ggi"
129   fi
130   AC_SUBST(GGI_LIBS)
131   AM_CONDITIONAL(USE_GGI, test x$with_ggi = xyes)
132
133   # Check for SVGALib
134   AC_ARG_WITH(svga,
135     [  --with-svga             Build SVGALib support ],,)
136   if test x$with_svga = xyes; then
137     AC_CHECK_LIB(vga,vga_getmousetype,
138       SVGA_LIBS="-lvga",
139       [AC_MSG_ERROR([vga not found, SVGALib cannot be built])
140        svga=false],
141        )
142     AC_CHECK_LIB(vgagl,gl_getcontext,
143       SVGA_LIBS="${SVGA_LIBS} -lvgagl",
144       [AC_MSG_ERROR([vgagl not found, SVGALib cannot be built])
145        svga=false],
146        -lvga)
147     AC_DEFINE(SVGA)
148     TARGETS=d2x-svga
149     D2X_ARCH_SUBDIRS = "${D2X_ARCH_SUBDIRS} svgalib"
150   fi
151   AC_SUBST(SVGA_LIBS)
152   AM_CONDITIONAL(USE_SVGALIB, test x$with_svga = yes)
153
154   if test x$MINGW32 = xyes; then
155     D2X_ARCH_SUBDIRS="${D2X_ARCH_SUBDIRS} win32"
156   else
157     CFLAGS="-I \$(top_srcdir)/arch/linux/include $CFLAGS"
158     D2X_ARCH_SUBDIRS="${D2X_ARCH_SUBDIRS} linux"
159   fi
160
161   AC_PATH_PROG(NASM, $NASM_PROG, no)
162 fi
163
164 dnl Check for network
165 AC_ARG_ENABLE(network,
166   [  --disable-network       Do not build network/serial support ],,)
167 if test x$enable_network != xno; then
168     AC_DEFINE(NETWORK)
169 fi
170 AM_CONDITIONAL(USE_NETWORK, test x$enable_network != xno)
171
172 dnl Check for assembler
173 AC_ARG_ENABLE(assembler,
174   [  --disable-assembler     Do not use assembler optimization ],,)
175 if test x$enable_assembler = xno; then
176     AC_DEFINE(NO_ASM)
177 else
178     if test x$NASM = xno; then
179         AC_MSG_ERROR([$NASM_PROG not found. Install it or use --disable-assembler])
180     else
181         NASMFLAGS="-i\$(srcdir)/ $NASMFLAGS"
182         case $host_os in
183           cygwin)
184               NASMFLAGS="-f win32 $NASMFLAGS"
185               ;;
186           msdosdjgpp)
187               NASMFLAGS="-f coff $NASMFLAGS"
188               ;;
189           linux*)
190               NASMFLAGS="-f elf -d__linux__ $NASMFLAGS"
191               ;;
192           *)
193               AC_MSG_ERROR([Assembler not supported for this OS])
194         esac
195     fi
196 fi
197 AM_CONDITIONAL(USE_ASM, test x$enable_assembler != xno)
198
199 AC_SUBST(D2X_ARCH_SUBDIRS)
200
201 AC_SUBST(TARGETS)
202
203 AC_SUBST(NASMFLAGS)
204
205 AC_SUBST(CFLAGS)
206
207 AC_OUTPUT(
208 Makefile
209 2d/Makefile
210 3d/Makefile
211 arch/Makefile
212 arch/dos/Makefile
213 arch/ggi/Makefile
214 arch/linux/Makefile
215 arch/sdl/Makefile
216 arch/svgalib/Makefile
217 arch/win32/Makefile
218 cfile/Makefile
219 iff/Makefile
220 main/Makefile
221 maths/Makefile
222 mem/Makefile
223 misc/Makefile
224 sound/Makefile
225 texmap/Makefile
226 video/Makefile
227 )