-
Notifications
You must be signed in to change notification settings - Fork 1
/
yogh.sh
executable file
·80 lines (65 loc) · 2.4 KB
/
yogh.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/bash
# Build yosys + GHDL synthesizer fully open source toolchain for FPGA bitstreams
# Plus icestorm (bitstream packager and installer for Lattice ICE40)
# build prerequisites for ghdlsynth:
# gnat-8 or newer (https://www.adacore.com/download)
# libffi-dev and tcl-dev (probably in your distro repo).
# It'll use libreadline-dev if present.
# build prerequisites for icestorm: libftdi-dev
# build prerequisites for nextpnr: libboost{,thread,system,iostreams,program-options,filesystem}-dev libeigen3-dev
# We use nproc to autodetect parallism, use "taskset 1 COMMAND..." to thwart
# where to install to
[ -z "$PREFIX" ] && PREFIX=~/yogh
echo "Installing into $PREFIX"
export PATH="$PREFIX/bin:$PATH"
# In this toolchain, ghdl = clang, ghdlsynth-beta = llvm, yosys = binutils,
# and yosys internally uses abc (optimizer plumbing).
#
# We need all 4 to produce a bitstream.
# Check out or update the 3 repositories
for i in ghdl/ghdl tgingold/ghdlsynth-beta YosysHQ/{yosys,abc,nextpnr,icestorm}
do
if ! cd $(basename $i) 2>/dev/null
then
git clone https://github.com/$i || exit 1
continue;
fi
[ -z "$NOCLEAN" ] && git clean -fdx
if [ -z "$NONET" ]
then
git pull || exit 1
fi
cd ..
done
# Build each repo
# todo: yosys does a "git clone" of ABC in the middle of the build,
# integrate that into the above git pull stuff and disable in the makefile
# so we can build it without network access.
cd yosys || exit 1
# If you haven't got clang, use gcc
! which clang && X=CONFIG=gcc
# Don't use libreadline-dev when not installed. Note: not cross-compile aware.
[ ! -e /usr/include/readline/readline.h ] && X="$X ENABLE_READLINE=0"
# Use the optimizer revision the yosys guys regression tested
[ ! -e abc ] && ln -sf ../abc abc
make PREFIX="$PREFIX" all install -j $(nproc) $X ABCREV=default ABCPULL=0 &&
cd .. || exit 1
cd ghdl &&
./configure --enable-libghdl --enable-synth --prefix="$PREFIX" &&
make all install -j $(nproc)
cd .. || exit 1
cd ghdlsynth-beta &&
make all install -j $(nproc) &&
cd .. || exit 1
cd icestorm &&
make PREFIX="$PREFIX" STATIC=1 all -j $(nproc) &&
# The build is SMP safe but the install is not for some reason
make PREFIX="$PREFIX" install &&
cd .. || exit 1
cd nextpnr &&
cmake . -DARCH=ice40 -DCMAKE_INSTALL_PREFIX="$PREFIX" \
-DICESTORM_INSTALL_PREFIX="$PREFIX" -DBUILD_GUI=OFF -DBUILD_PYTHON=OFF \
-DSTATIC_BUILD=ON &&
make -j $(nproc) &&
make install &&
cd .. || exit 1