1##############################################################################
2#
3#    file                 : configure.in
4#    created              : Mon Dec 11 22:34:38 CET 2000
5#    copyright            : (C) 2000-2016 by Eric Espie, Bernhard Wymann
6#    email                : Eric.Espie@torcs.org
7#    version              : $Id: configure.in,v 1.57.2.16 2016/05/18 18:30:44 berniw Exp $
8#
9##############################################################################
10#
11#   This program is free software; you can redistribute it and/or modify
12#   it under the terms of the GNU General Public License as published by
13#   the Free Software Foundation; either version 2 of the License, or
14#   (at your option) any later version.
15#
16##############################################################################
17
18AC_INIT(Make-config.in)
19AC_CONFIG_HEADERS(config.h)
20AM_INIT_AUTOMAKE(torcs, 1.3.7)
21
22dnl Checks for programs.
23AC_PROG_CC
24AC_PROG_CPP
25
26AC_LANG_CPLUSPLUS
27
28AC_PROG_CXX
29AC_PROG_RANLIB
30AC_PROG_INSTALL
31
32dnl Checks for header files.
33AC_HEADER_STDC
34
35dnl Checks for typedefs, structures, and compiler characteristics.
36AC_C_CONST
37AC_C_INLINE
38AC_HEADER_TIME
39
40AC_CHECK_PROG(AR, ar, :, ar, /usr/bin/ar)
41AC_CHECK_PROG(LD, ld, :, ld, /usr/bin/gxx)
42
43AC_C_BIGENDIAN
44
45AC_PATH_X
46#CFLAGS="-ansi -Wall -Wstrict-prototypes -W"
47ADDCFLAGS="-Wall -fPIC -fno-strict-aliasing"
48AC_ARG_ENABLE(debug,
49	[  --enable-debug          set the debug mode],
50	ADDCFLAGS="$ADDCFLAGS -g -DDEBUG -DDEBUG_OUT",
51	ADDCFLAGS="$ADDCFLAGS -O2")
52
53AC_ARG_ENABLE(xrandr,
54	[  --disable-xrandr	   reset the XRANDR mode],
55	if test "$enableval" = "yes";
56	then ADDCFLAGS="$ADDCFLAGS -DUSE_RANDR_EXT"
57	fi,
58	ADDCFLAGS="$ADDCFLAGS -DUSE_RANDR_EXT")
59
60AC_ARG_ENABLE(ccmalloc,
61	[  --enable-ccmalloc       set the ccmalloc mode (beware path...)],
62	LDFLAGS="$LDFLAGS ccmalloc-g++.o -lccmalloc -ldl",
63	LDFLAGS="$LDFLAGS")
64
65AC_ARG_ENABLE(profiler,
66	[  --enable-profiler       set the profiler mode],
67	ADDCFLAGS="$ADDCFLAGS -DPROFILER",
68	ADDCFLAGS="$ADDCFLAGS")
69
70AC_ARG_ENABLE(glextprototypes,
71	[  --disable-glextprototypes       disable prototypes in glext.h],
72	if test "$enableval" = "yes";
73	then ADDCFLAGS="$ADDCFLAGS -DGL_GLEXT_PROTOTYPES"
74	fi,
75	ADDCFLAGS="$ADDCFLAGS -DGL_GLEXT_PROTOTYPES")
76
77
78CFLAGS="$CFLAGS $ADDCFLAGS"
79CXXFLAGS="$CXXFLAGS $ADDCFLAGS"
80
81dnl Checks for includes (devel part of packages)
82AC_CHECK_HEADER(GL/gl.h,, AC_MSG_ERROR([Can't find GL/gl.h. Look for Mesa devel packages for your distro.]))
83AC_CHECK_HEADER(GL/glut.h,, AC_MSG_ERROR([Can't find GL/glut.h. freeglut can be found on http://freeglut.sourceforge.net/]))
84AC_CHECK_HEADER(GL/glx.h,, AC_MSG_ERROR([Can't find GL/glx.h. Please check config.log and if you can't solve the problem send the file to torcs-users@lists.sourceforge.net with the subject \"torcs compilation problem\"]))
85AC_CHECK_HEADER(X11/Xlib.h,, AC_MSG_ERROR([Can't find X11/Xlib.h. Please check config.log and if you can't solve the problem send the file to torcs-users@lists.sourceforge.net with the subject \"torcs compilation problem\"]))
86AC_CHECK_HEADER(X11/Xatom.h,, AC_MSG_ERROR([Can't find X11/Xatom.h. Please check config.log and if you can't solve the problem send the file to torcs-users@lists.sourceforge.net with the subject \"torcs compilation problem\"]))
87AC_CHECK_HEADER(X11/keysym.h,, AC_MSG_ERROR([Can't find X11/keysym.h. Please check config.log and if you can't solve the problem send the file to torcs-users@lists.sourceforge.net with the subject \"torcs compilation problem\"]))
88AC_CHECK_HEADER(plib/ssg.h,, AC_MSG_ERROR([Can't find plib/ssg.h. PLIB can be found on http://plib.sourceforge.net/]))
89AC_CHECK_HEADER(plib/ul.h,, AC_MSG_ERROR([Can't find plib/ul.h. PLIB can be found on http://plib.sourceforge.net/]))
90AC_CHECK_HEADER(plib/ssgAux.h,, AC_MSG_ERROR([Can't find plib/ssgAux.h. PLIB can be found on http://plib.sourceforge.net/]))
91AC_CHECK_HEADER(plib/js.h,, AC_MSG_ERROR([Can't find plib/js.h. PLIB can be found on http://plib.sourceforge.net/]))
92AC_CHECK_HEADER(AL/al.h,, AC_MSG_ERROR([Can't find AL/al.h. OpenAL and FreeALUT can be found on http://www.openal.org/]))
93AC_CHECK_HEADER(AL/alut.h,, AC_MSG_ERROR([Can't find AL/alut.h. OpenAL and FreeALUT can be found on http://www.openal.org/]))
94AC_CHECK_HEADER(vorbis/vorbisfile.h,, AC_MSG_ERROR([Can't find vorbis/vorbisfile.h]))
95
96#AC_CHECK_HEADER(X11/Xfuncproto.h,, AC_MSG_ERROR([Can't find X11/Xfuncproto.h. Please check config.log and if you can't solve the problem send the file totorcs-users@lists.sourceforge.net with the subject \"torcs compilation problem\"]))
97#AC_CHECK_HEADER(X11/extensions/randr.h,, AC_MSG_ERROR([Can't find X11/extensions/randr.h. Please check config.log and if you can't solve the problem send the file to torcs-users@lists.sourceforge.net with the subject \"torcs compilation problem\"]))
98#AC_CHECK_HEADER(X11/extensions/Xrandr.h,, AC_MSG_ERROR([Can't find X11/extensions/Xrandr.h. Please check config.log and if you can't solve the problem send the file to torcs-users@lists.sourceforge.net with the subject \"torcs compilation problem\"]))
99
100dnl Checks for libraries.
101
102dnl Replace `main' with a function in -lm:
103AC_CHECK_LIB(m, sin,,AC_MSG_ERROR([Can't find libm. Please check config.log and if you can't solve the problem send the file to torcs-users@lists.sourceforge.net with the subject \"torcs compilation problem\"]))
104
105if test "$x_libraries" != ""; then
106	LDFLAGS="$LDFLAGS -L$x_libraries"
107fi
108
109dnl Replace `main' with a function in -lX11:
110AC_CHECK_LIB(X11, XOpenDisplay,,AC_MSG_ERROR([Can't find libX11. Please check config.log and if you can't solve the problem send the file to torcs-users@lists.sourceforge.net with the subject \"torcs compilation problem\"]))
111dnl Replace `main' with a function in -lXext:
112AC_CHECK_LIB(Xext, XShmCreateImage,,AC_MSG_ERROR([Can't find libXext. Please check config.log and if you can't solve the problem send the file to torcs-users@lists.sourceforge.net with the subject \"torcs compilation problem\"]))
113dnl Replace `main' with a function in -lICE:
114AC_CHECK_LIB(ICE, IceSetIOErrorHandler,,AC_MSG_ERROR([Can't find libICE. Please check config.log and if you can't solve the problem send the file to torcs-users@lists.sourceforge.net with the subject \"torcs compilation problem\"]))
115dnl Replace `main' with a function in -lSM:
116AC_CHECK_LIB(SM, SmsSetErrorHandler,,AC_MSG_ERROR([Can't find libSM. Please check config.log and if you can't solve the problem send the file to torcs-users@lists.sourceforge.net with the subject \"torcs compilation problem\"]))
117dnl Replace `main' with a function in -lXt:
118AC_CHECK_LIB(Xt, XtDisplay,,AC_MSG_ERROR([Can't find libXt. Please check config.log and if you can't solve the problem send the file to torcs-users@lists.sourceforge.net with the subject \"torcs compilation problem\"]))
119dnl Replace `main' with a function in -lXi:
120AC_CHECK_LIB(Xi, XOpenDevice,,AC_MSG_ERROR([Can't find libXi. Please check config.log and if you can't solve the problem send the file to torcs-users@lists.sourceforge.net with the subject \"torcs compilation problem\"]))
121dnl Replace `main' with a function in -lXmu:
122AC_CHECK_LIB(Xmu, XmuSimpleErrorHandler,,AC_MSG_ERROR([Can't find libXmu. Please check config.log and if you can't solve the problem send the file to torcs-users@lists.sourceforge.net with the subject \"torcs compilation problem\"]))
123AC_CHECK_LIB(Xxf86vm, XF86VidModeSetViewPort,,AC_MSG_ERROR([Can't find libXxf86vm. Please check config.log and if you can't solve the problem send the file to torcs-users@lists.sourceforge.net with the subject \"torcs compilation problem\"]))
124AC_CHECK_LIB(Xrender, XRenderSetSubpixelOrder,,AC_MSG_ERROR([Can't find libXrender. Please check config.log and if you can't solve the problem send the file to torcs-users@lists.sourceforge.net with the subject \"torcs compilation problem\"]))
125AC_CHECK_LIB(Xrandr, XRRQueryVersion,,AC_MSG_ERROR([Can't find libXrandr. Please check config.log and if you can't solve the problem send the file to torcs-users@lists.sourceforge.net with the subject \"torcs compilation problem\"]))
126AC_CHECK_LIB(openal, alEnable, LDFLAGS="$LDFLAGS -lopenal", AC_MSG_ERROR([Can't find AL/al.h. OpenAL can be found on http://www.openal.org/]))
127AC_CHECK_LIB(alut, alutLoadWAVFile,
128	LDFLAGS="$LDFLAGS -lalut",
129	LDFLAGS="$LDFLAGS")
130AC_CHECK_LIB(vorbisfile, ov_fopen, LDFLAGS="$LDFLAGS -lvorbisfile", AC_MSG_ERROR([Can't find libvorbis.]))
131
132AC_CHECK_LIB(dl, dlopen)
133AC_CHECK_FUNC(dlopen,,AC_MSG_ERROR([Can't find dlopen function. Please check config.log and if you can't solve the problem send the file to torcs-users@lists.sourceforge.net with the subject \"torcs compilation problem\"]))
134
135AC_CHECK_FUNCS(strndup,,)
136
137dnl Replace `main' with a function in -lz:
138AC_CHECK_LIB(z, crc32,,AC_MSG_ERROR([Can't find libz. Please check config.log and if you can't solve the problem send the file to torcs-users@lists.sourceforge.net with the subject \"torcs compilation problem\"]))
139dnl Replace `main' with a function in -lpng:
140AC_CHECK_LIB(png, png_init_io,,AC_MSG_ERROR([Can't find libpng. Please check config.log and if you can't solve the problem send the file to torcs-users@lists.sourceforge.net with the subject \"torcs compilation problem\"]))
141
142AC_CHECK_LIB(GL, glGetString,,AC_MSG_ERROR([Can't find libGL. Please check config.log and if you can't solve the problem send the file to torcs-users@lists.sourceforge.net with the subject \"torcs compilation problem\"]))
143AC_CHECK_LIB(GLU, gluOrtho2D,,AC_MSG_ERROR([Can't find libGLU. Please check config.log and if you can't solve the problem send the file to torcs-users@lists.sourceforge.net with the subject \"torcs compilation problem\"]))
144AC_CHECK_LIB(glut, glutSwapBuffers,,AC_MSG_ERROR([Can't find libglut. freeglut can be found on http://freeglut.sourceforge.net/]))
145
146dnl Checks for plib libraries.
147AC_CHECK_LIB(plibul, main,,AC_MSG_ERROR([Can't find libplibul. PLIB can be found on http://plib.sourceforge.net/]))
148AC_CHECK_LIB(plibsg, main,,AC_MSG_ERROR([Can't find libplibsg. PLIB can be found on http://plib.sourceforge.net/]))
149AC_CHECK_LIB(plibsl, main,,AC_MSG_ERROR([Can't find libplibsl. PLIB can be found on http://plib.sourceforge.net/]))
150AC_CHECK_LIB(plibsm, main,,AC_MSG_ERROR([Can't find libplibsm. PLIB can be found on http://plib.sourceforge.net/]))
151AC_CHECK_LIB(plibssg, main,,AC_MSG_ERROR([Can't find libplibssg. PLIB can be found on http://plib.sourceforge.net/]))
152AC_CHECK_LIB(plibssgaux, main,,AC_MSG_ERROR([Can't find libplibssgaux. PLIB can be found on http://plib.sourceforge.net/]))
153AC_CHECK_LIB(plibjs, main,,AC_MSG_ERROR([Can't find libjs. PLIB can be found on http://plib.sourceforge.net/]))
154
155
156dnl Taken from FlightGear
157AC_MSG_CHECKING([for plib 1.8.3 or newer])
158AC_RUN_IFELSE([AC_LANG_SOURCE([[
159#include <unistd.h>
160#include <plib/ul.h>
161#define MIN_PLIB_VERSION 183
162int main() {
163    if ( PLIB_VERSION < MIN_PLIB_VERSION ) {
164	 return -1;
165    }
166    return 0;
167}
168]])],
169  AC_MSG_RESULT(yes),
170  [AC_MSG_RESULT([PLIB 1.8.3 was not detected. TORCS can run only with PLIB 1.8.3, so verify that the PLIB 1.8.3 is really the version installed on your system.])],
171  AC_MSG_RESULT(yes)
172)
173
174
175
176AC_MSG_CHECKING([for GL_VERSION_1_3])
177AC_RUN_IFELSE([AC_LANG_SOURCE([[
178#include <GL/gl.h>
179int main() {
180#ifdef GL_VERSION_1_3
181	return 0;
182#else
183	return -1;
184#endif
185}
186]])],
187  AC_MSG_RESULT(yes),
188  [AC_MSG_ERROR([GL_VERSION_1_3 not defined via gl.h. Please get the GL header files from mesa3d.org.])],
189  AC_MSG_RESULT(yes)
190)
191
192
193
194AC_MSG_CHECKING([for GL_ARB_texture_compression])
195AC_RUN_IFELSE([AC_LANG_SOURCE([[
196#include <GL/gl.h>
197int main() {
198#ifdef GL_ARB_texture_compression
199	return 0;
200#else
201	return -1;
202#endif
203}
204]])],
205  AC_MSG_RESULT(yes),
206  [AC_MSG_ERROR([GL_ARB_texture_compression not defined via gl.h. Please get the GL header files from mesa3d.org.])],
207  AC_MSG_RESULT(yes)
208)
209
210
211
212CFLAGS="$CFLAGS $ADDCFLAGS"
213CXXFLAGS="$CXXFLAGS $ADDCFLAGS"
214
215
216AC_SUBST(TORCS_BASE)
217TORCS_BASE=$PWD
218
219AC_OUTPUT(Make-config \
220	src/linux/torcs \
221	src/tools/accc/accc \
222	src/tools/nfs2ac/nfs2ac \
223	src/tools/nfsperf/nfsperf \
224	src/tools/texmapper/texmapper \
225	src/tools/trackgen/trackgen \
226	src/doc/torcsdoc.conf \
227	src/tools/package/specfiles/torcs-data.spec \
228	src/tools/package/specfiles/torcs-data-cars-Patwo-Design.spec \
229	src/tools/package/specfiles/torcs-data-cars-kcendra-gt.spec \
230	src/tools/package/specfiles/torcs-data-cars-kcendra-sport.spec \
231	src/tools/package/specfiles/torcs-data-cars-kcendra-roadsters.spec \
232	src/tools/package/specfiles/torcs-data-cars-extra.spec \
233	src/tools/package/specfiles/torcs-data-tracks-base.spec \
234	src/tools/package/specfiles/torcs-robot-K1999.spec \
235	src/tools/package/specfiles/torcs-robot-base.spec \
236	src/tools/package/specfiles/torcs.spec \
237)
238