configure.ac 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532
  1. dnl Process this file with autoconf to produce a configure script
  2. dnl ------------------------------------------------
  3. dnl Initialization and Versioning
  4. dnl ------------------------------------------------
  5. AC_INIT(libtheora,[1.1.1+svn])
  6. AC_CANONICAL_HOST
  7. AC_CANONICAL_TARGET
  8. AM_CONFIG_HEADER([config.h])
  9. AC_CONFIG_SRCDIR([lib/fdct.c])
  10. AM_INIT_AUTOMAKE
  11. AM_MAINTAINER_MODE
  12. m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
  13. dnl Library versioning
  14. dnl CURRENT, REVISION, AGE
  15. dnl - library source changed -> increment REVISION
  16. dnl - interfaces added/removed/changed -> increment CURRENT, REVISION = 0
  17. dnl - interfaces added -> increment AGE
  18. dnl - interfaces removed -> AGE = 0
  19. TH_LIB_CURRENT=3
  20. TH_LIB_REVISION=10
  21. TH_LIB_AGE=3
  22. AC_SUBST(TH_LIB_CURRENT)
  23. AC_SUBST(TH_LIB_REVISION)
  24. AC_SUBST(TH_LIB_AGE)
  25. THDEC_LIB_CURRENT=2
  26. THDEC_LIB_REVISION=4
  27. THDEC_LIB_AGE=1
  28. AC_SUBST(THDEC_LIB_CURRENT)
  29. AC_SUBST(THDEC_LIB_REVISION)
  30. AC_SUBST(THDEC_LIB_AGE)
  31. THENC_LIB_CURRENT=2
  32. THENC_LIB_REVISION=2
  33. THENC_LIB_AGE=1
  34. AC_SUBST(THENC_LIB_CURRENT)
  35. AC_SUBST(THENC_LIB_REVISION)
  36. AC_SUBST(THENC_LIB_AGE)
  37. dnl Extra linker options (for version script)
  38. THEORA_LDFLAGS=""
  39. dnl --------------------------------------------------
  40. dnl Check for programs
  41. dnl --------------------------------------------------
  42. dnl save $CFLAGS since AC_PROG_CC likes to insert "-g -O2"
  43. dnl if $CFLAGS is blank
  44. cflags_save="$CFLAGS"
  45. AC_PROG_CC
  46. AC_PROG_CPP
  47. CFLAGS="$cflags_save"
  48. AM_PROG_CC_C_O
  49. AC_LIBTOOL_WIN32_DLL
  50. AM_PROG_LIBTOOL
  51. dnl Add parameters for aclocal
  52. AC_SUBST(ACLOCAL_AMFLAGS, "-I m4")
  53. dnl Check for doxygen
  54. AC_ARG_ENABLE([doc],
  55. AS_HELP_STRING([--enable-doc], [Build API documentation]),
  56. [ac_enable_doc=$enableval], [ac_enable_doc=auto])
  57. if test "x$ac_enable_doc" != "xno"; then
  58. AC_CHECK_PROG(HAVE_DOXYGEN, doxygen, true, false)
  59. if test "x$HAVE_DOXYGEN" = "xfalse" -a "x$ac_enable_doc" = "xyes"; then
  60. AC_MSG_ERROR([*** API documentation explicitly requested but Doxygen not found])
  61. fi
  62. else
  63. HAVE_DOXYGEN=false
  64. fi
  65. AM_CONDITIONAL(HAVE_DOXYGEN,$HAVE_DOXYGEN)
  66. if test $HAVE_DOXYGEN = "false"; then
  67. AC_MSG_WARN([*** doxygen not found, API documentation will not be built])
  68. fi
  69. dnl Check for tools used to build the format specification
  70. BUILD_SPEC="false"
  71. ac_build_spec=no
  72. AC_ARG_ENABLE(spec,
  73. AS_HELP_STRING([--enable-spec], [(re)build the specification document]),
  74. [
  75. if test "x$enableval" = "xyes"; then
  76. ac_build_spec=$enableval
  77. fi
  78. ], [
  79. ac_build_spec=no
  80. ] )
  81. if test "x$ac_build_spec" = "xyes"; then
  82. AC_CHECK_PROG(HAVE_PDFLATEX, pdflatex, yes)
  83. AC_CHECK_PROG(HAVE_BIBTEX, bibtex, yes)
  84. AC_CHECK_PROG(HAVE_TRANSFIG, fig2dev, yes)
  85. if test -r doc/spec/spec.tex; then
  86. if test "x$HAVE_PDFLATEX" = "xyes"; then
  87. if test "x$HAVE_BIBTEX" = "xyes"; then
  88. if test "x$HAVE_TRANSFIG" = "xyes"; then
  89. tex_pkg_list=`fgrep usepackage doc/spec/spec.tex | grep \{ | grep -v ltablex`
  90. tex_pkg_ok="yes"
  91. for pkg_line in $tex_pkg_list; do
  92. pkg_name=`echo $pkg_line | sed -e 's/.*{\(.*\)}.*/\1/'`
  93. AC_MSG_CHECKING([for Tex package $pkg_name])
  94. cat >conftest.tex <<_ACEOF
  95. \\documentclass{book}
  96. $pkg_line
  97. \\begin{document}
  98. Hello World.
  99. \\end{document}
  100. _ACEOF
  101. if pdflatex -interaction batchmode -halt-on-error conftest < /dev/null > /dev/null 2>&1; then
  102. AC_MSG_RESULT([ok])
  103. else
  104. tex_pkg_ok="no"
  105. AC_MSG_RESULT([no])
  106. fi
  107. done
  108. if test -w conftest.tex; then rm conftest.tex; fi
  109. if test -w conftest.tex; then rm conftest.aux; fi
  110. if test -w conftest.pdf; then rm conftest.pdf; fi
  111. if test "x$tex_pkg_ok" = "xyes"; then
  112. BUILD_SPEC="true"
  113. fi
  114. fi
  115. fi
  116. fi
  117. fi
  118. fi
  119. AM_CONDITIONAL(BUILD_SPEC, $BUILD_SPEC)
  120. if test $BUILD_SPEC = "false"; then
  121. AC_MSG_WARN([*** Format Specification will not built.])
  122. fi
  123. dnl Check for valgrind
  124. VALGRIND_ENVIRONMENT=""
  125. ac_enable_valgrind=no
  126. AC_ARG_ENABLE(valgrind-testing,
  127. AS_HELP_STRING([--enable-valgrind-testing], [Enable running of tests inside Valgrind]),
  128. [ ac_enable_valgrind=$enableval ], [ ac_enable_valgrind=no] )
  129. if test "x${ac_enable_valgrind}" = xyes ; then
  130. if test "x${enable_shared}" = xyes ; then
  131. VALGRIND_ENVIRONMENT="libtool --mode=execute "
  132. fi
  133. AC_CHECK_PROG(HAVE_VALGRIND, valgrind, yes, no)
  134. if test "x$HAVE_VALGRIND" = xyes ; then
  135. VALGRIND_ENVIRONMENT="$VALGRIND_ENVIRONMENT valgrind -q --leak-check=yes --show-reachable=yes --num-callers=100"
  136. AC_SUBST(VALGRIND_ENVIRONMENT)
  137. TESTS_INFO="Type 'make check' to run test suite. Tests will be run under:
  138. ${VALGRIND_ENVIRONMENT}"
  139. else
  140. TESTS_INFO="Type 'make check' to run test suite (Valgrind not found)"
  141. fi
  142. else
  143. TESTS_INFO="Type 'make check' to run test suite (Valgrind testing not enabled)"
  144. fi
  145. dnl --------------------------------------------------
  146. dnl Set build flags based on environment
  147. dnl --------------------------------------------------
  148. dnl Set some target options
  149. cflags_save="$CFLAGS"
  150. if test -z "$GCC"; then
  151. case $host in
  152. *)
  153. DEBUG="-g -DDEBUG"
  154. CFLAGS="-O"
  155. PROFILE="-g -p -DDEBUG" ;;
  156. esac
  157. else
  158. case $host in
  159. *)
  160. DEBUG="-g -Wall -Wno-parentheses -DDEBUG -D__NO_MATH_INLINES"
  161. CFLAGS="-Wall -Wno-parentheses -O3 -fforce-addr -fomit-frame-pointer -finline-functions -funroll-loops"
  162. PROFILE="-Wall -Wno-parentheses -pg -g -O3 -fno-inline-functions -DDEBUG";;
  163. esac
  164. fi
  165. CFLAGS="$CFLAGS $cflags_save"
  166. cpu_x86_64=no
  167. cpu_x86_32=no
  168. AC_ARG_ENABLE(asm,
  169. AS_HELP_STRING([--disable-asm], [Disable assembly optimizations]),
  170. [ ac_enable_asm=$enableval ], [ ac_enable_asm=yes] )
  171. if test "x${ac_enable_asm}" = xyes; then
  172. cpu_optimization="no optimization for your platform, please send a patch"
  173. case $target_cpu in
  174. i[[3456]]86)
  175. cpu_x86_32=yes
  176. cpu_optimization="32 bit x86"
  177. AC_DEFINE([OC_X86_ASM], [], [make use of x86 asm optimization])
  178. if test "x$target_vendor" = "xapple"; then
  179. THEORA_LDFLAGS="$THEORA_LDFLAGS -Wl,-read_only_relocs,suppress"
  180. fi
  181. ;;
  182. x86_64)
  183. cpu_x86_64=yes
  184. cpu_optimization="64 bit x86"
  185. AC_DEFINE([OC_X86_ASM], [], [make use of x86 asm optimization])
  186. AC_DEFINE([OC_X86_64_ASM], [], [make use of x86_64 asm optimization])
  187. ;;
  188. esac
  189. else
  190. cpu_optimization="disabled"
  191. fi
  192. AM_CONDITIONAL([CPU_x86_64], [test x$cpu_x86_64 = xyes])
  193. AM_CONDITIONAL([CPU_x86_32], [test x$cpu_x86_32 = xyes])
  194. # Test whenever ld supports -version-script
  195. AC_PROG_LD
  196. AC_PROG_LD_GNU
  197. AC_MSG_CHECKING([how to control symbol export])
  198. THDEC_VERSION_ARG=""
  199. THENC_VERSION_ARG=""
  200. TH_VERSION_ARG=""
  201. if test "x$lt_cv_prog_gnu_ld" = "xyes"; then
  202. case "$target_os" in
  203. *mingw*)
  204. THEORA_LDFLAGS="$THEORA_LDFLAGS -no-undefined"
  205. THDEC_VERSION_ARG="-export-symbols \$(top_srcdir)/win32/xmingw32/libtheoradec-all.def"
  206. THENC_VERSION_ARG="-export-symbols \$(top_srcdir)/win32/xmingw32/libtheoraenc-all.def"
  207. THENC_VERSION_ARG="$THENC_VERSION_ARG -ltheoradec"
  208. THC_VERSION_ARG="-export-symbols \$(top_srcdir)/win32/libtheora.def"
  209. AC_MSG_RESULT([-export-symbols])
  210. ;;
  211. linux* | solaris* | gnu* | k*bsd*-gnu)
  212. THDEC_VERSION_ARG='-Wl,--version-script=$(srcdir)/Version_script-dec'
  213. THENC_VERSION_ARG='-Wl,--version-script=$(srcdir)/Version_script-enc'
  214. TH_VERSION_ARG='-Wl,--version-script=$(srcdir)/Version_script'
  215. AC_MSG_RESULT([--version-script])
  216. ;;
  217. *)
  218. # build without versioning
  219. AC_MSG_RESULT([no])
  220. ;;
  221. esac
  222. else
  223. case "$target_os" in
  224. darwin*)
  225. THDEC_VERSION_ARG='-Wl,-exported_symbols_list,$(srcdir)/theoradec.exp'
  226. THENC_VERSION_ARG='-Wl,-exported_symbols_list,$(srcdir)/theoraenc.exp'
  227. TH_VERSION_ARG='-Wl,-exported_symbols_list,$(srcdir)/theora.exp'
  228. AC_MSG_RESULT([-exported_symbols_list])
  229. ;;
  230. *)
  231. # build without versioning
  232. AC_MSG_RESULT([no])
  233. ;;
  234. esac
  235. fi
  236. THEORADEC_LDFLAGS="$THEORA_LDFLAGS $THDEC_VERSION_ARG"
  237. THEORAENC_LDFLAGS="$THEORA_LDFLAGS $THENC_VERSION_ARG"
  238. THEORA_LDFLAGS="$THEORA_LDFLAGS $TH_VERSION_ARG"
  239. AC_SUBST(THEORADEC_LDFLAGS)
  240. AC_SUBST(THEORAENC_LDFLAGS)
  241. AC_SUBST(THEORA_LDFLAGS)
  242. dnl --------------------------------------------------
  243. dnl Checks for support libraries and headers
  244. dnl --------------------------------------------------
  245. dnl check for Ogg
  246. HAVE_OGG=no
  247. dnl first check through pkg-config since it's more flexible
  248. dnl check for pkg-config itself so we don't try the m4 macro without pkg-config
  249. AC_CHECK_PROG(HAVE_PKG_CONFIG, pkg-config, yes)
  250. if test "x$HAVE_PKG_CONFIG" = "xyes"
  251. then
  252. PKG_CHECK_MODULES(OGG, ogg >= 1.1, HAVE_OGG=yes, HAVE_OGG=no)
  253. fi
  254. if test "x$HAVE_OGG" = "xno"
  255. then
  256. dnl fall back to the old school test
  257. XIPH_PATH_OGG(, AC_MSG_ERROR([
  258. libogg is required to build this package!
  259. please see http://www.xiph.org/ for how to
  260. obtain a copy.
  261. ]))
  262. cflags_save=$CFLAGS
  263. libs_save=$LIBS
  264. CFLAGS="$CFLAGS $OGG_CFLAGS"
  265. LIBS="$LIBS $OGG_LIBS"
  266. AC_CHECK_FUNC(oggpackB_read, , [
  267. AC_MSG_ERROR([newer libogg version (1.1 or later) required])
  268. ])
  269. CFLAGS=$cflags_save
  270. LIBS=$libs_save
  271. fi
  272. dnl check for Vorbis
  273. HAVE_VORBIS=no
  274. dnl first check through pkg-config since it's more flexible
  275. if test "x$HAVE_PKG_CONFIG" = "xyes"
  276. then
  277. PKG_CHECK_MODULES(VORBIS, vorbis >= 1.0.1, HAVE_VORBIS=yes, HAVE_VORBIS=no)
  278. dnl also set VORBISENC_LIBS since an examples needs it
  279. dnl the old .m4 sets this to a value to use on top of VORBIS_LIBS,
  280. dnl so we do the same here.
  281. VORBISENC_LIBS="-lvorbisenc"
  282. AC_SUBST(VORBISENC_LIBS)
  283. fi
  284. if test "x$HAVE_VORBIS" = "xno"
  285. then
  286. dnl fall back to the old school test
  287. XIPH_PATH_VORBIS(HAVE_VORBIS=yes, HAVE_VORBIS=no)
  288. fi
  289. dnl check for SDL
  290. HAVE_SDL=no
  291. AM_PATH_SDL(,[
  292. HAVE_SDL=yes
  293. SDL_LIBS=`$SDL_CONFIG --libs`
  294. ],AC_MSG_WARN([*** Unable to find SDL -- Not compiling example players ***]))
  295. dnl check for OSS
  296. HAVE_OSS=no
  297. AC_CHECK_HEADERS([sys/soundcard.h soundcard.h machine/soundcard.h],[
  298. HAVE_OSS=yes
  299. break
  300. ])
  301. if test x$HAVE_OSS != xyes; then
  302. AC_MSG_WARN([OSS audio support not found -- not compiling player_example])
  303. fi
  304. dnl OpenBSD needs -lossaudio to use the oss interface
  305. OSS_LIBS=
  306. case "$target_os" in
  307. openbsd*)
  308. OSS_LIBS='-lossaudio'
  309. ;;
  310. esac
  311. AC_SUBST(OSS_LIBS)
  312. dnl check for libpng
  313. HAVE_PNG=no
  314. if test "x$HAVE_PKG_CONFIG" = "xyes"
  315. then
  316. PKG_CHECK_MODULES(PNG, libpng, HAVE_PNG=yes, HAVE_PNG=no)
  317. fi
  318. AC_SUBST(PNG_CFLAGS)
  319. AC_SUBST(PNG_LIBS)
  320. dnl check for libcairo
  321. HAVE_CAIRO=no
  322. AC_ARG_ENABLE(telemetry,
  323. AS_HELP_STRING([--enable-telemetry], [Enable debugging output controls]),
  324. [ ac_enable_telemetry=$enableval ], [ ac_enable_telemetry=no] )
  325. if test "x${ac_enable_telemetry}" = xyes; then
  326. if test "x$HAVE_PKG_CONFIG" = "xyes"
  327. then
  328. PKG_CHECK_MODULES(CAIRO, cairo, HAVE_CAIRO=yes, HAVE_CAIRO=no)
  329. AC_DEFINE([HAVE_CAIRO], [], [libcairo is available for visual debugging output])
  330. fi
  331. if test x$HAVE_CAIRO != xyes; then
  332. AC_MSG_WARN([libcairo not found -- not compiling telemetry output support ])
  333. fi
  334. AC_SUBST(CAIRO_CFLAGS)
  335. AC_SUBST(CAIRO_LIBS)
  336. fi
  337. dnl --------------------------------------------------
  338. dnl Overall build configuration options
  339. dnl --------------------------------------------------
  340. dnl Configuration option for building of floating point code.
  341. ac_enable_float=yes
  342. AC_ARG_ENABLE(float,
  343. AS_HELP_STRING([--disable-float], [Disable use of floating point code]),
  344. [ ac_enable_float=$enableval ], [ ac_enable_float=yes] )
  345. if test "x${ac_enable_float}" != xyes ; then
  346. AC_DEFINE([THEORA_DISABLE_FLOAT], [],
  347. [Define to exclude floating point code from the build])
  348. fi
  349. AM_CONDITIONAL(THEORA_DISABLE_FLOAT, [test "x${ac_enable_float}" != xyes])
  350. dnl Configuration option for building of encoding support.
  351. ac_enable_encode=yes
  352. AC_ARG_ENABLE(encode,
  353. AS_HELP_STRING([--disable-encode], [Disable encoding support]),
  354. [ ac_enable_encode=$enableval ], [ ac_enable_encode=yes] )
  355. if test "x${ac_enable_encode}" != xyes ; then
  356. AC_DEFINE([THEORA_DISABLE_ENCODE], [],
  357. [Define to exclude encode support from the build])
  358. else
  359. if test x$HAVE_VORBIS = xyes; then
  360. BUILDABLE_EXAMPLES="$BUILDABLE_EXAMPLES encoder_example\$(EXEEXT)"
  361. else
  362. AC_MSG_NOTICE([Vorbis missing, cannot build example encoder])
  363. fi
  364. fi
  365. AM_CONDITIONAL(THEORA_DISABLE_ENCODE, [test "x${ac_enable_encode}" != xyes])
  366. dnl Configuration option for examples
  367. ac_enable_examples=yes
  368. AC_ARG_ENABLE(examples,
  369. AS_HELP_STRING([--disable-examples], [Disable examples]),
  370. [ ac_enable_examples=$enableval ], [ ac_enable_examples=yes] )
  371. AM_CONDITIONAL(THEORA_ENABLE_EXAMPLES, [test "x${ac_enable_examples}" != xno])
  372. dnl --------------------------------------------------
  373. dnl Check for headers
  374. dnl --------------------------------------------------
  375. dnl none here
  376. dnl --------------------------------------------------
  377. dnl Check for typedefs, structures, etc
  378. dnl --------------------------------------------------
  379. dnl none
  380. dnl --------------------------------------------------
  381. dnl Check for library functions
  382. dnl --------------------------------------------------
  383. dnl OpenBSD needs -lcompat for ftime() used by dump_video.c
  384. AC_SEARCH_LIBS([ftime], [compat])
  385. dnl substitute the included getopt if the system doesn't support long options
  386. AC_CHECK_FUNC(getopt_long,
  387. [GETOPT_OBJS=''],
  388. [GETOPT_OBJS='getopt.$(OBJEXT) getopt1.$(OBJEXT)'])
  389. AC_SUBST(GETOPT_OBJS)
  390. if test x$HAVE_SDL = xyes -a x$HAVE_OSS = xyes -a x$HAVE_VORBIS = xyes; then
  391. BUILDABLE_EXAMPLES="$BUILDABLE_EXAMPLES player_example\$(EXEEXT)"
  392. fi
  393. if test x$HAVE_PNG = xyes; then
  394. BUILDABLE_EXAMPLES="$BUILDABLE_EXAMPLES png2theora\$(EXEEXT)"
  395. fi
  396. AC_SUBST(BUILDABLE_EXAMPLES)
  397. dnl --------------------------------------------------
  398. dnl Do substitutions
  399. dnl --------------------------------------------------
  400. AC_SUBST(DEBUG)
  401. AC_SUBST(PROFILE)
  402. AC_OUTPUT([
  403. Makefile
  404. lib/Makefile
  405. include/Makefile include/theora/Makefile
  406. examples/Makefile
  407. doc/Makefile doc/Doxyfile doc/spec/Makefile
  408. tests/Makefile
  409. m4/Makefile
  410. libtheora.spec
  411. theora.pc
  412. theora-uninstalled.pc
  413. theoradec.pc
  414. theoradec-uninstalled.pc
  415. theoraenc.pc
  416. theoraenc-uninstalled.pc
  417. ])
  418. AS_AC_EXPAND(LIBDIR, ${libdir})
  419. AS_AC_EXPAND(INCLUDEDIR, ${includedir})
  420. AS_AC_EXPAND(BINDIR, ${bindir})
  421. AS_AC_EXPAND(DOCDIR, ${docdir})
  422. if test $HAVE_DOXYGEN = "false"; then
  423. doc_build="no"
  424. else
  425. doc_build="yes"
  426. fi
  427. if test $BUILD_SPEC = "false"; then
  428. spec_build="no"
  429. else
  430. spec_build="yes"
  431. fi
  432. AC_MSG_RESULT([
  433. ------------------------------------------------------------------------
  434. $PACKAGE $VERSION: Automatic configuration OK.
  435. General configuration:
  436. Encoding support: ........... ${ac_enable_encode}
  437. Floating point support: ..... ${ac_enable_float}
  438. Assembly optimization: ...... ${cpu_optimization}
  439. Debugging telemetry: ........ ${ac_enable_telemetry}
  440. Build example code: ......... ${ac_enable_examples}
  441. API Documentation: .......... ${doc_build}
  442. Format Documentation: ....... ${spec_build}
  443. Installation paths:
  444. libtheora: ................... ${LIBDIR}
  445. C header files: .............. ${INCLUDEDIR}/theora
  446. Documentation: ............... ${DOCDIR}
  447. Building:
  448. Type 'make' to compile $PACKAGE.
  449. Type 'make install' to install $PACKAGE.
  450. ${TESTS_INFO}
  451. Example programs will be built but not installed.
  452. ------------------------------------------------------------------------
  453. ])