1dnl Process this file with autoconf to produce a configure script.
2AC_INIT([prboom],[2.5.0])
3AC_CONFIG_AUX_DIR(autotools)
4AC_CONFIG_MACRO_DIR(autotools)
5
6dnl --- Check for target system type - before initialising Automake
7AC_CANONICAL_TARGET
8
9dnl --- Fire up automake
10AM_INIT_AUTOMAKE([check-news foreign -Woverride -Wobsolete -Wportability -Wsyntax -Wunsupported])
11AM_CONFIG_HEADER(config.h)
12
13AC_MSG_CHECKING([checking whether to use x86 asm versions of some functions])
14AC_ARG_ENABLE(i386-asm,AC_HELP_STRING([--disable-i386-asm],[Do not use i386 assembly]),,[
15enable_i386_asm="no"
16case "$target" in
17        i?86-*) enable_i386_asm="yes" ;;
18esac])
19if test "$enable_i386_asm" = yes; then
20    AC_DEFINE(I386_ASM,1,[Define on targets supporting 386 assembly])
21    AC_MSG_RESULT(yes)
22else
23    AC_MSG_RESULT(no)
24fi
25
26AC_ARG_WITH(waddir,AC_HELP_STRING([--with-waddir],[Path to install prboom.wad and look for other WAD files]),
27DOOMWADDIR="$withval",
28if test "x$prefix" != xNONE; then
29  DOOMWADDIR="$prefix/share/games/doom"
30else
31  DOOMWADDIR="$ac_default_prefix/share/games/doom"
32fi
33)
34AC_DEFINE_UNQUOTED(DOOMWADDIR,"$DOOMWADDIR",[Define to be the path where Doom WADs are stored])
35
36dnl --- Check for programs
37AC_PROG_CC
38AC_PROG_LN_S
39AC_PROG_RANLIB
40
41if test "x$GCC" = "xyes"; then
42  AC_DEFINE(PACKEDATTR,[__attribute__((packed))],[Set to the attribute to apply to struct definitions to make them packed])
43else
44  AC_DEFINE(PACKEDATTR,[])
45  echo "-!- Your compiler is not gcc. We probably don't know how to force"
46  echo '    structures to be packed with your compiler. You may have to edit'
47  echo '    the source to insert the relevant pragmas so structures are packed.'
48fi
49
50dnl --- cph: work out flags to pass to compiler
51CFLAGS_OPT="-O2 -fomit-frame-pointer"
52AC_C_COMPILE_FLAGS(-Wall)
53dnl --- Option to enable debugging
54AC_ARG_ENABLE(debug,AC_HELP_STRING([--enable-debug],[turns on various debugging features, like range checking and internal heap diagnostics]),,enable_debug="no")
55if test "$enable_debug" = "no"
56then
57    AC_C_COMPILE_FLAGS(-Wno-unused -Wno-switch)
58else
59    CFLAGS_OPT="-g"
60    AC_C_COMPILE_FLAGS(-Wmissing-noreturn -Wredundant-decls -Wnested-externs -Wold-style-definition -Wmissing-declarations -Wmissing-format-attribute -Wvariadic-macros -Wdisabled-optimization -Wlarger-than-128000 -Waggregate-return -Wvolatile-register-var)
61    AC_DEFINE(RANGECHECK,1,[Define to enable internal range checking])
62    AC_DEFINE(INSTRUMENTED,1,[Define this to see real-time memory allocation statistics, and enable extra debugging features])
63    AC_DEFINE(TIMEDIAG,1,[Defining this causes time stamps to be created each time a lump is locked, and lumps locked for long periods of time are reported])
64fi
65AC_ARG_ENABLE(profile,AC_HELP_STRING([--enable-profile],[turns on profiling]),,enable_profile="no")
66if test "$enable_profile" = "yes"
67then
68    CFLAGS_OPT="-pg"
69fi
70AM_WITH_DMALLOC
71
72dnl --- Try for processor optimisations
73AC_CPU_OPTIMISATIONS
74
75dnl --- some defaults for CFLAGS
76AC_C_COMPILE_FLAGS(-Wextra -Wno-missing-field-initializers -Winline -Wwrite-strings -Wundef -Wbad-function-cast -Wcast-align -Wcast-qual -Wdeclaration-after-statement -ffast-math $CFLAGS_OPT)
77dnl -Wmissing-prototypes -Wmissing-declarations
78CFLAGS="$CFLAGS -I\$(top_srcdir)/src"
79
80dnl --- Compiler characteristics
81AC_C_CONST
82AC_C_INLINE
83if test "$cross_compiling" != "yes"; then
84        AC_C_BIGENDIAN
85fi
86
87dnl --- Header files, typedefs, structures
88AC_TYPE_UID_T
89AC_TYPE_SIZE_T
90AC_DECL_SYS_SIGLIST
91AC_HEADER_SYS_WAIT
92AC_CHECK_HEADERS(unistd.h asm/byteorder.h sched.h)
93
94dnl --- Library functions
95AC_CHECK_FUNC(stricmp,,AC_DEFINE(stricmp,strcasecmp,[Define to strcasecmp, if we have it]))
96AC_CHECK_FUNC(strnicmp,,AC_DEFINE(strnicmp,strncasecmp,[Define to strncasecmp, if we have it]))
97AC_CHECK_FUNC(min,AC_DEFINE(MIN,min,[If your platform has a fast version of min, define MIN to it]),)
98AC_CHECK_FUNC(max,AC_DEFINE(MAX,max,[If your platform has a fast version of max, define MAX to it]),)
99AC_CHECK_FUNCS(getopt inet_aton inet_pton inet_ntop snprintf vsnprintf mmap usleep sched_setaffinity)
100
101dnl --- Check for libraries
102dnl --- cph: we need pow(3) in SDL/i_sound.c; on some systems it gets pulled
103dnl ---  in by other libraries, but we can't rely on that.
104AC_CHECK_LIB(m,pow)
105dnl - system specific stuff
106case "$target" in
107    *-*-cygwin* | *-*-mingw32*)
108        SYS_GL_LIBS="-lopengl32"
109        ;;
110    *-*-beos*)
111        SYS_GL_LIBS="-lGL -lGLU"
112        ;;
113    *-*-aix*)
114        if test x$ac_cv_prog_gcc = xyes; then
115            CFLAGS="$CFLAGS -mthreads"
116        fi
117        ;;
118    *)
119	SYS_GL_LIBS="-lGL -lGLU"
120	;;
121esac
122
123dnl - GL
124AC_ARG_ENABLE(gl,AC_HELP_STRING([--disable-gl],[disable OpenGL rendering code]),,enable_gl="yes")
125if test "$enable_gl" = "yes"
126then
127    AC_MSG_CHECKING(for OpenGL support)
128    have_opengl=no
129    AC_TRY_COMPILE([
130     #include <GL/gl.h>
131    ],[
132    ],[
133    have_opengl=yes
134    ])
135    AC_MSG_RESULT($have_opengl)
136    if test x$have_opengl = xyes; then
137        AC_DEFINE(GL_DOOM,1,[Define if you are building with OpenGL support])
138        AC_DEFINE(USE_GLU_IMAGESCALE,1,[Define if you want to use gluImageScale])
139        AC_DEFINE(USE_GLU_MIPMAP,1,[Define if you want to use gluBuild2DMipmaps])
140        GL_LIBS="$SYS_GL_LIBS"
141    else
142        AC_MSG_ERROR([You must have the relevant OpenGL development libraries & headers installed to compile with OpenGL support])
143    fi
144fi
145AM_CONDITIONAL(BUILD_GL,test "$enable_gl" = "yes")
146
147dnl - SDL
148AM_PATH_SDL(1.1.3, sdl_main="yes")
149if test "$sdl_main" != "yes"
150then
151 AC_MSG_ERROR([*** You must have the SDL libraries installed before you can compile prboom
152 *** See http://prboom.sourceforge.net/linux.html
153 ])
154fi
155
156savelibs="$LIBS"
157LIBS="$LIBS $SDL_LIBS"
158AC_CHECK_FUNCS(SDL_JoystickGetAxis)
159LIBS="$savelibs"
160AC_ARG_WITH([mixer],
161  AC_HELP_STRING([--without-mixer],[Do not use SDL_mixer even if available]),
162  [], AC_CHECK_LIB(SDL_mixer,Mix_OpenAudio,[],[],[$SDL_LIBS $MIXER_LIBS]))
163
164AC_ARG_WITH(net,
165  AS_HELP_STRING([--without-net],[Do not use SDL_net even if available]),
166  [
167    dnl -- Networking was disabled by the user.
168    NET_LIBS=
169  ],[
170    dnl -- Check for networking support
171    AC_CHECK_LIB(SDL_net,SDLNet_UDP_Bind,[
172      AC_DEFINE(HAVE_NET,1,[Define if you want network game support])
173      AC_DEFINE(HAVE_LIBSDL_NET,1,
174        [Define if you have the SDL net library -lSDL_net])
175      AC_DEFINE(USE_SDL_NET,1,[Define if you want to use the SDL net lib])
176      NET_LIBS=-lSDL_net
177      sdl_net=yes
178      save_CFLAGS="$CFLAGS"
179      CFLAGS="$CFLAGS $SDL_CFLAGS"
180      AC_TRY_COMPILE([
181          #include "SDL_net.h"
182          ],[
183          UDPpacket *p;
184          int n = sizeof(p->src);
185          ],
186          AC_DEFINE(SDL_NET_UDP_PACKET_SRC,1,[Define if you have an old SDL_net, such that the UDPpacket structure has a src member instead of an address member]))
187      CFLAGS="$save_CFLAGS"
188    ],[
189      dnl -- Warn if networking support was not disabled but sdlnet is missing
190      AC_MSG_WARN([*** SDL networking library not found. The game will not be compiled with network game support.])
191    ],$SDL_LIBS)
192  ])
193
194dnl - Other libs
195AC_CHECK_LIB(png,png_create_info_struct)
196AC_EGREP_HEADER(sockaddr_in6,netinet/in.h,AC_DEFINE(HAVE_IPv6,1,[Define if you have struct sockaddr_in6]))
197
198dnl --- Options
199dnl - Always use highres mode and basic checks - anyone that wants these off can edit the config.h
200AC_DEFINE(HIGHRES,1,[Define for high resolution support])
201AC_DEFINE(SIMPLECHECKS,1,[When defined this causes quick checks which only impose significant overhead if a posible error is detected.])
202AC_DEFINE(ZONEIDCHECK,1,[Define this to perform id checks on zone blocks, to detect corrupted and illegally freed blocks])
203
204AC_ARG_ENABLE(dogs,AC_HELP_STRING([--disable-dogs],[disables support for helper dogs]),,enable_dogs="yes")
205if test x"$enable_dogs" = xyes
206then
207	AC_DEFINE(DOGS,1,[Define for support for MBF helper dogs])
208fi
209
210AC_ARG_ENABLE(heapcheck,AC_HELP_STRING([--enable-heapcheck],[turns on continuous heap checking (very slow)]),,enable_heapcheck="no")
211AC_ARG_ENABLE(heapdump,AC_HELP_STRING([--enable-heapdump],[turns on dumping the heap state for debugging]),,enable_heapdump="no")
212if test "$enable_heapcheck" = "yes"
213then
214    AC_DEFINE(CHECKHEAP,1,[Uncomment this to exhaustively run memory checks while the game is running (this is EXTREMELY slow).])
215fi
216if test "$enable_heapdump" = "yes"
217then
218    AC_DEFINE(HEAPDUMP,1,[Uncomment this to cause heap dumps to be generated. Only useful if INSTRUMENTED is also defined.])
219fi
220
221AM_CONDITIONAL(WAD_MMAP,test "$ac_cv_func_mmap" = yes)
222AC_SUBST(MIXER_CFLAGS)
223AC_SUBST(MIXER_LIBS)
224AC_SUBST(NET_CFLAGS)
225AC_SUBST(NET_LIBS)
226AC_SUBST(MATH_LIB)
227AC_SUBST(GL_LIBS)
228AC_SUBST(CFLAGS)
229AC_SUBST(DOOMWADDIR)
230
231dnl --- output
232AC_OUTPUT(Makefile src/Makefile src/POSIX/Makefile src/SDL/Makefile src/MAC/Makefile doc/Makefile data/Makefile ICONS/Makefile VisualC6/Makefile VisualC8/Makefile prboom.spec)
233