Skip to content

Commit

Permalink
build: implement autotools build system for libopusfile. (v4)
Browse files Browse the repository at this point in the history
Includes
- A make debug target that disables optimizations and enables
   assertions,
- Proper ./configure switches for the optional features,
- A configuration summary,
- libtool versioning information,
- Visibility and warning flags,
- API documentation, and
- Support for out-of-tree builds.

Signed-off-by: Diego Elio Pettenò <[email protected]>
  • Loading branch information
Flameeyes authored and Timothy B. Terriberry committed Sep 29, 2012
1 parent 2132235 commit 9391fec
Show file tree
Hide file tree
Showing 6 changed files with 528 additions and 3 deletions.
29 changes: 29 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
*.la
*.lo
*.o
*~
.deps
.dirstamp
.libs
/Makefile
Makefile.in
aclocal.m4
autom4te.cache/
config.guess
config.log
config.status
config.sub
configure
depcomp
examples/opusfile_example
examples/seeking_example
install-sh
libopusfile-*.tar.*
libtool
ltmain.sh
m4/libtool.m4
m4/ltoptions.m4
m4/ltsugar.m4
m4/ltversion.m4
m4/lt~obsolete.m4
missing
51 changes: 51 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
ACLOCAL_AMFLAGS = -I m4

AM_CFLAGS = -I$(top_srcdir)/include $(DEPS_CFLAGS)

dist_doc_DATA = COPYING AUTHORS README.txt

include_HEADERS = include/opusfile.h

lib_LTLIBRARIES = libopusfile.la
libopusfile_la_SOURCES = \
src/http.c src/info.c \
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@

noinst_PROGRAMS = examples/opusfile_example examples/seeking_example

examples_opusfile_example_LDADD = libopusfile.la
examples_seeking_example_LDADD = libopusfile.la

debug:
$(MAKE) CFLAGS="${CFLAGS} -O0 -ggdb -DOP_ENABLE_ASSERTIONS" all

#API Documentation

if HAVE_DOXYGEN

EXTRA_DIST = doc/Doxyfile.in doc/git-version.sh

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
16 changes: 16 additions & 0 deletions autogen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +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
108 changes: 108 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
AC_INIT([libopusfile], [0.0])

AC_USE_SYSTEM_EXTENSIONS
AC_SYS_LARGEFILE

AM_INIT_AUTOMAKE([1.11 foreign])
LT_INIT

m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])

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])
])

AC_ARG_ENABLE([http],
AS_HELP_STRING([--disable-http], [Disable HTTP support]),,
enable_http=yes)

AS_IF([test "x$enable_http" != "xno"],
[openssl="openssl"
AC_DEFINE([OP_ENABLE_HTTP], [1], [Enable HTTP support])
])

PKG_CHECK_MODULES([DEPS], [ogg opus ]${openssl})

AC_ARG_ENABLE([fixed-point],
AS_HELP_STRING([--enable-fixed-point], [Enable fixed-point calculation]),,
enable_fixed_point=no)
AC_ARG_ENABLE([float],
AS_HELP_STRING([--disable-float], [Disable floating-point API]),,
enable_float=yes)

AS_IF([test "x$enable_float" = "xno"],
[enable_fixed_point=yes
AC_DEFINE([OP_DISABLE_FLOAT_API], [1], [Disable floating-point API])
]
)

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])
lrintf_notice="
Library for lrintf() ....... : ${ac_cv_search_lrintf}"
])
]
)

CC_ATTRIBUTE_VISIBILITY([default], [
CC_FLAG_VISIBILITY([CFLAGS="${CFLAGS} -fvisibility=hidden"])
])

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

dnl Check for doxygen
AC_ARG_ENABLE([doc],
AS_HELP_STRING([--disable-doc], [Do not build API documentation]),,
[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_assertions}
HTTP support ................. : ${enable_http}
Fixed-point .................. : ${enable_fixed_point}
Floating-point API ........... : ${enable_float}${lrintf_notice}
Hidden visibility ............ : ${cc_cv_flag_visibility}
API documentation ............ : ${enable_doc}
])
6 changes: 3 additions & 3 deletions doc/Doxyfile → doc/Doxyfile.in
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Process with doxygen to generate API documentation

PROJECT_NAME = "opusfile"
PROJECT_NUMBER =
PROJECT_NUMBER = @VERSION@
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
Expand Down
Loading

0 comments on commit 9391fec

Please sign in to comment.