Clone of mesa.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087
  1. dnl Process this file with autoconf to create configure.
  2. AC_PREREQ([2.59])
  3. dnl Versioning - scrape the version from configs/default
  4. m4_define([mesa_version],
  5. [m4_esyscmd([${MAKE-make} -s -f bin/version.mk version | tr -d '\n'])])
  6. m4_ifval(mesa_version,[],[
  7. m4_errprint([Error: Failed to get the Mesa version from the output of
  8. running `make -f bin/version.mk version'
  9. ])
  10. m4_exit([1])
  11. ])
  12. dnl Tell the user about autoconf.html in the --help output
  13. m4_divert_once([HELP_END], [
  14. See docs/autoconf.html for more details on the options for Mesa.])
  15. AC_INIT([Mesa],[mesa_version],
  16. [https://bugs.freedesktop.org/enter_bug.cgi?product=Mesa])
  17. AC_CONFIG_AUX_DIR([bin])
  18. AC_CANONICAL_HOST
  19. dnl Versions for external dependencies
  20. LIBDRM_REQUIRED=2.3.1
  21. DRI2PROTO_REQUIRED=1.1
  22. dnl Check for progs
  23. AC_PROG_CPP
  24. AC_PROG_CC
  25. AC_PROG_CXX
  26. AC_CHECK_PROGS([MAKE], [gmake make])
  27. AC_PATH_PROG([MKDEP], [makedepend])
  28. AC_PATH_PROG([SED], [sed])
  29. dnl We need a POSIX shell for parts of the build. Assume we have one
  30. dnl in most cases.
  31. case "$host_os" in
  32. solaris*)
  33. # Solaris /bin/sh is too old/non-POSIX compliant
  34. AC_PATH_PROGS(POSIX_SHELL, [ksh93 ksh sh])
  35. SHELL="$POSIX_SHELL"
  36. ;;
  37. esac
  38. MKDEP_OPTIONS=-fdepend
  39. dnl Ask gcc where it's keeping its secret headers
  40. if test "x$GCC" = xyes; then
  41. GCC_INCLUDES=`$CC -print-file-name=include`
  42. if test "x$GCC_INCLUDES" != x; then
  43. MKDEP_OPTIONS="$MKDEP_OPTIONS -I$GCC_INCLUDES"
  44. fi
  45. fi
  46. AC_SUBST([MKDEP_OPTIONS])
  47. dnl Make sure the pkg-config macros are defined
  48. m4_ifdef([PKG_PROG_PKG_CONFIG],[],[
  49. m4_errprint([Error: Could not locate the pkg-config autoconf macros.
  50. These are usually located in /usr/share/aclocal/pkg.m4. If your
  51. macros are in a different location, try setting the environment
  52. variable ACLOCAL="aclocal -I/other/macro/dir" before running
  53. autoreconf.
  54. ])
  55. m4_exit([1])
  56. ])
  57. PKG_PROG_PKG_CONFIG()
  58. dnl LIB_DIR - library basename
  59. LIB_DIR=`echo $libdir | $SED 's%.*/%%'`
  60. AC_SUBST([LIB_DIR])
  61. dnl Cache LDFLAGS so we can add EXTRA_LIB_PATH and restore it later
  62. _SAVE_LDFLAGS="$LDFLAGS"
  63. AC_ARG_VAR([EXTRA_LIB_PATH],[Extra -L paths for the linker])
  64. AC_SUBST([EXTRA_LIB_PATH])
  65. dnl Cache CPPFLAGS so we can add *_INCLUDES and restore it later
  66. _SAVE_CPPFLAGS="$CPPFLAGS"
  67. AC_ARG_VAR([X11_INCLUDES],[Extra -I paths for X11 headers])
  68. AC_SUBST([X11_INCLUDES])
  69. dnl Compiler macros
  70. DEFINES=""
  71. AC_SUBST([DEFINES])
  72. case "$host_os" in
  73. linux*)
  74. if test "x$GCC" = xyes; then
  75. DEFINES="$DEFINES -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_BSD_SOURCE"
  76. fi
  77. DEFINES="$DEFINES -D_SVID_SOURCE -D_GNU_SOURCE -DPTHREADS"
  78. ;;
  79. solaris*)
  80. DEFINES="$DEFINES -DPTHREADS -DSVR4"
  81. ;;
  82. esac
  83. dnl Add flags for gcc and g++
  84. if test "x$GCC" = xyes; then
  85. CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -std=c99 -ffast-math"
  86. # Work around aliasing bugs - developers should comment this out
  87. CFLAGS="$CFLAGS -fno-strict-aliasing"
  88. fi
  89. if test "x$GXX" = xyes; then
  90. CXXFLAGS="$CXXFLAGS -Wall"
  91. # Work around aliasing bugs - developers should comment this out
  92. CXXFLAGS="$CXXFLAGS -fno-strict-aliasing"
  93. fi
  94. dnl These should be unnecessary, but let the user set them if they want
  95. AC_ARG_VAR([OPT_FLAGS], [Additional optimization flags for the compiler.
  96. Default is to use CFLAGS.])
  97. AC_ARG_VAR([ARCH_FLAGS], [Additional architecture specific flags for the
  98. compiler. Default is to use CFLAGS.])
  99. AC_SUBST([OPT_FLAGS])
  100. AC_SUBST([ARCH_FLAGS])
  101. dnl
  102. dnl Hacks to enable 32 or 64 bit build
  103. dnl
  104. AC_ARG_ENABLE([32-bit],
  105. [AS_HELP_STRING([--enable-32-bit],
  106. [build 32-bit libraries @<:@default=auto@:>@])],
  107. [enable_32bit="$enableval"],
  108. [enable_32bit=auto]
  109. )
  110. if test "x$enable_32bit" = xyes; then
  111. if test "x$GCC" = xyes; then
  112. CFLAGS="$CFLAGS -m32"
  113. fi
  114. if test "x$GXX" = xyes; then
  115. CXXFLAGS="$CXXFLAGS -m32"
  116. fi
  117. fi
  118. AC_ARG_ENABLE([64-bit],
  119. [AS_HELP_STRING([--enable-64-bit],
  120. [build 64-bit libraries @<:@default=auto@:>@])],
  121. [enable_64bit="$enableval"],
  122. [enable_64bit=auto]
  123. )
  124. if test "x$enable_64bit" = xyes; then
  125. if test "x$GCC" = xyes; then
  126. CFLAGS="$CFLAGS -m64"
  127. fi
  128. if test "x$GXX" = xyes; then
  129. CXXFLAGS="$CXXFLAGS -m64"
  130. fi
  131. fi
  132. dnl
  133. dnl shared/static libraries, mimic libtool options
  134. dnl
  135. AC_ARG_ENABLE([static],
  136. [AS_HELP_STRING([--enable-static],
  137. [build static libraries @<:@default=disabled@:>@])],
  138. [enable_static="$enableval"],
  139. [enable_static=no]
  140. )
  141. case "x$enable_static" in
  142. xyes|xno ) ;;
  143. x ) enable_static=no ;;
  144. * )
  145. AC_MSG_ERROR([Static library option '$enable_static' is not a valid])
  146. ;;
  147. esac
  148. AC_ARG_ENABLE([shared],
  149. [AS_HELP_STRING([--disable-shared],
  150. [build shared libraries @<:@default=enabled@:>@])],
  151. [enable_shared="$enableval"],
  152. [enable_shared=yes]
  153. )
  154. case "x$enable_shared" in
  155. xyes|xno ) ;;
  156. x ) enable_shared=yes ;;
  157. * )
  158. AC_MSG_ERROR([Shared library option '$enable_shared' is not a valid])
  159. ;;
  160. esac
  161. dnl Can't have static and shared libraries, default to static if user
  162. dnl explicitly requested. If both disabled, set to static since shared
  163. dnl was explicitly requirested.
  164. case "x$enable_static$enable_shared" in
  165. xyesyes )
  166. AC_MSG_WARN([Can't build static and shared libraries, disabling shared])
  167. enable_shared=no
  168. ;;
  169. xnono )
  170. AC_MSG_WARN([Can't disable both static and shared libraries, enabling static])
  171. enable_static=yes
  172. ;;
  173. esac
  174. dnl
  175. dnl mklib options
  176. dnl
  177. AC_ARG_VAR([MKLIB_OPTIONS],[Options for the Mesa library script, mklib])
  178. if test "$enable_static" = yes; then
  179. MKLIB_OPTIONS="$MKLIB_OPTIONS -static"
  180. fi
  181. AC_SUBST([MKLIB_OPTIONS])
  182. dnl
  183. dnl other compiler options
  184. dnl
  185. AC_ARG_ENABLE([debug],
  186. [AS_HELP_STRING([--enable-debug],
  187. [use debug compiler flags and macros @<:@default=disabled@:>@])],
  188. [enable_debug="$enableval"],
  189. [enable_debug=no]
  190. )
  191. if test "x$enable_debug" = xyes; then
  192. DEFINES="$DEFINES -DDEBUG"
  193. if test "x$GCC" = xyes; then
  194. CFLAGS="$CFLAGS -g"
  195. fi
  196. if test "x$GXX" = xyes; then
  197. CXXFLAGS="$CXXFLAGS -g"
  198. fi
  199. fi
  200. dnl
  201. dnl library names
  202. dnl
  203. if test "$enable_static" = yes; then
  204. GL_LIB_NAME='lib$(GL_LIB).a'
  205. GLU_LIB_NAME='lib$(GLU_LIB).a'
  206. GLUT_LIB_NAME='lib$(GLUT_LIB).a'
  207. GLW_LIB_NAME='lib$(GLW_LIB).a'
  208. OSMESA_LIB_NAME='lib$(OSMESA_LIB).a'
  209. else
  210. GL_LIB_NAME='lib$(GL_LIB).so'
  211. GLU_LIB_NAME='lib$(GLU_LIB).so'
  212. GLUT_LIB_NAME='lib$(GLUT_LIB).so'
  213. GLW_LIB_NAME='lib$(GLW_LIB).so'
  214. OSMESA_LIB_NAME='lib$(OSMESA_LIB).so'
  215. fi
  216. AC_SUBST([GL_LIB_NAME])
  217. AC_SUBST([GLU_LIB_NAME])
  218. AC_SUBST([GLUT_LIB_NAME])
  219. AC_SUBST([GLW_LIB_NAME])
  220. AC_SUBST([OSMESA_LIB_NAME])
  221. dnl
  222. dnl Arch/platform-specific settings
  223. dnl
  224. AC_ARG_ENABLE([asm],
  225. [AS_HELP_STRING([--disable-asm],
  226. [disable assembly usage @<:@default=enabled on supported plaforms@:>@])],
  227. [enable_asm="$enableval"],
  228. [enable_asm=yes]
  229. )
  230. asm_arch=""
  231. ASM_FLAGS=""
  232. ASM_SOURCES=""
  233. ASM_API=""
  234. AC_MSG_CHECKING([whether to enable assembly])
  235. test "x$enable_asm" = xno && AC_MSG_RESULT([no])
  236. # disable if cross compiling on x86/x86_64 since we must run gen_matypes
  237. if test "x$enable_asm" = xyes && test "x$cross_compiling" = xyes; then
  238. case "$host_cpu" in
  239. i?86 | x86_64)
  240. enable_asm=no
  241. AC_MSG_RESULT([no, cross compiling])
  242. ;;
  243. esac
  244. fi
  245. # check for supported arches
  246. if test "x$enable_asm" = xyes; then
  247. case "$host_cpu" in
  248. i?86)
  249. case "$host_os" in
  250. linux* | freebsd* | dragonfly*)
  251. test "x$enable_64bit" = xyes && asm_arch=x86_64 || asm_arch=x86
  252. ;;
  253. esac
  254. ;;
  255. x86_64)
  256. case "$host_os" in
  257. linux* | freebsd* | dragonfly*)
  258. test "x$enable_32bit" = xyes && asm_arch=x86 || asm_arch=x86_64
  259. ;;
  260. esac
  261. ;;
  262. powerpc)
  263. case "$host_os" in
  264. linux*)
  265. asm_arch=ppc
  266. ;;
  267. esac
  268. ;;
  269. esac
  270. case "$asm_arch" in
  271. x86)
  272. ASM_FLAGS="-DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM"
  273. ASM_SOURCES='$(X86_SOURCES)'
  274. ASM_API='$(X86_API)'
  275. AC_MSG_RESULT([yes, x86])
  276. ;;
  277. x86_64)
  278. ASM_FLAGS="-DUSE_X86_64_ASM"
  279. ASM_SOURCES='$(X86-64_SOURCES)'
  280. ASM_API='$(X86-64_API)'
  281. AC_MSG_RESULT([yes, x86_64])
  282. ;;
  283. ppc)
  284. ASM_FLAGS="-DUSE_PPC_ASM -DUSE_VMX_ASM"
  285. ASM_SOURCES='$(PPC_SOURCES)'
  286. AC_MSG_RESULT([yes, ppc])
  287. ;;
  288. *)
  289. AC_MSG_RESULT([no, platform not supported])
  290. ;;
  291. esac
  292. fi
  293. AC_SUBST([ASM_FLAGS])
  294. AC_SUBST([ASM_SOURCES])
  295. AC_SUBST([ASM_API])
  296. dnl PIC code macro
  297. MESA_PIC_FLAGS
  298. dnl Check to see if dlopen is in default libraries (like Solaris, which
  299. dnl has it in libc), or if libdl is needed to get it.
  300. AC_CHECK_FUNC([dlopen], [],
  301. [AC_CHECK_LIB([dl], [dlopen], [DLOPEN_LIBS="-ldl"])])
  302. dnl See if posix_memalign is available
  303. AC_CHECK_FUNC([posix_memalign], [DEFINES="$DEFINES -DHAVE_POSIX_MEMALIGN"])
  304. dnl SELinux awareness.
  305. AC_ARG_ENABLE([selinux],
  306. [AS_HELP_STRING([--enable-selinux],
  307. [Build SELinux-aware Mesa @<:@default=disabled@:>@])],
  308. [MESA_SELINUX="$enableval"],
  309. [MESA_SELINUX=no])
  310. if test "x$enable_selinux" = "xyes"; then
  311. AC_CHECK_HEADER([selinux/selinux.h],[],
  312. [AC_MSG_ERROR([SELinux headers not found])])
  313. AC_CHECK_LIB([selinux],[is_selinux_enabled],[],
  314. [AC_MSG_ERROR([SELinux library not found])])
  315. SELINUX_LIBS="-lselinux"
  316. DEFINES="$DEFINES -DMESA_SELINUX"
  317. fi
  318. dnl OS-specific libraries
  319. OS_LIBS=""
  320. case "$host_os" in
  321. solaris*)
  322. OS_LIBS="-lc"
  323. if test "x$GXX" != xyes; then
  324. OS_CPLUSPLUS_LIBS="-lCrun $OS_LIBS"
  325. fi
  326. ;;
  327. esac
  328. dnl
  329. dnl Driver configuration. Options are xlib, dri and osmesa right now.
  330. dnl More later: directfb, fbdev, ...
  331. dnl
  332. default_driver="xlib"
  333. case "$host_os" in
  334. linux*)
  335. case "$host_cpu" in
  336. i*86|x86_64|powerpc*) default_driver="dri";;
  337. esac
  338. ;;
  339. freebsd* | dragonfly*)
  340. case "$host_cpu" in
  341. i*86|x86_64) default_driver="dri";;
  342. esac
  343. ;;
  344. esac
  345. AC_ARG_WITH([driver],
  346. [AS_HELP_STRING([--with-driver=DRIVER],
  347. [driver for Mesa: xlib,dri,osmesa @<:@default=dri when available, or xlib@:>@])],
  348. [mesa_driver="$withval"],
  349. [mesa_driver="$default_driver"])
  350. dnl Check for valid option
  351. case "x$mesa_driver" in
  352. xxlib|xdri|xosmesa)
  353. ;;
  354. *)
  355. AC_MSG_ERROR([Driver '$mesa_driver' is not a valid option])
  356. ;;
  357. esac
  358. dnl
  359. dnl Driver specific build directories
  360. dnl
  361. SRC_DIRS="mesa"
  362. GLU_DIRS="sgi"
  363. WINDOW_SYSTEM=""
  364. case "$mesa_driver" in
  365. xlib)
  366. DRIVER_DIRS="x11"
  367. ;;
  368. dri)
  369. SRC_DIRS="glx/x11 $SRC_DIRS"
  370. DRIVER_DIRS="dri"
  371. WINDOW_SYSTEM="dri"
  372. ;;
  373. osmesa)
  374. DRIVER_DIRS="osmesa"
  375. ;;
  376. esac
  377. AC_SUBST([SRC_DIRS])
  378. AC_SUBST([GLU_DIRS])
  379. AC_SUBST([DRIVER_DIRS])
  380. AC_SUBST([WINDOW_SYSTEM])
  381. dnl
  382. dnl User supplied program configuration
  383. dnl
  384. if test -d "$srcdir/progs/demos"; then
  385. default_demos=yes
  386. else
  387. default_demos=no
  388. fi
  389. AC_ARG_WITH([demos],
  390. [AS_HELP_STRING([--with-demos@<:@=DIRS...@:>@],
  391. [optional comma delimited demo directories to build
  392. @<:@default=auto if source available@:>@])],
  393. [with_demos="$withval"],
  394. [with_demos="$default_demos"])
  395. if test "x$with_demos" = x; then
  396. with_demos=no
  397. fi
  398. dnl If $with_demos is yes, directories will be added as libs available
  399. PROGRAM_DIRS=""
  400. case "$with_demos" in
  401. no) ;;
  402. yes)
  403. # If the driver isn't osmesa, we have libGL and can build xdemos
  404. if test "$mesa_driver" != osmesa; then
  405. PROGRAM_DIRS="xdemos"
  406. fi
  407. ;;
  408. *)
  409. # verify the requested demos directories exist
  410. demos=`IFS=,; echo $with_demos`
  411. for demo in $demos; do
  412. test -d "$srcdir/progs/$demo" || \
  413. AC_MSG_ERROR([Program directory '$demo' doesn't exist])
  414. done
  415. PROGRAM_DIRS="$demos"
  416. ;;
  417. esac
  418. dnl
  419. dnl Find out if X is available. The variable have_x is set if libX11 is
  420. dnl found to mimic AC_PATH_XTRA.
  421. dnl
  422. if test -n "$PKG_CONFIG"; then
  423. AC_MSG_CHECKING([pkg-config files for X11 are available])
  424. PKG_CHECK_EXISTS([x11],[
  425. x11_pkgconfig=yes
  426. have_x=yes
  427. ],[
  428. x11_pkgconfig=no
  429. ])
  430. AC_MSG_RESULT([$x11_pkgconfig])
  431. else
  432. x11_pkgconfig=no
  433. fi
  434. dnl Use the autoconf macro if no pkg-config files
  435. if test "$x11_pkgconfig" = no; then
  436. AC_PATH_XTRA
  437. fi
  438. dnl Try to tell the user that the --x-* options are only used when
  439. dnl pkg-config is not available. This must be right after AC_PATH_XTRA.
  440. m4_divert_once([HELP_BEGIN],
  441. [These options are only used when the X libraries cannot be found by the
  442. pkg-config utility.])
  443. dnl We need X for xlib and dri, so bomb now if it's not found
  444. case "$mesa_driver" in
  445. xlib|dri)
  446. if test "$no_x" = yes; then
  447. AC_MSG_ERROR([X11 development libraries needed for $mesa_driver driver])
  448. fi
  449. ;;
  450. esac
  451. dnl XCB - this is only used for GLX right now
  452. AC_ARG_ENABLE([xcb],
  453. [AS_HELP_STRING([--enable-xcb],
  454. [use XCB for GLX @<:@default=disabled@:>@])],
  455. [enable_xcb="$enableval"],
  456. [enable_xcb=no])
  457. if test "x$enable_xcb" = xyes; then
  458. DEFINES="$DEFINES -DUSE_XCB"
  459. else
  460. enable_xcb=no
  461. fi
  462. dnl
  463. dnl libGL configuration per driver
  464. dnl
  465. case "$mesa_driver" in
  466. xlib)
  467. if test "$x11_pkgconfig" = yes; then
  468. PKG_CHECK_MODULES([XLIBGL], [x11 xext])
  469. X11_INCLUDES="$X11_INCLUDES $XLIBGL_CFLAGS"
  470. GL_LIB_DEPS="$XLIBGL_LIBS"
  471. else
  472. # should check these...
  473. X11_INCLUDES="$X11_INCLUDES $X_CFLAGS"
  474. GL_LIB_DEPS="$X_LIBS -lX11 -lXext"
  475. fi
  476. GL_LIB_DEPS="$GL_LIB_DEPS $SELINUX_LIBS -lm -lpthread $OS_LIBS"
  477. # if static, move the external libraries to the programs
  478. # and empty the libraries for libGL
  479. if test "$enable_static" = yes; then
  480. APP_LIB_DEPS="$APP_LIB_DEPS $GL_LIB_DEPS"
  481. GL_LIB_DEPS=""
  482. fi
  483. ;;
  484. dri)
  485. # DRI must be shared, I think
  486. if test "$enable_static" = yes; then
  487. AC_MSG_ERROR([Can't use static libraries for DRI drivers])
  488. fi
  489. # Check for libdrm
  490. PKG_CHECK_MODULES([LIBDRM], [libdrm >= $LIBDRM_REQUIRED])
  491. PKG_CHECK_MODULES([DRI2PROTO], [dri2proto >= $DRI2PROTO_REQUIRED])
  492. # find the DRI deps for libGL
  493. if test "$x11_pkgconfig" = yes; then
  494. # add xcb modules if necessary
  495. dri_modules="x11 xext xxf86vm xdamage xfixes"
  496. if test "$enable_xcb" = yes; then
  497. dri_modules="$dri_modules x11-xcb xcb-glx"
  498. fi
  499. PKG_CHECK_MODULES([DRIGL], [$dri_modules])
  500. X11_INCLUDES="$X11_INCLUDES $DRIGL_CFLAGS"
  501. GL_LIB_DEPS="$DRIGL_LIBS"
  502. else
  503. # should check these...
  504. X11_INCLUDES="$X11_INCLUDES $X_CFLAGS"
  505. GL_LIB_DEPS="$X_LIBS -lX11 -lXext -lXxf86vm -lXdamage -lXfixes"
  506. # XCB can only be used from pkg-config
  507. if test "$enable_xcb" = yes; then
  508. PKG_CHECK_MODULES([XCB],[x11-xcb xcb-glx])
  509. X11_INCLUDES="$X11_INCLUDES $XCB_CFLAGS"
  510. GL_LIB_DEPS="$GL_LIB_DEPS $XCB_LIBS"
  511. fi
  512. fi
  513. # need DRM libs, -lpthread, etc.
  514. GL_LIB_DEPS="$GL_LIB_DEPS $LIBDRM_LIBS -lm -lpthread $DLOPEN_LIBS $OS_LIBS"
  515. ;;
  516. osmesa)
  517. # No libGL for osmesa
  518. GL_LIB_DEPS="$OS_LIBS"
  519. ;;
  520. esac
  521. AC_SUBST([GL_LIB_DEPS])
  522. dnl
  523. dnl More X11 setup
  524. dnl
  525. if test "$mesa_driver" = xlib; then
  526. DEFINES="$DEFINES -DUSE_XSHM"
  527. fi
  528. dnl
  529. dnl More DRI setup
  530. dnl
  531. AC_ARG_ENABLE([glx-tls],
  532. [AS_HELP_STRING([--enable-glx-tls],
  533. [enable TLS support in GLX @<:@default=disabled@:>@])],
  534. [GLX_USE_TLS="$enableval"],
  535. [GLX_USE_TLS=no])
  536. dnl Directory for DRI drivers
  537. AC_ARG_WITH([dri-driverdir],
  538. [AS_HELP_STRING([--with-dri-driverdir=DIR],
  539. [directory for the DRI drivers @<:@${libdir}/dri@:>@])],
  540. [DRI_DRIVER_INSTALL_DIR="$withval"],
  541. [DRI_DRIVER_INSTALL_DIR='${libdir}/dri'])
  542. AC_SUBST([DRI_DRIVER_INSTALL_DIR])
  543. dnl Direct rendering or just indirect rendering
  544. AC_ARG_ENABLE([driglx-direct],
  545. [AS_HELP_STRING([--disable-driglx-direct],
  546. [enable direct rendering in GLX for DRI @<:@default=enabled@:>@])],
  547. [driglx_direct="$enableval"],
  548. [driglx_direct="yes"])
  549. dnl ttm support
  550. AC_ARG_ENABLE([ttm-api],
  551. [AS_HELP_STRING([--enable-ttm-api],
  552. [enable TTM API users @<:@default=disabled@:>@])],
  553. [ttmapi="$enableval"],
  554. [ttmapi="no"])
  555. if test "x$ttmapi" = "xyes"; then
  556. save_CFLAGS=$CFLAGS
  557. CFLAGS=$LIBDRM_CFLAGS
  558. AC_CHECK_HEADERS([xf86mm.h],[],[AC_MSG_ERROR([xf86mm.h required for TTM.])],[#include "stdint.h"\n#include "drm.h"])
  559. CFLAGS=$save_CFLAGS
  560. fi
  561. dnl Which drivers to build - default is chosen by platform
  562. AC_ARG_WITH([dri-drivers],
  563. [AS_HELP_STRING([--with-dri-drivers@<:@=DIRS...@:>@],
  564. [comma delimited DRI drivers list, e.g.
  565. "swrast,i965,radeon,nouveau" @<:@default=auto@:>@])],
  566. [with_dri_drivers="$withval"],
  567. [with_dri_drivers=yes])
  568. if test "x$with_dri_drivers" = x; then
  569. with_dri_drivers=no
  570. fi
  571. dnl If $with_dri_drivers is yes, directories will be added through
  572. dnl platform checks
  573. DRI_DIRS=""
  574. case "$with_dri_drivers" in
  575. no) ;;
  576. yes)
  577. DRI_DIRS="yes"
  578. ;;
  579. *)
  580. # verify the requested driver directories exist
  581. dri_drivers=`IFS=', '; echo $with_dri_drivers`
  582. for driver in $dri_drivers; do
  583. test -d "$srcdir/src/mesa/drivers/dri/$driver" || \
  584. AC_MSG_ERROR([DRI driver directory '$driver' doesn't exist])
  585. done
  586. DRI_DIRS="$dri_drivers"
  587. ;;
  588. esac
  589. dnl Just default to no EGL for now
  590. USING_EGL=0
  591. AC_SUBST([USING_EGL])
  592. dnl Set DRI_DIRS, DEFINES and LIB_DEPS
  593. if test "$mesa_driver" = dri; then
  594. # Use TLS in GLX?
  595. if test "x$GLX_USE_TLS" = xyes; then
  596. DEFINES="$DEFINES -DGLX_USE_TLS -DPTHREADS"
  597. fi
  598. if test "x$ttmapi" = xyes; then
  599. DEFINES="$DEFINES -DTTM_API"
  600. fi
  601. if test "x$USING_EGL" = x1; then
  602. PROGRAM_DIRS="egl"
  603. fi
  604. # Platform specific settings and drivers to build
  605. case "$host_os" in
  606. linux*)
  607. DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER"
  608. DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING -DHAVE_ALIAS"
  609. if test "x$driglx_direct" = xyes; then
  610. DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
  611. fi
  612. case "$host_cpu" in
  613. x86_64)
  614. # ffb, gamma, and sis are missing because they have not be
  615. # converted to use the new interface. i810 are missing
  616. # because there is no x86-64 system where they could *ever*
  617. # be used.
  618. if test "x$DRI_DIRS" = "xyes"; then
  619. DRI_DIRS="i915 i965 mach64 mga r128 r200 r300 radeon \
  620. savage tdfx unichrome swrast"
  621. fi
  622. ;;
  623. powerpc*)
  624. # Build only the drivers for cards that exist on PowerPC.
  625. # At some point MGA will be added, but not yet.
  626. if test "x$DRI_DIRS" = "xyes"; then
  627. DRI_DIRS="mach64 r128 r200 r300 radeon tdfx swrast"
  628. fi
  629. ;;
  630. sparc*)
  631. # Build only the drivers for cards that exist on sparc`
  632. if test "x$DRI_DIRS" = "xyes"; then
  633. DRI_DIRS="mach64 r128 r200 r300 radeon ffb swrast"
  634. fi
  635. ;;
  636. esac
  637. ;;
  638. freebsd* | dragonfly*)
  639. DEFINES="$DEFINES -DPTHREADS -DUSE_EXTERNAL_DXTN_LIB=1"
  640. DEFINES="$DEFINES -DIN_DRI_DRIVER -DHAVE_ALIAS"
  641. DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING"
  642. if test "x$driglx_direct" = xyes; then
  643. DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
  644. fi
  645. if test "x$GXX" = xyes; then
  646. CXXFLAGS="$CXXFLAGS -ansi -pedantic"
  647. fi
  648. # ffb and gamma are missing because they have not been converted
  649. # to use the new interface.
  650. if test "x$DRI_DIRS" = "xyes"; then
  651. DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 radeon tdfx \
  652. unichrome savage sis swrast"
  653. fi
  654. ;;
  655. solaris*)
  656. DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER"
  657. DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING"
  658. if test "x$driglx_direct" = xyes; then
  659. DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
  660. fi
  661. ;;
  662. esac
  663. # default drivers
  664. if test "x$DRI_DIRS" = "xyes"; then
  665. DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 radeon s3v \
  666. savage sis tdfx trident unichrome ffb swrast"
  667. fi
  668. DRI_DIRS=`echo "$DRI_DIRS" | $SED 's/ */ /g'`
  669. # Check for expat
  670. EXPAT_INCLUDES=""
  671. EXPAT_LIB=-lexpat
  672. AC_ARG_WITH([expat],
  673. [AS_HELP_STRING([--with-expat=DIR],
  674. [expat install directory])],[
  675. EXPAT_INCLUDES="-I$withval/include"
  676. CPPFLAGS="$CPPFLAGS $EXPAT_INCLUDES"
  677. LDFLAGS="$LDFLAGS -L$withval/$LIB_DIR"
  678. EXPAT_LIB="-L$withval/$LIB_DIR -lexpat"
  679. ])
  680. AC_CHECK_HEADER([expat.h],[],[AC_MSG_ERROR([Expat required for DRI.])])
  681. AC_CHECK_LIB([expat],[XML_ParserCreate],[],
  682. [AC_MSG_ERROR([Expat required for DRI.])])
  683. # put all the necessary libs together
  684. DRI_LIB_DEPS="$SELINUX_LIBS $LIBDRM_LIBS $EXPAT_LIB -lm -lpthread $DLOPEN_LIBS"
  685. fi
  686. AC_SUBST([DRI_DIRS])
  687. AC_SUBST([EXPAT_INCLUDES])
  688. AC_SUBST([DRI_LIB_DEPS])
  689. dnl
  690. dnl OSMesa configuration
  691. dnl
  692. if test "$mesa_driver" = xlib; then
  693. default_gl_osmesa=yes
  694. else
  695. default_gl_osmesa=no
  696. fi
  697. AC_ARG_ENABLE([gl-osmesa],
  698. [AS_HELP_STRING([--enable-gl-osmesa],
  699. [enable OSMesa on libGL @<:@default=enabled for xlib driver@:>@])],
  700. [gl_osmesa="$enableval"],
  701. [gl_osmesa="$default_gl_osmesa"])
  702. if test "x$gl_osmesa" = xyes; then
  703. if test "$mesa_driver" = osmesa; then
  704. AC_MSG_ERROR([libGL is not available for OSMesa driver])
  705. else
  706. DRIVER_DIRS="$DRIVER_DIRS osmesa"
  707. fi
  708. fi
  709. dnl Configure the channel bits for OSMesa (libOSMesa, libOSMesa16, ...)
  710. AC_ARG_WITH([osmesa-bits],
  711. [AS_HELP_STRING([--with-osmesa-bits=BITS],
  712. [OSMesa channel bits and library name: 8, 16, 32 @<:@default=8@:>@])],
  713. [osmesa_bits="$withval"],
  714. [osmesa_bits=8])
  715. if test "$mesa_driver" != osmesa && test "x$osmesa_bits" != x8; then
  716. AC_MSG_WARN([Ignoring OSMesa channel bits for non-OSMesa driver])
  717. osmesa_bits=8
  718. fi
  719. case "x$osmesa_bits" in
  720. x8)
  721. OSMESA_LIB=OSMesa
  722. ;;
  723. x16|x32)
  724. OSMESA_LIB="OSMesa$osmesa_bits"
  725. DEFINES="$DEFINES -DCHAN_BITS=$osmesa_bits -DDEFAULT_SOFTWARE_DEPTH_BITS=31"
  726. ;;
  727. *)
  728. AC_MSG_ERROR([OSMesa bits '$osmesa_bits' is not a valid option])
  729. ;;
  730. esac
  731. AC_SUBST([OSMESA_LIB])
  732. case "$mesa_driver" in
  733. osmesa)
  734. # only link libraries with osmesa if shared
  735. if test "$enable_static" = no; then
  736. OSMESA_LIB_DEPS="-lm -lpthread $SELINUX_LIBS"
  737. else
  738. OSMESA_LIB_DEPS=""
  739. fi
  740. OSMESA_MESA_DEPS=""
  741. ;;
  742. *)
  743. # Link OSMesa to libGL otherwise
  744. OSMESA_LIB_DEPS=""
  745. # only link libraries with osmesa if shared
  746. if test "$enable_static" = no; then
  747. OSMESA_MESA_DEPS='-l$(GL_LIB)'
  748. else
  749. OSMESA_MESA_DEPS=""
  750. fi
  751. ;;
  752. esac
  753. if test "$enable_static" = no; then
  754. OSMESA_LIB_DEPS="$OSMESA_LIB_DEPS $OS_LIBS"
  755. fi
  756. AC_SUBST([OSMESA_LIB_DEPS])
  757. AC_SUBST([OSMESA_MESA_DEPS])
  758. dnl
  759. dnl GLU configuration
  760. dnl
  761. AC_ARG_ENABLE([glu],
  762. [AS_HELP_STRING([--disable-glu],
  763. [enable OpenGL Utility library @<:@default=enabled@:>@])],
  764. [enable_glu="$enableval"],
  765. [enable_glu=yes])
  766. if test "x$enable_glu" = xyes; then
  767. SRC_DIRS="$SRC_DIRS glu"
  768. case "$mesa_driver" in
  769. osmesa)
  770. # If GLU is available and we have libOSMesa (not 16 or 32),
  771. # we can build the osdemos
  772. if test "$with_demos" = yes && test "$osmesa_bits" = 8; then
  773. PROGRAM_DIRS="$PROGRAM_DIRS osdemos"
  774. fi
  775. # Link libGLU to libOSMesa instead of libGL
  776. GLU_LIB_DEPS=""
  777. if test "$enable_static" = no; then
  778. GLU_MESA_DEPS='-l$(OSMESA_LIB)'
  779. else
  780. GLU_MESA_DEPS=""
  781. fi
  782. ;;
  783. *)
  784. # If static, empty GLU_LIB_DEPS and add libs for programs to link
  785. if test "$enable_static" = no; then
  786. GLU_LIB_DEPS="-lm"
  787. GLU_MESA_DEPS='-l$(GL_LIB)'
  788. else
  789. GLU_LIB_DEPS=""
  790. GLU_MESA_DEPS=""
  791. APP_LIB_DEPS="$APP_LIB_DEPS -lstdc++"
  792. fi
  793. ;;
  794. esac
  795. fi
  796. if test "$enable_static" = no; then
  797. GLU_LIB_DEPS="$GLU_LIB_DEPS $OS_CPLUSPLUS_LIBS"
  798. fi
  799. AC_SUBST([GLU_LIB_DEPS])
  800. AC_SUBST([GLU_MESA_DEPS])
  801. dnl
  802. dnl GLw configuration
  803. dnl
  804. AC_ARG_ENABLE([glw],
  805. [AS_HELP_STRING([--disable-glw],
  806. [enable Xt/Motif widget library @<:@default=enabled@:>@])],
  807. [enable_glw="$enableval"],
  808. [enable_glw=yes])
  809. dnl Don't build GLw on osmesa
  810. if test "x$enable_glw" = xyes && test "$mesa_driver" = osmesa; then
  811. AC_MSG_WARN([Disabling GLw since the driver is OSMesa])
  812. enable_glw=no
  813. fi
  814. AC_ARG_ENABLE([motif],
  815. [AS_HELP_STRING([--enable-motif],
  816. [use Motif widgets in GLw @<:@default=disabled@:>@])],
  817. [enable_motif="$enableval"],
  818. [enable_motif=no])
  819. if test "x$enable_glw" = xyes; then
  820. SRC_DIRS="$SRC_DIRS glw"
  821. if test "$x11_pkgconfig" = yes; then
  822. PKG_CHECK_MODULES([GLW],[x11 xt])
  823. GLW_LIB_DEPS="$GLW_LIBS"
  824. else
  825. # should check these...
  826. GLW_LIB_DEPS="$X_LIBS -lXt -lX11"
  827. fi
  828. GLW_SOURCES="GLwDrawA.c"
  829. MOTIF_CFLAGS=
  830. if test "x$enable_motif" = xyes; then
  831. GLW_SOURCES="$GLW_SOURCES GLwMDrawA.c"
  832. AC_PATH_PROG([MOTIF_CONFIG], [motif-config], [no])
  833. if test "x$MOTIF_CONFIG" != xno; then
  834. MOTIF_CFLAGS=`$MOTIF_CONFIG --cflags`
  835. MOTIF_LIBS=`$MOTIF_CONFIG --libs`
  836. else
  837. AC_CHECK_HEADER([Xm/PrimitiveP.h], [],
  838. [AC_MSG_ERROR([Can't locate Motif headers])])
  839. AC_CHECK_LIB([Xm], [XmGetPixmap], [MOTIF_LIBS="-lXm"],
  840. [AC_MSG_ERROR([Can't locate Motif Xm library])])
  841. fi
  842. # MOTIF_LIBS is prepended to GLW_LIB_DEPS since Xm needs Xt/X11
  843. GLW_LIB_DEPS="$MOTIF_LIBS $GLW_LIB_DEPS"
  844. fi
  845. # If static, empty GLW_LIB_DEPS and add libs for programs to link
  846. if test "$enable_static" = no; then
  847. GLW_MESA_DEPS='-l$(GL_LIB)'
  848. GLW_LIB_DEPS="$GLW_LIB_DEPS $OS_LIBS"
  849. else
  850. APP_LIB_DEPS="$APP_LIB_DEPS $GLW_LIB_DEPS"
  851. GLW_LIB_DEPS=""
  852. GLW_MESA_DEPS=""
  853. fi
  854. fi
  855. AC_SUBST([GLW_LIB_DEPS])
  856. AC_SUBST([GLW_MESA_DEPS])
  857. AC_SUBST([GLW_SOURCES])
  858. AC_SUBST([MOTIF_CFLAGS])
  859. dnl
  860. dnl GLUT configuration
  861. dnl
  862. if test -f "$srcdir/include/GL/glut.h"; then
  863. default_glut=yes
  864. else
  865. default_glut=no
  866. fi
  867. AC_ARG_ENABLE([glut],
  868. [AS_HELP_STRING([--disable-glut],
  869. [enable GLUT library @<:@default=enabled if source available@:>@])],
  870. [enable_glut="$enableval"],
  871. [enable_glut="$default_glut"])
  872. dnl Can't build glut if GLU not available
  873. if test "x$enable_glu$enable_glut" = xnoyes; then
  874. AC_MSG_WARN([Disabling glut since GLU is disabled])
  875. enable_glut=no
  876. fi
  877. dnl Don't build glut on osmesa
  878. if test "x$enable_glut" = xyes && test "$mesa_driver" = osmesa; then
  879. AC_MSG_WARN([Disabling glut since the driver is OSMesa])
  880. enable_glut=no
  881. fi
  882. if test "x$enable_glut" = xyes; then
  883. SRC_DIRS="$SRC_DIRS glut/glx"
  884. GLUT_CFLAGS=""
  885. if test "x$GCC" = xyes; then
  886. GLUT_CFLAGS="-fexceptions"
  887. fi
  888. if test "$x11_pkgconfig" = yes; then
  889. PKG_CHECK_MODULES([GLUT],[x11 xmu xi])
  890. GLUT_LIB_DEPS="$GLUT_LIBS"
  891. else
  892. # should check these...
  893. GLUT_LIB_DEPS="$X_LIBS -lX11 -lXmu -lXi"
  894. fi
  895. GLUT_LIB_DEPS="$GLUT_LIB_DEPS -lm $OS_LIBS"
  896. # If glut is available, we can build most programs
  897. if test "$with_demos" = yes; then
  898. PROGRAM_DIRS="$PROGRAM_DIRS demos redbook samples glsl"
  899. fi
  900. # If static, empty GLUT_LIB_DEPS and add libs for programs to link
  901. if test "$enable_static" = no; then
  902. GLUT_MESA_DEPS='-l$(GLU_LIB) -l$(GL_LIB)'
  903. else
  904. APP_LIB_DEPS="$APP_LIB_DEPS $GLUT_LIB_DEPS"
  905. GLUT_LIB_DEPS=""
  906. GLUT_MESA_DEPS=""
  907. fi
  908. fi
  909. AC_SUBST([GLUT_LIB_DEPS])
  910. AC_SUBST([GLUT_MESA_DEPS])
  911. AC_SUBST([GLUT_CFLAGS])
  912. dnl
  913. dnl Program library dependencies
  914. dnl Only libm is added here if necessary as the libraries should
  915. dnl be pulled in by the linker
  916. dnl
  917. if test "x$APP_LIB_DEPS" = x; then
  918. case "$host_os" in
  919. solaris*)
  920. APP_LIB_DEPS="-lX11 -lsocket -lnsl -lm"
  921. ;;
  922. *)
  923. APP_LIB_DEPS="-lm"
  924. ;;
  925. esac
  926. fi
  927. AC_SUBST([APP_LIB_DEPS])
  928. AC_SUBST([PROGRAM_DIRS])
  929. dnl Restore LDFLAGS and CPPFLAGS
  930. LDFLAGS="$_SAVE_LDFLAGS"
  931. CPPFLAGS="$_SAVE_CPPFLAGS"
  932. dnl Substitute the config
  933. AC_CONFIG_FILES([configs/autoconf])
  934. dnl Replace the configs/current symlink
  935. AC_CONFIG_COMMANDS([configs],[
  936. if test -f configs/current || test -L configs/current; then
  937. rm -f configs/current
  938. fi
  939. ln -s autoconf configs/current
  940. ])
  941. AC_OUTPUT
  942. dnl
  943. dnl Output some configuration info for the user
  944. dnl
  945. echo ""
  946. echo " prefix: $prefix"
  947. echo " exec_prefix: $exec_prefix"
  948. echo " libdir: $libdir"
  949. echo " includedir: $includedir"
  950. dnl Driver info
  951. echo ""
  952. echo " Driver: $mesa_driver"
  953. if echo "$DRIVER_DIRS" | grep 'osmesa' >/dev/null 2>&1; then
  954. echo " OSMesa: lib$OSMESA_LIB"
  955. else
  956. echo " OSMesa: no"
  957. fi
  958. if test "$mesa_driver" = dri; then
  959. # cleanup the drivers var
  960. dri_dirs=`echo $DRI_DIRS | $SED 's/^ *//;s/ */ /;s/ *$//'`
  961. if test "x$DRI_DIRS" = x; then
  962. echo " DRI drivers: no"
  963. else
  964. echo " DRI drivers: $dri_dirs"
  965. fi
  966. echo " DRI driver dir: $DRI_DRIVER_INSTALL_DIR"
  967. echo " TTM API support: $ttmapi"
  968. fi
  969. dnl Libraries
  970. echo ""
  971. echo " Shared libs: $enable_shared"
  972. echo " Static libs: $enable_static"
  973. echo " GLU: $enable_glu"
  974. echo " GLw: $enable_glw (Motif: $enable_motif)"
  975. echo " glut: $enable_glut"
  976. dnl Programs
  977. # cleanup the programs var for display
  978. program_dirs=`echo $PROGRAM_DIRS | $SED 's/^ *//;s/ */ /;s/ *$//'`
  979. if test "x$program_dirs" = x; then
  980. echo " Demos: no"
  981. else
  982. echo " Demos: $program_dirs"
  983. fi
  984. dnl Compiler options
  985. # cleanup the CFLAGS/CXXFLAGS/DEFINES vars
  986. cflags=`echo $CFLAGS $OPT_FLAGS $PIC_FLAGS $ARCH_FLAGS | \
  987. $SED 's/^ *//;s/ */ /;s/ *$//'`
  988. cxxflags=`echo $CXXFLAGS $OPT_FLAGS $PIC_FLAGS $ARCH_FLAGS | \
  989. $SED 's/^ *//;s/ */ /;s/ *$//'`
  990. defines=`echo $DEFINES $ASM_FLAGS | $SED 's/^ *//;s/ */ /;s/ *$//'`
  991. echo ""
  992. echo " CFLAGS: $cflags"
  993. echo " CXXFLAGS: $cxxflags"
  994. echo " Macros: $defines"
  995. echo ""
  996. echo " Run '${MAKE-make}' to build Mesa"
  997. echo ""