[opus] [libopusfile PATCH] build: implement autotools build system for libopusfile. (v2)

Timothy B. Terriberry tterribe at xiph.org
Sat Sep 29 08:59:45 PDT 2012


Timothy B. Terriberry wrote:
> ../configure: line 11818: syntax error near unexpected token `default,'
> ../configure: line 11818: `CC_ATTRIBUTE_VISIBILITY(default,'

So, the problem here was that I was doing an out-of-tree build, so it 
wasn't looking for $top_srcdir/m4, just m4. I've done some more work on 
this patch:
* Fix autogen.sh to allow it to be run out-of-tree.
* Added soname versioning
* Always compile the examples (they have no additional dependencies, and 
they're trivial to compile, so no reason to make people jump through two 
steps... especially since my guess of "make examples" was not the target 
you actually picked for them).
* Silent build rules support.
* Use --enable-assertions instead of --enable-assert. libopus uses the 
former, so we should too, for consistency.
* Don't use lrintf with --enable-fixed, even with the floating-point 
API, as it's only needed if we convert from float->fixed, and in 
fixed-point mode, we only ever convert the other direction.
* Omit the lrintf notice at the end if the current mode doesn't need it.
* Add support for building and installing the Doxygen documentation.

I've attached an interdiff from your patch here, so you can see exactly 
what changed. I'll post a roll-up patch in a moment, and if that looks 
good to you, I can commit it.


diff --git a/Makefile.am b/Makefile.am
index 6c05491..d9f491e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -12,13 +12,40 @@ libopusfile_la_SOURCES = \
  	src/internal.c src/internal.h \
  	src/opusfile.c src/stream.c
  libopusfile_la_LIBADD = $(DEPS_LIBS)
+libopusfile_la_LDFLAGS = -no-undefined \
+ -version-info @OP_LT_CURRENT@:@OP_LT_REVISION@:@OP_LT_AGE@

-EXTRA_PROGRAMS = examples/opusfile_example examples/seeking_example
+noinst_PROGRAMS = examples/opusfile_example examples/seeking_example

  examples_opusfile_example_LDADD = libopusfile.la
  examples_seeking_example_LDADD = libopusfile.la

-example: $(EXTRA_PROGRAMS)
-
  debug:
  	$(MAKE) CFLAGS="${CFLAGS} -O0 -ggdb -DOP_ENABLE_ASSERTIONS" all example
+
+#API Documentation
+
+if HAVE_DOXYGEN
+
+EXTRA_DIST = doc/Doxyfile.in
+
+all-local: doc/doxygen-build.stamp
+
+doc/doxygen-build.stamp: doc/Doxyfile $(top_srcdir)/include/*.h
+	cd doc && doxygen
+	touch "$@"
+
+install-data-local:
+	cd doc && for f in `find html -type f \! -name "installdox"` ; do \
+	  $(INSTALL_DATA) -D $$f $(DESTDIR)$(docdir)/$$f ; \
+	done
+
+clean-local:
+	$(RM) -r doc/html
+	$(RM) -r doc/latex
+	$(RM) doc/doxygen-build.stamp
+
+uninstall-local:
+	$(RM) -r $(DESTDIR)$(docdir)/html
+
+endif
diff --git a/autogen.sh b/autogen.sh
index e31a822..58d140a 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -1,3 +1,16 @@
  #!/bin/sh
+# Run this to set up the build system: configure, makefiles, etc.
+set -e

+package="opusfile"
+
+ACLOCAL_FLAGS="-I m4"
+
+olddir=`pwd`
+srcdir=`dirname $0`
+test -z "$srcdir" && srcdir=.
+
+cd "$srcdir"
+
+echo "Updating build configuration files for $package, please wait...."
  autoreconf -is
diff --git a/configure.ac b/configure.ac
index 3f4e6f4..42d0de5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -6,11 +6,31 @@ AC_SYS_LARGEFILE
  AM_INIT_AUTOMAKE([1.11 foreign dist-bzip2 no-dist-gzip])
  LT_INIT

-AC_ARG_ENABLE([assert],
-  AS_HELP_STRING([--enable-assert], [Enable assertions in code]),,
-  enable_assert=no)
+m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])

-AS_IF([test "x$enable_assert" = "xyes"], [
+AC_CONFIG_MACRO_DIR([m4])
+
+dnl Library versioning for libtool.
+dnl Please update these for releases.
+dnl CURRENT, REVISION, AGE
+dnl - library source changed -> increment REVISION
+dnl - interfaces added/removed/changed -> increment CURRENT, REVISION = 0
+dnl - interfaces added -> increment AGE
+dnl - interfaces removed -> AGE = 0
+
+OP_LT_CURRENT=0
+OP_LT_REVISION=0
+OP_LT_AGE=0
+
+AC_SUBST(OP_LT_CURRENT)
+AC_SUBST(OP_LT_REVISION)
+AC_SUBST(OP_LT_AGE)
+
+AC_ARG_ENABLE([assertions],
+  AS_HELP_STRING([--enable-assertions], [Enable assertions in code]),,
+  enable_assertions=no)
+
+AS_IF([test "x$enable_assertions" = "xyes"], [
    AC_DEFINE([OP_ENABLE_ASSERTIONS], [1], [Enable assertions in code])
  ])

@@ -35,16 +55,19 @@ AC_ARG_ENABLE([float],
  AS_IF([test "x$enable_float" = "xno"],
    [enable_fixed_point=yes
     AC_DEFINE([OP_DISABLE_FLOAT_API], [1], [Disable floating-point API])
-  ],
-  [dnl This only has to be tested for if float API is enabled
+  ]
+)
+
+AS_IF([test "x$enable_fixed_point" = "xyes"],
+  [AC_DEFINE([OP_FIXED_POINT], [1], [Enable fixed-point calculation])],
+  [dnl This only has to be tested for if float->fixed conversions are 
required
     AC_SEARCH_LIBS([lrintf], [m], [
        AC_DEFINE([OP_HAVE_LRINTF], [1], [Enable use of lrintf function])
-  ])
-])
-
-AS_IF([test "x$enable_fixed_point" = "xyes"], [
-  AC_DEFINE([OP_FIXED_POINT], [1], [Enable fixed-point calculation])
-])
+      lrintf_notice="
+  Library for lrintf() ....... : ${ac_cv_search_lrintf}"
+   ])
+  ]
+)

  CC_ATTRIBUTE_VISIBILITY([default], [
    CC_FLAG_VISIBILITY([CFLAGS="${CFLAGS} -fvisibility=hidden"])
@@ -52,15 +75,34 @@ CC_ATTRIBUTE_VISIBILITY([default], [

  CC_CHECK_CFLAGS_APPEND([-std=c89 -pedantic -Wall -Wextra 
-Wno-parentheses -Wno-long-long])

-AC_OUTPUT([Makefile])
+dnl Check for doxygen
+AC_ARG_ENABLE([doc],
+  AS_HELP_STRING([--disable-doc], [Do not build API documentation]),
+  [enable_doc=$enableval], [enable_doc=yes]
+)
+
+if test "x$enable_doc" != "xno"; then
+  AC_CHECK_PROG(HAVE_DOXYGEN, doxygen, true, false)
+  if test "x$HAVE_DOXYGEN" = "xfalse" -a "x$enable_doc" = "xyes" ; then
+    AC_MSG_ERROR([*** Doxygen not found. Cannot build API 
documentation. ***])
+  fi
+else
+  HAVE_DOXYGEN=false
+fi
+AM_CONDITIONAL(HAVE_DOXYGEN,$HAVE_DOXYGEN)
+
+AC_OUTPUT([
+  Makefile
+  doc/Doxyfile
+])

  AC_MSG_NOTICE([
  Summary:

-Assertions ................... : ${enable_assert}
+Assertions ................... : ${enable_assertions}
  HTTP support ................. : ${enable_http}
  Fixed-point .................. : ${enable_fixed_point}
-Floating-point API ........... : ${enable_float}
-  Library for lrintf() ....... : ${ac_cv_search_lrintf}
+Floating-point API ........... : ${enable_float}${lrintf_notice}
  Hidden visibility ............ : ${cc_cv_flag_visibility}
+API documentation ............ : ${enable_doc}
  ])
diff --git a/doc/Doxyfile.in b/doc/Doxyfile.in
index 5f771d0..6f9ef54 100644
--- a/doc/Doxyfile.in
+++ b/doc/Doxyfile.in
@@ -3,10 +3,10 @@
  PROJECT_NAME           = "opusfile"
  PROJECT_NUMBER         =
  PROJECT_BRIEF          = "Stand alone decoder library for .opus files."
-INPUT                  = ../include/opusfile.h
+INPUT                  = @top_srcdir@/include/opusfile.h
  OPTIMIZE_OUTPUT_FOR_C  = YES

-FILE_VERSION_FILTER    = "/bin/sh git-version.sh"
+FILE_VERSION_FILTER    = "/bin/sh @top_srcdir@/doc/git-version.sh"

  QUIET                  = YES
  WARNINGS               = YES


More information about the opus mailing list