More wad fixes.
[theoddone33/hheretic.git] / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2 dnl configure.in for HHeretic
3 AC_REVISION([configure.in 1.00])
4 AC_INIT(base/am_map.c)          
5 AC_CONFIG_HEADER(include/config.h)
6
7 dnl **** Command-line arguments ****
8
9 dnl Default values
10 GLHEXEN="false"
11 GLLIBS=""
12 BASELIBS=""
13 LIBS="-L/usr/X11R6/lib"
14 HAVEGL="no"
15 BUILDNAMES=""
16
17 AC_ARG_ENABLE(gl,
18 [  --enable-gl                  Enable OpenGL mode],
19 [GLHEXEN="true";SDL_VERSION="1.1.2"; AC_DEFINE(RENDER3D)],
20 [SDL_VERSION="1.1.0"])
21
22 AC_SUBST(GLHEXEN)
23 AC_SUBST(SVGALIBS)
24
25 AC_DEFINE(_REENTRANT)
26 AC_DEFINE(NORANGECHECKING)
27
28 dnl **** Check for some programs ****
29
30 AC_PROG_CC
31 AC_PROG_CPP
32
33 dnl **** Check for some libraries ****
34
35 dnl Check for pthread
36 AC_CHECK_LIB(pthread, pthread_join, [BASELIBS="-lpthread"])
37
38 AC_SUBST(BASELIBS)
39
40 dnl Check for SDL
41 AM_PATH_SDL($SDL_VERSION,
42         [HAVESDL="yes";GLBASE="sdl/i_sdlgl.o";BUILDNAMES="sdl $BUILDNAMES"],
43         [HAVESDL="no"]
44 )
45
46 AC_SUBST(GLLIBS)
47 AC_SUBST(SDL_OGL)
48 AC_SUBST(HAVESDL)
49 AC_SUBST(GLBASE)
50
51 AC_CHECK_LIB(dl, dlopen)
52 AC_CHECK_LIB(m, sqrt)
53
54 dnl Check for GL libraries
55
56 if test "$GLHEXEN" = "true"
57 then
58     AC_CHECK_LIB(GL, glBindTexture,[LIBS="$LIBS -lGL";]
59       AC_CHECK_LIB(GLU, gluOrtho2D, [HAVEGL="yes"],
60         AC_CHECK_LIB(MesaGL, glBindTexture,[LIBS="$LIBS -lMesaGL";]
61           AC_CHECK_LIB(MesaGLU, gluOrtho2D, [HAVEGL="yes"], HAVEGL="no"),
62           HAVEGL="no")
63         ),
64         AC_CHECK_LIB(MesaGL, glBindTexture,[LIBS="$LIBS -lMesaGL";]
65           AC_CHECK_LIB(MesaGLU, gluOrtho2D, [HAVEGL="yes"], HAVEGL="no"),
66         HAVEGL="no")
67     )
68 fi
69
70 dnl **** Check for gcc strength-reduce bug ****
71
72 if test "x${GCC}" = "xyes"
73 then
74   CFLAGS="$CFLAGS -Wall"
75   AC_CACHE_CHECK( "for gcc strength-reduce bug", ac_cv_c_gcc_strength_bug,
76                   AC_TRY_RUN([
77 int main(void) {
78   static int Array[[3]];
79   unsigned int B = 3;
80   int i;
81   for(i=0; i<B; i++) Array[[i]] = i - 3;
82   exit( Array[[1]] != -2 );
83 }],
84     ac_cv_c_gcc_strength_bug="no",
85     ac_cv_c_gcc_strength_bug="yes",
86     ac_cv_c_gcc_strength_bug="yes") )
87   if test "$ac_cv_c_gcc_strength_bug" = "yes"
88   then
89     CFLAGS="$CFLAGS -fno-strength-reduce"
90   fi
91 fi
92
93 dnl **** Check for underscore on external symbols ****
94
95 AC_CACHE_CHECK("whether external symbols need an underscore prefix",
96                ac_cv_c_extern_prefix,
97 [saved_libs=$LIBS
98 LIBS="conftest_asm.s $LIBS"
99 cat > conftest_asm.s <<EOF
100         .globl _ac_test
101 _ac_test:
102         .long 0
103 EOF
104 AC_TRY_LINK([extern int ac_test;],[if (ac_test) return 1],
105             ac_cv_c_extern_prefix="yes",ac_cv_c_extern_prefix="no")
106 LIBS=$saved_libs])
107
108 dnl **** Check for endianness ****
109
110 dnl AC_C_BIGENDIAN
111
112 dnl **** Check for functions ****
113
114 AC_FUNC_ALLOCA()
115
116 dnl **** Check for header files ****
117
118 AC_CHECK_HEADERS(\
119         linux/cdrom.h \
120 )
121 AC_HEADER_STAT()
122
123 dnl **** Check for types ****
124
125 AC_C_CONST()
126 AC_C_INLINE()
127 AC_TYPE_SIZE_T()
128 AC_CHECK_SIZEOF(long long,0)
129
130 if test "$HAVEGL" = "yes"
131 then
132   if test "$HAVESDL" = "yes"
133   then
134     BUILDNAMES="OpenGL (SDL)"
135   fi 
136 fi
137
138 dnl **** Generate output files ****
139
140 MAKE_NAME=Makefile
141 AC_SUBST_FILE(MAKE_RULES)
142
143 AC_OUTPUT(Makefile)
144
145 echo
146 echo "HHeretic configuration finished."
147 echo "Enabled targets: $BUILDNAMES"
148 echo
149 if test "$HAVESDL" = "no"
150 then
151   echo "It is recommended that you install SDL (http://www.libsdl.org)."
152   echo "Other targets will compile, but they are no longer supported."
153   echo "If SDL is installed, you will need to upgrade to version $SDL_VERSION"
154   echo
155 fi  
156 echo "Type 'make' to compile."
157 echo