I want to include cpputest in my project's source tree as a git submodule, but I am not terribly familiar with autotools.
I have been looking at this page as a guide
I've created the following Makefile, cpputest is in a sub-directory beneath it:
CPPUTEST_BUILD_DIR := cpputest/cpputest_build
CPPUTEST_LIBS := \
$(CPPUTEST_BUILD_DIR)/libCppUTest.a \
$(CPPUTEST_BUILD_DIR)/libCppUTestExt.a
CPPUTEST_TESTS := \
$(CPPUTEST_BUILD_DIR)/CppUTestTests \
$(CPPUTEST_BUILD_DIR)/CppUTestExtTests
cpputest: \
cpputest/configure \
$(CPPUTEST_BUILD_DIR)/Makefile \
$(CPPUTEST_LIBS) \
$(CPPUTEST_TESTS)
cpputest/configure: cpputest/configure.ac cpputest/autogen.sh
cd cpputest && ./autogen.sh
cpputest/cpputest_build/Makefile: cpputest/configure
cd $(CPPUTEST_BUILD_DIR) && ../configure
$(CPPUTEST_LIBS): $(CPPUTEST_BUILD_DIR)/Makefile
cd $(CPPUTEST_BUILD_DIR) && make
$(CPPUTEST_TESTS): $(CPPUTEST_LIBS)
cd $(CPPUTEST_BUILD_DIR) && make tdd
Running this makefile does what I want but I am not sure how robust the dependencies are. Is there anything else I should consider adding to this, besides a clean rule?
Here is my final Makefile after John Bollinger's answer.
It is located in the root of the CppUTest directory.
# This makefile will generate a platform specific makefile, build CppUTest
# library outputs, and build and run tests on CppUTest.
BUILD_DIR := cpputest_build
LIBS := $(BUILD_DIR)/lib/libCppUTest.a $(BUILD_DIR)/lib/libCppUTestExt.a
TESTS := $(BUILD_DIR)/CppUTestTests $(BUILD_DIR)/CppUTestExtTests
# All builds both libraries, to build and run all of the tests for CppUTest use
# the phony target run_tests.
all: $(LIBS)
.PHONY: all run_tests clean FORCE
# The Makefile rule depends on the "configure" shell script existing. If
# CppUTest is updated from upstream or configure doesn't exist then run
# autogen.sh or uncomment the rule below. All of the outputs autogen.sh should
# be tracked in the develop branch.
#
#configure: configure.ac autogen.sh
# ./autogen.sh
$(BUILD_DIR)/Makefile: configure
mkdir -p $(BUILD_DIR) && cd $(BUILD_DIR) && ../configure
$(LIBS) : $(BUILD_DIR)/Makefile FORCE
cd $(BUILD_DIR) && make $(subst $(BUILD_DIR)/,,$@)
$(TESTS) : $(BUILD_DIR)/Makefile FORCE
cd $(BUILD_DIR) && make $(@F)
run_tests: $(TESTS)
for test in $(TESTS); do $$test -c || exit 1; done
clean:
rm -rf $(BUILD_DIR)