0377f327cb4207025e4aaff27460162c68cbc56f
[dev-env-setup.git] / ghdl-install
1 #!/bin/bash
2 # really this is covered by hdl-tools-yosys already, it's best to
3 # use that (and install yosys at the same time, you'll need it anyway)
4 if [ "$EUID" -ne 0 ]
5 then echo "Please run as root using 'sudo bash'"
6 exit
7 fi
8
9 apt-get update -y
10 apt-get install -y git gnat gcc g++ make file texinfo zlib1g-dev
11
12 # change into $SUDO_USER home directory
13 cd /home/$SUDO_USER
14 mkdir -p src/ghdl
15 cd src/ghdl
16
17 git clone https://github.com/ghdl/ghdl.git
18 wget https://ftp.gnu.org/gnu/gmp/gmp-6.2.1.tar.xz
19 wget https://ftp.gnu.org/gnu/mpc/mpc-1.2.1.tar.gz
20 wget https://www.mpfr.org/mpfr-4.1.0/mpfr-4.1.0.tar.xz
21 wget https://gcc.gnu.org/pub/gcc/infrastructure/isl-0.18.tar.bz2
22 wget https://ftp.gnu.org/gnu/gcc/gcc-10.3.0/gcc-10.3.0.tar.xz
23
24 tar -xf gcc-10.3.0.tar.xz
25 cd gcc-10.3.0
26 tar -xf ../gmp-6.2.1.tar.xz
27 mv gmp-6.2.1 gmp
28 tar -xf ../mpc-1.2.1.tar.gz
29 mv mpc-1.2.1 mpc
30 tar -xf ../mpfr-4.1.0.tar.xz
31 mv mpfr-4.1.0 mpfr
32 tar -xf ../isl-0.18.tar.bz2
33 mv isl-0.18 isl
34 cd ..
35
36 # see hdl-tools-yosys, a *very* specific version is needed to work
37 # with yosys and the yosys-ghdl-plugin
38 cd ghdl
39 #git checkout v1.0.0
40 git checkout 263c843ed49f59cb4cc3038bafcac2b9238ebad4
41 mkdir build
42 cd build
43 ../configure --with-gcc=../../gcc-10.3.0 --prefix=/usr/local/ghdl
44 make copy-sources
45 mkdir gcc-objs; cd gcc-objs
46 ../../../gcc-10.3.0/configure --prefix=/usr/local/ghdl \
47 --enable-languages=c,vhdl --disable-bootstrap --disable-lto \
48 --disable-multilib --disable-libssp --disable-libgomp \
49 --disable-libquadmath --enable-default-pie
50 make -j$(nproc)
51 make install
52 cd ..
53 make ghdllib
54 make install
55
56 cd /home/$SUDO_USER/src/ghdl
57 chown -R $SUDO_USER .
58 chgrp -R $SUDO_USER .
59