diff --git a/testing/Makefile b/testing/Makefile index 79d45ab4..a7276e52 100644 --- a/testing/Makefile +++ b/testing/Makefile @@ -1,25 +1,26 @@ -LIB_DIR?=${PWD}/lib -TEST_DIRS=$(dir $(wildcard */*_test.cpp)) +COMMON_LIB_DIR?=${PWD}/lib +TEST_DIRS=$(shell dirname $(wildcard */Makefile)) -Makefile: build-libs ${TEST_DIRS} - @: - -build-libs: googletest common - @: +Makefile: ${TEST_DIRS} FORCE + @echo TEST_DIRS="${TEST_DIRS}" googletest: FORCE cd googletest && $(MAKE) common: FORCE - cd common && env LIB_DIR="${LIB_DIR}" $(MAKE) + cd common && env COMMON_LIB_DIR="${COMMON_LIB_DIR}" $(MAKE) -clean: FORCE - rm -rf "${LIB_DIR}" +clean: + rm -rf "${COMMON_LIB_DIR}" + cd googletest && make clean cd common && make clean cd hello-simulator && make clean cd kaleidoscope && make clean -%: common googltest FORCE - if [ -f "$@/Makefile" ]; then cd "$@"; $(MAKE); fi +hello-simulator: + @: + +%: common googletest FORCE + cd "$@" && $(MAKE) .PHONY: FORCE googletest build-libs diff --git a/testing/common/Makefile b/testing/common/Makefile index 9a70e991..bd24989b 100644 --- a/testing/common/Makefile +++ b/testing/common/Makefile @@ -1,17 +1,16 @@ -LIB_DIR ?= ${PWD}/lib +COMMON_LIB_DIR ?= ${PWD}/lib OBJ_DIR ?= ${PWD}/obj - CXX_FILES=$(wildcard *.cpp) LIB_FILE=libcommon.a OBJ_FILES=$(patsubst %.cpp,${OBJ_DIR}/%.o,$(CXX_FILES)) -Makefile: ${OBJ_FILES} ${LIB_DIR}/${LIB_FILE} +Makefile: ${OBJ_FILES} ${COMMON_LIB_DIR}/${LIB_FILE} @: -${LIB_DIR}/${LIB_FILE}: ${OBJ_FILES} - mkdir -p "${LIB_DIR}" - ar rcs "${LIB_DIR}/${LIB_FILE}" ${OBJ_FILES} +${COMMON_LIB_DIR}/${LIB_FILE}: ${OBJ_FILES} + mkdir -p "${COMMON_LIB_DIR}" + ar rcs "${COMMON_LIB_DIR}/${LIB_FILE}" ${OBJ_FILES} ${OBJ_DIR}/%.o: %.cpp $(wildcard *.h) @echo "compile $@" @@ -36,4 +35,4 @@ ${OBJ_DIR}/%.o: %.cpp $(wildcard *.h) $< clean: - rm -rf "${LIB_DIR}" "${OBJ_DIR}" + rm -rf "${COMMON_LIB_DIR}" "${OBJ_DIR}" diff --git a/testing/hello-simulator/Makefile b/testing/hello-simulator/Makefile index bb6fb3ca..d1c6cdbf 100644 --- a/testing/hello-simulator/Makefile +++ b/testing/hello-simulator/Makefile @@ -23,13 +23,13 @@ ${OBJ_DIR}/%.o: %.cpp @echo "compile $@" mkdir -p "${OBJ_DIR}" g++ -o "$@" -c \ - -I../.. \ - -I../../src \ - -I../../../../../virtual/cores/arduino \ - -I../../../Kaleidoscope-HIDAdaptor-KeyboardioHID/src \ - -I../../../KeyboardioHID/src \ - -I../../testing/googletest/googlemock/include \ - -I../../testing/googletest/googletest/include \ + -I${PWD}/../.. \ + -I${PWD}/../../src \ + -I${PWD}/../../../../../virtual/cores/arduino \ + -I${PWD}/../../../Kaleidoscope-HIDAdaptor-KeyboardioHID/src \ + -I${PWD}/../../../KeyboardioHID/src \ + -I${PWD}/../../testing/googletest/googlemock/include \ + -I${PWD}/../../testing/googletest/googletest/include \ -DARDUINO=10607 \ -DARDUINO_ARCH_VIRTUAL \ -DARDUINO_AVR_MODEL01 \ @@ -41,7 +41,7 @@ ${OBJ_DIR}/%.o: %.cpp '-DUSB_PRODUCT="Model 01"' \ $< -clean: FORCE +clean: rm -rf "${BIN_DIR}" "${LIB_DIR}" "${OBJ_DIR}" .PHONY: FORCE diff --git a/testing/kaleidoscope/Makefile b/testing/kaleidoscope/Makefile index e94ac7c3..063dba21 100644 --- a/testing/kaleidoscope/Makefile +++ b/testing/kaleidoscope/Makefile @@ -1,4 +1,5 @@ BIN_DIR=bin +COMMON_LIB_DIR ?= ${PWD}/../lib LIB_DIR=lib OBJ_DIR=obj SRC_DIR=test @@ -23,7 +24,7 @@ ${BIN_DIR}/${BIN_FILE}: ${TEST_OBJS} FORCE -g \ -w \ ${TEST_OBJS} \ - -L"${PWD}/../lib" \ + -L"${COMMON_LIB_DIR}" \ -lcommon \ "${LIB_DIR}/${LIB_FILE}" \ -L"$(PWD)/../googletest/lib" \