From 782ca55aee6fa382a82b28e9a3aac59fb8cf6203 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Fri, 29 Apr 2011 22:09:34 +0100 Subject: [PATCH] Add autotools build. --- AUTHORS | 1 + Makefile.am | 10 +++++++ autogen.sh | 13 +++++++++ configure.ac | 75 ++++++++++++++++++++++++++++++++++++++++++++++++ lib/Makefile.am | 26 +++++++++++++++++ test/Makefile.am | 11 +++++++ 6 files changed, 136 insertions(+) create mode 100644 AUTHORS create mode 100644 Makefile.am create mode 100755 autogen.sh create mode 100644 configure.ac create mode 100644 lib/Makefile.am create mode 100644 test/Makefile.am diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..ed0ab08 --- /dev/null +++ b/AUTHORS @@ -0,0 +1 @@ +Simon Howard diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..e301e9b --- /dev/null +++ b/Makefile.am @@ -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 + diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 0000000..a0c35a6 --- /dev/null +++ b/autogen.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +mkdir -p autotools + +aclocal +libtoolize +autoheader +automake -a +autoconf +automake -a + +./configure $@ + diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..f3c328b --- /dev/null +++ b/configure.ac @@ -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 +]) + diff --git a/lib/Makefile.am b/lib/Makefile.am new file mode 100644 index 0000000..fc4eaee --- /dev/null +++ b/lib/Makefile.am @@ -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) + diff --git a/test/Makefile.am b/test/Makefile.am new file mode 100644 index 0000000..0defc0d --- /dev/null +++ b/test/Makefile.am @@ -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) +