From 44b47b57e3825821438460bb7cccd3ff661e4948 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Tue, 31 Jan 2017 10:06:06 -0300 Subject: [PATCH 1/8] use Homebrew only if installed --- Makefile | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 01e1f6ad4..57e935174 100644 --- a/Makefile +++ b/Makefile @@ -62,15 +62,17 @@ 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 homebrew's libffi include and library path - CXXFLAGS += $(shell PKG_CONFIG_PATH=$$(brew list libffi | grep pkgconfig | xargs dirname) pkg-config --silence-errors --cflags libffi) - LDFLAGS += $(shell PKG_CONFIG_PATH=$$(brew list libffi | grep pkgconfig | xargs dirname) pkg-config --silence-errors --libs libffi) - # use bison installed by homebrew if available - BISON = $(shell (brew list bison | grep -m1 "bin/bison") || echo bison) - SED = sed + # 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) else LDFLAGS += -rdynamic LDLIBS += -lrt From 19f36271c2634f6829b4f7fe75b848aa74fd168d Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Tue, 7 Feb 2017 11:09:15 -0300 Subject: [PATCH 2/8] Allow standard tools to be overwritten in make invocation --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 57e935174..280c9d6a1 100644 --- a/Makefile +++ b/Makefile @@ -57,9 +57,9 @@ CXXFLAGS += -Wall -Wextra -ggdb -I. -I"$(YOSYS_SRC)" -MD -D_YOSYS_ -fPIC -I$(PRE LDFLAGS += -L$(LIBDIR) LDLIBS = -lstdc++ -lm -PKG_CONFIG = pkg-config -SED = sed -BISON = bison +PKG_CONFIG ?= pkg-config +SED ?= sed +BISON ?= bison ifeq (Darwin,$(findstring Darwin,$(shell uname))) BREW := $(shell command -v brew 2> /dev/null) From 7e08e37961a061807cec7aa335edbbab47891ce9 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Tue, 7 Feb 2017 11:12:12 -0300 Subject: [PATCH 3/8] 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; }) From b8d531957d4ff77afa10f12a7909f763aa367230 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Tue, 7 Feb 2017 11:12:31 -0300 Subject: [PATCH 4/8] Added notes for compilation on OS X --- README.md | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9b9f72cc0..f56bbf8cd 100644 --- a/README.md +++ b/README.md @@ -40,14 +40,14 @@ Web Site More information and documentation can be found on the Yosys web site: http://www.clifford.at/yosys/ - -Getting Started -=============== +Setup +====== You need a C++ compiler with C++11 support (up-to-date CLANG or GCC is recommended) and some standard tools such as GNU Flex, GNU Bison, and GNU Make. TCL, readline and libffi are optional (see ENABLE_* settings in Makefile). Xdot (graphviz) is used by the ``show`` command in yosys to display schematics. + For example on Ubuntu Linux 16.04 LTS the following commands will install all prerequisites for building yosys: @@ -55,6 +55,13 @@ prerequisites for building yosys: libreadline-dev gawk tcl-dev libffi-dev git mercurial \ graphviz xdot pkg-config python3 +Similarily, on Mac OS X MacPorts or Homebrew can be used to install dependencies: + + $ brew install bison flex gawk libffi \ + git mercurial graphviz pkg-config python3 + $ sudo port install bison flex readline gawk libffi \ + git mercurial graphviz pkg-config python3 + There are also pre-compiled Yosys binary packages for Ubuntu and Win32 as well as a source distribution for Visual Studio. Visit the Yosys download page for more information: http://www.clifford.at/yosys/download.html @@ -80,6 +87,9 @@ To build Yosys simply type 'make' in this directory. Note that this also downloads, builds and installs ABC (using yosys-abc as executable name). +Getting Started +=============== + Yosys can be used with the interactive command shell, with synthesis scripts or with command line arguments. Let's perform a simple synthesis job using the interactive command shell: From 94c76f85da755e1d6bcba7d746deba2223016dcf Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Thu, 9 Feb 2017 18:53:37 -0300 Subject: [PATCH 5/8] Applied fixes from @joshhead (thanks for your effors!) --- Makefile | 10 ++++++---- README.md | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 11cef84a2..50dc1b865 100644 --- a/Makefile +++ b/Makefile @@ -70,7 +70,8 @@ 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) +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 @@ -81,7 +82,8 @@ 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) +PKG_CONFIG_PATH := $(PORT_PREFIX)/lib/pkgconfig:$(PKG_CONFIG_PATH) + export PATH := $(PORT_PREFIX)/bin:$(PATH) endif @@ -224,8 +226,8 @@ endif endif ifeq ($(ENABLE_PLUGINS),1) -CXXFLAGS += -DYOSYS_ENABLE_PLUGINS $(shell $(PKG_CONFIG) --silence-errors --cflags libffi) -LDLIBS += $(shell $(PKG_CONFIG) --silence-errors --libs libffi || echo -lffi) -ldl +CXXFLAGS += -DYOSYS_ENABLE_PLUGINS $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKG_CONFIG) --silence-errors --cflags libffi) +LDLIBS += $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKG_CONFIG) --silence-errors --libs libffi || echo -lffi) -ldl endif ifeq ($(ENABLE_TCL),1) diff --git a/README.md b/README.md index f56bbf8cd..b4b3d36ee 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ Similarily, on Mac OS X MacPorts or Homebrew can be used to install dependencies $ brew install bison flex gawk libffi \ git mercurial graphviz pkg-config python3 $ sudo port install bison flex readline gawk libffi \ - git mercurial graphviz pkg-config python3 + git mercurial graphviz pkgconfig python36 There are also pre-compiled Yosys binary packages for Ubuntu and Win32 as well as a source distribution for Visual Studio. Visit the Yosys download page for From a3f19f047c4f6fa659bfbb04524ffa42804a5d26 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Thu, 9 Feb 2017 19:08:21 -0300 Subject: [PATCH 6/8] Remove space after backslash --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b4b3d36ee..79abad629 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ Similarily, on Mac OS X MacPorts or Homebrew can be used to install dependencies $ brew install bison flex gawk libffi \ git mercurial graphviz pkg-config python3 - $ sudo port install bison flex readline gawk libffi \ + $ sudo port install bison flex readline gawk libffi \ git mercurial graphviz pkgconfig python36 There are also pre-compiled Yosys binary packages for Ubuntu and Win32 as well From 9eca3671abe054e973b6c38c6670b0053954b4c2 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Fri, 10 Feb 2017 10:04:42 -0300 Subject: [PATCH 7/8] Dont mix Homebrew and MacPorts build options --- Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 50dc1b865..1a430277f 100644 --- a/Makefile +++ b/Makefile @@ -73,10 +73,9 @@ LDFLAGS += -L$(BREW_PREFIX)/readline/lib 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),) +else ifneq ($(shell which port),) PORT_PREFIX := $(patsubst %/bin/port,%,$(shell which port)) CXXFLAGS += -I$(PORT_PREFIX)/include From 422ffd5c0699613f98cff3c45267b0af7d944a80 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Fri, 10 Feb 2017 10:06:54 -0300 Subject: [PATCH 8/8] Use pkg-config for linking tcl-tk Both MacPorts and Homebrew have a pkg-config file for TCL. So lets use it. --- Makefile | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 1a430277f..50b189081 100644 --- a/Makefile +++ b/Makefile @@ -71,6 +71,7 @@ CXXFLAGS += -I$(BREW_PREFIX)/readline/include LDFLAGS += -L$(BREW_PREFIX)/readline/lib PKG_CONFIG_PATH := $(BREW_PREFIX)/libffi/lib/pkgconfig:$(PKG_CONFIG_PATH) +PKG_CONFIG_PATH := $(BREW_PREFIX)/tcl-tk/lib/pkgconfig:$(PKG_CONFIG_PATH) export PATH := $(BREW_PREFIX)/bison/bin:$(BREW_PREFIX)/gettext/bin:$(BREW_PREFIX)/flex/bin:$(PATH) @@ -225,15 +226,16 @@ endif endif ifeq ($(ENABLE_PLUGINS),1) -CXXFLAGS += -DYOSYS_ENABLE_PLUGINS $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKG_CONFIG) --silence-errors --cflags libffi) +CXXFLAGS += $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKG_CONFIG) --silence-errors --cflags libffi) -DYOSYS_ENABLE_PLUGINS LDLIBS += $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKG_CONFIG) --silence-errors --libs libffi || echo -lffi) -ldl endif ifeq ($(ENABLE_TCL),1) TCL_VERSION ?= tcl$(shell bash -c "tclsh <(echo 'puts [info tclversion]')") TCL_INCLUDE ?= /usr/include/$(TCL_VERSION) -CXXFLAGS += -I$(TCL_INCLUDE) -DYOSYS_ENABLE_TCL -LDLIBS += -l$(TCL_VERSION) + +CXXFLAGS += $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKG_CONFIG) --silence-errors --cflags tcl || echo -I$(TCL_INCLUDE)) -DYOSYS_ENABLE_TCL +LDLIBS += $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKG_CONFIG) --silence-errors --libs tcl || echo -l$(TCL_VERSION)) endif ifeq ($(ENABLE_GPROF),1)