acinclude.m4 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851
  1. dnl ---------------------------------------------------------------------------
  2. dnl Message output
  3. dnl ---------------------------------------------------------------------------
  4. AC_DEFUN([LOC_MSG],[echo "$1"])
  5. dnl ---------------------------------------------------------------------------
  6. dnl Available from the GNU Autoconf Macro Archive at:
  7. dnl http://www.gnu.org/software/ac-archive/vl_prog_cc_warnings.html
  8. dnl ---------------------------------------------------------------------------
  9. dnl @synopsis VL_PROG_CC_WARNINGS([ANSI])
  10. dnl
  11. dnl Enables a reasonable set of warnings for the C compiler.
  12. dnl Optionally, if the first argument is nonempty, turns on flags which
  13. dnl enforce and/or enable proper ANSI C if such are known with the
  14. dnl compiler used.
  15. dnl
  16. dnl Currently this macro knows about GCC, Solaris C compiler, Digital
  17. dnl Unix C compiler, C for AIX Compiler, HP-UX C compiler, IRIX C
  18. dnl compiler, NEC SX-5 (Super-UX 10) C compiler, and Cray J90 (Unicos
  19. dnl 10.0.0.8) C compiler.
  20. dnl
  21. dnl @category C
  22. dnl @author Ville Laurikari <vl@iki.fi>
  23. dnl @version 2002-04-04
  24. dnl @license AllPermissive
  25. AC_DEFUN([VL_PROG_CC_WARNINGS], [
  26. ansi=$1
  27. if test -z "$ansi"; then
  28. msg="for C compiler warning flags"
  29. else
  30. msg="for C compiler warning and ANSI conformance flags"
  31. fi
  32. AC_CACHE_CHECK($msg, vl_cv_prog_cc_warnings, [
  33. if test -n "$CC"; then
  34. cat > conftest.c <<EOF
  35. int main(int argc, char **argv) { return 0; }
  36. EOF
  37. dnl GCC. -W option has been renamed in -wextra in latest gcc versions.
  38. if test "$GCC" = "yes"; then
  39. if test -z "$ansi"; then
  40. vl_cv_prog_cc_warnings="-Wall -W"
  41. else
  42. vl_cv_prog_cc_warnings="-Wall -W -ansi -pedantic"
  43. fi
  44. dnl Most compilers print some kind of a version string with some command
  45. dnl line options (often "-V"). The version string should be checked
  46. dnl before doing a test compilation run with compiler-specific flags.
  47. dnl This is because some compilers (like the Cray compiler) only
  48. dnl produce a warning message for unknown flags instead of returning
  49. dnl an error, resulting in a false positive. Also, compilers may do
  50. dnl erratic things when invoked with flags meant for a different
  51. dnl compiler.
  52. dnl Solaris C compiler
  53. elif $CC -V 2>&1 | grep -i "WorkShop" > /dev/null 2>&1 &&
  54. $CC -c -v -Xc conftest.c > /dev/null 2>&1 &&
  55. test -f conftest.o; then
  56. if test -z "$ansi"; then
  57. vl_cv_prog_cc_warnings="-v"
  58. else
  59. vl_cv_prog_cc_warnings="-v -Xc"
  60. fi
  61. dnl Digital Unix C compiler
  62. elif $CC -V 2>&1 | grep -i "Digital UNIX Compiler" > /dev/null 2>&1 &&
  63. $CC -c -verbose -w0 -warnprotos -std1 conftest.c > /dev/null 2>&1 &&
  64. test -f conftest.o; then
  65. if test -z "$ansi"; then
  66. vl_cv_prog_cc_warnings="-verbose -w0 -warnprotos"
  67. else
  68. vl_cv_prog_cc_warnings="-verbose -w0 -warnprotos -std1"
  69. fi
  70. dnl C for AIX Compiler
  71. elif $CC 2>&1 | grep -i "C for AIX Compiler" > /dev/null 2>&1 &&
  72. $CC -c -qlanglvl=ansi -qinfo=all conftest.c > /dev/null 2>&1 &&
  73. test -f conftest.o; then
  74. if test -z "$ansi"; then
  75. vl_cv_prog_cc_warnings="-qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd"
  76. else
  77. vl_cv_prog_cc_warnings="-qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd -qlanglvl=ansi"
  78. fi
  79. dnl IRIX C compiler
  80. elif $CC -version 2>&1 | grep -i "MIPSpro Compilers" > /dev/null 2>&1 &&
  81. $CC -c -fullwarn -ansi -ansiE conftest.c > /dev/null 2>&1 &&
  82. test -f conftest.o; then
  83. if test -z "$ansi"; then
  84. vl_cv_prog_cc_warnings="-fullwarn"
  85. else
  86. vl_cv_prog_cc_warnings="-fullwarn -ansi -ansiE"
  87. fi
  88. dnl HP-UX C compiler
  89. elif what $CC 2>&1 | grep -i "HP C Compiler" > /dev/null 2>&1 &&
  90. $CC -c -Aa +w1 conftest.c > /dev/null 2>&1 &&
  91. test -f conftest.o; then
  92. if test -z "$ansi"; then
  93. vl_cv_prog_cc_warnings="+w1"
  94. else
  95. vl_cv_prog_cc_warnings="+w1 -Aa"
  96. fi
  97. dnl The NEC SX-5 (Super-UX 10) C compiler
  98. elif $CC -V 2>&1 | grep "/SX" > /dev/null 2>&1 &&
  99. $CC -c -pvctl[,]fullmsg -Xc conftest.c > /dev/null 2>&1 &&
  100. test -f conftest.o; then
  101. if test -z "$ansi"; then
  102. vl_cv_prog_cc_warnings="-pvctl[,]fullmsg"
  103. else
  104. vl_cv_prog_cc_warnings="-pvctl[,]fullmsg -Xc"
  105. fi
  106. dnl The Cray C compiler (Unicos)
  107. elif $CC -V 2>&1 | grep -i "Cray" > /dev/null 2>&1 &&
  108. $CC -c -h msglevel 2 conftest.c > /dev/null 2>&1 &&
  109. test -f conftest.o; then
  110. if test -z "$ansi"; then
  111. vl_cv_prog_cc_warnings="-h msglevel 2"
  112. else
  113. vl_cv_prog_cc_warnings="-h msglevel 2 -h conform"
  114. fi
  115. fi
  116. rm -f conftest.*
  117. fi
  118. if test -n "$vl_cv_prog_cc_warnings"; then
  119. CFLAGS="$CFLAGS $vl_cv_prog_cc_warnings"
  120. else
  121. vl_cv_prog_cc_warnings="unknown"
  122. fi
  123. ])
  124. ])dnl
  125. dnl ---------------------------------------------------------------------------
  126. dnl Available from the GNU Autoconf Macro Archive at:
  127. dnl http://autoconf-archive.cryp.to/ax_lang_compiler_ms.html
  128. dnl ---------------------------------------------------------------------------
  129. dnl @synopsis AX_LANG_COMPILER_MS
  130. dnl
  131. dnl Check whether the compiler for the current language is Microsoft.
  132. dnl
  133. dnl This macro is modeled after _AC_LANG_COMPILER_GNU in the GNU
  134. dnl Autoconf implementation.
  135. dnl
  136. dnl @category InstalledPackages
  137. dnl @author Braden McDaniel <braden@endoframe.com>
  138. dnl @version 2004-11-15
  139. dnl @license AllPermissive
  140. AC_DEFUN([AX_LANG_COMPILER_MS],
  141. [AC_CACHE_CHECK([whether we are using the Microsoft _AC_LANG compiler],
  142. [ax_cv_[]_AC_LANG_ABBREV[]_compiler_ms],
  143. [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[#ifndef _MSC_VER
  144. choke me
  145. #endif
  146. ]])],
  147. [ax_compiler_ms=yes],
  148. [ax_compiler_ms=no])
  149. ax_cv_[]_AC_LANG_ABBREV[]_compiler_ms=$ax_compiler_ms
  150. ])])
  151. dnl ---------------------------------------------------------------------------
  152. dnl Available from the GNU Autoconf Macro Archive at:
  153. dnl http://www.gnu.org/software/ac-archive/ax_check_gl.html
  154. dnl ---------------------------------------------------------------------------
  155. dnl SYNOPSIS
  156. dnl
  157. dnl AX_CHECK_GL
  158. dnl
  159. dnl DESCRIPTION
  160. dnl
  161. dnl Check for an OpenGL implementation. If GL is found, the required
  162. dnl compiler and linker flags are included in the output variables
  163. dnl "GL_CFLAGS" and "GL_LIBS", respectively. If no usable GL implementation
  164. dnl is found, "no_gl" is set to "yes".
  165. dnl
  166. dnl If the header "GL/gl.h" is found, "HAVE_GL_GL_H" is defined. If the
  167. dnl header "OpenGL/gl.h" is found, HAVE_OPENGL_GL_H is defined. These
  168. dnl preprocessor definitions may not be mutually exclusive.
  169. dnl
  170. dnl LICENSE
  171. dnl
  172. dnl Copyright (c) 2009 Braden McDaniel <braden@endoframe.com>
  173. dnl
  174. dnl This program is free software; you can redistribute it and/or modify it
  175. dnl under the terms of the GNU General Public License as published by the
  176. dnl Free Software Foundation; either version 2 of the License, or (at your
  177. dnl option) any later version.
  178. dnl
  179. dnl This program is distributed in the hope that it will be useful, but
  180. dnl WITHOUT ANY WARRANTY; without even the implied warranty of
  181. dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
  182. dnl Public License for more details.
  183. dnl
  184. dnl You should have received a copy of the GNU General Public License along
  185. dnl with this program. If not, see <http://www.gnu.org/licenses/>.
  186. dnl
  187. dnl As a special exception, the respective Autoconf Macro's copyright owner
  188. dnl gives unlimited permission to copy, distribute and modify the configure
  189. dnl scripts that are the output of Autoconf when processing the Macro. You
  190. dnl need not follow the terms of the GNU General Public License when using
  191. dnl or distributing such scripts, even though portions of the text of the
  192. dnl Macro appear in them. The GNU General Public License (GPL) does govern
  193. dnl all other use of the material that constitutes the Autoconf Macro.
  194. dnl
  195. dnl This special exception to the GPL applies to versions of the Autoconf
  196. dnl Macro released by the Autoconf Archive. When you make and distribute a
  197. dnl modified version of the Autoconf Macro, you may extend this special
  198. dnl exception to the GPL to apply to your modified version as well.
  199. AC_DEFUN([AX_CHECK_GL],
  200. [AC_REQUIRE([AC_CANONICAL_HOST])
  201. AC_REQUIRE([AC_PATH_X])dnl
  202. AC_REQUIRE([AX_PTHREAD])dnl
  203. AC_LANG_PUSH([C])
  204. AX_LANG_COMPILER_MS
  205. AS_IF([test X$ax_compiler_ms = Xno],
  206. [GL_CFLAGS="${PTHREAD_CFLAGS}"; GL_LIBS="${PTHREAD_LIBS} -lm"])
  207. dnl
  208. dnl Use x_includes and x_libraries if they have been set (presumably by
  209. dnl AC_PATH_X).
  210. dnl
  211. AS_IF([test "X$no_x" != "Xyes"],
  212. [AS_IF([test -n "$x_includes"],
  213. [GL_CFLAGS="-I${x_includes} ${GL_CFLAGS}"])]
  214. AS_IF([test -n "$x_libraries"],
  215. [GL_LIBS="-L${x_libraries} -lX11 ${GL_LIBS}"]))
  216. ax_save_CPPFLAGS="${CPPFLAGS}"
  217. CPPFLAGS="${GL_CFLAGS} ${CPPFLAGS}"
  218. AC_CHECK_HEADERS([GL/gl.h OpenGL/gl.h])
  219. CPPFLAGS="${ax_save_CPPFLAGS}"
  220. AC_CHECK_HEADERS([windows.h])
  221. m4_define([AX_CHECK_GL_PROGRAM],
  222. [AC_LANG_PROGRAM([[
  223. # if defined(HAVE_WINDOWS_H) && defined(_WIN32)
  224. # include <windows.h>
  225. # endif
  226. # ifdef HAVE_GL_GL_H
  227. # include <GL/gl.h>
  228. # elif defined(HAVE_OPENGL_GL_H)
  229. # include <OpenGL/gl.h>
  230. # else
  231. # error no gl.h
  232. # endif]],
  233. [[glBegin(0)]])])
  234. AC_CACHE_CHECK([for OpenGL library], [ax_cv_check_gl_libgl],
  235. [ax_cv_check_gl_libgl="no"
  236. case $host_cpu in
  237. x86_64) ax_check_gl_libdir=lib64 ;;
  238. *) ax_check_gl_libdir=lib ;;
  239. esac
  240. ax_save_CPPFLAGS="${CPPFLAGS}"
  241. CPPFLAGS="${GL_CFLAGS} ${CPPFLAGS}"
  242. ax_save_LIBS="${LIBS}"
  243. LIBS=""
  244. ax_check_libs="-lopengl32 -lGL"
  245. for ax_lib in ${ax_check_libs}; do
  246. AS_IF([test X$ax_compiler_ms = Xyes],
  247. [ax_try_lib=`echo $ax_lib | sed -e 's/^-l//' -e 's/$/.lib/'`],
  248. [ax_try_lib="${ax_lib}"])
  249. LIBS="${ax_try_lib} ${GL_LIBS} ${ax_save_LIBS}"
  250. AC_LINK_IFELSE([AX_CHECK_GL_PROGRAM],
  251. [ax_cv_check_gl_libgl="${ax_try_lib}"; break],
  252. [ax_check_gl_nvidia_flags="-L/usr/${ax_check_gl_libdir}/nvidia" LIBS="${ax_try_lib} ${ax_check_gl_nvidia_flags} ${GL_LIBS} ${ax_save_LIBS}"
  253. AC_LINK_IFELSE([AX_CHECK_GL_PROGRAM],
  254. [ax_cv_check_gl_libgl="${ax_try_lib} ${ax_check_gl_nvidia_flags}"; break],
  255. [ax_check_gl_dylib_flag='-dylib_file /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib' LIBS="${ax_try_lib} ${ax_check_gl_dylib_flag} ${GL_LIBS} ${ax_save_LIBS}"
  256. AC_LINK_IFELSE([AX_CHECK_GL_PROGRAM],
  257. [ax_cv_check_gl_libgl="${ax_try_lib} ${ax_check_gl_dylib_flag}"; break])])])
  258. done
  259. AS_IF([test "X$ax_cv_check_gl_libgl" = Xno -a "X$no_x" = Xyes],
  260. [LIBS='-framework OpenGL'
  261. AC_LINK_IFELSE([AX_CHECK_GL_PROGRAM],
  262. [ax_cv_check_gl_libgl="$LIBS"])])
  263. LIBS=${ax_save_LIBS}
  264. CPPFLAGS=${ax_save_CPPFLAGS}])
  265. AS_IF([test "X$ax_cv_check_gl_libgl" = Xno],
  266. [no_gl=yes; GL_CFLAGS=""; GL_LIBS=""],
  267. [GL_LIBS="${ax_cv_check_gl_libgl} ${GL_LIBS}"])
  268. AC_LANG_POP([C])
  269. AC_SUBST([GL_CFLAGS])
  270. AC_SUBST([GL_LIBS])
  271. ])dnl
  272. dnl ---------------------------------------------------------------------------
  273. dnl Available from the GNU Autoconf Macro Archive at:
  274. dnl http://www.gnu.org/software/ac-archive/ax_check_glu.html
  275. dnl ---------------------------------------------------------------------------
  276. dnl SYNOPSIS
  277. dnl
  278. dnl AX_CHECK_GLU
  279. dnl
  280. dnl DESCRIPTION
  281. dnl
  282. dnl Check for GLU. If GLU is found, the required preprocessor and linker
  283. dnl flags are included in the output variables "GLU_CFLAGS" and "GLU_LIBS",
  284. dnl respectively. If no GLU implementation is found, "no_glu" is set to
  285. dnl "yes".
  286. dnl
  287. dnl If the header "GL/glu.h" is found, "HAVE_GL_GLU_H" is defined. If the
  288. dnl header "OpenGL/glu.h" is found, HAVE_OPENGL_GLU_H is defined. These
  289. dnl preprocessor definitions may not be mutually exclusive.
  290. dnl
  291. dnl Some implementations (in particular, some versions of Mac OS X) are
  292. dnl known to treat the GLU tesselator callback function type as "GLvoid
  293. dnl (*)(...)" rather than the standard "GLvoid (*)()". If the former
  294. dnl condition is detected, this macro defines "HAVE_VARARGS_GLU_TESSCB".
  295. dnl
  296. dnl LICENSE
  297. dnl
  298. dnl Copyright (c) 2009 Braden McDaniel <braden@endoframe.com>
  299. dnl
  300. dnl This program is free software; you can redistribute it and/or modify it
  301. dnl under the terms of the GNU General Public License as published by the
  302. dnl Free Software Foundation; either version 2 of the License, or (at your
  303. dnl option) any later version.
  304. dnl
  305. dnl This program is distributed in the hope that it will be useful, but
  306. dnl WITHOUT ANY WARRANTY; without even the implied warranty of
  307. dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
  308. dnl Public License for more details.
  309. dnl
  310. dnl You should have received a copy of the GNU General Public License along
  311. dnl with this program. If not, see <http://www.gnu.org/licenses/>.
  312. dnl
  313. dnl As a special exception, the respective Autoconf Macro's copyright owner
  314. dnl gives unlimited permission to copy, distribute and modify the configure
  315. dnl scripts that are the output of Autoconf when processing the Macro. You
  316. dnl need not follow the terms of the GNU General Public License when using
  317. dnl or distributing such scripts, even though portions of the text of the
  318. dnl Macro appear in them. The GNU General Public License (GPL) does govern
  319. dnl all other use of the material that constitutes the Autoconf Macro.
  320. dnl
  321. dnl This special exception to the GPL applies to versions of the Autoconf
  322. dnl Macro released by the Autoconf Archive. When you make and distribute a
  323. dnl modified version of the Autoconf Macro, you may extend this special
  324. dnl exception to the GPL to apply to your modified version as well.
  325. AC_DEFUN([AX_CHECK_GLU],
  326. [AC_REQUIRE([AX_CHECK_GL])dnl
  327. AC_REQUIRE([AC_PROG_CXX])dnl
  328. GLU_CFLAGS="${GL_CFLAGS}"
  329. ax_save_CPPFLAGS="${CPPFLAGS}"
  330. CPPFLAGS="${GL_CFLAGS} ${CPPFLAGS}"
  331. AC_CHECK_HEADERS([GL/glu.h OpenGL/glu.h])
  332. CPPFLAGS="${ax_save_CPPFLAGS}"
  333. m4_define([AX_CHECK_GLU_PROGRAM],
  334. [AC_LANG_PROGRAM([[
  335. # if defined(HAVE_WINDOWS_H) && defined(_WIN32)
  336. # include <windows.h>
  337. # endif
  338. # ifdef HAVE_GL_GLU_H
  339. # include <GL/glu.h>
  340. # elif defined(HAVE_OPENGL_GLU_H)
  341. # include <OpenGL/glu.h>
  342. # else
  343. # error no glu.h
  344. # endif]],
  345. [[gluBeginCurve(0)]])])
  346. AC_CACHE_CHECK([for OpenGL Utility library], [ax_cv_check_glu_libglu],
  347. [ax_cv_check_glu_libglu="no"
  348. ax_save_CPPFLAGS="${CPPFLAGS}"
  349. CPPFLAGS="${GL_CFLAGS} ${CPPFLAGS}"
  350. ax_save_LIBS="${LIBS}"
  351. dnl
  352. dnl First, check for the possibility that everything we need is already in
  353. dnl GL_LIBS.
  354. dnl
  355. LIBS="${GL_LIBS} ${ax_save_LIBS}"
  356. dnl
  357. dnl libGLU typically links with libstdc++ on POSIX platforms.
  358. dnl However, setting the language to C++ means that test program
  359. dnl source is named "conftest.cc"; and Microsoft cl doesn't know what
  360. dnl to do with such a file.
  361. dnl
  362. AC_LANG_PUSH([C++])
  363. AS_IF([test X$ax_compiler_ms = Xyes],
  364. [AC_LANG_PUSH([C])])
  365. AC_LINK_IFELSE(
  366. [AX_CHECK_GLU_PROGRAM],
  367. [ax_cv_check_glu_libglu=yes],
  368. [LIBS=""
  369. ax_check_libs="-lglu32 -lGLU"
  370. for ax_lib in ${ax_check_libs}; do
  371. AS_IF([test X$ax_compiler_ms = Xyes],
  372. [ax_try_lib=`echo $ax_lib | sed -e 's/^-l//' -e 's/$/.lib/'`],
  373. [ax_try_lib="${ax_lib}"])
  374. LIBS="${ax_try_lib} ${GL_LIBS} ${ax_save_LIBS}"
  375. AC_LINK_IFELSE([AX_CHECK_GLU_PROGRAM],
  376. [ax_cv_check_glu_libglu="${ax_try_lib}"; break])
  377. done
  378. ])
  379. AS_IF([test X$ax_compiler_ms = Xyes],
  380. [AC_LANG_POP([C])])
  381. AC_LANG_POP([C++])
  382. LIBS=${ax_save_LIBS}
  383. CPPFLAGS=${ax_save_CPPFLAGS}])
  384. AS_IF([test "X$ax_cv_check_glu_libglu" = Xno],
  385. [no_glu=yes; GLU_CFLAGS=""; GLU_LIBS=""],
  386. [AS_IF([test "X$ax_cv_check_glu_libglu" = Xyes],
  387. [GLU_LIBS="$GL_LIBS"],
  388. [GLU_LIBS="${ax_cv_check_glu_libglu} ${GL_LIBS}"])])
  389. AC_SUBST([GLU_CFLAGS])
  390. AC_SUBST([GLU_LIBS])
  391. dnl
  392. dnl Some versions of Mac OS X include a broken interpretation of the GLU
  393. dnl tesselation callback function signature.
  394. dnl
  395. AS_IF([test "X$ax_cv_check_glu_libglu" != Xno],
  396. [AC_CACHE_CHECK([for varargs GLU tesselator callback function type],
  397. [ax_cv_varargs_glu_tesscb],
  398. [ax_cv_varargs_glu_tesscb=no
  399. ax_save_CFLAGS="$CFLAGS"
  400. CFLAGS="$GL_CFLAGS $CFLAGS"
  401. AC_COMPILE_IFELSE(
  402. [AC_LANG_PROGRAM([[
  403. # ifdef HAVE_GL_GLU_H
  404. # include <GL/glu.h>
  405. # else
  406. # include <OpenGL/glu.h>
  407. # endif]],
  408. [[GLvoid (*func)(...); gluTessCallback(0, 0, func)]])],
  409. [ax_cv_varargs_glu_tesscb=yes])
  410. CFLAGS="$ax_save_CFLAGS"])
  411. AS_IF([test X$ax_cv_varargs_glu_tesscb = Xyes],
  412. [AC_DEFINE([HAVE_VARARGS_GLU_TESSCB], [1],
  413. [Use nonstandard varargs form for the GLU tesselator callback])])])
  414. ])
  415. dnl ---------------------------------------------------------------------------
  416. dnl Available from the GNU Autoconf Macro Archive at:
  417. dnl http://www.gnu.org/software/ac-archive/ax_check_glut.html
  418. dnl ---------------------------------------------------------------------------
  419. dnl
  420. dnl SYNOPSIS
  421. dnl
  422. dnl AX_CHECK_GLUT
  423. dnl
  424. dnl DESCRIPTION
  425. dnl
  426. dnl Check for GLUT. If GLUT is found, the required compiler and linker flags
  427. dnl are included in the output variables "GLUT_CFLAGS" and "GLUT_LIBS",
  428. dnl respectively. If GLUT is not found, "no_glut" is set to "yes".
  429. dnl
  430. dnl If the header "GL/glut.h" is found, "HAVE_GL_GLUT_H" is defined. If the
  431. dnl header "GLUT/glut.h" is found, HAVE_GLUT_GLUT_H is defined. These
  432. dnl preprocessor definitions may not be mutually exclusive.
  433. dnl
  434. dnl LICENSE
  435. dnl
  436. dnl Copyright (c) 2009 Braden McDaniel <braden@endoframe.com>
  437. dnl
  438. dnl This program is free software; you can redistribute it and/or modify it
  439. dnl under the terms of the GNU General Public License as published by the
  440. dnl Free Software Foundation; either version 2 of the License, or (at your
  441. dnl option) any later version.
  442. dnl
  443. dnl This program is distributed in the hope that it will be useful, but
  444. dnl WITHOUT ANY WARRANTY; without even the implied warranty of
  445. dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
  446. dnl Public License for more details.
  447. dnl
  448. dnl You should have received a copy of the GNU General Public License along
  449. dnl with this program. If not, see <http://www.gnu.org/licenses/>.
  450. dnl
  451. dnl As a special exception, the respective Autoconf Macro's copyright owner
  452. dnl gives unlimited permission to copy, distribute and modify the configure
  453. dnl scripts that are the output of Autoconf when processing the Macro. You
  454. dnl need not follow the terms of the GNU General Public License when using
  455. dnl or distributing such scripts, even though portions of the text of the
  456. dnl Macro appear in them. The GNU General Public License (GPL) does govern
  457. dnl all other use of the material that constitutes the Autoconf Macro.
  458. dnl
  459. dnl This special exception to the GPL applies to versions of the Autoconf
  460. dnl Macro released by the Autoconf Archive. When you make and distribute a
  461. dnl modified version of the Autoconf Macro, you may extend this special
  462. dnl exception to the GPL to apply to your modified version as well.
  463. AC_DEFUN([AX_CHECK_GLUT],
  464. [AC_REQUIRE([AX_CHECK_GLU])dnl
  465. AC_REQUIRE([AC_PATH_XTRA])dnl
  466. ax_save_CPPFLAGS="${CPPFLAGS}"
  467. CPPFLAGS="${GLU_CFLAGS} ${CPPFLAGS}"
  468. AC_CHECK_HEADERS([GL/glut.h GLUT/glut.h])
  469. CPPFLAGS="${ax_save_CPPFLAGS}"
  470. GLUT_CFLAGS=${GLU_CFLAGS}
  471. GLUT_LIBS=${GLU_LIBS}
  472. m4_define([AX_CHECK_GLUT_PROGRAM],
  473. [AC_LANG_PROGRAM([[
  474. # if HAVE_WINDOWS_H && defined(_WIN32)
  475. # include <windows.h>
  476. # endif
  477. # ifdef HAVE_GL_GLUT_H
  478. # include <GL/glut.h>
  479. # elif defined(HAVE_GLUT_GLUT_H)
  480. # include <GLUT/glut.h>
  481. # else
  482. # error no glut.h
  483. # endif]],
  484. [[glutMainLoop()]])])
  485. dnl
  486. dnl If X is present, assume GLUT depends on it.
  487. dnl
  488. AS_IF([test X$no_x != Xyes],
  489. [GLUT_LIBS="${X_PRE_LIBS} -lXi ${X_EXTRA_LIBS} ${GLUT_LIBS}"])
  490. AC_CACHE_CHECK([for GLUT library], [ax_cv_check_glut_libglut],
  491. [ax_cv_check_glut_libglut="no"
  492. AC_LANG_PUSH(C)
  493. ax_save_CPPFLAGS="${CPPFLAGS}"
  494. CPPFLAGS="${GLUT_CFLAGS} ${CPPFLAGS}"
  495. ax_save_LIBS="${LIBS}"
  496. LIBS=""
  497. ax_check_libs="-lglut32 -lglut"
  498. for ax_lib in ${ax_check_libs}; do
  499. AS_IF([test X$ax_compiler_ms = Xyes],
  500. [ax_try_lib=`echo $ax_lib | sed -e 's/^-l//' -e 's/$/.lib/'`],
  501. [ax_try_lib="${ax_lib}"])
  502. LIBS="${ax_try_lib} ${GLUT_LIBS} ${ax_save_LIBS}"
  503. AC_LINK_IFELSE([AX_CHECK_GLUT_PROGRAM],
  504. [ax_cv_check_glut_libglut="${ax_try_lib}"; break])
  505. done
  506. AS_IF([test "X$ax_cv_check_glut_libglut" = Xno -a "X$no_x" = Xyes],
  507. [LIBS='-framework GLUT'
  508. AC_LINK_IFELSE([AX_CHECK_GLUT_PROGRAM],
  509. [ax_cv_check_glut_libglut="$LIBS"])])
  510. CPPFLAGS="${ax_save_CPPFLAGS}"
  511. LIBS="${ax_save_LIBS}"
  512. AC_LANG_POP(C)])
  513. AS_IF([test "X$ax_cv_check_glut_libglut" = Xno],
  514. [no_glut="yes"; GLUT_CFLAGS=""; GLUT_LIBS=""],
  515. [GLUT_LIBS="${ax_cv_check_glut_libglut} ${GLUT_LIBS}"])
  516. AC_SUBST([GLUT_CFLAGS])
  517. AC_SUBST([GLUT_LIBS])
  518. ])dnl
  519. dnl ---------------------------------------------------------------------------
  520. dnl Available from the GNU Autoconf Macro Archive at:
  521. dnl http://www.gnu.org/software/autoconf-archive/ax_pthread.html
  522. dnl ---------------------------------------------------------------------------
  523. dnl SYNOPSIS
  524. dnl
  525. dnl AX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
  526. dnl
  527. dnl DESCRIPTION
  528. dnl
  529. dnl This macro figures out how to build C programs using POSIX threads. It
  530. dnl sets the PTHREAD_LIBS output variable to the threads library and linker
  531. dnl flags, and the PTHREAD_CFLAGS output variable to any special C compiler
  532. dnl flags that are needed. (The user can also force certain compiler
  533. dnl flags/libs to be tested by setting these environment variables.)
  534. dnl
  535. dnl Also sets PTHREAD_CC to any special C compiler that is needed for
  536. dnl multi-threaded programs (defaults to the value of CC otherwise). (This
  537. dnl is necessary on AIX to use the special cc_r compiler alias.)
  538. dnl
  539. dnl NOTE: You are assumed to not only compile your program with these flags,
  540. dnl but also link it with them as well. e.g. you should link with
  541. dnl $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS
  542. dnl
  543. dnl If you are only building threads programs, you may wish to use these
  544. dnl variables in your default LIBS, CFLAGS, and CC:
  545. dnl
  546. dnl LIBS="$PTHREAD_LIBS $LIBS"
  547. dnl CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
  548. dnl CC="$PTHREAD_CC"
  549. dnl
  550. dnl In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant
  551. dnl has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to that name
  552. dnl (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
  553. dnl
  554. dnl ACTION-IF-FOUND is a list of shell commands to run if a threads library
  555. dnl is found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it
  556. dnl is not found. If ACTION-IF-FOUND is not specified, the default action
  557. dnl will define HAVE_PTHREAD.
  558. dnl
  559. dnl Please let the authors know if this macro fails on any platform, or if
  560. dnl you have any other suggestions or comments. This macro was based on work
  561. dnl by SGJ on autoconf scripts for FFTW (http://www.fftw.org/) (with help
  562. dnl from M. Frigo), as well as ac_pthread and hb_pthread macros posted by
  563. dnl Alejandro Forero Cuervo to the autoconf macro repository. We are also
  564. dnl grateful for the helpful feedback of numerous users.
  565. dnl
  566. dnl LICENSE
  567. dnl
  568. dnl Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
  569. dnl
  570. dnl This program is free software: you can redistribute it and/or modify it
  571. dnl under the terms of the GNU General Public License as published by the
  572. dnl Free Software Foundation, either version 3 of the License, or (at your
  573. dnl option) any later version.
  574. dnl
  575. dnl This program is distributed in the hope that it will be useful, but
  576. dnl WITHOUT ANY WARRANTY; without even the implied warranty of
  577. dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
  578. dnl Public License for more details.
  579. dnl
  580. dnl You should have received a copy of the GNU General Public License along
  581. dnl with this program. If not, see <http://www.gnu.org/licenses/>.
  582. dnl
  583. dnl As a special exception, the respective Autoconf Macro's copyright owner
  584. dnl gives unlimited permission to copy, distribute and modify the configure
  585. dnl scripts that are the output of Autoconf when processing the Macro. You
  586. dnl need not follow the terms of the GNU General Public License when using
  587. dnl or distributing such scripts, even though portions of the text of the
  588. dnl Macro appear in them. The GNU General Public License (GPL) does govern
  589. dnl all other use of the material that constitutes the Autoconf Macro.
  590. dnl
  591. dnl This special exception to the GPL applies to versions of the Autoconf
  592. dnl Macro released by the Autoconf Archive. When you make and distribute a
  593. dnl modified version of the Autoconf Macro, you may extend this special
  594. dnl exception to the GPL to apply to your modified version as well.
  595. AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD])
  596. AC_DEFUN([AX_PTHREAD], [
  597. AC_REQUIRE([AC_CANONICAL_HOST])
  598. AC_LANG_SAVE
  599. AC_LANG_C
  600. ax_pthread_ok=no
  601. dnl We used to check for pthread.h first, but this fails if pthread.h
  602. dnl requires special compiler flags (e.g. on True64 or Sequent).
  603. dnl It gets checked for in the link test anyway.
  604. dnl First of all, check if the user has set any of the PTHREAD_LIBS,
  605. dnl etcetera environment variables, and if threads linking works using
  606. dnl them:
  607. if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
  608. save_CFLAGS="$CFLAGS"
  609. CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
  610. save_LIBS="$LIBS"
  611. LIBS="$PTHREAD_LIBS $LIBS"
  612. AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
  613. AC_TRY_LINK_FUNC(pthread_join, ax_pthread_ok=yes)
  614. AC_MSG_RESULT($ax_pthread_ok)
  615. if test x"$ax_pthread_ok" = xno; then
  616. PTHREAD_LIBS=""
  617. PTHREAD_CFLAGS=""
  618. fi
  619. LIBS="$save_LIBS"
  620. CFLAGS="$save_CFLAGS"
  621. fi
  622. dnl We must check for the threads library under a number of different
  623. dnl names; the ordering is very important because some systems
  624. dnl (e.g. DEC) have both -lpthread and -lpthreads, where one of the
  625. dnl libraries is broken (non-POSIX).
  626. dnl Create a list of thread flags to try. Items starting with a "-" are
  627. dnl C compiler flags, and other items are library names, except for "none"
  628. dnl which indicates that we try without any flags at all, and "pthread-config"
  629. dnl which is a program returning the flags for the Pth emulation library.
  630. ax_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
  631. dnl The ordering *is* (sometimes) important. Some notes on the
  632. dnl individual items follow:
  633. dnl pthreads: AIX (must check this before -lpthread)
  634. dnl none: in case threads are in libc; should be tried before -Kthread and
  635. dnl other compiler flags to prevent continual compiler warnings
  636. dnl -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
  637. dnl -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
  638. dnl lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
  639. dnl -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
  640. dnl -pthreads: Solaris/gcc
  641. dnl -mthreads: Mingw32/gcc, Lynx/gcc
  642. dnl -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
  643. dnl doesn't hurt to check since this sometimes defines pthreads too;
  644. dnl also defines -D_REENTRANT)
  645. dnl ... -mt is also the pthreads flag for HP/aCC
  646. dnl pthread: Linux, etcetera
  647. dnl --thread-safe: KAI C++
  648. dnl pthread-config: use pthread-config program (for GNU Pth library)
  649. case "${host_cpu}-${host_os}" in
  650. *solaris*)
  651. dnl On Solaris (at least, for some versions), libc contains stubbed
  652. dnl (non-functional) versions of the pthreads routines, so link-based
  653. dnl tests will erroneously succeed. (We need to link with -pthreads/-mt/
  654. dnl -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
  655. dnl a function called by this macro, so we could check for that, but
  656. dnl who knows whether they'll stub that too in a future libc.) So,
  657. dnl we'll just look for -pthreads and -lpthread first:
  658. ax_pthread_flags="-pthreads pthread -mt -pthread $ax_pthread_flags"
  659. ;;
  660. *-darwin*)
  661. ax_pthread_flags="-pthread $ax_pthread_flags"
  662. ;;
  663. esac
  664. if test x"$ax_pthread_ok" = xno; then
  665. for flag in $ax_pthread_flags; do
  666. case $flag in
  667. none)
  668. AC_MSG_CHECKING([whether pthreads work without any flags])
  669. ;;
  670. -*)
  671. AC_MSG_CHECKING([whether pthreads work with $flag])
  672. PTHREAD_CFLAGS="$flag"
  673. ;;
  674. pthread-config)
  675. AC_CHECK_PROG(ax_pthread_config, pthread-config, yes, no)
  676. if test x"$ax_pthread_config" = xno; then continue; fi
  677. PTHREAD_CFLAGS="`pthread-config --cflags`"
  678. PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
  679. ;;
  680. *)
  681. AC_MSG_CHECKING([for the pthreads library -l$flag])
  682. PTHREAD_LIBS="-l$flag"
  683. ;;
  684. esac
  685. save_LIBS="$LIBS"
  686. save_CFLAGS="$CFLAGS"
  687. LIBS="$PTHREAD_LIBS $LIBS"
  688. CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
  689. dnl Check for various functions. We must include pthread.h,
  690. dnl since some functions may be macros. (On the Sequent, we
  691. dnl need a special flag -Kthread to make this header compile.)
  692. dnl We check for pthread_join because it is in -lpthread on IRIX
  693. dnl while pthread_create is in libc. We check for pthread_attr_init
  694. dnl due to DEC craziness with -lpthreads. We check for
  695. dnl pthread_cleanup_push because it is one of the few pthread
  696. dnl functions on Solaris that doesn't have a non-functional libc stub.
  697. dnl We try pthread_create on general principles.
  698. AC_TRY_LINK([#include <pthread.h>
  699. static void routine(void* a) {a=0;}
  700. static void* start_routine(void* a) {return a;}],
  701. [pthread_t th; pthread_attr_t attr;
  702. pthread_create(&th,0,start_routine,0);
  703. pthread_join(th, 0);
  704. pthread_attr_init(&attr);
  705. pthread_cleanup_push(routine, 0);
  706. pthread_cleanup_pop(0); ],
  707. [ax_pthread_ok=yes])
  708. LIBS="$save_LIBS"
  709. CFLAGS="$save_CFLAGS"
  710. AC_MSG_RESULT($ax_pthread_ok)
  711. if test "x$ax_pthread_ok" = xyes; then
  712. break;
  713. fi
  714. PTHREAD_LIBS=""
  715. PTHREAD_CFLAGS=""
  716. done
  717. fi
  718. dnl Various other checks:
  719. if test "x$ax_pthread_ok" = xyes; then
  720. save_LIBS="$LIBS"
  721. LIBS="$PTHREAD_LIBS $LIBS"
  722. save_CFLAGS="$CFLAGS"
  723. CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
  724. dnl Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
  725. AC_MSG_CHECKING([for joinable pthread attribute])
  726. attr_name=unknown
  727. for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
  728. AC_TRY_LINK([#include <pthread.h>], [int attr=$attr; return attr;],
  729. [attr_name=$attr; break])
  730. done
  731. AC_MSG_RESULT($attr_name)
  732. if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
  733. AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name,
  734. [Define to necessary symbol if this constant
  735. uses a non-standard name on your system.])
  736. fi
  737. AC_MSG_CHECKING([if more special flags are required for pthreads])
  738. flag=no
  739. case "${host_cpu}-${host_os}" in
  740. *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";;
  741. *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";;
  742. esac
  743. AC_MSG_RESULT(${flag})
  744. if test "x$flag" != xno; then
  745. PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
  746. fi
  747. LIBS="$save_LIBS"
  748. CFLAGS="$save_CFLAGS"
  749. dnl More AIX lossage: must compile with xlc_r or cc_r
  750. if test x"$GCC" != xyes; then
  751. AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC})
  752. else
  753. PTHREAD_CC=$CC
  754. fi
  755. else
  756. PTHREAD_CC="$CC"
  757. fi
  758. AC_SUBST(PTHREAD_LIBS)
  759. AC_SUBST(PTHREAD_CFLAGS)
  760. AC_SUBST(PTHREAD_CC)
  761. dnl Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
  762. if test x"$ax_pthread_ok" = xyes; then
  763. ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1])
  764. :
  765. else
  766. ax_pthread_ok=no
  767. $2
  768. fi
  769. AC_LANG_RESTORE
  770. ])dnl AX_PTHREAD