-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
executable file
·83 lines (65 loc) · 2.12 KB
/
Makefile
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
BUILD_DIR := build
SRC_DIR := $(filter-out src/old, $(wildcard src/*))
EXAMPLES_DIR := $(wildcard examples/*)
TESTS_DIR := $(wildcard tests/*)
PREFIX ?= /usr/local
# Paths to tools needed in dependencies
GIT := $(shell which git)
CMAKE := $(shell which cmake)
# Pico variables
PICO_BOARD ?= pico_w
# Targets
all: config picotool test examples
test: config
@make -C ${BUILD_DIR} all test
examples: config
@make -C ${BUILD_DIR} all examples
config: dependencies mkdir submodule
@echo cmake config
@${CMAKE} -B ${BUILD_DIR} -DPICO_BOARD=${PICO_BOARD}
picotool: dependencies mkdir submodule
@echo make picotool
@PICO_SDK_PATH=../../../lib/pico-sdk ${CMAKE} -S lib/picotool -B ${BUILD_DIR}/lib/picotool
@make -C ${BUILD_DIR}/lib/picotool
@echo "\nRun:\n install -s ${BUILD_DIR}/lib/picotool/picotool ${PREFIX}/bin\n"
src: $(SRC_DIR)
$(TESTS_DIR): dependencies mkdir
@echo make $(notdir $@)
@make -C ${BUILD_DIR}/$@
$(SRC_DIR): dependencies mkdir
@echo make $(notdir $@)
@make -C ${BUILD_DIR}/$@
$(TESTS_DIR): dependencies mkdir
@echo make $(notdir $@)
@make -C ${BUILD_DIR}/$@
$(EXAMPLES_DIR): dependencies mkdir
@echo make $(notdir $@)
@make -C ${BUILD_DIR}/$@
# Update submodule to the 2.0.0 version
submodule-update: dependencies
@echo "Updating submodules"
@${GIT} pull --recurse-submodules
@cd lib/pico-sdk && ${GIT} pull origin 2.0.0 && cd ../..
@cd lib/picotool && ${GIT} pull origin 2.0.0 && cd ../..
@${GIT} submodule sync --recursive
# Submodule checkout
submodule: dependencies
@echo "Checking out submodules"
@${GIT} submodule update --init --recursive
# Submodule clean
submodule-clean: dependencies
@echo "Cleaning submodules"
@${GIT} reset --hard
@${GIT} submodule sync --recursive
@${GIT} submodule update --init --force --recursive
@${GIT} clean -ffdx
@${GIT} submodule foreach --recursive git clean -ffdx
mkdir:
@echo mkdir ${BUILD_DIR}
@install -d ${BUILD_DIR}
clean: submodule-clean
@echo clean
@rm -fr $(BUILD_DIR)
dependencies:
@test -f "${CMAKE}" && test -x "${CMAKE}" || (echo "Missing cmake binary" && exit 1)
@test -f "${GIT}" && test -x "${GIT}" || (echo "Missing git binary" && exit 1)