https://doi.org/10.5201/ipol.2022.215
Makefile
BIN = paraws
LIB = src/libparaws.a
TESTS = tests/unit_tests
# default: build paraws binary
.PHONY: all
all: $(BIN)
# since it contains a 'common-clean' rule, common.mk should be
# included after the 'all' rule to keep it as the default rule
include common.mk
# to build paraws binary
$(BIN) : $(BIN).o $(LIB)
$(CXX) -o $@ $^ $(CXXFLAGS) $(LDFLAGS) $(LDLIBS)
# to build libparaws.a
$(LIB):
$(MAKE) -C src
# to build and run tests
.PHONY: test
test: $(LIB)
$(MAKE) -C tests run
# to run paraws binary
.PHONY: run
run: $(BIN)
./$^
# what does this rule means?
print-% : ; @echo $* = $($*)
.PHONY: clean
clean: common-clean
$(RM) paraws.o paraws
$(MAKE) -C src $@
$(MAKE) -C tests $@
.PHONY: tags
tags:
ctags -e --file-scope=no -R
TIDY = clang-tidy
CHECK = clang-check
FORMAT = clang-format
SRCS = $(shell find . -type f -name '*.cpp')
HDRS = $(shell find . -type f -name '*.hpp')
CCMD = build
ARGS = -extra-arg=-std=c++11
.PHONY: tidy
tidy:
$(TIDY) -p $(CCMD) $(ARG) $(SRCS)
.PHONY: check
check:
$(CHECK) -p $(CCMD) $(ARGS) $(SRCS)
.PHONY: format
format:
$(FORMAT) -i $(SRCS) $(HDRS)