-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
110 lines (86 loc) · 2.95 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
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
# SPDX-License-Identifier: Apache-2.0
#
# Copyright (c) 2021 Blue Clover Devices
#
PRJTAG := ly11-ble-fw
# Makefile default shell is /bin/sh which does not implement `source`.
SHELL := /bin/bash
BASE_PATH := $(realpath .)
DIST := $(BASE_PATH)/dist
.PHONY: default
default: build
.PHONY: GIT-VERSION-FILE
GIT-VERSION-FILE:
@sh ./GIT-VERSION-GEN
-include GIT-VERSION-FILE
VERSION_TAG := $(patsubst v%,%,$(GIT_DESC))
DOCKER_BUILD_ARGS :=
DOCKER_BUILD_ARGS += --network=host
DOCKER_RUN_ARGS :=
DOCKER_RUN_ARGS += --network=none
ZEPHYR_TAG := 3.5.0
ZEPHYR_SYSROOT := /usr/src/zephyr-$(ZEPHYR_TAG)/zephyr
ZEPHYR_USRROOT := $(HOME)/src/zephyr-$(ZEPHYR_TAG)/zephyr
# Determine Zephyr Root
ZEPHYR_ROOT :=
ifneq "$(wildcard $(ZEPHYR_SYSROOT) )" ""
# If ZEPHYR_SYSROOT exists, we use it.
ZEPHYR_ROOT = $(ZEPHYR_SYSROOT)
else
# Otherwise, we look for ZEPHYR_USRROOT
ifneq "$(wildcard $(ZEPHYR_USRROOT) )" ""
ZEPHYR_ROOT = $(ZEPHYR_USRROOT)
endif
endif
ZEPHYR_BOARD_ROOT := $(BASE_PATH)
BOARDS :=
BOARDS += adafruit_feather_nrf52840
BOARDS += nrf52840dk_nrf52840
BOARDS += nrf52840dongle_nrf52840
TARGETS := $(patsubst %,build.%/hci_usb_h4/zephyr/zephyr.hex,$(BOARDS))
TARGETS += build.nrf52840dongle_nrf52840/hci_usb_h4/zephyr/zephyr-dfu.zip
build.%/hci_usb_h4/zephyr/zephyr.hex: check-zephyr
source $(ZEPHYR_ROOT)/zephyr-env.sh ; \
west build --build-dir build.$*/hci_usb_h4 --pristine auto \
--board $* \
-- -DCONFIG_USB_DEVICE_PRODUCT=\"$(PRJTAG)-v$(VERSION_TAG)\"
%/zephyr-dfu.zip: %/zephyr.hex
nrfutil pkg generate --hw-version 52 --sd-req=0x00 \
--application $+ \
--application-version 1 $@
.PHONY: versions
versions:
@echo "GIT_DESC: $(GIT_DESC)"
@echo "VERSION_TAG: $(VERSION_TAG)"
.PHONY: build
build: $(TARGETS)
.PHONY: distclean
distclean: clean
-rm -rf dist
.PHONY: clean
clean:
-rm -rf $(BINS) build build.*
.PHONY: dist-prep
dist-prep:
-install -d $(DIST)
.PHONY: dist-clean
dist-clean:
-rm -rf $(DIST)
.PHONY: check-zephyr
check-zephyr:
ifeq "$(wildcard $(ZEPHYR_ROOT) )" ""
$(error No Zephyr root found: Neither $(ZEPHYR_SYSROOT) or $(ZEPHYR_USRROOT) exist!)
endif
.PHONY: dist
dist: dist-clean dist-prep build
install -m 666 build.adafruit_feather_nrf52840/hci_usb_h4/zephyr/zephyr.hex dist/hci_usb_h4-adafruit_feather_nrf52840-$(ZEPHYR_TAG).hex
install -m 666 build.nrf52840dk_nrf52840/hci_usb_h4/zephyr/zephyr.hex dist/hci_usb_h4-nrf52840dk-$(ZEPHYR_TAG).hex
install -m 666 build.nrf52840dongle_nrf52840/hci_usb_h4/zephyr/zephyr.hex dist/hci_usb_h4-nrf52840dongle-$(ZEPHYR_TAG).hex
install -m 666 build.nrf52840dongle_nrf52840/hci_usb_h4/zephyr/zephyr-dfu.zip dist/hci_usb_h4-nrf52840dongle-$(ZEPHYR_TAG)-dfu.zip
.PHONY: docker
docker: dist-prep
docker build $(DOCKER_BUILD_ARGS) -t "bcdevices/$(PRJTAG)" .
-@docker rm -f "$(PRJTAG)-$(VERSION_TAG)" 2>/dev/null
docker run $(DOCKER_RUN_ARGS) --name "$(PRJTAG)-$(VERSION_TAG)" -t "bcdevices/$(PRJTAG)" \
/bin/bash -c "make dist"
docker cp "$(PRJTAG)-$(VERSION_TAG):/usr/src/dist" $(BASE_PATH)