From f4a17177ce05f74cc33a985868f704d086ac75d5 Mon Sep 17 00:00:00 2001 From: Anup Patel <anup.patel@wdc.com> Date: Mon, 18 Feb 2019 09:40:51 +0530 Subject: Makefile: Fix error evaluating OPENSBI_CC_XLEN We get following error evaluating OPENSBI_CC_XLEN on Ubuntu-18.04: /bin/sh: 1: Bad substitution This patch fixes above error by using "awk" in string assigned to OPENSBI_CC_XLEN and it also moves "Setup compilation commands" before OPENSBI_CC_XLEN. Signed-off-by: Anup Patel <anup.patel@wdc.com> --- Makefile | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index c1ac54c..81e427b 100644 --- a/Makefile +++ b/Makefile @@ -54,8 +54,25 @@ export firmware_dir=$(CURDIR)/firmware OPENSBI_VERSION_MAJOR=`grep MAJOR $(include_dir)/sbi/sbi_version.h | awk '{ print $$3 }'` OPENSBI_VERSION_MINOR=`grep MINOR $(include_dir)/sbi/sbi_version.h | awk '{ print $$3 }'` +# Setup compilation commands +ifdef CROSS_COMPILE +CC = $(CROSS_COMPILE)gcc +CPP = $(CROSS_COMPILE)cpp +AR = $(CROSS_COMPILE)ar +LD = $(CROSS_COMPILE)ld +OBJCOPY = $(CROSS_COMPILE)objcopy +else +CC ?= gcc +CPP ?= cpp +AR ?= ar +LD ?= ld +OBJCOPY ?= objcopy +endif +AS = $(CC) +DTC = dtc + # Guess the compillers xlen -OPENSBI_CC_XLEN := $(shell TMP=`$(CC) -dumpmachine`; echo $${TMP:5:2}) +OPENSBI_CC_XLEN := $(shell TMP=`$(CC) -dumpmachine | sed 's/riscv\([0-9][0-9]\).*/\1/'`; echo $${TMP}) # Setup list of objects.mk files ifdef PLATFORM @@ -95,30 +112,6 @@ deps-y+=$(platform-common-objs-path-y:.o=.dep) deps-y+=$(lib-objs-path-y:.o=.dep) deps-y+=$(firmware-objs-path-y:.o=.dep) -GENFLAGS = -I$(platform_dir)/include -GENFLAGS += -I$(platform_common_dir)/include -GENFLAGS += -I$(include_dir) -GENFLAGS += $(platform-common-genflags-y) -GENFLAGS += $(platform-genflags-y) -GENFLAGS += $(firmware-genflags-y) - -# Setup compilation commands -ifdef CROSS_COMPILE -CC = $(CROSS_COMPILE)gcc -CPP = $(CROSS_COMPILE)cpp -AR = $(CROSS_COMPILE)ar -LD = $(CROSS_COMPILE)ld -OBJCOPY = $(CROSS_COMPILE)objcopy -else -CC ?= gcc -CPP ?= cpp -AR ?= ar -LD ?= ld -OBJCOPY ?= objcopy -endif -AS = $(CC) -DTC = dtc - # Setup platform XLEN, ABI, ISA and Code Model ifndef PLATFORM_RISCV_XLEN ifeq ($(OPENSBI_CC_XLEN), 32) @@ -142,6 +135,13 @@ ifndef PLATFORM_RISCV_CODE_MODEL endif # Setup compilation commands flags +GENFLAGS = -I$(platform_dir)/include +GENFLAGS += -I$(platform_common_dir)/include +GENFLAGS += -I$(include_dir) +GENFLAGS += $(platform-common-genflags-y) +GENFLAGS += $(platform-genflags-y) +GENFLAGS += $(firmware-genflags-y) + CFLAGS = -g -Wall -Werror -nostdlib -fno-strict-aliasing -O2 CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls CFLAGS += -mno-save-restore -mstrict-align -- cgit v1.2.3