-
Notifications
You must be signed in to change notification settings - Fork 92
/
Makefile
99 lines (75 loc) · 2.8 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
KR ?= $(shell uname -r)
ID = $(shell id -u)
RPI = rpi-4
DRIVER = SBC/$(RPI)/device_driver/driver/radioberry.ko
FIRMWARE = SBC/$(RPI)/device_driver/firmware/radioberry
PIHPSDR = pihpsdr/pigpsdr
WDSP = wdsp/libwdsp.so
FPGATYPE =
INSTALL = install
DESTDIR = /usr/local/bin
KERNEL_HEADERS=$(DESTDIR)/lib/modules/$(KR)/build
MAKEFLAGS += --no-print-directory
export INSTALL DESTDIR KERNEL_HEADERS
.PHONY: all check-if-root clean clean-driver clean-firmware clean-pihpsdr \
wdsp driver firmware pihpsdr \
install install-firmware install-driver install-service stop-radioberry \
all: driver firmware pihpsdr wdsp
driver: $(DRIVER)
$(DRIVER): $(dir $(DRIVER))
# Sub-make does not work here
bash -c 'cd SBC/$(RPI)/device_driver/driver && make'
firmware: $(FIRMWARE)
clean-firmware:
$(MAKE) -C SBC/$(RPI)/device_driver/firmware clean
pihpsdr: $(PIHPSDR)
wdsp: $(WDSP)
clean: clean-pihpsdr clean-wdsp clean-firmware
clean-pihpsdr:
$(MAKE) -C pihpsdr clean
clean-wdsp:
$(MAKE) -C wdsp clean
$(FIRMWARE): $(dir $(FIRMWARE))
$(MAKE) -C SBC/$(RPI)/device_driver/firmware
# TODO build phpsdr with not-yet installed wdsp
$(PIHPSDR): $(WDSP) $(dir $(PIHPSDR))
+$(MAKE) -C pihpsdr GPIO_INCLUDE= PURESIGNAL_INCLUDE= MIDI_INCLUDE=MIDI
$(WDSP): $(dir $(WDSP))
+$(MAKE) -C wdsp
install: check-if-root stop-radioberry install-driver install-firmware install-service install-software
%/:
@mkdir -p $@
install-firmware: firmware check-if-root stop-radioberry
ifeq ($(FPGATYPE),)
$(error FPGATYPE is required, specify FPGATYPE=CL016 or FPGATYPE=CL025)
endif
$(INSTALL) SBC/$(RPI)/releases/dev/$(FPGATYPE)/radioberry.rbf /lib/firmware
$(info Radioberry gateware Cyclone 10 $(FPGATYPE) installed.)
install-service: check-if-root stop-radioberry
$(INSTALL) SBC/$(RPI)/device_driver/systemd/radioberry.service /etc/systemd/system/
$(INSTALL) SBC/$(RPI)/device_driver/systemd/radioberryd /etc/init.d/
@echo chmod +x /etc/init.d/radioberryd
install-driver: check-if-root $(DRIVER)
$(PRE_INSTALL) # Pre-install commands follow.
$(if $(DESTDIR),,-systemctl stop radioberry)
$(if $(DESTDIR),,-systemctl disable radioberry)
$(if $(DESTDIR),,-modprobe -r radioberry)
$(NORMAL_INSTALL) # Normal commands follow.
echo $(MAKE) -C SBC/$(RPI)/device_driver/driver install
$(POST_INSTALL) # Post-install commands follow.
$(if $(DESTDIR),,insmod $(DRIVER))
$(if $(DESTDIR),,chmod 666 /dev/radioberry)
install-software: check-if-root
$(MAKE) -C pihpsdr install GPIO_INCLUDE= PURESIGNAL_INCLUDE= MIDI_INCLUDE=MIDI
$(MAKE) -C wdsp install
check-if-root:
ifeq ($(DESTDIR),)
ifneq ($(ID),0)
$(warning root privileges are missing)
endif
endif
stop-radioberry: check-if-root
$(if $(DESTDIR),,-systemctl stop radioberry)
$(if $(DESTDIR),,-systemctl disable radioberry)
$(if $(DESTDIR),,-modprobe -r radioberry)
.SECONDARY: $(DRIVER) $(FIRMWARE) $(PIHPSDR)