Update Makefile

replaced detecting pi version using /proc/device-tree/model w/ a prompt asking you to select your pi's arm architecture.
This commit is contained in:
Tom 2024-04-15 19:23:44 -04:00 committed by GitHub
parent dc5d94be02
commit 06f437e61e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 27 additions and 34 deletions

View File

@ -1,34 +1,27 @@
CC = gcc
STD_CFLAGS = -Wall -std=gnu99 -c -g
# Enable ARM-specific options only on ARM, and compilation of the app only on ARM
UNAME := $(shell uname -m)
# Prompt user to select architecture
ARCH_PROMPT := "Select the architecture (1 for armv6l, 2 for armv7l, 3 for aarch64): "
ARCH_CHOICE := $(shell read -p $(ARCH_PROMPT) arch && echo $$arch)
# Determine Raspberry Pi version (if 2 or greater)
RPI_VERSION := $(shell cat /proc/device-tree/model | grep -a -o "Raspberry\sPi\s[0-9]" | grep -o "[0-9]")
# Determine the hardware platform and set proper compilation flags
ifeq ($(UNAME), armv6l)
# Determine hardware platform and set proper compilation flags based on user choice
ifeq ($(ARCH_CHOICE), 1)
ARCH_CFLAGS = -march=armv6 -O3 -mtune=arm1176jzf-s -mfloat-abi=hard -mfpu=vfp -ffast-math
TARGET = 1
else ifeq ($(shell expr $(RPI_VERSION) \> 1), 1)
ifeq ($(UNAME), armv7l)
else ifeq ($(ARCH_CHOICE), 2)
ARCH_CFLAGS = -march=armv7-a -O3 -mtune=arm1176jzf-s -mfloat-abi=hard -mfpu=vfp -ffast-math
else ifeq ($(UNAME), aarch64)
ARCH_CFLAGS = -march=armv8-a -O2 -pipe -fstack-protector-strong -fno-plt -ffast-math
endif
ifeq ($(shell expr $(RPI_VERSION) \>= 4), 1)
TARGET = 4
else
TARGET = 2
endif
else ifeq ($(ARCH_CHOICE), 3)
ARCH_CFLAGS = -march=armv8-a -O2 -pipe -fstack-protector-strong -fno-plt -ffast-math
TARGET = 3
else
ARCH_CFLAGS = -O3
TARGET = other
$(error Invalid architecture choice. Please choose 1 for armv6l, 2 for armv7l, or 3 for aarch64.)
endif
CFLAGS = $(STD_CFLAGS) $(ARCH_CFLAGS) -DRASPI=$(TARGET)
ifneq ($(TARGET), other)
ifneq ($(TARGET), 4)
app: rds.o waveforms.o pi_fm_rds.o rds_strings.o fm_mpx.o control_pipe.o mailbox.o
$(CC) $(LDFLAGS) -o pi_fm_rds rds.o rds_strings.o waveforms.o mailbox.o pi_fm_rds.o fm_mpx.o control_pipe.o -lsndfile -lm