1dnl	This file is an input file used by the GNU "autoconf" program to
2dnl	generate the file "configure", which is run during Netrek installation
3dnl	to configure the system for the local environment.
4AC_INIT(name.c)
5AC_CANONICAL_SYSTEM
6AC_CONFIG_HEADER(config.h)
7
8AC_PROG_INSTALL
9
10AC_PROG_CC
11AC_PROG_CPP
12AC_PROG_LN_S
13
14AC_AIX
15
16AC_C_INLINE
17
18#--------------------------------------------------------------------
19#	Include sys/select.h if it exists and if it supplies things
20#	that appear to be useful.  This appears to be true only on
21#	the RS/6000 under AIX.  Some systems like OSF/1 have a
22#	sys/select.h that's of no use, and other systems like SCO
23#	UNIX have a sys/select.h that's pernicious.  If there isn't
24#	a sys/select.h, then make sure that "fd_set" is defined in
25#	sys/types.h.
26#--------------------------------------------------------------------
27
28AC_MSG_CHECKING(if fd_set requires sys/select.h)
29AC_TRY_COMPILE( [#include <sys/types.h>], [fd_set readMask, writeMask;],
30  AC_MSG_RESULT(no) ,
31  AC_EGREP_HEADER(fd_set, sys/select.h,
32      AC_DEFINE(NEED_SYS_SELECT_H) AC_MSG_RESULT(yes),
33      AC_DEFINE(NO_FD_SET) AC_MSG_RESULT(fd_set missing)))
34
35#--------------------------------------------------------------------
36#	Check for various typedefs and provide substitutes if
37#	they don't exist.
38#--------------------------------------------------------------------
39
40AC_HEADER_STDC
41AC_CHECK_HEADERS(unistd.h memory.h math.h stdlib.h)
42AC_CHECK_HEADERS(sys/timeb.h sys/ptyio.h sys/fcntl.h fcntl.h)
43AC_CHECK_HEADERS(ctype.h machine/endian.h sys/resource.h)
44AC_CHECK_HEADERS(sys/wait.h netinet/in.h netinet/tcp.h sys/filio.h)
45
46AC_TYPE_PID_T
47AC_TYPE_UID_T
48AC_TYPE_SIZE_T
49AC_FUNC_VFORK
50AC_STRUCT_TM
51
52AC_MSG_CHECKING(for itimer in time.h)
53AC_EGREP_HEADER(itimerval, time.h, AC_MSG_RESULT(yes) , AC_DEFINE(NEED_SYS_TIME_H) AC_MSG_RESULT(no))
54
55AC_CHECK_SIZEOF(long)
56
57AC_MSG_CHECKING(for u_int in sys/types.h)
58AC_EGREP_HEADER(u_int, sys/types.h, AC_MSG_RESULT(yes) , AC_DEFINE(NO_U_INT) AC_MSG_RESULT(no))
59
60AC_MSG_CHECKING(for PATH_MAX in limits.h)
61AC_EGREP_CPP(PATH_MAX, [
62#include <limits.h>
63PATH_MAX
64], AC_DEFINE(NO_PATH_MAX) AC_MSG_RESULT(no), AC_MSG_RESULT(yes))
65
66AC_CHECK_FUNCS(strcmpi strncmpi)
67
68#--------------------------------------------------------------------
69#	Locate the X11 header files and the X11 library archive.
70#--------------------------------------------------------------------
71
72AC_PATH_X
73
74AC_DEFINE(HAVE_X11)
75AC_DEFINE(HAVE_X11_XPM_H)
76NOWIN32="#"
77
78if test -z "$NOX11" ; then
79
80if test -z "$x_libraries" ; then
81echo checking for X11 header files
82XINCLUDES=""
83AC_TRY_CPP([#include <X11/Intrinsic.h>], , XINCLUDES="nope")
84if test "$XINCLUDES" = nope; then
85    dirs="/usr/unsupported/include /usr/local/include /usr/X386/include \
86      /usr/include/X11R4 /usr/X11R5/include /usr/include/X11R5 \
87      /usr/openwin/include /usr/X11/include /pub/X11R5/include \
88      /usr/local/X11R5/include /usr/X11R6/include /usr/include/X11R6 \
89      /pub/X11R6/include /usr/local/X11R6/include"
90
91    for i in $dirs ; do
92	if test -r $i/X11/Intrinsic.h; then
93	    XINCLUDES=" -I$i"
94	fi
95    done
96fi
97if test "$XINCLUDES" = nope; then
98  echo "Warning:  couldn't find any X11 include files."
99  XINCLUDES=""
100fi
101
102echo "checking for X11 library archive"
103AC_CHECK_LIB(X11, main, XLIBSWLIB="-lX11", XLIBSWLIB=nope)
104if test "$XLIBSWLIB" = nope; then
105    dirs="/usr/unsupported/lib /usr/local/lib /usr/X386/lib \
106      /usr/lib/X11R4 /usr/X11R5/lib /usr/lib/X11R5 /usr/openwin/lib \
107      /usr/X11/lib /pub/X11R5/lib /usr/local/X11R5/lib \
108      /usr/X11R6/lib /usr/lib/X11R6 /pub/X11R6/lib /usr/local/X11R6/lib"
109
110    for i in $dirs ; do
111	if test -r $i/libX11.a; then
112	    XLIBSWDIR="-L$i"
113	    XLIBSWLIB="-lX11"
114	fi
115    done
116fi
117if test "$XLIBSWLIB" = nope ; then
118    AC_CHECK_LIB(Xwindow, main, XLIBSWLIB=-lXwindow)
119fi
120if test "$XLIBSWLIB" = nope ; then
121    echo "Warning:  couldn't find the X11 library archive.  Using -lX11."
122    XLIBSWLIB=-lX11
123fi
124else
125XINCLUDES="-I$x_includes"
126XLIBSWDIR="-L$x_libraries"
127XLIBSWLIB="-lX11"
128fi
129
130fi
131
132AC_SUBST(NOX11)
133AC_SUBST(NOWIN32)
134
135SAVELIBS="$LIBS"
136LIBS="$LIBS $XLIBSWDIR $XLIBSWLIB"
137SAVEINCS="$INCS"
138INCS="$INCS $XINCLUDES"
139AC_CHECK_LIB(Xpm, main, [AC_DEFINE(HAVE_XPM) XPMLIBS="-lXpm"])
140AC_CHECK_HEADERS(X11/xpm.h)
141LIBS="$SAVELIBS"
142INCS="$SAVEINCS"
143
144# Fix link order for Xpm
145XLIBSW="$XLIBSWDIR $XPMLIBS $XLIBSWLIB"
146
147INCS="$INCS $XINCLUDES"
148AC_SUBST(INCS)
149LIBS="$LIBS $XLIBSW"
150
151#--------------------------------------------------------------------
152#	Check for the existence of various libraries.  The order here
153#	is important, so that then end up in the right order in the
154#	command line generated by Make.
155#--------------------------------------------------------------------
156
157AC_CHECK_LIB(Xbsd, main, [LIBS="$LIBS -lXbsd"])
158AC_CHECK_LIB(socket, main, [LIBS="$LIBS -lsocket"])
159AC_CHECK_LIB(inet, main, [LIBS="$LIBS -linet"])
160AC_CHECK_LIB(nsl, main, [LIBS="$LIBS -lnsl"])
161AC_CHECK_LIB(seq, main, [LIBS="$LIBS -lseq"])
162AC_CHECK_LIB(sun, main, [LIBS="$LIBS -lsun"])
163
164#--------------------------------------------------------------------
165#    	Check for type of signals
166#--------------------------------------------------------------------
167
168AC_TYPE_SIGNAL
169AC_CHECK_FUNCS(usleep random setstate strftime ftime)
170AC_CHECK_LIB(m, main, [LIBS="$LIBS -lm"])
171AC_CHECK_FUNCS(nint)
172AC_EGREP_HEADER(rint, math.h, , AC_DEFINE(NEED_RINT_DEC))
173AC_REPLACE_FUNCS(usleep setstate strdup rint)
174
175#--------------------------------------------------------------------
176#       Check for system dependent programs
177#--------------------------------------------------------------------
178
179#--------------------------------------------------------------------
180#       Check for Imlib
181#--------------------------------------------------------------------
182AC_SEARCH_LIBS([imlib_load_image], [Imlib2], [],
183               [AC_MSG_ERROR([Could not find Imlib2])])
184
185#--------------------------------------------------------------------
186#       Check for SDL
187#--------------------------------------------------------------------
188
189AM_PATH_SDL(1.2.4, AC_DEFINE(HAVE_SDL),[])
190AM_CONDITIONAL(HAVE_SDL, [test x"$no_sdl" != x"yes"])
191
192if test x$no_sdl != xyes; then
193  have_SDLmixer=no
194  AC_CHECK_LIB(SDL_mixer, Mix_OpenAudio, [have_SDLmixer=yes SDL_MIXER_LIBS="-lSDL_mixer"])
195  if test x$have_SDLmixer != xyes; then
196    AC_MSG_ERROR([*** Can't find the SDL_mixer library Try: http://www.libsdl.org/projects/SDL_mixer/])
197    AC_SUBST(SDL_MIXER_LIBS)
198  fi
199fi
200
201#--------------------------------------------------------------------
202#       Emit output
203#--------------------------------------------------------------------
204AC_OUTPUT(system.mk)
205