From 7e08e37961a061807cec7aa335edbbab47891ce9 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Tue, 7 Feb 2017 11:12:12 -0300 Subject: [PATCH] Fix compilation on OS X in order to support both MacPorts and Homebrew --- Makefile | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 280c9d6a1..11cef84a2 100644 --- a/Makefile +++ b/Makefile @@ -62,20 +62,32 @@ SED ?= sed BISON ?= bison ifeq (Darwin,$(findstring Darwin,$(shell uname))) - BREW := $(shell command -v brew 2> /dev/null) - ifdef BREW - export PKG_CONFIG_PATH = $(shell $(BREW) list libffi | grep pkgconfig | xargs dirname) - BISON = $(shell $(BREW) list bison | grep -m1 "bin/bison") - endif - # add macports/homebrew include and library path to search directories, don't use '-rdynamic' and '-lrt': - CXXFLAGS += -I/opt/local/include -I/usr/local/opt/readline/include - LDFLAGS += -L/opt/local/lib -L/usr/local/opt/readline/lib - # add macports/homebrew's libffi include and library path - CXXFLAGS += $(shell pkg-config --silence-errors --cflags libffi) - LDFLAGS += $(shell pkg-config --silence-errors --libs libffi) + +# homebrew search paths +ifneq ($(shell which brew),) +BREW_PREFIX := $(shell brew --prefix)/opt + +CXXFLAGS += -I$(BREW_PREFIX)/readline/include +LDFLAGS += -L$(BREW_PREFIX)/readline/lib + +export PKG_CONFIG_PATH := $(BREW_PREFIX)/libffi/lib/pkgconfig:$(PKG_CONFIG_PATH) +export PATH := $(BREW_PREFIX)/bison/bin:$(BREW_PREFIX)/gettext/bin:$(BREW_PREFIX)/flex/bin:$(PATH) +endif + +# macports search paths +ifneq ($(shell which port),) +PORT_PREFIX := $(patsubst %/bin/port,%,$(shell which port)) + +CXXFLAGS += -I$(PORT_PREFIX)/include +LDFLAGS += -L$(PORT_PREFIX)/lib + +export PKG_CONFIG_PATH := $(PORT_PREFIX)/lib/pkgconfig:$(PKG_CONFIG_PATH) +export PATH := $(PORT_PREFIX)/bin:$(PATH) +endif + else - LDFLAGS += -rdynamic - LDLIBS += -lrt +LDFLAGS += -rdynamic +LDLIBS += -lrt endif YOSYS_VER := 0.7+$(shell cd $(YOSYS_SRC) && test -e .git && { git log --author=clifford@clifford.at --oneline 61f6811.. | wc -l; })