diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..1cf1f8a --- /dev/null +++ b/Makefile.am @@ -0,0 +1,13 @@ +ACLOCAL_AMFLAGS = -I m4 + +SUBDIRS = src example + +if BUILD_TESTS +SUBDIRS += tests +endif + +pkgincludedir = $(includedir)/cli +pkginclude_HEADERS = \ + include/cli.h \ + include/cli_parse_utils.h \ + include/compiler.h diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 0000000..3eeefb2 --- /dev/null +++ b/autogen.sh @@ -0,0 +1,3 @@ +#!/bin/sh +set -e +autoreconf --install --verbose diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..33deb53 --- /dev/null +++ b/configure.ac @@ -0,0 +1,47 @@ +AC_PREREQ([2.69]) +AC_INIT([libcli], [0.1.0], []) +AC_CONFIG_AUX_DIR([build-aux]) +AC_CONFIG_MACRO_DIRS([m4]) +AM_INIT_AUTOMAKE([foreign -Wall -Werror subdir-objects]) +AC_PROG_CC +AM_PROG_AR + +LT_PREREQ([2.2]) +LT_INIT + +# --enable-tests +AC_ARG_ENABLE([tests], + [AS_HELP_STRING([--enable-tests], [Build Criterion unit tests (default: no)])], + [enable_tests=$enableval], + [enable_tests=no]) + +AM_CONDITIONAL([BUILD_TESTS], [test "x$enable_tests" = "xyes"]) + +AS_IF([test "x$enable_tests" = "xyes"], [ + PKG_CHECK_MODULES([CRITERION], [criterion], [], [ + AC_MSG_NOTICE([pkg-config could not find criterion -- trying manual detection]) + AC_CHECK_HEADER([criterion/criterion.h], [], [ + AC_MSG_ERROR([criterion/criterion.h not found])]) + AC_CHECK_LIB([criterion], [main], + [CRITERION_LIBS="-lcriterion"], + [AC_MSG_ERROR([libcriterion not found])]) + ]) +]) + +AC_CONFIG_FILES([ + Makefile + src/Makefile + tests/Makefile + example/Makefile +]) +AC_OUTPUT + +AC_MSG_NOTICE([ + + libcli $VERSION + --------------- + prefix : $prefix + CC : $CC + CFLAGS : $CFLAGS + tests : $enable_tests +]) diff --git a/example/Makefile.am b/example/Makefile.am new file mode 100644 index 0000000..d5ef278 --- /dev/null +++ b/example/Makefile.am @@ -0,0 +1,6 @@ +noinst_PROGRAMS = greet + +greet_SOURCES = main.c +greet_CPPFLAGS = -I$(top_srcdir)/include +greet_CFLAGS = -std=c99 -Wall -Wextra +greet_LDADD = $(top_builddir)/src/libcli.la diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..5113a05 --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,12 @@ +lib_LTLIBRARIES = libcli.la + +libcli_la_SOURCES = \ + parse.c \ + parse_utils/parse_int.c \ + parse_utils/parse_float.c + +libcli_la_CPPFLAGS = -I$(top_srcdir)/include +libcli_la_CFLAGS = -std=c99 -Wall -Wextra + +# Libtool versioning: current:revision:age +libcli_la_LDFLAGS = -version-info 0:1:0 diff --git a/tests/Makefile.am b/tests/Makefile.am new file mode 100644 index 0000000..bd68604 --- /dev/null +++ b/tests/Makefile.am @@ -0,0 +1,15 @@ +AM_CPPFLAGS = -I$(top_srcdir)/include $(CRITERION_CFLAGS) +AM_CFLAGS = -std=c99 + +check_PROGRAMS = test_cli + +test_cli_SOURCES = \ + test_main.c \ + parse_utils/test_parse_int.c \ + parse_utils/test_parse_float.c + +test_cli_LDADD = \ + $(top_builddir)/src/libcli.la \ + $(CRITERION_LIBS) + +TESTS = test_cli