Skip to content

Commit

Permalink
Add autotools build.
Browse files Browse the repository at this point in the history
  • Loading branch information
fragglet committed Apr 29, 2011
1 parent afea2d0 commit 782ca55
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 0 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Simon Howard <fraggle@gmail.com>
10 changes: 10 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

AUX_DIST_GEN = $(ac_aux_dir)

EXTRA_DIST = $(AUX_DIST_GEN)
MAINTAINERCLEANFILES = $(AUX_DIST_GEN)

$(pkgconfig_DATA) : config.status

SUBDIRS=lib test

13 changes: 13 additions & 0 deletions autogen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh

mkdir -p autotools

aclocal
libtoolize
autoheader
automake -a
autoconf
automake -a

./configure $@

75 changes: 75 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
AC_INIT(Lhasa, 0.0.1, fraggle@users.sourceforge.net, lhasa)
AC_CONFIG_AUX_DIR(autotools)

AM_INIT_AUTOMAKE($PACKAGE_TARNAME, $PACKAGE_VERSION, no-define)
AM_PROG_CC_C_O

AC_PROG_CXX
AC_PROG_LIBTOOL
AC_PROG_INSTALL
AC_PROG_MAKE_SET

if [[ "$GCC" = "yes" ]]; then
is_gcc=true
else
is_gcc=false
fi

TEST_CFLAGS=""

# Turn on all warnings for gcc. Turn off optimisation for the test build.

if $is_gcc; then
WARNINGS="-Wall -Wsign-compare -Wconversion"
CFLAGS="$CFLAGS $WARNINGS"
TEST_CFLAGS="$TEST_CFLAGS $WARNINGS -O0"
fi

# Support for coverage analysis via gcov:

coverage=no
AC_ARG_ENABLE(coverage,
[ --enable-coverage Enable coverage testing. ],
[ coverage=yes ])

if [[ "$coverage" = "yes" ]]; then
if $is_gcc; then
TEST_CFLAGS="$TEST_CFLAGS -fprofile-arcs -ftest-coverage"
else
AC_MSG_ERROR([Can only enable coverage when using gcc.])
fi
fi

# Support for running test cases using valgrind:

use_valgrind=false
AC_ARG_ENABLE(valgrind,
[ --enable-valgrind Use valgrind when running unit tests. ],
[ use_valgrind=true ])

if [[ "$use_valgrind" = "true" ]]; then
AC_CHECK_PROG(HAVE_VALGRIND, valgrind, yes, no)

if [[ "$HAVE_VALGRIND" = "no" ]]; then
AC_MSG_ERROR([Valgrind not found in PATH. ])
fi
fi

AM_CONDITIONAL(USE_VALGRIND, $use_valgrind)

# Save the default CFLAGS and clear them, so that the test build
# of the library doesn't get the optimisation flags.

MAIN_CFLAGS="$CFLAGS"
CFLAGS=""

AC_SUBST(MAIN_CFLAGS)
AC_SUBST(TEST_CFLAGS)
AC_SUBST(ac_aux_dir)

AC_OUTPUT([
Makefile
lib/Makefile
test/Makefile
])

26 changes: 26 additions & 0 deletions lib/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
lib_LTLIBRARIES=liblhasa.la
check_LIBRARIES=liblhasatest.a

SRC= \
lha_decoder.h \
lha_file_header.h \
lha_input_stream.h \
lha_lzss_decoder.h \
lha_reader.h

HEADER_FILES= \
lha_decoder.c \
lha_file_header.c \
lha_input_stream.c \
lha_lzss_decoder.c \
lha_reader.c

liblhasatest_a_CFLAGS=$(TEST_CFLAGS) -DALLOC_TESTING -I../test -g
liblhasatest_a_SOURCES=$(SRC) $(HEADER_FILES)

liblhasa_la_CFLAGS=$(MAIN_CFLAGS)
liblhasa_la_SOURCES=$(SRC) $(HEADER_FILES)

headerfilesdir=$(includedir)/liblhasa-1.0
headerfiles_HEADERS=$(HEADER_FILES)

11 changes: 11 additions & 0 deletions test/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

AM_CFLAGS=$(TEST_CFLAGS) -I../lib -g
LDADD=$(top_builddir)/lib/liblhasatest.a

TESTS= \
test-larc

EXTRA_DIST=larc_lz4.lzs larc_lz5.lzs

check_PROGRAMS=$(TESTS)

0 comments on commit 782ca55

Please sign in to comment.