Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
81 lines (63 loc) · 2.11 KB
/
Copy pathMakefile
File metadata and controls
81 lines (63 loc) · 2.11 KB
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
# Installation prefix and build directory
BUILD_DIR ?= build
PREFIX ?= $(BUILD_DIR)
CMAKE_BUILD_TYPE ?= Release
# Tools
CMAKE ?= $(shell which cmake 2>/dev/null)
DOCKER ?= $(shell which docker 2>/dev/null)
GIT ?= $(shell which git 2>/dev/null)
# Determine the program version from git tags or commit hash
PROGRAM_VERSION ?= $(shell \
if test -x "${GIT}"; then \
${GIT} describe --tags --exact-match 2>/dev/null || \
${GIT} rev-parse --short HEAD 2>/dev/null; \
fi)
VERSION_NUMBER := $(if $(strip ${PROGRAM_VERSION}),${PROGRAM_VERSION},0.0.0)
###############################################################################
# CONFIGURE AND BUILD
.PHONY: build
build: configure
@${CMAKE} --build ${BUILD_DIR} --target all -j 8
.PHONY: configure
configure: dep-cmake submodule
@${CMAKE} -B ${BUILD_DIR} \
-D CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \
$(if ${PROGRAM_VERSION},-D PROGRAM_VERSION=${PROGRAM_VERSION}) \
$(if ${PICO_BOARD},-D PICO_BOARD=${PICO_BOARD})
.PHONY: test
test: build
@${CMAKE} --build ${BUILD_DIR} --target test
.PHONY: version
version:
@echo ${VERSION_NUMBER}
.PHONY: submodule
submodule: dep-git
@${GIT} submodule update --init --recursive
###############################################################################
# INSTALL
.PHONY: install
install: build
@${CMAKE} --install ${BUILD_DIR} --prefix ${PREFIX}
###############################################################################
# CLEAN
.PHONY: clean
clean:
@rm -rf ${BUILD_DIR}
###############################################################################
# DOCUMENTATION
.PHONY: doc
doc: dep-docker
@echo
@echo make doc
@${DOCKER} run -v .:/data greenbone/doxygen doxygen /data/doxygen/Doxyfile
###############################################################################
# DEPENDENCIES
.PHONY: dep-cmake
dep-cmake:
@test -f "${CMAKE}" && test -x "${CMAKE}" || (echo "Missing CMAKE: ${CMAKE}" && exit 1)
.PHONY: dep-docker
dep-docker:
@test -f "${DOCKER}" && test -x "${DOCKER}" || (echo "Missing DOCKER: ${DOCKER}" && exit 1)
.PHONY: dep-git
dep-git:
@test -f "${GIT}" && test -x "${GIT}" || (echo "Missing GIT: ${GIT}" && exit 1)