-
Notifications
You must be signed in to change notification settings - Fork 2
/
.Makefile-c
110 lines (96 loc) · 2.8 KB
/
.Makefile-c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
###########################
# Makefile for C/C++ code #
###########################
# Set the build directory based on the variable 'config'
ifndef config
config=release
endif
ifeq ($(config),release)
BUILD_DIR_C:=build
else ifeq ($(config),debug)
BUILD_DIR_C:=build-debug
else ifeq ($(config),test)
BUILD_DIR_C:=build-test
else
$(error Invalid build 'config' {$(config)} specified.)
endif
###########################################
# cmake build, install, docs, etc targets #
###########################################
# Perform build
.PHONY: build-c
build-c: cmake
@$(ECHO) "Performing C/C++ build..."
@cd $(BUILD_DIR_C);make
@$(ECHO) "Done."
# Run cmake
.PHONY: cmake
cmake: $(BUILD_DIR_C).DIR
@$(ECHO) "Running 'cmake'..."
# TODO: Check if this works
# @cd $(BUILD_DIR_C);cmake --config config ..
@cd $(BUILD_DIR_C);cmake ..
@$(ECHO) "Done."
# Make the build directory
# This '.DIR' trick is needed to avoid
# conflicts with the 'build' target.
$(BUILD_DIR_C).DIR:
ifeq ($(wildcard $(BUILD_DIR_C)),)
@$(ECHO) -n "Making build directory {"$(basename $@)"}..."
@mkdir $(basename $@)
@$(ECHO) "Done."
endif
# Run Doxygen to generate C/C++ API information
.PHONY: docs-c
docs-c: .print_status
@$(ECHO) "Generating project docs..."
@cd $(BUILD_DIR_C);make docs-api
@$(ECHO) "Done."
# Install
.PHONY: install-c
install-c: .print_status build-c
@$(ECHO) "Installing C/C++ code..."
@cd $(BUILD_DIR_C);make install
@$(ECHO) "Done."
# Clean C/C++ build
.PHONY: clean-c
clean-c: .print_status
@$(ECHO) -n "Cleaning-up build directory '"$(BUILD_DIR_C)"'..."
@rm -rf $(BUILD_DIR_C)
@$(ECHO) "Done."
#################################
# C/C++ targets for developers #
#################################
# Run C tests
.PHONY: test-c
test-c: .print_status build-c
@$(ECHO) "Running C/C++ tests..."
@make -f test/Makefile tests
@$(ECHO) "Done."
# Compute C/C++ test coverage
.PHONY: coverage-c
coverage-c: .print_status build-c
@$(ECHO) "Generating C/C++ test coverage report..."
@make -f test/Makefile kcov
@$(ECHO) "Done."
# Report C/C++ linting issues
.PHONY: lint-check-c
lint-check-c: .print_status build-c
@$(ECHO) "Linting C/C++ code..."
@cd $(BUILD_DIR_C);make clang-format-check
@$(ECHO) "Done."
# Fix C/C++ linting issues in-place
.PHONY: lint-fix-c
lint-fix-c: .print_status build-c
@$(ECHO) "Applying linting suggestions to C/C++ code..."
@cd $(BUILD_DIR_C);make clang-format-fix
@$(ECHO) "Done."
####################################################################
# Supported 'cmake' targets not covered by the targets given above #
####################################################################
CMAKE_TARGETS = clang-tidy-suggest clang-tidy-fix
.PHONY: $(CMAKE_TARGETS)
$(CMAKE_TARGETS): .print_status cmake
@$(ECHO) "Running cmake target '"$@"'..."
@cd $(BUILD_DIR_C);make $@
@$(ECHO) "Done."