summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorAlex Richardson <Alexander.Richardson@cl.cam.ac.uk>2020-02-06 07:27:34 +0300
committerAnup Patel <anup@brainfault.org>2020-02-06 13:12:47 +0300
commit5ff1ab0ed8908825966f566b996a0735d937a0ec (patch)
tree6fc183f0a1c53b8a2dc22f1be22c47675a478d7f /Makefile
parent2c2bbe7374b127b4ca4e0aa5d6cfb3f5bd21a2ee (diff)
downloadopensbi-5ff1ab0ed8908825966f566b996a0735d937a0ec.tar.xz
makefile: add support for building on macOS
On macOS the readlink command does not include a -f flag. Instead default to using GNU readlink (which is often installed as greadlink). Signed-off-by: Alex Richardson <Alexander.Richardson@cl.cam.ac.uk> Signed-off-by: Anup Patel <anup.patel@wdc.com>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile13
1 files changed, 10 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index aac422a..ccf8ea3 100644
--- a/Makefile
+++ b/Makefile
@@ -12,10 +12,17 @@
# o Do not print "Entering directory ...";
MAKEFLAGS += -r --no-print-directory
+# Readlink -f requires GNU readlink
+ifeq ($(shell uname -s),Darwin)
+READLINK ?= greadlink
+else
+READLINK ?= readlink
+endif
+
# Find out source, build, and install directories
src_dir=$(CURDIR)
ifdef O
- build_dir=$(shell readlink -f $(O))
+ build_dir=$(shell $(READLINK) -f $(O))
else
build_dir=$(CURDIR)/build
endif
@@ -23,7 +30,7 @@ ifeq ($(build_dir),$(CURDIR))
$(error Build directory is same as source directory.)
endif
ifdef I
- install_dir=$(shell readlink -f $(I))
+ install_dir=$(shell $(READLINK) -f $(I))
else
install_dir=$(CURDIR)/install
endif
@@ -34,7 +41,7 @@ ifeq ($(install_dir),$(build_dir))
$(error Install directory is same as build directory.)
endif
ifdef PLATFORM_DIR
- platform_dir_path=$(shell readlink -f $(PLATFORM_DIR))
+ platform_dir_path=$(shell $(READLINK) -f $(PLATFORM_DIR))
ifdef PLATFORM
platform_parent_dir=$(platform_dir_path)
else