blob: 5563fa218094187589d4552dc4463cd9935be2c7 [file] [log] [blame]
Dan Nicholsondca1b792007-10-23 09:25:58 -07001dnl Process this file with autoconf to create configure.
2
3AC_PREREQ(2.59)
4
5dnl Versioning
6dnl Make version number available to autoconf and configure
7m4_define(mesa_major, 7)
8m4_define(mesa_minor, 1)
9m4_define(mesa_tiny, 0)
10m4_define(mesa_version, [mesa_major().mesa_minor().mesa_tiny()])
11
12AC_INIT(Mesa, mesa_version(), mesa3d@sourceforge.net)
13AC_CONFIG_AUX_DIR(bin)
14AC_CANONICAL_HOST
15
16dnl Substitute the version number into shell variables
17MESA_MAJOR=mesa_major()
18MESA_MINOR=mesa_minor()
19MESA_TINY=mesa_tiny()
20AC_SUBST(MESA_MAJOR)
21AC_SUBST(MESA_MINOR)
22AC_SUBST(MESA_TINY)
23
24dnl Check for progs
25AC_PROG_CPP
26AC_PROG_CC
27AC_PROG_CXX
28AC_PATH_PROG(MAKE, make)
29AC_PATH_PROG(MKDEP, makedepend)
30AC_PATH_PROG(SED, sed)
31PKG_PROG_PKG_CONFIG()
32
33dnl LIB_DIR - library basename
34LIB_DIR=`echo $libdir | $SED 's%.*/%%'`
35AC_SUBST(LIB_DIR)
36
37dnl Cache LDFLAGS so we can add EXTRA_LIB_PATH and restore it later
38_SAVE_LDFLAGS="$LDFLAGS"
39AC_ARG_VAR(EXTRA_LIB_PATH,[Extra -L paths for the linker])
40AC_SUBST(EXTRA_LIB_PATH)
41
42dnl Cache CPPFLAGS so we can add *_INCLUDES and restore it later
43_SAVE_CPPFLAGS="$CPPFLAGS"
44AC_ARG_VAR(X11_INCLUDES,[Extra -I paths for X11 headers])
45AC_SUBST(X11_INCLUDES)
46
47dnl Compiler macros
48DEFINES=""
49AC_SUBST(DEFINES)
50if test "x$GCC" = xyes; then
51 DEFINES="-D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_BSD_SOURCE"
52fi
53case "$host_os" in
54linux*)
55 DEFINES="$DEFINES -D_SVID_SOURCE -D_GNU_SOURCE -DPTHREADS -DHAVE_POSIX_MEMALIGN"
56 ;;
57esac
58
59dnl Add flags for gcc and g++
60if test "x$GCC" = xyes; then
61 CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -std=c99 -ffast-math"
62fi
63if test "x$GXX" = xyes; then
64 CXXFLAGS="$CXXFLAGS -Wall"
65fi
66
67dnl These should be unnecessary, but let the user set them if they want
68AC_ARG_VAR(OPT_FLAGS, [Additional optimization flags for the compiler.
69 Default is to use CFLAGS.])
70AC_ARG_VAR(ARCH_FLAGS, [Additional architecture specific flags for the
71 compiler. Default is to use CFLAGS.])
72AC_SUBST(OPT_FLAGS)
73AC_SUBST(ARCH_FLAGS)
74
75dnl
76dnl library names
77dnl
78GL_LIB_NAME='lib$(GL_LIB).so'
79GLU_LIB_NAME='lib$(GLU_LIB).so'
80GLUT_LIB_NAME='lib$(GLUT_LIB).so'
81GLW_LIB_NAME='lib$(GLW_LIB).so'
82OSMESA_LIB_NAME='lib$(OSMESA_LIB).so'
83AC_SUBST(GL_LIB_NAME)
84AC_SUBST(GLU_LIB_NAME)
85AC_SUBST(GLUT_LIB_NAME)
86AC_SUBST(GLW_LIB_NAME)
87AC_SUBST(OSMESA_LIB_NAME)
88
89dnl
90dnl Build directories for xlib driver
91dnl
92SRC_DIRS="mesa"
93DRIVER_DIRS="x11 osmesa"
94GLU_DIRS="sgi"
95AC_SUBST(SRC_DIRS)
96AC_SUBST(GLU_DIRS)
97AC_SUBST(DRIVER_DIRS)
98
99dnl
100dnl Find out if X is available. The variables have_x or no_x will be
101dnl set and used later in the driver setups
102dnl
103if test -n "$PKG_CONFIG"; then
104 AC_MSG_CHECKING([pkg-config files for X11 are available])
105 if $PKG_CONFIG --exists x11; then
106 x11_pkgconfig=yes
107 have_x=yes
108 AC_MSG_RESULT(yes)
109 else
110 x11_pkgconfig=no
111 no_x=yes
112 AC_MSG_RESULT(no)
113 fi
114else
115 x11_pkgconfig=no
116fi
117dnl Use the autoconf macro if no pkg-config files
118if test "$x11_pkgconfig" = no; then
119 AC_PATH_XTRA
120fi
121
122dnl
123dnl libGL for xlib driver
124dnl
125if test "$no_x" = yes; then
126 AC_MSG_ERROR([X11 development libraries needed for Xlib driver])
127fi
128
129if test "$x11_pkgconfig" = yes; then
130PKG_CHECK_MODULES(X11GL, x11 xext)
131 X11_INCLUDES="$X11_INCLUDES $X11GL_CFLAGS"
132 GL_LIB_DEPS="$X11GL_LIBS"
133else
134 # should check these...
135 X11_INCLUDES="$X11_INCLUDES $X_CFLAGS"
136 GL_LIB_DEPS="$X_LIBS -lX11 -lXext"
137fi
138GL_LIB_DEPS="$GL_LIB_DEPS -lm -lpthread"
139AC_SUBST(GL_LIB_DEPS)
140
141dnl
142dnl More X11 setup
143dnl
144if test "$mesa_driver" = x11; then
145 DEFINES="$DEFINES -DUSE_XSHM"
146fi
147
148dnl
149dnl OSMesa configuration
150dnl
151OSMESA_LIB_DEPS=""
152OSMESA_MESA_DEPS='-l$(GL_LIB)'
153AC_SUBST(OSMESA_LIB_DEPS)
154AC_SUBST(OSMESA_MESA_DEPS)
155
156dnl
157dnl GLU configuration
158dnl
159AC_ARG_ENABLE(glu,
160 [AS_HELP_STRING([--enable-glu],
161 [enable OpenGL Utility library @<:@default=yes@:>@])],
162 enable_glu="$enableval",
163 enable_glu=yes)
164if test "x$enable_glu" = xyes; then
165 SRC_DIRS="$SRC_DIRS glu"
166
167 # If GLU is available, we can build some programs
168 PROGRAM_DIRS="$PROGRAM_DIRS xdemos"
169
170 GLU_LIB_DEPS="-lm"
171 GLU_MESA_DEPS='-l$(GL_LIB)'
172fi
173AC_SUBST(GLU_LIB_DEPS)
174AC_SUBST(GLU_MESA_DEPS)
175
176dnl
177dnl GLw configuration
178dnl
179AC_ARG_ENABLE(glw,
180 [AS_HELP_STRING([--enable-glw],
181 [enable Xt/Motif widget library @<:@default=yes@:>@])],
182 enable_glw="$enableval",
183 enable_glw=yes)
184if test "x$enable_glw" = xyes; then
185 SRC_DIRS="$SRC_DIRS glw"
186 if test "$x11_pkgconfig" = yes; then
187 PKG_CHECK_MODULES(GLW, x11 xt)
188 GLW_LIB_DEPS="$GLW_LIBS"
189 else
190 # should check these...
191 GLW_LIB_DEPS="$X_LIBS -lX11 -lXt"
192 fi
193
194 GLW_MESA_DEPS='-l$(GL_LIB)'
195fi
196AC_SUBST(GLW_LIB_DEPS)
197AC_SUBST(GLW_MESA_DEPS)
198
199dnl
200dnl GLUT configuration
201dnl
202if test -f "$srcdir/include/GL/glut.h"; then
203 default_glut=yes
204else
205 default_glut=no
206fi
207AC_ARG_ENABLE(glut,
208 [AS_HELP_STRING([--enable-glut],
209 [enable GLUT library @<:@default=yes if source available@:>@])],
210 enable_glut="$enableval",
211 enable_glut="$default_glut")
212
213dnl Can't build glut if GLU not available
214if test "x$enable_glu$enable_glut" = xnoyes; then
215 AC_MSG_WARN([Disabling glut since GLU is disabled])
216 enable_glut=no
217fi
218if test "x$enable_glut" = xyes; then
219 SRC_DIRS="$SRC_DIRS glut/glx"
220 GLUT_CFLAGS=""
221 if test "x$GCC" = xyes; then
222 GLUT_CFLAGS="-fexceptions"
223 fi
224 if test "$x11_pkgconfig" = yes; then
225 PKG_CHECK_MODULES(GLUT, x11 xmu xt xi)
226 GLUT_LIB_DEPS="$GLUT_LIBS"
227 else
228 # should check these...
229 GLUT_LIB_DEPS="$X_LIBS -lX11 -lXmu -lXt -lXi"
230 fi
231 GLUT_LIB_DEPS="$GLUT_LIB_DEPS -lm"
232
233 # If glut is available, we can build most programs
234 PROGRAM_DIRS="$PROGRAM_DIRS demos redbook samples glsl"
235
236 GLUT_MESA_DEPS='-l$(GLU_LIB) -l$(GL_LIB)'
237fi
238AC_SUBST(GLUT_LIB_DEPS)
239AC_SUBST(GLUT_MESA_DEPS)
240AC_SUBST(GLUT_CFLAGS)
241
242dnl
243dnl Program library dependencies
244dnl Only libm is added here if necessary as the libraries should
245dnl be pulled in by the linker
246dnl
247if test "x$APP_LIB_DEPS" = x; then
248 APP_LIB_DEPS="-lm"
249fi
250AC_SUBST(APP_LIB_DEPS)
251AC_SUBST(PROGRAM_DIRS)
252
253dnl Arch/platform-specific settings
254PIC_FLAGS=""
255ASM_FLAGS=""
256ASM_SOURCES=""
257ASM_API=""
258AC_SUBST(PIC_FLAGS)
259AC_SUBST(ASM_FLAGS)
260AC_SUBST(ASM_SOURCES)
261AC_SUBST(ASM_API)
262case "$host_os" in
263linux*)
264 PIC_FLAGS="-fPIC"
265 case "$host_cpu" in
266 i*86)
267 ASM_FLAGS="-DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM"
268 ASM_SOURCES='$(X86_SOURCES)'
269 ASM_API='$(X86_API)'
270 ;;
271 x86_64)
272 ASM_FLAGS="-DUSE_X86_64_ASM"
273 ASM_SOURCES='$(X86-64_SOURCES)'
274 ASM_API='$(X86-64_API)'
275 ;;
276 powerpc)
277 ASM_FLAGS="-DUSE_PPC_ASM -DUSE_VMX_ASM"
278 ASM_SOURCES='$(PPC_SOURCES)'
279 ;;
280 esac
281 ;;
282freebsd*)
283 PIC_FLAGS="-fPIC"
284 case "$host_os" in
285 i*86)
286 PIC_FLAGS=""
287 ASM_FLAGS="-DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM"
288 ASM_SOURCES='$(X86_SOURCES)'
289 ASM_API='$(X86_API)'
290 ;;
291 x86_64)
292 ASM_FLAGS="-DUSE_X86_64_ASM"
293 ASM_SOURCES='$(X86-64_SOURCES)'
294 ASM_API='$(X86-64_API)'
295 ;;
296 esac
297 ;;
298esac
299
300dnl Restore LDFLAGS and CPPFLAGS
301LDFLAGS="$_SAVE_LDFLAGS"
302CPPFLAGS="$_SAVE_CPPFLAGS"
303
304dnl Substitute the config
305AC_OUTPUT([configs/autoconf])
306
307echo ""
308echo " Run 'make autoconf' to build Mesa"
309echo ""