It's very simple to acomplish with autotools. In configure.ac you check for existance of Check unit testing framework on the target system:
PKG_CHECK_MODULES([CHECK],[check >= 0.8.2],[have_check="yes"],
AC_MSG_WARN(['Check' unit testing framework not found. It would be impossible to run unit tests!"])
[have_check="no"])
In Makefile.am you specify what files and how to compile to build unit tests:
if HAVE_CHECK
check_PROGRAMS = bin/some_unit_tests
bin_some_unit_tests_SOURCES = source1.c source2.c ...
bin_some_unit_tests_CFLAGS = -g -pg -O2 -fprofile-arcs -ftest-coverage ...
bin_some_unit_tests_LDFLAGS = -g -pg -no-install
bin_some_unit_tests_LDADD = @CHECK_LIBS@
TESTS = bin/some_unit_tests
TESTS_ENVIRONMENT = CK_FORK=yes
CK_VERBOSITY = verbose
CLEANFILES = some_unit_tests.log
endif
Then you run unit test by issuing the command:
make check
By using -pg flag you would be able to obtain profiling information from executing unit tests.