From 0b95cfac8d66671ed605b126f02762b7344d446a Mon Sep 17 00:00:00 2001 From: Derek Date: Thu, 15 Oct 2020 20:19:36 -0400 Subject: [PATCH] Modifies makefiles to support haskell stack tool, updates README --- Makefile | 20 +++++++++++++++++--- README.md | 20 ++++++++++++++++++++ src/Makefile | 7 +++++-- src/comp/Makefile | 5 +++++ src/vendor/htcl/Makefile | 5 +++++ 5 files changed, 52 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 4938b24c2..6d66dfebd 100644 --- a/Makefile +++ b/Makefile @@ -17,12 +17,26 @@ rem_inst: rem_build: rm -fr $(BUILDDIR) +.PHONY: rem_stack +rem_stack: + rm -f stack.yaml stack.yaml.lock + rm -fr $(TOP)/.stack-work + rm -fr $(TOP)/src/.stack-work + # ------------------------- .PHONY: install install: $(MAKE) -C src PREFIX=$(PREFIX) install +# ------------------------- + +.PHONY: stack-install +stack-install: + stack init --force + stack install regex-compat syb old-time split + -$(MAKE) -C src PREFIX=$(PREFIX) NO_DEPS_CHECKS=yes USING_STACK=yes install + # In the future, this will be much more expansive, and run the actual test # suite once it's open sourced. # @@ -33,12 +47,12 @@ install: check: @(export PATH=$(PREFIX)/bin:$(PATH); $(MAKE) -C examples/smoke_test smoke_test) + # ------------------------- -clean: rem_inst rem_build +clean: rem_inst rem_build -$(MAKE) -C src clean -full_clean: rem_inst rem_build +full_clean: rem_inst rem_build rem_stack -$(MAKE) -C src full_clean -# ------------------------- diff --git a/README.md b/README.md index 1de159909..d67098cb1 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,10 @@ The core of BSC is written in Haskell, with some libraries in C/C++. ### Install the Haskell compiler (GHC) +Note: *If you prefer to build the Bluespec toolchain with the Haskell +Stack project tool then skip down to the Additional Requirements +section* + You will need the standard Haskell compiler `ghc` which is available for Linux, macOS and Windows, along with some additional Haskell libraries. These are available as standard packages in most Linux distributions. For example, on @@ -134,6 +138,7 @@ Beyond that, any version up to 8.10.1 (the latest at the time of writing) will work, since the source code has been written with extensive preprocessor macros to support every minor release since. + ### Additional requirements For building and using the Bluespec Tcl shell (`bluetcl`), @@ -185,6 +190,9 @@ the submodules later with a separate command: ### Build and test the toolchain +Note: *The stack build tool can be used to avoid installing ghc +system wide, see the next section for more details.* + At the root of the repository: $ make all @@ -208,6 +216,18 @@ An unoptimized, debug, or profiling build can be done using one of: For more extensive testing, see the [bsc-testsuite] repository. +### Installing with the Haskell Stack project management tool + +If you do not yet have the stack tool, then follow these instructions +to install it. + +https://docs.haskellstack.org/en/stabcle/README/ + +Once stack is installed, build and install the Bluespec toolchain: + + $ make stack-install + + #### Choosing a Verilog simulator The Makefile in `examples/smoke_test` shows how you can point the default diff --git a/src/Makefile b/src/Makefile index 1daeb3aa0..2e61bb024 100644 --- a/src/Makefile +++ b/src/Makefile @@ -43,13 +43,16 @@ endif # NO_DEPS_CHECKS .PHONY: all all: install + +USING_STACK=no + .PHONY: install clean full_clean install clean full_clean: $(MAKE) -C vendor/stp PREFIX=$(PREFIX) $@ $(MAKE) -C vendor/yices PREFIX=$(PREFIX) $@ - $(MAKE) -C vendor/htcl PREFIX=$(PREFIX) $@ + $(MAKE) -C vendor/htcl PREFIX=$(PREFIX) USING_STACK=$(USING_STACK) $@ # we need to build targets from here sequentially, as they operate in the same workspace - $(MAKE) -C comp -j1 PREFIX=$(PREFIX) $@ + $(MAKE) -C comp -j1 PREFIX=$(PREFIX) USING_STACK=$(USING_STACK) $@ $(MAKE) -C Libraries PREFIX=$(PREFIX) $@ $(MAKE) -C exec PREFIX=$(PREFIX) $@ $(MAKE) -C VPI PREFIX=$(PREFIX) $@ diff --git a/src/comp/Makefile b/src/comp/Makefile index 3795829fe..db61be1a4 100644 --- a/src/comp/Makefile +++ b/src/comp/Makefile @@ -81,7 +81,12 @@ TCL_LIB_FLAGS = -ltcl$(TCL_VER) # ----- # GHC +ifeq ($(USING_STACK),yes) +GHC ?= stack ghc -- +else GHC ?= ghc +endif + GHCJOBS ?= 1 GHCVERSION=$(shell $(GHC) --version | head -1 | egrep -o "[0-9]+\.[0-9]+\.[0-9]" ) diff --git a/src/vendor/htcl/Makefile b/src/vendor/htcl/Makefile index a4da686a8..1ce43c7cf 100644 --- a/src/vendor/htcl/Makefile +++ b/src/vendor/htcl/Makefile @@ -1,5 +1,10 @@ GHCFLAGS += -Wall $(shell pkg-config --silence-errors --cflags-only-I tcl || echo -I/usr/include/tcl) + +ifeq ($(USING_STACK),yes) +GHC ?= stack ghc -- +else GHC ?= ghc +endif # We use GHC to compile this, so it has the proper RTS includes %.o: %.c