diff --git a/Makefile.am b/Makefile.am index 798942c..f26a7fe 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,10 +2,19 @@ include $(top_srcdir)/build-aux/glib-tap.mk AM_CFLAGS = # CFLAGS applicable to all executables (products) +# Convenience library so that it can be resued +# between my_executable and the tests +noinst_LIBRARIES = libcommon.a +libcommon_a_SOURCES = src/common.c + +# The main product bin_PROGRAMS = myexecutable # make all will generate ./my_executable myexecutable_SOURCES = \ src/main.c myexecutable_CFLAGS = #--std=c11 # CFLAGS applicable to myexecutable_SOURCES +myexecutable_LDADD = libcommon.a + + # Tests # 'check' comes from 'make check' @@ -19,7 +28,8 @@ testsuite_SOURCES = tests/test.c # CFLAGS and -l options that are retrieved from pkg-config (configure.ac) # DEPS_CFLAGS and DEPS_LIBS are filled by PKG_CHECK_MODULES (configure.ac) +testsuite_CPPFLAGS = -I$(top_srcdir)/src testsuite_CFLAGS = $(GLIB_CFLAGS) # DEPS_* are filled by PKG_CHECK_MODULES -testsuite_LDADD = $(GLIB_LIBS) # in configure.ac +testsuite_LDADD = $(GLIB_LIBS) libcommon.a # in configure.ac diff --git a/configure.ac b/configure.ac index ef5d695..c4c32e3 100644 --- a/configure.ac +++ b/configure.ac @@ -30,6 +30,8 @@ AC_PROG_CC AC_PROG_CC_C99 # or AC_PROG_CC_89 to force C89 mode or AC_PROG_CC_STDC to go to latest supported standard (currently C99) AC_PROG_INSTALL +AC_PROG_CC_C_O # Need to have per product flags myexecutable_CFLAG +AC_PROG_RANLIB # Need for to create libraries: .a # Checks for libraries. diff --git a/src/common.c b/src/common.c new file mode 100644 index 0000000..cc19901 --- /dev/null +++ b/src/common.c @@ -0,0 +1,6 @@ +#include +#include "common.h" +void myfunc() +{ + printf("myfunc() called\n"); +} diff --git a/src/common.h b/src/common.h new file mode 100644 index 0000000..1292508 --- /dev/null +++ b/src/common.h @@ -0,0 +1,5 @@ +#ifndef COMMON_H +#define COMMON_H +void myfunc(); + +#endif /* COMMON_H */ diff --git a/src/main.c b/src/main.c index 8236c9c..581d09b 100644 --- a/src/main.c +++ b/src/main.c @@ -1,7 +1,9 @@ #include +#include "common.h" int main(int argc, char *argv[]) { printf ("Hello world\n"); + myfunc(); return 0; } diff --git a/tests/test.c b/tests/test.c index edda26c..af4ed86 100644 --- a/tests/test.c +++ b/tests/test.c @@ -3,6 +3,8 @@ #include #include +#include "common.h" + typedef struct { int a; /* usually some other data structure that you * need for your tests */ @@ -26,6 +28,7 @@ void my_second_test(dfixture *df, gconstpointer ignored) { } void my_third_test(dfixture *df, gconstpointer ignored) { + myfunc(); g_test_incomplete("incomplete means that there is some functionality missing"); }