From d0de6f5b9a9b23df8920388f04993096a450788e Mon Sep 17 00:00:00 2001 From: Marcin Kondej Date: Thu, 19 Sep 2019 10:05:51 +0200 Subject: [PATCH] Makefile update for aarch64 --- src/Makefile | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/src/Makefile b/src/Makefile index 2491afc..601429c 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,30 +1,34 @@ CC = gcc -STD_CFLAGS = -Wall -std=gnu99 -c -g -O3 +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) +# 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 propper compilation flags ifeq ($(UNAME), armv6l) - CFLAGS = $(STD_CFLAGS) -march=armv6 -mtune=arm1176jzf-s -mfloat-abi=hard -mfpu=vfp -ffast-math -DRASPI=1 + ARCH_CFLAGS = -march=armv6 -O3 -mtune=arm1176jzf-s -mfloat-abi=hard -mfpu=vfp -ffast-math TARGET = 1 -else ifeq ($(UNAME), armv7l) - RPI_VERSION := $(shell cat /proc/device-tree/model | grep -a -o "Raspberry\sPi\s[0-9]" | grep -o "[0-9]") - ifeq ($(shell expr $(RPI_VERSION) \>= 4), 1) - CFLAGS = $(STD_CFLAGS) -march=armv7-a -mtune=arm1176jzf-s -mfloat-abi=hard -mfpu=vfp -ffast-math -DRASPI=4 - else - CFLAGS = $(STD_CFLAGS) -march=armv7-a -mtune=arm1176jzf-s -mfloat-abi=hard -mfpu=vfp -ffast-math -DRASPI=2 +else ifeq ($(shell expr $(RPI_VERSION) \> 1), 1) + ifeq ($(UNAME), armv7l) + 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 - TARGET = 1 -else ifeq ($(UNAME), aarch64) - CFLAGS = $(STD_CFLAGS) -march=armv8-a -O2 -pipe -fstack-protector-strong -fno-plt -ffast-math -DRASPI=2 - TARGET = 1 else - CFLAGS = $(STD_CFLAGS) - TARGET = 0 + ARCH_CFLAGS = -O3 + TARGET = other endif +CFLAGS = $(STD_CFLAGS) $(ARCH_CFLAGS) -DRASPI=$(TARGET) -ifeq ($(TARGET), 1) +ifneq ($(TARGET), other) app: rds.o waveforms.o pi_fm_rds.o fm_mpx.o control_pipe.o mailbox.o $(CC) -o pi_fm_rds rds.o waveforms.o mailbox.o pi_fm_rds.o fm_mpx.o control_pipe.o -lm -lsndfile