Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makefiles now support haskell stack #267

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#
Expand All @@ -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

# -------------------------
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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`),
Expand Down Expand Up @@ -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
Expand 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
Expand Down
7 changes: 5 additions & 2 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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) $@
Expand Down
5 changes: 5 additions & 0 deletions src/comp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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]" )
Expand Down
5 changes: 5 additions & 0 deletions src/vendor/htcl/Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down