Permalink
Browse files

Add autotools build.

  • Loading branch information...
1 parent afea2d0 commit 782ca55aee6fa382a82b28e9a3aac59fb8cf6203 @fragglet committed Apr 29, 2011
Showing with 136 additions and 0 deletions.
  1. +1 −0 AUTHORS
  2. +10 −0 Makefile.am
  3. +13 −0 autogen.sh
  4. +75 −0 configure.ac
  5. +26 −0 lib/Makefile.am
  6. +11 −0 test/Makefile.am
View
@@ -0,0 +1 @@
+Simon Howard <fraggle@gmail.com>
View
@@ -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
+
View
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+mkdir -p autotools
+
+aclocal
+libtoolize
+autoheader
+automake -a
+autoconf
+automake -a
+
+./configure $@
+
View
@@ -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
+])
+
View
@@ -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)
+
View
@@ -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.