1# $Id: configure.in,v 1.7 2002/09/14 15:54:06 stefan Exp $
2AC_INIT
3AC_PREREQ(2.53)
4AC_CANONICAL_HOST
5AC_CANONICAL_TARGET
6AM_INIT_AUTOMAKE(jfk,0.1.1)
7AM_CONFIG_HEADER(config.h)
8
9AC_PROG_CC
10AM_PROG_CC_STDC
11AC_PROG_CXX
12AC_PROG_LN_S
13AC_PROG_RANLIB
14
15build_client=1
16
17AC_IPV6
18
19# Win32 needs -lwsock32
20AC_MSG_CHECKING([for wsock32])
21svLIBS=$LIBS
22LIBS="$LIBS -lwsock32"
23AC_TRY_LINK([
24#include <winsock2.h>
25],[
26socket(0, 0, 0);
27],[AC_MSG_RESULT(yes)],
28  [LIBS=$svLIBS
29   AC_MSG_RESULT(no)])
30
31# SDL Checks --------------------------------------------
32SDL_VERSION=1.2.4
33AM_PATH_SDL($SDL_VERSION,,build_client=0)
34svCXXFLAGS=$CXXFLAGS
35svLIBS=$LIBS
36CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
37LIBS="$LIBS $SDL_LIBS"
38AC_CHECK_LIB(SDL_image, main,,build_client=0)
39LIBS=$svLIBS
40CXXFLAGS=$svCXXFLAGS
41AM_CONDITIONAL(BUILD_CLIENT, test $build_client = 1)
42if test $build_client = 0; then
43	AC_MSG_WARN([SDL and/or SDL_image not found, only jfkserver will be built])
44fi
45if test $build_client = 1; then
46	AC_DEFINE([JFK_OUTPUT_BUILD_SDL],,[define if SDL output should be built])
47fi
48
49AC_HEADER_STDC
50AC_CHECK_HEADERS([arpa/inet.h arpa/nameser.h fcntl.h netdb.h netinet/in.h \
51	netinet/tcp.h poll.h resolv.h stdint.h sys/param.h sys/select.h   \
52	sys/socket.h sys/syctl.h sys/time.h sys/types.h unistd.h])
53
54AC_CHECK_TYPE(ssize_t, int)
55TYPE_SOCKLEN_T
56
57AC_STRUCT_SA_LEN
58
59AC_CXX_NAMESPACES
60if test $ac_cv_cxx_namespaces = "no"; then
61	AC_MSG_ERROR([jfk needs a C++ compiler that supports namespaces!])
62fi
63AC_CXX_HAVE_SSTREAM
64if test $ac_cv_cxx_have_sstream = "no"; then
65	AC_MSG_ERROR([jfk needs a C++ compiler that supports stringstreams!])
66fi
67AC_CXX_HAVE_STD_COMPARE
68
69AC_CHECK_FUNCS([gettimeofday gethostbyname2 fcntl nanosleep poll select \
70	setsockopt])
71AC_REPLACE_FUNCS([getaddrinfo inet_ntop inet_pton])
72
73AC_ARG_ENABLE(debug,[  --enable-debug          Enable development build],
74	enable_debug=yes, enable_debug=no)
75if test $enable_debug = yes; then
76	CXXFLAGS="$CXXFLAGS -DDEBUG"
77fi
78
79# Unfortunately, autoconf lacks a --docdir option. This is a workaround:
80AC_ARG_WITH(docdir, [  --with-docdir=DIR       Where to put the documentation],
81    [ if test "x$withval" = xyes || test "x$withval" = xno; then
82         docdir='${prefix}/share/doc/jfk'
83      else
84         docdir="$withval"
85      fi
86    ], [ docdir='${prefix}/share/doc/jfk' ])
87AC_SUBST(docdir)
88
89CXXFLAGS="$CXXFLAGS -W -Wall"
90CFLAGS="$CFLAGS -W -Wall"
91
92# Output Files
93AC_OUTPUT([
94	Makefile
95	art/Makefile
96	art/bar/Makefile
97	art/font/Makefile
98	art/ground/Makefile
99	art/splash/Makefile
100	art/object/Makefile
101	art/object/bullet/Makefile
102	art/object/explosion/Makefile
103	art/object/item/Makefile
104	art/object/obstacle/Makefile
105	art/object/person/Makefile
106	art/object/weapon/Makefile
107	doc/Makefile
108	levels/Makefile
109	macros/Makefile
110	src/Makefile
111	src/lib/Makefile
112	src/server/Makefile
113	src/client/Makefile
114],[
115	echo timestamp > stamp-h
116])
117