Merge pull request #45 from hutorny/feature/mastermake

Master Makefile
pull/58/head
Johan 2023-11-26 11:34:09 +01:00 zatwierdzone przez GitHub
commit 0781ceaa10
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
4 zmienionych plików z 140 dodań i 8 usunięć

14
.gitignore vendored
Wyświetl plik

@ -9,3 +9,17 @@ incremental_db/
output_files/
output_files_cl_016/
output_files_cl_025/
# Eclipse files
.cproject
.project
.settings/
# Build/stage directories
stage/
build/
#Intermediate driver files
.Module.symvers.cmd
.modules.order.cmd
Module.symvers
modules.order

99
Makefile 100644
Wyświetl plik

@ -0,0 +1,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)

Wyświetl plik

@ -22,3 +22,21 @@ WIKI FOR MORE DETAILS: https://github.com/pa3gsb/Radioberry-2.x/wiki
![Radioberry-2.x](docs/gallery/radioberry-open-incase-small.jpg)
## Building
### Install dependencies
sudo apt-get update
sudo apt-get install git libpulse-dev libgtk-3-dev libasound2-dev libcurl4-openssl-dev \
libusb-1.0-0-dev raspberrypi-kernel-headers device-tree-compiler pigpio
### Obtain the source codes
cd /tmp
git clone --depth=1 https://github.com/pa3gsb/Radioberry-2.x.git
cd Radioberry-2.x
git submodule update --init --recursive --depth=1
### Build the software
make -j$(nproc)
## Installation
sudo make install FPGATYPE=CL016

Wyświetl plik

@ -1,5 +1,7 @@
CC=gcc
LINK=gcc
INSTALL = install
BLDDIR = $(BUILDDIR:%=%/)
OPTIONS=-g -O3
@ -7,7 +9,7 @@ LIBS=-lrt -lm -lpthread
COMPILE=$(CC) $(OPTIONS) $(INCLUDES)
PROGRAM=radioberry
PROGRAM=$(BLDDIR)radioberry
SOURCES= \
measure.c \
@ -28,22 +30,21 @@ bias.o \
measure.o \
radioberry.o
all: prebuild $(PROGRAM) $(HEADERS) $(SOURCES)
all: prebuild $(PROGRAM) | $(HEADERS) $(SOURCES)
prebuild:
rm -f version.o
$(PROGRAM): $(OBJS)
$(LINK) -o $(PROGRAM) $(OBJS) $(LIBS)
$(PROGRAM): $(OBJS:%.o=$(BLDDIR)%.o)
$(LINK) -o $(PROGRAM) $^ $(LIBS)
.c.o:
$(BLDDIR)%.o: %.c
$(COMPILE) -c -o $@ $<
clean:
-rm -f *.o
-rm -f $(BLDDIR)*.o
-rm -f $(PROGRAM)
install: $(PROGRAM)
cp $(PROGRAM) /usr/local/bin
$(INSTALL) $(PROGRAM) $(DESTDIR)/usr/local/bin