Makefile 1.4 KB
Newer Older
Guido Gunther's avatar
Guido Gunther committed
1
2
# SPDX-License-Identifier: GPL-3.0+

3
4
BOARD ?= devkit
TYPE ?= latest
Hugo Grostabussiat's avatar
Hugo Grostabussiat committed
5
6
DIST ?= buster+ci

7
8
9
10
11
12
13
14
SHELL := /bin/bash

# Get a variable from the board config
# $1 : Variable name to get the value for
define get_board_var
$(shell pureos_board=$(BOARD); . conf/board; echo $$$1)
endef

Hugo Grostabussiat's avatar
Hugo Grostabussiat committed
15
16
STAMPFILE := tmp/$(BOARD).img.stamp
IMAGES := $(BOARD).img
17
18
19
ifeq ($(call get_board_var,want_boot_image),1)
  IMAGES += $(BOARD)-boot.img
endif
Hugo Grostabussiat's avatar
Hugo Grostabussiat committed
20
21
COMPRESSED := $(addsuffix .xz,$(IMAGES))
CHECKSUM := sha256sums
22
23
24
25
26
27
28
DEPS=\
  build-image   \
  root.sh       \
  conf/board    \
  conf/packages \
  $(NULL)

29
30
31
32
SHELLCHECK_SCRIPTS=\
  ./build-image             \
  build/build_kernel_deb.sh \
  $(NULL)
Guido Gunther's avatar
Guido Gunther committed
33

34
all: $(COMPRESSED)
Guido Gunther's avatar
Guido Gunther committed
35

Hugo Grostabussiat's avatar
Hugo Grostabussiat committed
36
37
38
39
40
41
42
$(IMAGES): $(STAMPFILE)

# Use an order-only dependency to prevent rebuilding $(STAMPFILE) every time
# local.sh-link is out of date (it is always out of date because of .PHONY).
$(STAMPFILE): | local.sh-link

$(STAMPFILE): $(DEPS)
Guido Gunther's avatar
Guido Gunther committed
43
	./build-image -b $(BOARD) -T $(TYPE) -d $(DIST)
Hugo Grostabussiat's avatar
Hugo Grostabussiat committed
44
	touch $@
Guido Gunther's avatar
Guido Gunther committed
45

Hugo Grostabussiat's avatar
Hugo Grostabussiat committed
46
%.img.xz: %.img
47
48
	xz -T0 --stdout $< > $@.tmp
	mv $@.tmp $@
Guido Gunther's avatar
Guido Gunther committed
49

Hugo Grostabussiat's avatar
Hugo Grostabussiat committed
50
$(CHECKSUM): $(COMPRESSED)
51
	sha256sum $(COMPRESSED) > $@.tmp
Guido Gunther's avatar
Guido Gunther committed
52
	mv $@.tmp $@
Guido Gunther's avatar
Guido Gunther committed
53

Guido Gunther's avatar
Guido Gunther committed
54
clean:
Hugo Grostabussiat's avatar
Hugo Grostabussiat committed
55
	rm -rf files/ tmp/ $(IMAGES) $(COMPRESSED) $(CHECKSUM) *.tmp
Guido Gunther's avatar
Guido Gunther committed
56
57

check:
58
	shellcheck -x $(SHELLCHECK_SCRIPTS)
Guido Gunther's avatar
Guido Gunther committed
59
	bash -n root.sh
Guido Gunther's avatar
Guido Gunther committed
60

Guido Gunther's avatar
Guido Gunther committed
61
62
publish: $(CHECKSUM)
	bin/sign-checksum
63
	bin/publish -T ${TYPE}
64

65
66
67
68
69
70
71
local.sh-link:
	if test -e local.sh; then \
		mkdir -p files; \
		ln -sf ../local.sh files; \
	fi

.PHONY: all publish local.sh-link