-
Notifications
You must be signed in to change notification settings - Fork 22
/
Makefile
75 lines (59 loc) · 2 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
DTC ?= dtc
DTC_OPTIONS ?= -@ -q
PREFIX ?= $(DESTDIR)/opt/librecomputer/libretech-wiring-tool
DESTGPIOMAPS := $(patsubst %,$(PREFIX)/%,$(wildcard libre-computer/*/gpio.map))
DESTDTMAPS := $(patsubst %,$(PREFIX)/%,$(wildcard libre-computer/*/dt.map))
DTOS := $(patsubst %.dts,%.dtbo,$(wildcard libre-computer/*/dt/*.dts))
DESTDTOCFG := $(patsubst %,$(PREFIX)/%,$(wildcard libre-computer/*/dt.config))
DESTDTBOS := $(patsubst %,$(PREFIX)/%,$(wildcard libre-computer/*/dt/*.dtbo))
.PHONY : clean install-lgpio install-ldto install
all: $(DTOS)
%.pre.dts: %.dts
@if [ -L $(@D) ]; then \
exit; \
fi
@echo "CC $^"
@$(CC) -E -nostdinc -Iinclude -x assembler-with-cpp -undef -o $@ $^
%.dtbo: %.pre.dts
@if [ -L $(@D) ]; then \
exit; \
fi
@echo "DTC $^"
@$(DTC) $(DTC_OPTIONS) -I dts -O dtb -o $@ $^
clean:
rm -f $(DTOS)
boarddirs:
mkdir -p $(PREFIX) $(patsubst %,$(PREFIX)/%,$(wildcard libre-computer/*))
dtodirs: boarddirs
@for dtodir in $(wildcard libre-computer/*/dt); do \
if [ -L $$dtodir ]; then \
ln -fns $$(readlink $$dtodir) $(PREFIX)/$$dtodir; \
else \
mkdir -p $(PREFIX)/$$dtodir; \
fi \
done
$(PREFIX)/libre-computer/%/gpio.map: boarddirs
@if [ -L $(patsubst $(PREFIX)/%,%,$@) ]; then \
ln -fns $$(readlink $(patsubst $(PREFIX)/%,%,$@)) $@; \
else \
install -p -m 644 $(patsubst $(PREFIX)/%,%,$@) $@; \
fi
install-lgpio: boarddirs $(DESTGPIOMAPS)
install -p -m 755 lgpio $(PREFIX)
$(PREFIX)/libre-computer/%/dt.map: boarddirs
@if [ -L $(patsubst $(PREFIX)/%,%,$@) ]; then \
ln -fns $$(readlink $(patsubst $(PREFIX)/%,%,$@)) $@; \
else \
install -p -m 644 $(patsubst $(PREFIX)/%,%,$@) $@; \
fi
$(PREFIX)/libre-computer/%/dt.config: boarddirs
install -p -m 644 $(patsubst $(PREFIX)/%,%,$@) $@
$(PREFIX)/libre-computer/%.dtbo: boarddirs dtodirs
@if [ -L $(@D) ]; then \
exit; \
else \
install -p -m 644 $(patsubst $(PREFIX)/%,%,$@) $@; \
fi
install-ldto: boarddirs $(DESTDTOCFG) $(DESTDTMAPS) $(DESTDTBOS)
install -p -m 755 ldto $(PREFIX)
install: install-lgpio install-ldto