6. Script and configuration index¶
6.1. build_tools¶
6.1.1. install_build_essentials.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 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Jun. 23 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# require sudo
if [[ $UID != 0 ]]; then
echo "Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# exit when any command fails
set -e
# required tools
TOOLS="build-essential git clang gcc meson ninja-build g++ python3-dev \
openjdk-8-jdk scala sbt make"
# install and upgrade tools
echo "deb https://dl.bintray.com/sbt/debian /" | sudo tee -a /etc/apt/sources.list.d/sbt.list
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 642AC823
apt-get update
apt-get install -y $TOOLS
apt-get install --only-upgrade -y $TOOLS
|
6.1.2. install_everything.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 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Jul. 23 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# constants
RED='\033[1;31m'
NC='\033[0m'
CONFIG="config.cfg"
BUILDFOLDER="build_and_install_quantumrisc_tools"
VERSIONFILE="installed_version.txt"
SUCCESS_FILE_TOOLS="latest_success_tools.txt"
SUCCESS_FILE_PROJECTS="latest_success_projects.txt"
DIALOUT_USERS=default
VERSION_FILE_USERS=default
CLEANUP=false
VERBOSE=false
SCRIPTS="YOSYS TRELLIS ICESTORM NEXTPNR_ICE40 NEXTPNR_ECP5 UJPROG OPENOCD \
OPENOCD_VEXRISCV VERILATOR GTKTERM GTKWAVE RISCV_NEWLIB RISCV_LINUX"
PROJECTS="PQRISCV_VEXRISCV DEMO_PROJECT_ICE40"
# parse arguments
USAGE="$(basename "$0") [-c] [-h] [-o] [-p] [-v] [-d dir] -- Build and install QuantumRisc toolchain.
where:
-c cleanup, delete everything after successful execution
-h show this help text
-o space seperated list of users who shall be added to dialout
(default: every logged in user)
-p space seperated list of users for whom the version file shall
be copied to the desktop (default: every logged in user)
-v be verbose (spams the terminal)
-d dir build files in \"dir\" (default: ${BUILDFOLDER})"
while getopts ':chopvd:' OPTION; do
case "$OPTION" in
c) echo "-c set: Cleaning up everything in the end"
CLEANUP=true
;;
d) echo "-d set: Using folder $OPTARG"
BUILDFOLDER="$OPTARG"
;;
h) echo "$USAGE"
exit
;;
o) echo "-o set: Adding users \"${OPTARG}\" to dialout"
DIALOUT_USERS="$OPTARG"
;;
p) echo "-o set: Copying version file to desktop of \"${OPTARG}\""
VERSION_FILE_USERS="$OPTARG"
;;
v) echo "-v set: Being verbose"
VERBOSE=true
;;
:) echo -e "${RED}ERROR: missing argument for -${OPTARG}\n${NC}" >&2
echo "$USAGE" >&2
exit 1
;;
\?) echo -e "${RED}ERROR: illegal option: -${OPTARG}\n${NC}" >&2
echo "$USAGE" >&2
exit 1
;;
esac
done
shift $((OPTIND - 1))
# Prints only if verbose is set
function echo_verbose {
if [ $VERBOSE = true ]; then
echo "$1"
fi
}
# Prints only errors from executed commands if verbose is set
# Parameter $1: Command to execute
# Parameter $2: Path to error file
function exec_verbose {
if [ $VERBOSE = false ]; then
$1 > /dev/null 2>> "$2"
else
$1 2>> "$2"
fi
}
# This function does checkout the correct version and return the commit hash or tag name
# Parameter 1: Branch name, commit hash, tag or one of the special keywords default/latest/stable
# Parameter 2: Return variable name (commit hash or tag name)
function select_and_get_project_version {
# Stable selected: Choose latest tag if available, otherwise use default branch
if [ "$1" == "stable" ]; then
local L_TAGLIST=`git rev-list --tags --max-count=1`
# tags found?
if [ -n "$L_TAGLIST" ]; then
local L_COMMIT_HASH="`git describe --tags $L_TAGLIST`"
git checkout --recurse-submodules "$L_COMMIT_HASH"
else
git checkout --recurse-submodules $(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')
local L_COMMIT_HASH="$(git rev-parse HEAD)"
>&2 echo -e "${RED}WARNING: No git tags found, using default branch${NC}"
fi
else
# Either checkout defaut/stable branch or use custom commit hash, tag or branch name
if [ "$1" == "default" ] || [ "$1" == "latest" ]; then
git checkout --recurse-submodules $(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')
local L_COMMIT_HASH="$(git rev-parse HEAD)"
else
# Check if $1 contains a valid tag and use it as the version if it does
git checkout --recurse-submodules "$1"
local L_COMMIT_HASH="$(git rev-parse HEAD)"
for CUR_TAG in `git tag --list`; do
if [ "$CUR_TAG" == "$1" ]; then
L_COMMIT_HASH="$1"
break
fi
done
fi
fi
# Apply return value
eval "$2=\"$L_COMMIT_HASH\""
}
# Read latest executed tool/project/etc.
# Parameter $1: tool/project/etc. list
# Parameter $2: success file
# Parameter $3: string containing list element type (tool/project/etc.)
# Parameter $4: Return variable name
function get_latest {
if [ ! -f "$2" ]; then
return 0
fi
local LATEST_SCRIPT=`cat $2`
local SCRIPTS_ADAPTED=`echo "$1" | sed "s/.*${LATEST_SCRIPT} //"`
if [ "$SCRIPTS_ADAPTED" == "$1" ]; then
local AT_END=true
echo -e "\nThe script detected a checkpoint after the last ${3}. This means that all ${3}s already have been checked and installed if configured that way. Do you want to check every ${3} and install them again if configured that way (y/n)?"
else
local AT_END=false
echo -e "\nThe script detected a checkpoint. Do you want to install every ${3} from the checkpoint onwards (y) if configured that way or do you want to start over from the beginning (n)?"
echo "${3}s yet to be check for installation after the checkpoint: $SCRIPTS_ADAPTED"
fi
local DECISION="z"
while [ $DECISION != "n" ] && [ $DECISION != "y" ]; do
read -p "Decision(y/n): " DECISION
if [ -z $DECISION ]; then
DECISION="z"
fi
done
echo -e "\n"
if [ $DECISION == "n" ]; then
if [ $AT_END = true ]; then
eval "$4=\"\""
fi
else
eval "$4=\"$SCRIPTS_ADAPTED\""
fi
}
# Process riscv_gnu_toolchain script parameters
# Parameter $1: Script name
# Parameter $2: Variable to store the parameters in
function parameters_tool_riscv {
# set -n flag
if [ "${1:6}" == "NEWLIB" ]; then
eval "$2=\"${!2} -n\""
fi
# Set "e" parameter
if [ "$(eval "echo $`echo $1`_EXTEND_PATH")" = true ]; then
eval "$2=\"${!2} -e\""
fi
# set "u" parameter
local L_BUILD_USER="$(eval "echo $`echo $1`_USER")"
if [ -n "$L_BUILD_USER" ] && [ "$L_BUILD_USER" != "default" ]; then
eval "$2=\"${!2} -u \"$L_BUILD_USER\"\""
fi
# set "p" parameter
local L_BUILD_INSTALL_PATH="$(eval "echo $`echo $1`_INSTALL_PATH")"
if [ -n "$L_BUILD_INSTALL_PATH" ] && [ "$L_BUILD_INSTALL_PATH" != "default" ]; then
eval "$2=\"${!2} -p \"$L_BUILD_INSTALL_PATH\"\""
fi
}
# Process nextpnr script parameters
# Parameter $1: Script name
# Parameter $2: Variable to store the parameters in
function parameters_tool_nextpnr {
# set -e flag
if [ "${1:8}" == "ECP5" ]; then
eval "$2=\"${!2} -e\""
fi
local L_BUILD_CHIPDB="$(eval "echo $`echo $1`_CHIPDB_PATH")"
if [ -n "$L_BUILD_CHIPDB" ] && [ "$L_BUILD_CHIPDB" != "default" ]; then
eval "$2=\"${!2} -l \"$L_BUILD_CHIPDB\"\""
fi
}
# Process common script parameters
# Parameter $1: Script name
# Parameter $2: Variable to store the parameters in
function parameters_tool {
# Set "i" parameter
if [ "$(eval "echo $`echo $1`_INSTALL")" = true ]; then
eval "$2=\"${!2} -i $(eval "echo $`echo $1`_INSTALL_PATH")\""
fi
# Set "c" parameter
if [ "$(eval "echo $`echo $1`_CLEANUP")" = true ]; then
eval "$2=\"${!2} -c\""
fi
# Set "d" parameter
local L_BUILD_DIR="$(eval "echo $`echo $1`_DIR")"
if [ -n "$L_BUILD_DIR" ] && [ "$L_BUILD_DIR" != "default" ]; then
eval "$2=\"${!2} -d \"$L_BUILD_DIR\"\""
fi
# Set "t" parameter
local L_BUILD_TAG="$(eval "echo $`echo $1`_TAG")"
if [ -n "$L_BUILD_TAG" ] && [ "$L_BUILD_TAG" != "default" ]; then
eval "$2=\"${!2} -t \"$L_BUILD_TAG\"\""
fi
# Set "b" for Yosys only
if [ $1 == "YOSYS" ]; then
local L_BUILD_COMPILER="$(eval "echo $`echo $1`_COMPILER")"
if [ -n "$L_BUILD_COMPILER" ]; then
eval "$2=\"${!2} -b \"$L_BUILD_COMPILER\"\""
fi
fi
# Append special parameters for gnu-riscv-toolchain and nextpnr variants
if [ "${1::5}" == "RISCV" ]; then
parameters_tool_riscv "$1" "$2"
elif [ "${1::7}" == "NEXTPNR" ]; then
parameters_tool_nextpnr "$1" "$2"
fi
}
# Copies the project to documents and creates a symbolic link if desired
# Parameter $1: Project name
# Parameter $2: User name
# Parameter $3: Create symbolic link (bool)
function install_project_for_user {
# Get user and home directory
local L_USER_HOME=$(getent passwd "$2" | cut -d: -f6)
# User not found
if [ -z "$L_USER_HOME" ]; then
echo -e "${RED}ERROR: User ${L_USER} does not exist (home directory not found).${NC}"
exit 1;
fi
# Lookup Documents and Desktop and create if not existant
local L_USER_DOCUMENTS="${L_USER_HOME}/Documents"
local L_USER_DESKTOP="${L_USER_HOME}/Desktop"
# TODO: Improve for multiple languages (currently only en support)
if [ ! -d "${L_USER_DOCUMENTS}" ]; then
mkdir $L_USER_DOCUMENTS
chown -R ${L_USER}:$L_USER $L_USER_DOCUMENTS
fi
if [ ! -d "${L_USER_DESKTOP}" ]; then
mkdir $L_USER_DESKTOP
chown -R ${L_USER}:$L_USER $L_USER_DESKTOP
fi
# Copy project to Documents
cp -r "$1" "$L_USER_DOCUMENTS"
chown -R ${L_USER}:$L_USER "${L_USER_DOCUMENTS}/$1"
# Create symbolic link if desired
if [ "$3" = true ]; then
ln -s "${L_USER_DOCUMENTS}/$1" "${L_USER_DESKTOP}/$1"
fi
}
# Install project ("configure projects" section in config.cfg)
# Parameter $1: Project name
function install_project {
if [ "${!1}" = false ]; then
return 0
fi
local L_NAME_LOWER=`echo "$1" | tr [A-Z] [a-z]`
# Clone
if [ ! -d "$L_NAME_LOWER" ]; then
exec_verbose "git clone --recurse-submodules ""$(eval "echo $`echo $1`_URL")"" ""$L_NAME_LOWER""" "$ERROR_FILE"
fi
# Checkout specified version
local L_TAG="$(eval "echo $`echo $1`_TAG")"
if [ "$L_TAG" != "default" ]; then
pushd $L_NAME_LOWER > /dev/null
exec_verbose "select_and_get_project_version ""$L_TAG"" ""L_COMMIT_HASH""" "$ERROR_FILE"
popd > /dev/null
fi
local L_LINK="$(eval "echo $`echo $1`_LINK_TO_DESKTOP")"
# Get users to install the projects for
local L_USERLIST="$(eval "echo $`echo $1`_USER")"
if [ "$L_USERLIST" == "default" ]; then
for L_USER in `who | cut -d: -f1`; do
install_project_for_user "$L_NAME_LOWER" "$L_USER" $L_LINK
done
else
for L_USER in "$L_USERLIST"; do
install_project_for_user "$L_NAME_LOWER" "$L_USER" $L_LINK
done
fi
rm -rf "$L_NAME_LOWER"
}
# Moves script folder into build folder and returns script path
# Parameter $1: Script name
# Parameter $2: Variable to store the script path for requirements script in
# Parameter $3: Variable to store the script path for installation script in
function find_script {
if [ "${SCRIPT::5}" == "RISCV" ]; then
cp -r ../riscv_tools .
eval "$2=\"$(pwd -P)/riscv_tools/install_riscv_essentials.sh\""
eval "$3=\"$(pwd -P)/riscv_tools/install_riscv.sh\""
cp "$(pwd -P)/riscv_tools/versions.cfg" .
elif [ "${SCRIPT::7}" == "NEXTPNR" ]; then
cp -r ../nextpnr .
eval "$2=\"$(pwd -P)/nextpnr/install_nextpnr_essentials.sh\""
eval "$3=\"$(pwd -P)/nextpnr/install_nextpnr.sh\""
else
local L_NAME_LOWER=`echo "$1" | tr [A-Z] [a-z]`
cp -r ../${L_NAME_LOWER} .
eval "$2=\"$(pwd -P)/${L_NAME_LOWER}/install_${L_NAME_LOWER}_essentials.sh\""
eval "$3=\"$(pwd -P)/${L_NAME_LOWER}/install_${L_NAME_LOWER}.sh\""
# TODO: Extend to automatically find all configuration files
if [ -f "$(pwd -P)/${L_NAME_LOWER}/versions.cfg" ]; then
cp "$(pwd -P)/${L_NAME_LOWER}/versions.cfg" .
fi
fi
}
# Copies version file $1 to the desktop of the users specified in $2
# Parameter $1: Version file path
# Parameter $2: User list
function copy_version_file {
if [ ! -f "$1" ]; then
return
fi
for L_USER in "$2"; do
local L_VERSION_USER_DESKTOP="$(getent passwd "$L_USER" | cut -d: -f6)/Desktop"
# TODO: add multiple language support
if [ ! -d "$L_VERSION_USER_DESKTOP" ]; then
mkdir "$L_VERSION_USER_DESKTOP"
fi
cp "$1" "$L_VERSION_USER_DESKTOP"
done
}
# exit when any command fails
set -e
# require sudo
if [[ $UID != 0 ]]; then
echo -e "${RED}Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# Read config
echo_verbose "Loading configuration file"
source config.cfg
# create and cd into buildfolder
if [ ! -d $BUILDFOLDER ]; then
echo_verbose "Creating build folder \"${BUILDFOLDER}\""
mkdir $BUILDFOLDER
fi
cp -r install_build_essentials.sh $BUILDFOLDER
pushd $BUILDFOLDER > /dev/null
ERROR_FILE="$(pwd -P)/errors.log"
# Potentially create and empty errors.log file
echo '' > errors.log
echo "Executing: ./install_build_essentials.sh"
exec_verbose "./install_build_essentials.sh" "$ERROR_FILE"
# Cleanup files if the programm was shutdown unexpectedly
# trap 'echo -e "${RED}ERROR: Script was terminated unexpectedly, cleaning up files..." && pushd -0 > /dev/null && rm -rf $BUILDFOLDER' INT TERM
echo -e "\n--- Installing tools ---\n"
get_latest "$SCRIPTS" "$SUCCESS_FILE_TOOLS" "tool" "SCRIPTS"
# Process scripts
for SCRIPT in $SCRIPTS; do
# Should the tool be build/installed?
if [ "${!SCRIPT}" = true ]; then
echo "Installing $SCRIPT"
PARAMETERS=""
parameters_tool "$SCRIPT" "PARAMETERS"
COMMAND_INSTALL_ESSENTIALS=""
COMMAND_INSTALL=""
find_script "$SCRIPT" "COMMAND_INSTALL_ESSENTIALS" "COMMAND_INSTALL"
COMMAND_INSTALL="${COMMAND_INSTALL} $PARAMETERS"
echo "Executing: $COMMAND_INSTALL_ESSENTIALS"
exec_verbose "$COMMAND_INSTALL_ESSENTIALS" "$ERROR_FILE"
echo "Executing: $COMMAND_INSTALL"
exec_verbose "$COMMAND_INSTALL" "$ERROR_FILE"
echo "$SCRIPT" > $SUCCESS_FILE_TOOLS
fi
done
echo -e "\n--- Setting up projects ---\n"
get_latest "$PROJECTS" "$SUCCESS_FILE_PROJECTS" "project" "PROJECTS"
for PROJECT in $PROJECTS; do
if [ "${!PROJECT}" = true ]; then
echo "Setting up $PROJECT"
install_project "$PROJECT"
echo "$PROJECT" > $SUCCESS_FILE_PROJECTS
fi
done
# secure version file before it gets deleted (-c)
pushd -0 > /dev/null
if [ -f "${BUILDFOLDER}/${VERSIONFILE}" ]; then
cp "${BUILDFOLDER}/${VERSIONFILE}" .
fi
# add users to dialout
if [ "$DIALOUT_USERS" == "default" ]; then
for DIALOUT_USER in `who | cut -d: -f1`; do
usermod -a -G dialout "$DIALOUT_USER"
done
else
for DIALOUT_USER in "$DIALOUT_USERS"; do
usermod -a -G dialout "$DIALOUT_USER"
done
fi
# copy version file to users desktop
if [ "$VERSION_FILE_USERS" == "default" ]; then
copy_version_file "$(pwd -P)/${VERSIONFILE}" `who | cut -d: -f1`
else
copy_version_file "$(pwd -P)/${VERSIONFILE}" "$VERSION_FILE_USERS"
fi
# cleanup
if [ $CLEANUP = true ]; then
echo_verbose "Cleaning up files"
rm -rf $BUILDFOLDER
fi
echo "Script finished successfully."
|
6.1.3. config.cfg¶
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 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 | ### Configure tools
## Yosys
# Build and (if desired) install Yosys?
YOSYS=true
# Build AND install yosys?
YOSYS_INSTALL=true
# Install path (default = default path)
YOSYS_INSTALL_PATH=default
# Remove build directory after successful install?
YOSYS_CLEANUP=true
# Folder name in which the project is built
YOSYS_DIR=default
# Compiler (gcc or clang)
YOSYS_COMPILER=clang
# Specify project version to pull (default/latest, stable, tag, branch, hash)
YOSYS_TAG=default
## Project Trellis
# Build and (if desired) install Project Trellis?
TRELLIS=true
# Build AND install Project Trellis?
TRELLIS_INSTALL=true
# Install path (default = default path)
TRELLIS_INSTALL_PATH=default
# Remove build directory after successful install?
TRELLIS_CLEANUP=true
# Folder name in which the project is built
TRELLIS_DIR=default
# Specify project version to pull (default/latest, stable, tag, branch, hash)
TRELLIS_TAG=default
## Icestorm
# Build and (if desired) install Icestorm?
ICESTORM=true
# Build AND install Icestorm?
ICESTORM_INSTALL=true
# Install path (default = default path)
ICESTORM_INSTALL_PATH=default
# Remove build directory after successful install?
ICESTORM_CLEANUP=true
# Folder name in which the project is built
ICESTORM_DIR=default
# Specify project version to pull (default/latest, stable, tag, branch, hash)
ICESTORM_TAG=default
## NextPNR-Ice40
# Build and (if desired) install NextPNR-ice40?
NEXTPNR_ICE40=true
# Build AND install NextPNR-ice40?
NEXTPNR_ICE40_INSTALL=true
# Install path (default = default path)
NEXTPNR_ICE40_INSTALL_PATH=default
# Remove build directory after successful install?
NEXTPNR_ICE40_CLEANUP=false
# Folder name in which the project is built
NEXTPNR_ICE40_DIR=default
# Specify project version to pull (default/latest, stable, tag, branch, hash)
NEXTPNR_ICE40_TAG=default
# Use chip dbs from the following path (default = fetch latest chip dbs)
NEXTPNR_ICE40_CHIPDB_PATH=default
## NextPNR-Ecp5
# Build and (if desired) install NextPNR-Ecp5?
NEXTPNR_ECP5=true
# Build AND install NextPNR-NextPNR-Ecp5?
NEXTPNR_ECP5_INSTALL=true
# Install path (default = default path)
NEXTPNR_ECP5_INSTALL_PATH=default
# Remove build directory after successful install?
NEXTPNR_ECP5_CLEANUP=true
# Folder name in which the project is built
NEXTPNR_ECP5_DIR=default
# Specify project version to pull (default/latest, stable, tag, branch, hash)
NEXTPNR_ECP5_TAG=default
# Use chip dbs from the following path (default = fetch latest chip dbs)
NEXTPNR_ECP5_CHIPDB_PATH=default
## Ujprog
# Build and (if desired) install Ujprog?
UJPROG=true
# Build AND install Ujprog?
UJPROG_INSTALL=true
# Install path (default = default path)
UJPROG_INSTALL_PATH=default
# Remove build directory after successful install?
UJPROG_CLEANUP=true
# Folder name in which the project is built
UJPROG_DIR=default
# Specify project version to pull (default/latest, stable, tag, branch, hash)
UJPROG_TAG=default
## OpenOCD
# Build and (if desired) install OpenOCD?
OPENOCD=true
# Build AND install OpenOCD?
OPENOCD_INSTALL=true
# Install path (default = default path)
OPENOCD_INSTALL_PATH=default
# Remove build directory after successful install?
OPENOCD_CLEANUP=true
# Folder name in which the project is built
OPENOCD_DIR=default
# Specify project version to pull (default/latest, stable, tag, branch, hash)
OPENOCD_TAG=default
## OpenOCD-VexRiscV
# Build and (if desired) install OpenOCD-VexRiscV?
OPENOCD_VEXRISCV=true
# Build AND install OpenOCD-VexRiscV?
OPENOCD_VEXRISCV_INSTALL=true
# Install path (default = default path)
OPENOCD_VEXRISCV_INSTALL_PATH=default
# Remove build directory after successful install?
OPENOCD_VEXRISCV_CLEANUP=true
# Folder name in which the project is built
OPENOCD_VEXRISCV_DIR=default
# Specify project version to pull (default/latest, stable, tag, branch, hash)
OPENOCD_VEXRISCV_TAG=default
## Verilator
# Build and (if desired) install Verilator?
VERILATOR=true
# Build AND install Verilator?
VERILATOR_INSTALL=true
# Install path (default = default path)
VERILATOR_INSTALL_PATH=default
# Remove build directory after successful install?
VERILATOR_CLEANUP=true
# Folder name in which the project is built
VERILATOR_DIR=default
# Specify project version to pull (default/latest, stable, tag, branch, hash)
VERILATOR_TAG=default
## GTKTerm
# Build and (if desired) install GTKTerm?
GTKTERM=true
# Build AND install GTKTerm?
GTKTERM_INSTALL=true
# Install path (default = default path)
GTKTERM_INSTALL_PATH=default
# Remove build directory after successful install?
GTKTERM_CLEANUP=true
# Folder name in which the project is built
GTKTERM_DIR=default
# Specify project version to pull (default/latest, stable, tag, branch, hash)
GTKTERM_TAG=default
## GTKWave
# Build and (if desired) install GTKWave?
GTKWAVE=true
# Build AND install GTKWave?
GTKWAVE_INSTALL=true
# Install path (default = default path)
GTKWAVE_INSTALL_PATH=default
# Remove build directory after successful install?
GTKWAVE_CLEANUP=true
# Folder name in which the project is built
GTKWAVE_DIR=default
# Specify project version to pull (default/latest, stable, tag, branch, hash)
GTKWAVE_TAG=default
## RiscV-GNU-Toolchain Newlib Multilib
# build and install RiscV-GNU-Toolchain?
RISCV_NEWLIB=true
# Remove build directory after successful install?
RISCV_NEWLIB_CLEANUP=false
# Folder name in which the project is built
RISCV_NEWLIB_DIR=default
# Specify project version to pull (default/latest, stable, tag, branch, hash)
# Note: You can specify the version of every single tool of this toolchain in
# ./riscv_tools/versions.cfg
RISCV_NEWLIB_TAG=default
# Extend PATH by RiscV-GNU-Toolchain path?
RISCV_NEWLIB_EXTEND_PATH=true
# Specify user to install the toolchain for (default = everybody)
# Note: this only makes sense if PATH is extended (RISCV_NEWLIB_EXTEND_PATH)
RISCV_NEWLIB_USER=default
# Specify install path (default: /opt/riscv)
RISCV_NEWLIB_INSTALL_PATH=default
## RiscV-GNU-Toolchain Linux Multilib
# build and install RiscV-GNU-Toolchain?
RISCV_LINUX=true
# Remove build directory after successful install?
RISCV_LINUX_CLEANUP=true
# Folder name in which the project is built
RISCV_LINUX_DIR=default
# Specify project version to pull (default/latest, stable, tag, branch, hash)
# Note: You can specify the version of every single tool of this toolchain in
# ./riscv_tools/versions.cfg
RISCV_LINUX_TAG=default
# Extend PATH by RiscV-GNU-Toolchain path?
RISCV_LINUX_EXTEND_PATH=true
# Specify user to install the toolchain for (default = everybody)
# Note: this only makes sense if PATH is extended (RISCV_LINUX_EXTEND_PATH)
RISCV_LINUX_USER=default
# Specify install path (default: /opt/riscv)
RISCV_LINUX_INSTALL_PATH=default
### Configure projects
## Pqvexriscv project
# Download git repostiory
PQRISCV_VEXRISCV=false
# Git URL
PQRISCV_VEXRISCV_URL="https://github.com/mupq/pqriscv-vexriscv.git"
# Specify project version to pull (default/latest, stable, tag, branch, hash)
PQRISCV_VEXRISCV_TAG=default
# Space seperated list of users (in quotation marks) to install the project for
# in /home/$user/Documents. default = all logged in users
PQRISCV_VEXRISCV_USER=default
# Symbolic link to /home/$user/Desktop
PQRISCV_VEXRISCV_LINK_TO_DESKTOP=true
## Hello world demo application
# Download git repostiory
DEMO_PROJECT_ICE40=false
# Git URL
DEMO_PROJECT_ICE40_URL="https://github.com/ThorKn/icebreaker-vexriscv-helloworld.git"
# Specify project version to pull (default/latest, stable, tag, branch, hash)
DEMO_PROJECT_ICE40_TAG=default
# Space seperated list of users (in quotation marks) to install the project for
# in /home/$user/Documents. default = all logged in users
DEMO_PROJECT_ICE40_USER=default
# Symbolic link to /home/$user/Desktop
DEMO_PROJECT_ICE40_LINK_TO_DESKTOP=true
|
6.2. openocd_vexriscv¶
6.2.1. install_openocd_vexriscv.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 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Jun. 25 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# constants
RED='\033[1;31m'
NC='\033[0m'
REPO="https://github.com/SpinalHDL/openocd_riscv.git"
PROJ="openocd_vexriscv"
BUILDFOLDER="build_and_install_openocd_vexriscv"
VERSIONFILE="installed_version.txt"
TAG="latest"
INSTALL=false
INSTALL_PREFIX="default"
CLEANUP=false
CONFIGURE_STRING="--prefix=/usr/local --program-suffix=-vexriscv
--datarootdir=/usr/local/share/vexriscv --enable-maintainer-mode
--disable-werror --enable-ft232r --enable-ftdi --enable-jtag_vpi"
# parse arguments
USAGE="$(basename "$0") [-h] [-c] [-d dir] [-i path] [-t tag] -- Clone latested tagged ${PROJ} version and build it. Optionally select the build directory and version, install binaries and cleanup setup files.
where:
-h show this help text
-c cleanup project
-d dir build files in \"dir\" (default: ${BUILDFOLDER})
-i path install binaries to path (use \"default\" to use default path)
-t tag specify version (git tag or commit hash) to pull (default: Latest tag)"
while getopts ':hi:cd:t:' OPTION; do
case $OPTION in
i) INSTALL=true
# Adjust configure string
if [ "$OPTARG" != 'default' ]; then
CONFIGURE_STRING="${CONFIGURE_STRING//"/usr/local"/"$OPTARG"}"
fi
# INSTALL_PREFIX="$OPTARG"
echo "-i set: Installing built binaries to $OPTARG"
;;
esac
done
OPTIND=1
while getopts ':hi:cd:t:' OPTION; do
case "$OPTION" in
h) echo "$USAGE"
exit
;;
c) if [ $INSTALL = false ]; then
>&2 echo -e "${RED}ERROR: -c only makes sense if the built binaries were installed before (-i)"
exit 1
fi
CLEANUP=true
echo "-c set: Removing build directory"
;;
d) echo "-d set: Using folder $OPTARG"
BUILDFOLDER="$OPTARG"
;;
t) echo "-t set: Using version $OPTARG"
TAG="$OPTARG"
;;
:) echo -e "${RED}ERROR: missing argument for -${OPTARG}\n${NC}" >&2
echo "$USAGE" >&2
exit 1
;;
\?) echo -e "${RED}ERROR: illegal option: -${OPTARG}\n${NC}" >&2
echo "$USAGE" >&2
exit 1
;;
esac
done
shift "$((OPTIND - 1))"
# This function does checkout the correct version and return the commit hash or tag name
# Parameter 1: Branch name, commit hash, tag or one of the special keywords default/latest/stable
# Parameter 2: Return variable name (commit hash or tag name)
function select_and_get_project_version {
# Stable selected: Choose latest tag if available, otherwise use default branch
if [ "$1" == "stable" ]; then
local L_TAGLIST=`git rev-list --tags --max-count=1`
# tags found?
if [ -n "$L_TAGLIST" ]; then
local L_COMMIT_HASH="`git describe --tags $L_TAGLIST`"
git checkout --recurse-submodules "$L_COMMIT_HASH"
else
git checkout --recurse-submodules $(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')
local L_COMMIT_HASH="$(git rev-parse HEAD)"
>&2 echo -e "${RED}WARNING: No git tags found, using default branch${NC}"
fi
else
# Either checkout defaut/stable branch or use custom commit hash, tag or branch name
if [ "$1" == "default" ] || [ "$1" == "latest" ]; then
git checkout --recurse-submodules $(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')
local L_COMMIT_HASH="$(git rev-parse HEAD)"
else
# Check if $1 contains a valid tag and use it as the version if it does
git checkout --recurse-submodules "$1"
local L_COMMIT_HASH="$(git rev-parse HEAD)"
for CUR_TAG in `git tag --list`; do
if [ "$CUR_TAG" == "$1" ]; then
L_COMMIT_HASH="$1"
break
fi
done
fi
fi
# Apply return value
eval "$2=\"$L_COMMIT_HASH\""
}
# exit when any command fails
set -e
# require sudo
if [[ $UID != 0 ]]; then
echo -e "${RED}Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# Cleanup files if the programm was shutdown unexpectedly
trap 'echo -e "${RED}ERROR: Script was terminated unexpectedly, cleaning up files..." && pushd -0 > /dev/null && rm -rf $BUILDFOLDER' INT TERM
# fetch specified version
if [ ! -d $BUILDFOLDER ]; then
mkdir $BUILDFOLDER
fi
pushd $BUILDFOLDER > /dev/null
if [ ! -d "${PROJ%%/*}" ]; then
git clone --recursive "$REPO" "${PROJ%%/*}"
fi
pushd $PROJ > /dev/null
select_and_get_project_version "$TAG" "COMMIT_HASH"
# build and install if wanted
./bootstrap
./configure $CONFIGURE_STRING
make -j$(nproc)
if [ $INSTALL = true ]; then
make install
fi
# return to first folder and store version
pushd -0 > /dev/null
echo "${PROJ##*/}: $COMMIT_HASH" >> "$VERSIONFILE"
# cleanup if wanted
if [ $CLEANUP = true ]; then
rm -rf $BUILDFOLDER
fi
|
6.2.2. install_openocd_vexriscv_essentials.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 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Jun. 25 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# require sudo
if [[ $UID != 0 ]]; then
echo "Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# exit when any command fails
set -e
# required tools
TOOLS="build-essential git gcc make libtool pkg-config autoconf automake \
texinfo libftdi-dev libusb-1.0-0-dev libyaml-dev"
# install and upgrade tools
apt-get update
apt-get install -y $TOOLS
apt-get install --only-upgrade -y $TOOLS
|
6.3. gtkwave¶
6.3.1. install_gtkwave.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 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Jun. 25 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# constants
RED='\033[1;31m'
NC='\033[0m'
REPO="https://github.com/gtkwave/gtkwave.git"
PROJ="gtkwave/gtkwave3-gtk3"
BUILDFOLDER="build_and_install_gtkwave"
VERSIONFILE="installed_version.txt"
TAG="latest"
INSTALL=false
INSTALL_PREFIX="default"
CLEANUP=false
# parse arguments
USAGE="$(basename "$0") [-h] [-c] [-d dir] [-i path] [-t tag] -- Clone latested tagged ${PROJ} version and build it. Optionally select the build directory and version, install binaries and cleanup setup files.
where:
-h show this help text
-c cleanup project
-d dir build files in \"dir\" (default: ${BUILDFOLDER})
-i path install binaries to path (use \"default\" to use default path)
-t tag specify version (git tag or commit hash) to pull (default: Latest tag)"
while getopts ':hi:cd:t:' OPTION; do
case $OPTION in
i) INSTALL=true
INSTALL_PREFIX="$OPTARG"
echo "-i set: Installing built binaries to $INSTALL_PREFIX"
;;
esac
done
OPTIND=1
while getopts ':hi:cd:t:' OPTION; do
case "$OPTION" in
h) echo "$USAGE"
exit
;;
c) if [ $INSTALL = false ]; then
>&2 echo -e "${RED}ERROR: -c only makes sense if the built binaries were installed before (-i)"
exit 1
fi
CLEANUP=true
echo "-c set: Removing build directory"
;;
d) echo "-d set: Using folder $OPTARG"
BUILDFOLDER="$OPTARG"
;;
t) echo "-t set: Using version $OPTARG"
TAG="$OPTARG"
;;
:) echo -e "${RED}ERROR: missing argument for -${OPTARG}\n${NC}" >&2
echo "$USAGE" >&2
exit 1
;;
\?) echo -e "${RED}ERROR: illegal option: -${OPTARG}\n${NC}" >&2
echo "$USAGE" >&2
exit 1
;;
esac
done
shift "$((OPTIND - 1))"
# This function does checkout the correct version and return the commit hash or tag name
# Parameter 1: Branch name, commit hash, tag or one of the special keywords default/latest/stable
# Parameter 2: Return variable name (commit hash or tag name)
function select_and_get_project_version {
# Stable selected: Choose latest tag if available, otherwise use default branch
if [ "$1" == "stable" ]; then
local L_TAGLIST=`git rev-list --tags --max-count=1`
# tags found?
if [ -n "$L_TAGLIST" ]; then
local L_COMMIT_HASH="`git describe --tags $L_TAGLIST`"
git checkout --recurse-submodules "$L_COMMIT_HASH"
else
git checkout --recurse-submodules $(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')
local L_COMMIT_HASH="$(git rev-parse HEAD)"
>&2 echo -e "${RED}WARNING: No git tags found, using default branch${NC}"
fi
else
# Either checkout defaut/stable branch or use custom commit hash, tag or branch name
if [ "$1" == "default" ] || [ "$1" == "latest" ]; then
git checkout --recurse-submodules $(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')
local L_COMMIT_HASH="$(git rev-parse HEAD)"
else
# Check if $1 contains a valid tag and use it as the version if it does
git checkout --recurse-submodules "$1"
local L_COMMIT_HASH="$(git rev-parse HEAD)"
for CUR_TAG in `git tag --list`; do
if [ "$CUR_TAG" == "$1" ]; then
L_COMMIT_HASH="$1"
break
fi
done
fi
fi
# Apply return value
eval "$2=\"$L_COMMIT_HASH\""
}
# exit when any command fails
set -e
# require sudo
if [[ $UID != 0 ]]; then
echo -e "${RED}Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# Cleanup files if the programm was shutdown unexpectedly
trap 'echo -e "${RED}ERROR: Script was terminated unexpectedly, cleaning up files..." && pushd -0 > /dev/null && rm -rf $BUILDFOLDER' INT TERM
# fetch specified version
if [ ! -d $BUILDFOLDER ]; then
mkdir $BUILDFOLDER
fi
pushd $BUILDFOLDER > /dev/null
if [ ! -d "$PROJ" ]; then
git clone --recursive "$REPO" "${PROJ%%/*}"
fi
pushd $PROJ > /dev/null
select_and_get_project_version "$TAG" "COMMIT_HASH"
# build and install if wanted
if [ "$INSTALL_PREFIX" == "default" ]; then
./configure
else
./configure --prefix="$INSTALL_PREFIX"
fi
make -j$(nproc)
if [ $INSTALL = true ]; then
make install
fi
# return to first folder and store version
pushd -0 > /dev/null
echo "${PROJ##*/}: $COMMIT_HASH" >> "$VERSIONFILE"
# cleanup if wanted
if [ $CLEANUP = true ]; then
rm -rf $BUILDFOLDER
fi
|
6.3.2. install_gtkwave_essentials.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 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Jun. 25 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# require sudo
if [[ $UID != 0 ]]; then
echo "Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# exit when any command fails
set -e
# required tools
TOOLS="build-essential git gcc make debhelper libgtk2.0-dev zlib1g-dev \
libbz2-dev flex gperf tcl-dev tk-dev liblzma-dev libjudy-dev \
libgconf2-dev"
# install and upgrade tools
apt-get update
apt-get install -y $TOOLS
apt-get install --only-upgrade -y $TOOLS
|
6.4. nextpnr¶
6.4.1. install_nextpnr_essentials.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 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Jun. 24 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# require sudo
if [[ $UID != 0 ]]; then
echo "Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# exit when any command fails
set -e
# required tools
TOOLS="clang-format qt5-default libboost-dev libboost-filesystem-dev \
libboost-thread-dev libboost-program-options-dev libboost-python-dev \
libboost-iostreams-dev libboost-dev libeigen3-dev python3-dev cmake"
# install and upgrade tools
apt-get update
apt-get install -y $TOOLS
apt-get install --only-upgrade -y $TOOLS
|
6.4.2. install_nextpnr.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 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Jun. 25 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# constants
RED='\033[1;31m'
NC='\033[0m'
REPO="https://github.com/YosysHQ/nextpnr.git"
PROJ="nextpnr"
CHIP="ice40"
BUILDFOLDER="build_and_install_nextpnr"
VERSIONFILE="installed_version.txt"
TAG="latest"
LIBPATH=""
INSTALL=false
CLEANUP=false
# trellis config
TRELLIS_LIB="/usr"
TRELLIS_REPO="https://github.com/SymbiFlow/prjtrellis"
TRELLIS_PROJ="prjtrellis"
# icestorm config
ICESTORM_REPO="https://github.com/cliffordwolf/icestorm.git"
ICESTORM_PROJ="icestorm"
ICESTORM_LIB="/usr/local/share/icebox"
ICESTORM_ICEBOX_DIR="icestorm"
# parse arguments
USAGE="$(basename "$0") [-h] [-c] [-e] [-d dir] [-i path] [-l path] [-t tag] -- Clone latested tagged ${PROJ} version and build it. Optionally select the build directory, chip files, chipset and version, install binaries and cleanup setup files.
where:
-h show this help text
-c cleanup project
-e install NextPNR for ecp5 chips (default: ice40)
-d dir build files in \"dir\" (default: ${BUILDFOLDER})
-i path install binaries to path (use \"default\" to use default path)
-l path use local chip files for ice40 or ecp5 from \"path\" (use empty string for default path in ubuntu)
-t tag specify version (git tag or commit hash) to pull (default: Latest tag)"
while getopts ":hecd:i:t:l:" OPTION; do
case $OPTION in
i) INSTALL=true
INSTALL_PREFIX="$OPTARG"
echo "-i set: Installing built binaries to $INSTALL_PREFIX"
;;
e) echo "-e set: Installing NextPNR for ecp5 chipset"
CHIP="ecp5"
;;
esac
done
OPTIND=1
while getopts ':hecd:i:t:l:' OPTION; do
case "$OPTION" in
h) echo "$USAGE"
exit
;;
c) if [ $INSTALL = false ]; then
>&2 echo -e "${RED}ERROR: -c only makes sense if the built binaries were installed before (-i)"
exit 1
fi
CLEANUP=true
echo "-c set: Removing build directory"
;;
d) echo "-d set: Using folder $OPTARG"
BUILDFOLDER="$OPTARG"
;;
t) echo "-t set: Using version $OPTARG"
TAG="$OPTARG"
;;
l) echo "-l set: Using local chip data"
if [ -z "$OPTARG" ]; then
if [ "$CHIP" = "ice40" ]; then
LIBPATH="$ICESTORM_LIB"
else
LIBPATH="$TRELLIS_LIB"
fi
else
if [ ! -d "$OPTARG" ]; then
echo -e "${RED}ERROR: Invalid path \"${OPTARG}\""
exit 1
fi
LIBPATH="$OPTARG"
fi
;;
:) echo -e "${RED}ERROR: missing argument for -${OPTARG}\n${NC}" >&2
echo "$USAGE" >&2
exit 1
;;
\?) echo -e "${RED}ERROR: illegal option: -${OPTARG}\n${NC}" "$OPTARG" >&2
echo "$USAGE" >&2
exit 1
;;
esac
done
shift "$((OPTIND - 1))"
# This function does checkout the correct version and return the commit hash or tag name
# Parameter 1: Branch name, commit hash, tag or one of the special keywords default/latest/stable
# Parameter 2: Return variable name (commit hash or tag name)
function select_and_get_project_version {
# Stable selected: Choose latest tag if available, otherwise use default branch
if [ "$1" == "stable" ]; then
local L_TAGLIST=`git rev-list --tags --max-count=1`
# tags found?
if [ -n "$L_TAGLIST" ]; then
local L_COMMIT_HASH="`git describe --tags $L_TAGLIST`"
git checkout --recurse-submodules "$L_COMMIT_HASH"
else
git checkout --recurse-submodules $(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')
local L_COMMIT_HASH="$(git rev-parse HEAD)"
>&2 echo -e "${RED}WARNING: No git tags found, using default branch${NC}"
fi
else
# Either checkout defaut/stable branch or use custom commit hash, tag or branch name
if [ "$1" == "default" ] || [ "$1" == "latest" ]; then
git checkout --recurse-submodules $(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')
local L_COMMIT_HASH="$(git rev-parse HEAD)"
else
# Check if $1 contains a valid tag and use it as the version if it does
git checkout --recurse-submodules "$1"
local L_COMMIT_HASH="$(git rev-parse HEAD)"
for CUR_TAG in `git tag --list`; do
if [ "$CUR_TAG" == "$1" ]; then
L_COMMIT_HASH="$1"
break
fi
done
fi
fi
# Apply return value
eval "$2=\"$L_COMMIT_HASH\""
}
# exit when any command fails
set -e
# require sudo
if [[ $UID != 0 ]]; then
echo -e "${RED}Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# Cleanup files if the programm was shutdown unexpectedly
trap 'echo -e "${RED}ERROR: Script was terminated unexpectedly, cleaning up files..." && pushd -0 > /dev/null && rm -rf $BUILDFOLDER' INT TERM
# fetch specified version
if [ ! -d $BUILDFOLDER ]; then
mkdir $BUILDFOLDER
fi
pushd $BUILDFOLDER > /dev/null
if [ ! -d "$PROJ" ]; then
git clone --recursive "$REPO" "${PROJ%%/*}"
fi
pushd $PROJ > /dev/null
select_and_get_project_version "$TAG" "COMMIT_HASH"
# build and install if wanted
# chip ice40?
if [ "$CHIP" = "ice40" ]; then
# is icestorm installed?
if [ -n "$LIBPATH" ]; then
if [ "$INSTALL_PREFIX" == "default" ]; then
cmake -DARCH=ice40 -DICEBOX_ROOT=${LIBPATH} .
else
cmake -DARCH=ice40 -DICEBOX_ROOT=${LIBPATH} -DCMAKE_INSTALL_PREFIX="$INSTALL_PREFIX" .
fi
else
echo "Note: Pulling Icestorm from Github."
if [ ! -d "$ICESTORM_PROJ" ]; then
git clone $ICESTORM_REPO "$ICESTORM_ICEBOX_DIR"
fi
NEXTPNR_FOLDER=`pwd -P`
# build icebox (chipdbs)
pushd "${ICESTORM_ICEBOX_DIR}/icebox" > /dev/null
make -j$(nproc)
make install DESTDIR=$NEXTPNR_FOLDER PREFIX=''
popd +0 > /dev/null
# build icetime (timing)
pushd "${ICESTORM_ICEBOX_DIR}/icetime" > /dev/null
make -j$(nproc) PREFIX=$NEXTPNR_FOLDER
make install DESTDIR=$NEXTPNR_FOLDER PREFIX=''
popd +0 > /dev/null
# build nextpnr-ice40 next
if [ "$INSTALL_PREFIX" == "default" ]; then
cmake -j$(nproc) -DARCH=ice40 -DICEBOX_ROOT="${NEXTPNR_FOLDER}/share/icebox" .
else
cmake -j$(nproc) -DARCH=ice40 -DICEBOX_ROOT="${NEXTPNR_FOLDER}/share/icebox" -DCMAKE_INSTALL_PREFIX="$INSTALL_PREFIX" .
fi
fi
# chip ecp5?
else
# is project trellis installed?
if [ -d "$LIBPATH" ]; then
if [ "$INSTALL_PREFIX" == "default" ]; then
cmake -j$(nproc) -DARCH=ecp5 -DTRELLIS_INSTALL_PREFIX=${LIBPATH} .
else
cmake -j$(nproc) -DARCH=ecp5 -DTRELLIS_INSTALL_PREFIX=${LIBPATH} -DCMAKE_INSTALL_PREFIX="$INSTALL_PREFIX" .
fi
else
echo "Note: Pulling Trellis from Github."
if [ ! -d "$TRELLIS_PROJ" ]; then
git clone --recursive $TRELLIS_REPO
fi
TRELLIS_MAKE_PATH="$(pwd -P)/${TRELLIS_PROJ}/libtrellis"
pushd "$TRELLIS_MAKE_PATH" > /dev/null
cmake -j$(nproc) -DCMAKE_INSTALL_PREFIX="$TRELLIS_MAKE_PATH" .
make -j$(nproc)
make install
popd +0 > /dev/null
if [ "$INSTALL_PREFIX" == "default" ]; then
cmake -j$(nproc) -DARCH=ecp5 -DTRELLIS_INSTALL_PREFIX="$TRELLIS_MAKE_PATH" .
else
cmake -j$(nproc) -DARCH=ecp5 -DTRELLIS_INSTALL_PREFIX="$TRELLIS_MAKE_PATH" -DCMAKE_INSTALL_PREFIX="$INSTALL_PREFIX" .
fi
fi
fi
make -j$(nproc)
if [ $INSTALL = true ]; then
make install
fi
# return to first folder and store version
pushd -0 > /dev/null
if [ "$CHIP" == "ice40" ]; then
echo "${PROJ##*/}-ice40: $COMMIT_HASH" >> "$VERSIONFILE"
else
echo "${PROJ##*/}-ecp5: $COMMIT_HASH" >> "$VERSIONFILE"
fi
# cleanup if wanted
if [ $CLEANUP = true ]; then
rm -rf $BUILDFOLDER
fi
|
6.5. openocd¶
6.5.1. install_openocd.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 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Jun. 25 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# constants
RED='\033[1;31m'
NC='\033[0m'
REPO="https://git.code.sf.net/p/openocd/code"
PROJ="openocd"
BUILDFOLDER="build_and_install_openocd"
VERSIONFILE="installed_version.txt"
TAG="latest"
INSTALL=false
INSTALL_PREFIX="default"
CLEANUP=false
# parse arguments
USAGE="$(basename "$0") [-h] [-c] [-d dir] [-i path] [-t tag] -- Clone latested tagged ${PROJ} version and build it. Optionally select the build directory and version, install binaries and cleanup setup files.
where:
-h show this help text
-c cleanup project
-d dir build files in \"dir\" (default: ${BUILDFOLDER})
-i path install binaries to path (use \"default\" to use default path)
-t tag specify version (git tag or commit hash) to pull (default: Latest tag)"
while getopts ':hi:cd:t:' OPTION; do
case $OPTION in
i) INSTALL=true
INSTALL_PREFIX="$OPTARG"
echo "-i set: Installing built binaries to $INSTALL_PREFIX"
;;
esac
done
OPTIND=1
while getopts ':hi:cd:t:' OPTION; do
case "$OPTION" in
h) echo "$USAGE"
exit
;;
c) if [ $INSTALL = false ]; then
>&2 echo -e "${RED}ERROR: -c only makes sense if the built binaries were installed before (-i)"
exit 1
fi
CLEANUP=true
echo "-c set: Removing build directory"
;;
d) echo "-d set: Using folder $OPTARG"
BUILDFOLDER="$OPTARG"
;;
t) echo "-t set: Using version $OPTARG"
TAG="$OPTARG"
;;
:) echo -e "${RED}ERROR: missing argument for -${OPTARG}\n${NC}" >&2
echo "$USAGE" >&2
exit 1
;;
\?) echo -e "${RED}ERROR: illegal option: -${OPTARG}\n${NC}" >&2
echo "$USAGE" >&2
exit 1
;;
esac
done
shift "$((OPTIND - 1))"
# This function does checkout the correct version and return the commit hash or tag name
# Parameter 1: Branch name, commit hash, tag or one of the special keywords default/latest/stable
# Parameter 2: Return variable name (commit hash or tag name)
function select_and_get_project_version {
# Stable selected: Choose latest tag if available, otherwise use default branch
if [ "$1" == "stable" ]; then
local L_TAGLIST=`git rev-list --tags --max-count=1`
# tags found?
if [ -n "$L_TAGLIST" ] && [ "$L_TAGLIST" != "v0.10.0" ]; then
local L_COMMIT_HASH="`git describe --tags $L_TAGLIST`"
git checkout --recurse-submodules "$L_COMMIT_HASH"
else
git checkout --recurse-submodules $(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')
local L_COMMIT_HASH="$(git rev-parse HEAD)"
>&2 echo -e "${RED}WARNING: No git tags found, using default branch${NC}"
fi
else
# Either checkout defaut/stable branch or use custom commit hash, tag or branch name
if [ "$1" == "default" ] || [ "$1" == "latest" ]; then
git checkout --recurse-submodules $(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')
local L_COMMIT_HASH="$(git rev-parse HEAD)"
else
# Check if $1 contains a valid tag and use it as the version if it does
git checkout --recurse-submodules "$1"
local L_COMMIT_HASH="$(git rev-parse HEAD)"
for CUR_TAG in `git tag --list`; do
if [ "$CUR_TAG" == "$1" ]; then
L_COMMIT_HASH="$1"
break
fi
done
fi
fi
# Apply return value
eval "$2=\"$L_COMMIT_HASH\""
}
# exit when any command fails
set -e
# require sudo
if [[ $UID != 0 ]]; then
echo -e "${RED}Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# Cleanup files if the programm was shutdown unexpectedly
trap 'echo -e "${RED}ERROR: Script was terminated unexpectedly, cleaning up files..." && pushd -0 > /dev/null && rm -rf $BUILDFOLDER' INT TERM
# fetch specified version
if [ ! -d $BUILDFOLDER ]; then
mkdir $BUILDFOLDER
fi
pushd $BUILDFOLDER > /dev/null
if [ ! -d "$PROJ" ]; then
git clone --recursive "$REPO" "${PROJ%%/*}"
fi
pushd $PROJ > /dev/null
select_and_get_project_version "$TAG" "COMMIT_HASH"
# build and install if wanted
./bootstrap
if [ "$INSTALL_PREFIX" == "default" ]; then
./configure
else
./configure --prefix="$INSTALL_PREFIX"
fi
make -j$(nproc)
if [ $INSTALL = true ]; then
make install
fi
# return to first folder and store version
pushd -0 > /dev/null
echo "${PROJ##*/}: $COMMIT_HASH" >> "$VERSIONFILE"
# cleanup if wanted
if [ $CLEANUP = true ]; then
rm -rf $BUILDFOLDER
fi
|
6.5.2. install_openocd_essentials.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 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Jun. 25 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# require sudo
if [[ $UID != 0 ]]; then
echo "Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# exit when any command fails
set -e
# required tools
TOOLS="build-essential git gcc make libtool pkg-config autoconf automake \
texinfo libftdi-dev libusb-1.0-0-dev"
# install and upgrade tools
apt-get update
apt-get install -y $TOOLS
apt-get install --only-upgrade -y $TOOLS
|
6.6. yosys¶
6.6.1. install_yosys_essentials.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 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Jun. 23 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# require sudo
if [[ $UID != 0 ]]; then
echo "Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# exit when any command fails
set -e
# required tools
TOOLS="build-essential clang bison flex libreadline-dev gawk tcl-dev \
libffi-dev git graphviz xdot pkg-config python3 libboost-system-dev \
libboost-python-dev libboost-filesystem-dev zlib1g-dev"
# install and upgrade tools
apt-get update
apt-get install -y $TOOLS
apt-get install --only-upgrade -y $TOOLS
|
6.6.2. install_yosys.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 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Jun. 24 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# constants
RED='\033[1;31m'
NC='\033[0m'
REPO="https://github.com/YosysHQ/yosys.git"
PROJ="yosys"
BUILDFOLDER="build_and_install_yosys"
VERSIONFILE="installed_version.txt"
COMPILER="clang"
TAG="latest"
INSTALL=false
INSTALL_PREFIX="default"
CLEANUP=false
# parse arguments
USAGE="$(basename "$0") [-h] [-c] [-d dir] [-b buildtool] [-i path] [-t tag] -- Clone latested tagged ${PROJ} version and build it. Optionally select compiler (buildtool), build directory and version, install binaries and cleanup setup files.
where:
-h show this help text
-c cleanup project
-d dir build files in \"dir\" (default: ${BUILDFOLDER})
-i path install binaries to path (use \"default\" to use default path)
-b compiler specify compiler (default: ${COMPILER}, alternative: gcc)
-t tag specify version (git tag or commit hash) to pull (default: default branch)"
while getopts ':hi:cd:b:t:' OPTION; do
case $OPTION in
i) INSTALL=true
INSTALL_PREFIX="$OPTARG"
echo "-i set: Installing built binaries to $INSTALL_PREFIX"
;;
esac
done
OPTIND=1
while getopts ':hi:cd:b:t:' OPTION; do
case "$OPTION" in
h) echo "$USAGE"
exit
;;
c) if [ $INSTALL = false ]; then
>&2 echo -e "${RED}ERROR: -c only makes sense if the built binaries were installed before (-i)"
exit 1
fi
CLEANUP=true
echo "-c set: Removing build directory"
;;
d) echo "-d set: Using folder $OPTARG"
BUILDFOLDER="$OPTARG"
;;
b) echo "-b set: Using compiler $OPTARG"
COMPILER="$OPTARG"
;;
t) echo "-t set: Using version $OPTARG"
TAG="$OPTARG"
;;
:) echo -e "${RED}ERROR: missing argument for -${OPTARG}\n${NC}" >&2
echo "$USAGE" >&2
exit 1
;;
\?) echo -e "${RED}ERROR: illegal option: -${OPTARG}\n${NC}" >&2
echo "$USAGE" >&2
exit 1
;;
esac
done
shift "$((OPTIND - 1))"
# This function does checkout the correct version and return the commit hash or tag name
# Parameter 1: Branch name, commit hash, tag or one of the special keywords default/latest/stable
# Parameter 2: Return variable name (commit hash or tag name)
function select_and_get_project_version {
# Stable selected: Choose latest tag if available, otherwise use default branch
if [ "$1" == "stable" ]; then
local L_TAGLIST=`git rev-list --tags --max-count=1`
# tags found?
if [ -n "$L_TAGLIST" ]; then
local L_COMMIT_HASH="`git describe --tags $L_TAGLIST`"
git checkout --recurse-submodules "$L_COMMIT_HASH"
else
git checkout --recurse-submodules $(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')
local L_COMMIT_HASH="$(git rev-parse HEAD)"
>&2 echo -e "${RED}WARNING: No git tags found, using default branch${NC}"
fi
else
# Either checkout defaut/stable branch or use custom commit hash, tag or branch name
if [ "$1" == "default" ] || [ "$1" == "latest" ]; then
git checkout --recurse-submodules $(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')
local L_COMMIT_HASH="$(git rev-parse HEAD)"
else
# Check if $1 contains a valid tag and use it as the version if it does
git checkout --recurse-submodules "$1"
local L_COMMIT_HASH="$(git rev-parse HEAD)"
for CUR_TAG in `git tag --list`; do
if [ "$CUR_TAG" == "$1" ]; then
L_COMMIT_HASH="$1"
break
fi
done
fi
fi
# Apply return value
eval "$2=\"$L_COMMIT_HASH\""
}
# exit when any command fails
set -e
# require sudo
if [[ $UID != 0 ]]; then
echo -e "${RED}Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# Cleanup files if the programm was shutdown unexpectedly
trap 'echo -e "${RED}ERROR: Script was terminated unexpectedly, cleaning up files..." && pushd -0 > /dev/null && rm -rf $BUILDFOLDER' INT TERM
# fetch specified version
if [ ! -d $BUILDFOLDER ]; then
mkdir $BUILDFOLDER
fi
pushd $BUILDFOLDER > /dev/null
if [ ! -d "$PROJ" ]; then
git clone --recursive "$REPO" "${PROJ%%/*}"
fi
pushd $PROJ > /dev/null
select_and_get_project_version "$TAG" "COMMIT_HASH"
# build and install if wanted
make config-$COMPILER
make -j$(nproc)
if [ $INSTALL = true ]; then
if [ "$INSTALL_PREFIX" == "default" ]; then
make install
else
make install PREFIX="$INSTALL_PREFIX"
fi
fi
# return to first folder and store version
pushd -0 > /dev/null
echo "${PROJ##*/}: $COMMIT_HASH" >> "$VERSIONFILE"
# cleanup if wanted
if [ $CLEANUP = true ]; then
rm -rf $BUILDFOLDER
fi
|
6.7. spinalhdl¶
6.7.1. install_spinalhdl_essentials.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 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Jun. 23 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# require sudo
if [[ $UID != 0 ]]; then
echo "Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# exit when any command fails
set -e
# required tools
TOOLS="openjdk-8-jdk scala sbt"
# install and upgrade tools
echo "deb https://dl.bintray.com/sbt/debian /" | sudo tee -a /etc/apt/sources.list.d/sbt.list
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 642AC823
apt-get update
apt-get install -y $TOOLS
apt-get install --only-upgrade -y $TOOLS
|
6.8. ujprog¶
6.8.1. install_ujprog.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 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Jun. 25 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# constants
RED='\033[1;31m'
NC='\033[0m'
REPO="https://github.com/f32c/tools.git"
PROJ="tools/ujprog"
BUILDFOLDER="build_and_install_ujprog"
VERSIONFILE="installed_version.txt"
TAG="latest"
INSTALL=false
INSTALL_PREFIX="default"
CLEANUP=false
# parse arguments
USAGE="$(basename "$0") [-h] [-c] [-d dir] [-i path] [-t tag] -- Clone latested tagged ${PROJ} version and build it. Optionally select the build directory and version, install binaries and cleanup setup files.
where:
-h show this help text
-c cleanup project
-d dir build files in \"dir\" (default: ${BUILDFOLDER})
-i path install binaries to path (use \"default\" to use default path)
-t tag specify version (git tag or commit hash) to pull (default: Latest tag)"
while getopts ':hi:cd:t:' OPTION; do
case $OPTION in
i) INSTALL=true
INSTALL_PREFIX="$OPTARG"
echo "-i set: Installing built binaries to $INSTALL_PREFIX"
;;
esac
done
OPTIND=1
while getopts ':hi:cd:t:' OPTION; do
case "$OPTION" in
h) echo "$USAGE"
exit
;;
c) if [ $INSTALL = false ]; then
>&2 echo -e "${RED}ERROR: -c only makes sense if the built binaries were installed before (-i)"
exit 1
fi
CLEANUP=true
echo "-c set: Removing build directory"
;;
d) echo "-d set: Using folder $OPTARG"
BUILDFOLDER="$OPTARG"
;;
t) echo "-t set: Using version $OPTARG"
TAG="$OPTARG"
;;
:) echo -e "${RED}ERROR: missing argument for -${OPTARG}\n${NC}" >&2
echo "$USAGE" >&2
exit 1
;;
\?) echo -e "${RED}ERROR: illegal option: -${OPTARG}\n${NC}" >&2
echo "$USAGE" >&2
exit 1
;;
esac
done
shift "$((OPTIND - 1))"
# This function does checkout the correct version and return the commit hash or tag name
# Parameter 1: Branch name, commit hash, tag or one of the special keywords default/latest/stable
# Parameter 2: Return variable name (commit hash or tag name)
function select_and_get_project_version {
# Stable selected: Choose latest tag if available, otherwise use default branch
if [ "$1" == "stable" ]; then
local L_TAGLIST=`git rev-list --tags --max-count=1`
# tags found?
if [ -n "$L_TAGLIST" ]; then
local L_COMMIT_HASH="`git describe --tags $L_TAGLIST`"
git checkout --recurse-submodules "$L_COMMIT_HASH"
else
git checkout --recurse-submodules $(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')
local L_COMMIT_HASH="$(git rev-parse HEAD)"
>&2 echo -e "${RED}WARNING: No git tags found, using default branch${NC}"
fi
else
# Either checkout defaut/stable branch or use custom commit hash, tag or branch name
if [ "$1" == "default" ] || [ "$1" == "latest" ]; then
git checkout --recurse-submodules $(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')
local L_COMMIT_HASH="$(git rev-parse HEAD)"
else
# Check if $1 contains a valid tag and use it as the version if it does
git checkout --recurse-submodules "$1"
local L_COMMIT_HASH="$(git rev-parse HEAD)"
for CUR_TAG in `git tag --list`; do
if [ "$CUR_TAG" == "$1" ]; then
L_COMMIT_HASH="$1"
break
fi
done
fi
fi
# Apply return value
eval "$2=\"$L_COMMIT_HASH\""
}
# exit when any command fails
set -e
# require sudo
if [[ $UID != 0 ]]; then
echo -e "${RED}Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# Cleanup files if the programm was shutdown unexpectedly
trap 'echo -e "${RED}ERROR: Script was terminated unexpectedly, cleaning up files..." && pushd -0 > /dev/null && rm -rf $BUILDFOLDER' INT TERM
# fetch specified version
if [ ! -d $BUILDFOLDER ]; then
mkdir $BUILDFOLDER
fi
pushd $BUILDFOLDER > /dev/null
if [ ! -d "$PROJ" ]; then
git clone --recursive "$REPO" "${PROJ%%/*}"
fi
pushd $PROJ > /dev/null
select_and_get_project_version "$TAG" "COMMIT_HASH"
# build and install if wanted
cp Makefile.linux Makefile
# Adjust path if required
if [ "$INSTALL_PREFIX" != "default" ]; then
mkdir -p "${INSTALL_PREFIX}/bin"
sed -i "s /usr/local ${INSTALL_PREFIX} g" Makefile
fi
make -j$(nproc)
if [ $INSTALL = true ]; then
make install
fi
# return to first folder and store version
pushd -0 > /dev/null
echo "${PROJ##*/}: $COMMIT_HASH" >> "$VERSIONFILE"
# cleanup if wanted
if [ $CLEANUP = true ]; then
rm -rf $BUILDFOLDER
fi
|
6.8.2. install_ujprog_essentials.sh¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Jun. 25 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# require sudo
if [[ $UID != 0 ]]; then
echo "Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# exit when any command fails
set -e
# required tools
TOOLS="build-essential clang make"
# install and upgrade tools
apt-get update
apt-get install -y $TOOLS
apt-get install --only-upgrade -y $TOOLS
|
6.9. verilator¶
6.9.1. install_verilator_essentials.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 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Jun. 25 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# require sudo
if [[ $UID != 0 ]]; then
echo "Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# exit when any command fails
set -e
# required tools
TOOLS="git perl python3 make g++ libfl2 libfl-dev zlibc zlib1g zlib1g-dev \
ccache libgoogle-perftools-dev numactl git autoconf flex bison"
# install and upgrade tools
apt-get update
apt-get install -y $TOOLS
apt-get install --only-upgrade -y $TOOLS
|
6.9.2. install_verilator.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 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Jun. 25 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# constants
RED='\033[1;31m'
NC='\033[0m'
REPO="https://github.com/verilator/verilator.git"
PROJ="verilator"
BUILDFOLDER="build_and_install_verilator"
VERSIONFILE="installed_version.txt"
TAG="latest"
INSTALL=false
INSTALL_PREFIX="default"
CLEANUP=false
# parse arguments
USAGE="$(basename "$0") [-h] [-c] [-d dir] [-i path] [-t tag] -- Clone latested tagged ${PROJ} version and build it. Optionally select the build directory and version, install binaries and cleanup setup files.
where:
-h show this help text
-c cleanup project
-d dir build files in \"dir\" (default: ${BUILDFOLDER})
-i path install binaries to path (use \"default\" to use default path)
-t tag specify version (git tag or commit hash) to pull (default: Latest tag)"
while getopts ':hi:cd:t:' OPTION; do
case $OPTION in
i) INSTALL=true
INSTALL_PREFIX="$OPTARG"
echo "-i set: Installing built binaries to $INSTALL_PREFIX"
;;
esac
done
OPTIND=1
while getopts ':hi:cd:t:' OPTION; do
case "$OPTION" in
h) echo "$USAGE"
exit
;;
c) if [ $INSTALL = false ]; then
>&2 echo -e "${RED}ERROR: -c only makes sense if the built binaries were installed before (-i)"
exit 1
fi
CLEANUP=true
echo "-c set: Removing build directory"
;;
d) echo "-d set: Using folder $OPTARG"
BUILDFOLDER="$OPTARG"
;;
t) echo "-t set: Using version $OPTARG"
TAG="$OPTARG"
;;
:) echo -e "${RED}ERROR: missing argument for -${OPTARG}\n${NC}" >&2
echo "$USAGE" >&2
exit 1
;;
\?) echo -e "${RED}ERROR: illegal option: -${OPTARG}\n${NC}" >&2
echo "$USAGE" >&2
exit 1
;;
esac
done
shift "$((OPTIND - 1))"
# This function does checkout the correct version and return the commit hash or tag name
# Parameter 1: Branch name, commit hash, tag or one of the special keywords default/latest/stable
# Parameter 2: Return variable name (commit hash or tag name)
function select_and_get_project_version {
# Stable selected: Choose latest tag if available, otherwise use default branch
if [ "$1" == "stable" ]; then
local L_TAGLIST=`git rev-list --tags --max-count=1`
# tags found?
if [ -n "$L_TAGLIST" ]; then
local L_COMMIT_HASH="`git describe --tags $L_TAGLIST`"
git checkout --recurse-submodules "$L_COMMIT_HASH"
else
git checkout --recurse-submodules $(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')
local L_COMMIT_HASH="$(git rev-parse HEAD)"
>&2 echo -e "${RED}WARNING: No git tags found, using default branch${NC}"
fi
else
# Either checkout defaut/stable branch or use custom commit hash, tag or branch name
if [ "$1" == "default" ] || [ "$1" == "latest" ]; then
git checkout --recurse-submodules $(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')
local L_COMMIT_HASH="$(git rev-parse HEAD)"
else
# Check if $1 contains a valid tag and use it as the version if it does
git checkout --recurse-submodules "$1"
local L_COMMIT_HASH="$(git rev-parse HEAD)"
for CUR_TAG in `git tag --list`; do
if [ "$CUR_TAG" == "$1" ]; then
L_COMMIT_HASH="$1"
break
fi
done
fi
fi
# Apply return value
eval "$2=\"$L_COMMIT_HASH\""
}
# exit when any command fails
set -e
# require sudo
if [[ $UID != 0 ]]; then
echo -e "${RED}Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# Cleanup files if the programm was shutdown unexpectedly
trap 'echo -e "${RED}ERROR: Script was terminated unexpectedly, cleaning up files..." && pushd -0 > /dev/null && rm -rf $BUILDFOLDER' INT TERM
# fetch specified version
if [ ! -d $BUILDFOLDER ]; then
mkdir $BUILDFOLDER
fi
pushd $BUILDFOLDER > /dev/null
if [ ! -d "$PROJ" ]; then
git clone --recursive "$REPO" "${PROJ%%/*}"
fi
pushd $PROJ > /dev/null
select_and_get_project_version "$TAG" "COMMIT_HASH"
# build and install if wanted
# unset var
if [ -n "$BASH" ]; then
unset VERILATOR_ROOT
else
unsetenv VERILATOR_ROOT
fi
autoconf
if [ "$INSTALL_PREFIX" == "default" ]; then
./configure
else
./configure --prefix="$INSTALL_PREFIX"
fi
make -j$(nproc)
if [ $INSTALL = true ]; then
make install
fi
# return to first folder and store version
pushd -0 > /dev/null
echo "${PROJ##*/}: $COMMIT_HASH" >> "$VERSIONFILE"
# cleanup if wanted
if [ $CLEANUP = true ]; then
rm -rf $BUILDFOLDER
fi
|
6.10. gtkterm¶
6.10.1. install_gtkterm_essentials.sh¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Jun. 25 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# require sudo
if [[ $UID != 0 ]]; then
echo "Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# exit when any command fails
set -e
# required tools
TOOLS="libgtk-3-dev libvte-2.91-dev intltool libgudev-1.0 meson ninja-build"
# install and upgrade tools
apt-get update
apt-get install -y $TOOLS
apt-get install --only-upgrade -y $TOOLS
|
6.10.2. install_gtkterm.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 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Oct. 08 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# constants
RED='\033[1;31m'
NC='\033[0m'
REPO="https://github.com/Jeija/gtkterm"
PROJ="gtkterm"
BUILDFOLDER="build_and_install_gtkterm"
VERSIONFILE="installed_version.txt"
TAG="latest"
INSTALL=false
INSTALL_PREFIX="default"
CLEANUP=false
# parse arguments
USAGE="$(basename "$0") [-h] [-c] [-d dir] [-i path] [-t tag] -- Clone latested tagged ${PROJ} version and build it. Optionally select the build directory and version, install binaries and cleanup setup files.
where:
-h show this help text
-c cleanup project
-d dir build files in \"dir\" (default: ${BUILDFOLDER})
-i path install binaries to path (use \"default\" to use default path)
-t tag specify version (git tag or commit hash) to pull (default: Latest tag)"
while getopts ':hi:cd:t:' OPTION; do
case $OPTION in
i) INSTALL=true
INSTALL_PREFIX="$OPTARG"
echo "-i set: Installing built binaries to $INSTALL_PREFIX"
;;
esac
done
OPTIND=1
while getopts ':hi:cd:t:' OPTION; do
case "$OPTION" in
h) echo "$USAGE"
exit
;;
c) if [ $INSTALL = false ]; then
>&2 echo -e "${RED}ERROR: -c only makes sense if the built binaries were installed before (-i)"
exit 1
fi
CLEANUP=true
echo "-c set: Removing build directory"
;;
d) echo "-d set: Using folder $OPTARG"
BUILDFOLDER="$OPTARG"
;;
t) echo "-t set: Using version $OPTARG"
TAG="$OPTARG"
;;
:) echo -e "${RED}ERROR: missing argument for -${OPTARG}\n${NC}" >&2
echo "$USAGE" >&2
exit 1
;;
\?) echo -e "${RED}ERROR: illegal option: -${OPTARG}\n${NC}" >&2
echo "$USAGE" >&2
exit 1
;;
esac
done
shift "$((OPTIND - 1))"
# This function does checkout the correct version and return the commit hash or tag name
# Parameter 1: Branch name, commit hash, tag or one of the special keywords default/latest/stable
# Parameter 2: Return variable name (commit hash or tag name)
function select_and_get_project_version {
# Stable selected: Choose latest tag if available, otherwise use default branch
if [ "$1" == "stable" ]; then
local L_TAGLIST=`git rev-list --tags --max-count=1`
# tags found?
if [ -n "$L_TAGLIST" ]; then
local L_COMMIT_HASH="`git describe --tags $L_TAGLIST`"
git checkout --recurse-submodules "$L_COMMIT_HASH"
else
git checkout --recurse-submodules $(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')
local L_COMMIT_HASH="$(git rev-parse HEAD)"
>&2 echo -e "${RED}WARNING: No git tags found, using default branch${NC}"
fi
else
# Either checkout defaut/stable branch or use custom commit hash, tag or branch name
if [ "$1" == "default" ] || [ "$1" == "latest" ]; then
git checkout --recurse-submodules $(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')
local L_COMMIT_HASH="$(git rev-parse HEAD)"
else
# Check if $1 contains a valid tag and use it as the version if it does
git checkout --recurse-submodules "$1"
local L_COMMIT_HASH="$(git rev-parse HEAD)"
for CUR_TAG in `git tag --list`; do
if [ "$CUR_TAG" == "$1" ]; then
L_COMMIT_HASH="$1"
break
fi
done
fi
fi
# Apply return value
eval "$2=\"$L_COMMIT_HASH\""
}
# exit when any command fails
set -e
# require sudo
if [[ $UID != 0 ]]; then
echo -e "${RED}Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# Cleanup files if the programm was shutdown unexpectedly
trap 'echo -e "${RED}ERROR: Script was terminated unexpectedly, cleaning up files..." && pushd -0 > /dev/null && rm -rf $BUILDFOLDER' INT TERM
# fetch specified version
if [ ! -d $BUILDFOLDER ]; then
mkdir $BUILDFOLDER
fi
pushd $BUILDFOLDER > /dev/null
if [ ! -d "$PROJ" ]; then
git clone --recursive "$REPO" "${PROJ%%/*}"
fi
pushd $PROJ > /dev/null
select_and_get_project_version "$TAG" "COMMIT_HASH"
if [ "$INSTALL_PREFIX" == "default" ]; then
meson build
else
meson build -Dprefix="$INSTALL_PREFIX"
fi
if [ $INSTALL = true ]; then
ninja -C build install
else
ninja -C build
fi
# return to first folder and store version
pushd -0 > /dev/null
echo "${PROJ##*/}: $COMMIT_HASH" >> "$VERSIONFILE"
# cleanup if wanted
if [ $CLEANUP = true ]; then
rm -rf $BUILDFOLDER
fi
|
6.11. icestorm¶
6.11.1. install_icestorm.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 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Jun. 24 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# constants
RED='\033[1;31m'
NC='\033[0m'
REPO="https://github.com/cliffordwolf/icestorm.git"
PROJ="icestorm"
BUILDFOLDER="build_and_install_icestorm"
VERSIONFILE="installed_version.txt"
RULE_FILE="/etc/udev/rules.d/53-lattice-ftdi.rules"
# space seperate multiple rules
RULES='ACTION=="add", ATTR{idVendor}=="0403", ATTR{idProduct}=="6010", MODE:="666"'
TAG="latest"
INSTALL=false
INSTALL_PREFIX="default"
CLEANUP=false
# parse arguments
USAGE="$(basename "$0") [-h] [-c] [-d dir] [-i path] [-t tag] -- Clone latested tagged ${PROJ} version and build it. Optionally select the build directory and version, install binaries and cleanup setup files.
where:
-h show this help text
-c cleanup project
-d dir build files in \"dir\" (default: ${BUILDFOLDER})
-i path install binaries to path (use \"default\" to use default path)
-t tag specify version (git tag or commit hash) to pull (default: Latest tag)"
while getopts ':hi:cd:t:' OPTION; do
case $OPTION in
i) INSTALL=true
INSTALL_PREFIX="$OPTARG"
echo "-i set: Installing built binaries to $INSTALL_PREFIX"
;;
esac
done
OPTIND=1
while getopts ':hi:cd:t:' OPTION; do
case "$OPTION" in
h) echo "$USAGE"
exit
;;
c) if [ $INSTALL = false ]; then
>&2 echo -e "${RED}ERROR: -c only makes sense if the built binaries were installed before (-i)"
exit 1
fi
CLEANUP=true
echo "-c set: Removing build directory"
;;
d) echo "-d set: Using folder $OPTARG"
BUILDFOLDER="$OPTARG"
;;
t) echo "-t set: Using version $OPTARG"
TAG="$OPTARG"
;;
:) echo -e "${RED}ERROR: missing argument for -${OPTARG}\n${NC}" >&2
echo "$USAGE" >&2
exit 1
;;
\?) echo -e "${RED}ERROR: illegal option: -${OPTARG}\n${NC}" >&2
echo "$USAGE" >&2
exit 1
;;
esac
done
shift "$((OPTIND - 1))"
# This function does checkout the correct version and return the commit hash or tag name
# Parameter 1: Branch name, commit hash, tag or one of the special keywords default/latest/stable
# Parameter 2: Return variable name (commit hash or tag name)
function select_and_get_project_version {
# Stable selected: Choose latest tag if available, otherwise use default branch
if [ "$1" == "stable" ]; then
local L_TAGLIST=`git rev-list --tags --max-count=1`
# tags found?
if [ -n "$L_TAGLIST" ]; then
local L_COMMIT_HASH="`git describe --tags $L_TAGLIST`"
git checkout --recurse-submodules "$L_COMMIT_HASH"
else
git checkout --recurse-submodules $(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')
local L_COMMIT_HASH="$(git rev-parse HEAD)"
>&2 echo -e "${RED}WARNING: No git tags found, using default branch${NC}"
fi
else
# Either checkout defaut/stable branch or use custom commit hash, tag or branch name
if [ "$1" == "default" ] || [ "$1" == "latest" ]; then
git checkout --recurse-submodules $(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')
local L_COMMIT_HASH="$(git rev-parse HEAD)"
else
# Check if $1 contains a valid tag and use it as the version if it does
git checkout --recurse-submodules "$1"
local L_COMMIT_HASH="$(git rev-parse HEAD)"
for CUR_TAG in `git tag --list`; do
if [ "$CUR_TAG" == "$1" ]; then
L_COMMIT_HASH="$1"
break
fi
done
fi
fi
# Apply return value
eval "$2=\"$L_COMMIT_HASH\""
}
# exit when any command fails
set -e
# require sudo
if [[ $UID != 0 ]]; then
echo -e "${RED}Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# Cleanup files if the programm was shutdown unexpectedly
trap 'echo -e "${RED}ERROR: Script was terminated unexpectedly, cleaning up files..." && pushd -0 > /dev/null && rm -rf $BUILDFOLDER' INT TERM
# fetch specified version
if [ ! -d $BUILDFOLDER ]; then
mkdir $BUILDFOLDER
fi
pushd $BUILDFOLDER > /dev/null
if [ ! -d "$PROJ" ]; then
git clone --recursive "$REPO" "${PROJ%%/*}"
fi
pushd $PROJ > /dev/null
select_and_get_project_version "$TAG" "COMMIT_HASH"
# build and install if wanted
make -j$(nproc)
if [ $INSTALL = true ]; then
if [ "$INSTALL_PREFIX" == "default" ]; then
make install
else
make install PREFIX="$INSTALL_PREFIX"
fi
fi
# allow any user to access ice fpgas (no sudo)
touch "$RULE_FILE"
for RULE in "$RULES"; do
if ! grep -q "$RULE" "$RULE_FILE"; then
echo -e "$RULE" >> "$RULE_FILE"
fi
done
# return to first folder and store version
pushd -0 > /dev/null
echo "${PROJ##*/}: $COMMIT_HASH" >> "$VERSIONFILE"
# cleanup if wanted
if [ $CLEANUP = true ]; then
rm -rf $BUILDFOLDER
fi
|
6.11.2. install_icestorm_essentials.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 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Jun. 24 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# require sudo
if [[ $UID != 0 ]]; then
echo "Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# exit when any command fails
set -e
# required tools
TOOLS="build-essential clang bison flex libreadline-dev \
gawk tcl-dev libffi-dev git mercurial graphviz \
xdot pkg-config python python3 libftdi-dev \
qt5-default python3-dev libboost-all-dev cmake libeigen3-dev"
# install and upgrade tools
apt-get update
apt-get install -y $TOOLS
apt-get install --only-upgrade -y $TOOLS
|
6.12. riscv_tools¶
6.12.1. install_riscv_essentials.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 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Jul. 02 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# require sudo
if [[ $UID != 0 ]]; then
echo "Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# exit when any command fails
set -e
# required tools
TOOLS="autoconf automake autotools-dev curl python3 libmpc-dev libmpfr-dev \
libgmp-dev gawk build-essential bison flex texinfo gperf libtool \
patchutils bc zlib1g-dev libexpat-dev"
# install and upgrade tools
apt-get update
apt-get install -y $TOOLS
apt-get install --only-upgrade -y $TOOLS
|
6.12.2. install_riscv.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 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Jul. 02 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# constants
RED='\033[1;31m'
NC='\033[0m'
REPO="https://github.com/riscv/riscv-gnu-toolchain.git"
PROJ="riscv-gnu-toolchain"
BUILDFOLDER="build_and_install_riscv_gnu_toolchain"
VERSIONFILE="installed_version.txt"
TOOLCHAIN_SUFFIX="linux-multilib"
TAG="latest"
NEWLIB=false
# INSTALL=false
INSTALL_PATH="/opt/riscv"
PROFILE_PATH="/etc/profile"
CLEANUP=false
EXPORTPATH=false
VERSION_FILE_NAME="versions.cfg"
VERSION_FILE='## Define sourcecode branch
# default = use predefined versions from current riscv-gnu-toolchain branch
# or any arbitrary git tag or commit hash
# note that in most projects there is no master branch
QEMU=default
RISCV_BINUTILS=default
RISCV_DEJAGNU=default
RISCV_GCC=default
RISCV_GDB=default
RISCV_GLIBC=default
RISCV_NEWLIB=default
## Define which RiscV architectures and ABIs are supported (space seperated list "arch-abi")
# Taken from Sifive:
# https://github.com/sifive/freedom-tools/blob/120fa4d48815fc9e87c59374c499849934f2ce10/Makefile
NEWLIB_MULTILIBS_GEN="\
rv32e-ilp32e--c \
rv32ea-ilp32e--m \
rv32em-ilp32e--c \
rv32eac-ilp32e-- \
rv32emac-ilp32e-- \
rv32i-ilp32--c,f,fc,fd,fdc \
rv32ia-ilp32-rv32ima,rv32iaf,rv32imaf,rv32iafd,rv32imafd- \
rv32im-ilp32--c,f,fc,fd,fdc \
rv32iac-ilp32--f,fd \
rv32imac-ilp32-rv32imafc,rv32imafdc- \
rv32if-ilp32f--c,d,dc \
rv32iaf-ilp32f--c,d,dc \
rv32imf-ilp32f--d \
rv32imaf-ilp32f-rv32imafd- \
rv32imfc-ilp32f--d \
rv32imafc-ilp32f-rv32imafdc- \
rv32ifd-ilp32d--c \
rv32imfd-ilp32d--c \
rv32iafd-ilp32d-rv32imafd,rv32iafdc- \
rv32imafdc-ilp32d-- \
rv64i-lp64--c,f,fc,fd,fdc \
rv64ia-lp64-rv64ima,rv64iaf,rv64imaf,rv64iafd,rv64imafd- \
rv64im-lp64--c,f,fc,fd,fdc \
rv64iac-lp64--f,fd \
rv64imac-lp64-rv64imafc,rv64imafdc- \
rv64if-lp64f--c,d,dc \
rv64iaf-lp64f--c,d,dc \
rv64imf-lp64f--d \
rv64imaf-lp64f-rv64imafd- \
rv64imfc-lp64f--d \
rv64imafc-lp64f-rv64imafdc- \
rv64ifd-lp64d--c \
rv64imfd-lp64d--c \
rv64iafd-lp64d-rv64imafd,rv64iafdc- \
rv64imafdc-lp64d--"
# Linux install (cross-compile for linux)
# Default value from riscv-gcc repository
GLIBC_MULTILIBS_GEN="\
rv32imac-ilp32-rv32ima,rv32imaf,rv32imafd,rv32imafc,rv32imafdc- \
rv32imafdc-ilp32d-rv32imafd- \
rv64imac-lp64-rv64ima,rv64imaf,rv64imafd,rv64imafc,rv64imafdc- \
rv64imafdc-lp64d-rv64imafd-"'
# parse arguments
USAGE="$(basename "$0") [-h] [-c] [-n] [-d dir] [-t tag] [-u user] [-p path] -- Clone latested ${PROJ} version and build it. Optionally select compiler (buildtool), build directory and version, install binaries and cleanup setup files.
where:
-h show this help text
-c cleanup project
-n use \"newlib multilib\" instead of \"linux multilib\" cross-compiler
-e extend PATH in by RiscV binary path (default: /etc/profile)
-d dir build files in \"dir\" (default: ${BUILDFOLDER})
-t tag specify version (git tag or commit hash) to pull (default: default branch)
-u user install RiscV tools for user \"user\". (default: install globally)
-p path choose install path (default: /opt/riscv)"
while getopts ':hcend:t:u:p:' OPTION; do
case "$OPTION" in
h) echo "$USAGE"
exit
;;
c) if [ $INSTALL = false ]; then
>&2 echo -e "${RED}ERROR: -c only makes sense if the built binaries were installed before (-i)"
exit 1
fi
CLEANUP=true
echo "-c set: Removing build directory"
;;
e) EXPORTPATH=true
echo "-e set: Extending PATH by RiscV binary path"
;;
n) echo "-n set: Using newlib cross-compiler"
NEWLIB=true
TOOLCHAIN_SUFFIX="newlib-multilib"
;;
d) echo "-d set: Using folder $OPTARG"
BUILDFOLDER="$OPTARG"
;;
t) echo "-t set: Using version $OPTARG"
TAG="$OPTARG"
;;
p) echo "-p set: Using install path $OPTARG"
INSTALL_PATH="$OPTARG"
;;
u) echo "-u set: Installing for user $OPTARG"
PROFILE_PATH="$(grep $OPTARG /etc/passwd | cut -d ":" -f6)/.profile"
if [ ! -f "$PROFILE_PATH" ]; then
echo -e "${RED}ERROR: No .profile file found for user \"${OPTARG}\"${NC}" >&2
exit 1;
fi
;;
:) echo -e "${RED}ERROR: missing argument for -${OPTARG}\n${NC}" >&2
echo "$USAGE" >&2
exit 1
;;
\?) echo -e "${RED}ERROR: illegal option: -${OPTARG}\n${NC}" >&2
echo "$USAGE" >&2
exit 1
;;
esac
done
shift $((OPTIND - 1))
# This function does checkout the correct version and return the commit hash or tag name
# Parameter 1: Branch name, commit hash, tag or one of the special keywords default/latest/stable
# Parameter 2: Return variable name (commit hash or tag name)
function select_and_get_project_version {
# Stable selected: Choose latest tag if available, otherwise use default branch
if [ "$1" == "stable" ]; then
local L_TAGLIST=`git rev-list --tags --max-count=1`
# tags found?
if [ -n "$L_TAGLIST" ]; then
local L_COMMIT_HASH="`git describe --tags $L_TAGLIST`"
git checkout --recurse-submodules "$L_COMMIT_HASH"
else
git checkout --recurse-submodules $(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')
local L_COMMIT_HASH="$(git rev-parse HEAD)"
>&2 echo -e "${RED}WARNING: No git tags found, using default branch${NC}"
fi
else
# Either checkout defaut/stable branch or use custom commit hash, tag or branch name
if [ "$1" == "default" ] || [ "$1" == "latest" ]; then
git checkout --recurse-submodules $(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')
local L_COMMIT_HASH="$(git rev-parse HEAD)"
else
# Check if $1 contains a valid tag and use it as the version if it does
git checkout --recurse-submodules "$1"
local L_COMMIT_HASH="$(git rev-parse HEAD)"
for CUR_TAG in `git tag --list`; do
if [ "$CUR_TAG" == "$1" ]; then
L_COMMIT_HASH="$1"
break
fi
done
fi
fi
# Apply return value
eval "$2=\"$L_COMMIT_HASH\""
}
# exit when any command fails
set -e
# require sudo
if [[ $UID != 0 ]]; then
echo -e "${RED}Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# cleanup files if the programm was shutdown unexpectedly
trap 'echo -e "${RED}ERROR: Script was terminated unexpectedly, cleaning up files..." >&2 && pushd -0 > /dev/null && rm -rf $BUILDFOLDER' INT TERM
# does the config exist?
if [ ! -f "$VERSION_FILE_NAME" ]; then
echo -e "${RED}Warning: No version.cfg file found. Generating file and using default versions${NC}";
echo "$VERSION_FILE" > "$VERSION_FILE_NAME"
fi
source "$VERSION_FILE_NAME"
CFG_LOCATION=`pwd -P`
# fetch specified version
if [ ! -d $BUILDFOLDER ]; then
mkdir $BUILDFOLDER
fi
pushd $BUILDFOLDER > /dev/null
if [ ! -d "$PROJ" ]; then
git clone --recursive "$REPO" "${PROJ%%/*}"
fi
pushd $PROJ > /dev/null
select_and_get_project_version "$TAG" "COMMIT_HASH"
VERSIONLIST="RiscV-GNU-Toolchain-${TOOLCHAIN_SUFFIX}: $COMMIT_HASH"
# fetch versions for all subrepos (as specified in versions.cfg)
while read LINE; do
if [ -n "$LINE" ] && [ "${LINE:0:1}" != "#" ]; then
SUBREPO=`echo "$LINE" | sed "s/[=].*$//"`
if [ -n "${!SUBREPO}" ]; then
SUBREPO_LOWER=`echo "$SUBREPO" | tr [A-Z,_] [a-z,-]`
if [ "${!SUBREPO}" != "default" ]; then
if [ -d "$SUBREPO_LOWER" ]; then
pushd $SUBREPO_LOWER > /dev/null
git checkout --recurse-submodules ${!SUBREPO}
VERSIONLIST="${VERSIONLIST}\n${SUBREPO_LOWER}-${TOOLCHAIN_SUFFIX}: ${!SUBREPO}"
popd > /dev/null
fi
else
if [ -d "$SUBREPO_LOWER" ]; then
pushd $SUBREPO_LOWER > /dev/null
VERSIONLIST="${VERSIONLIST}\n${SUBREPO_LOWER}-${TOOLCHAIN_SUFFIX}: $(git rev-parse HEAD)"
popd > /dev/null
fi
fi
fi
fi
done < "${CFG_LOCATION}/${VERSION_FILE_NAME}"
# build and install if wanted
PATH="${INSTALL_PATH}:${PATH}"
if [ $NEWLIB = true ]; then
./configure --prefix=$INSTALL_PATH --enable-multilib --disable-linux
# activate custom multilibs
pushd "riscv-gcc/gcc/config/riscv" > /dev/null
chmod +x ./multilib-generator
./multilib-generator $NEWLIB_MULTILIBS_GEN > t-elf-multilib
popd > /dev/null
NEWLIB_MULTILIB_NAMES=`echo $NEWLIB_MULTILIBS_GEN | sed "s/-\(rv\(32\|64\)[a-zA-Z]*,*\)*-\([a-zA-Z]*,*\)*//g"`
echo "Building newlib-multilib for \"$NEWLIB_MULTILIB_NAMES\""
# build
make -j$(nproc) NEWLIB_MULTILIB_NAMES="$NEWLIB_MULTILIB_NAMES"
else
./configure --prefix=$INSTALL_PATH --enable-multilib --enable-linux
# activate custom multilibs
pushd "riscv-gcc/gcc/config/riscv" > /dev/null
chmod +x ./multilib-generator
./multilib-generator $GLIBC_MULTILIBS_GEN > t-linux-multilib
popd > /dev/null
GLIBC_MULTILIB_NAMES=`echo $GLIBC_MULTILIBS_GEN | sed "s/-\(rv\(32\|64\)[a-zA-Z]*,*\)*-\([a-zA-Z]*,*\)*//g"`
echo "Building linux-multilib for \"$GLIBC_MULTILIB_NAMES\""
# build
make -j$(nproc) GLIBC_MULTILIB_NAMES="$GLIBC_MULTILIB_NAMES" linux
fi
# extend path
if [ $EXPORTPATH = true ]; then
PATH_STRING="\n# Add RiscV tools to path
if [ -d \"${INSTALL_PATH}/bin\" ]; then
PATH=\"${INSTALL_PATH}/bin:\$PATH\"
fi"
if ! grep -q "PATH=\"${INSTALL_PATH}/bin:\$PATH\"" "$PROFILE_PATH"; then
echo -e "$PATH_STRING" >> "$PROFILE_PATH"
fi
fi
# return to first folder and store version
pushd -0 > /dev/null
echo -e "$VERSIONLIST" >> "$VERSIONFILE"
# cleanup if wanted
if [ $CLEANUP = true ]; then
rm -rf $BUILDFOLDER
fi
|
6.12.3. versions.cfg¶
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 | ## Define sourcecode branch
# default = use predefined versions from current riscv-gnu-toolchain branch
# or any arbitrary git tag or commit hash
# note that in most projects there is no master branch
QEMU=default
RISCV_BINUTILS=default
RISCV_DEJAGNU=default
RISCV_GCC=default
RISCV_GDB=default
RISCV_GLIBC=default
RISCV_NEWLIB=default
## Define which RiscV architectures and ABIs are supported (space seperated list "arch-abi")
# Taken from Sifive:
# https://github.com/sifive/freedom-tools/blob/120fa4d48815fc9e87c59374c499849934f2ce10/Makefile
NEWLIB_MULTILIBS_GEN="\
rv32e-ilp32e--c \
rv32ea-ilp32e--m \
rv32em-ilp32e--c \
rv32eac-ilp32e-- \
rv32emac-ilp32e-- \
rv32i-ilp32--c,f,fc,fd,fdc \
rv32ia-ilp32-rv32ima,rv32iaf,rv32imaf,rv32iafd,rv32imafd- \
rv32im-ilp32--c,f,fc,fd,fdc \
rv32iac-ilp32--f,fd \
rv32imac-ilp32-rv32imafc,rv32imafdc- \
rv32if-ilp32f--c,d,dc \
rv32iaf-ilp32f--c,d,dc \
rv32imf-ilp32f--d \
rv32imaf-ilp32f-rv32imafd- \
rv32imfc-ilp32f--d \
rv32imafc-ilp32f-rv32imafdc- \
rv32ifd-ilp32d--c \
rv32imfd-ilp32d--c \
rv32iafd-ilp32d-rv32imafd,rv32iafdc- \
rv32imafdc-ilp32d-- \
rv64i-lp64--c,f,fc,fd,fdc \
rv64ia-lp64-rv64ima,rv64iaf,rv64imaf,rv64iafd,rv64imafd- \
rv64im-lp64--c,f,fc,fd,fdc \
rv64iac-lp64--f,fd \
rv64imac-lp64-rv64imafc,rv64imafdc- \
rv64if-lp64f--c,d,dc \
rv64iaf-lp64f--c,d,dc \
rv64imf-lp64f--d \
rv64imaf-lp64f-rv64imafd- \
rv64imfc-lp64f--d \
rv64imafc-lp64f-rv64imafdc- \
rv64ifd-lp64d--c \
rv64imfd-lp64d--c \
rv64iafd-lp64d-rv64imafd,rv64iafdc- \
rv64imafdc-lp64d--"
# Linux install (cross-compile for linux)
# Default value from riscv-gcc repository
GLIBC_MULTILIBS_GEN="\
rv32imac-ilp32-rv32ima,rv32imaf,rv32imafd,rv32imafc,rv32imafdc- \
rv32imafdc-ilp32d-rv32imafd- \
rv64imac-lp64-rv64ima,rv64imaf,rv64imafd,rv64imafc,rv64imafdc- \
rv64imafdc-lp64d-rv64imafd-"
|
6.13. trellis¶
6.13.1. install_trellis.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 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Jun. 25 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# constants
RED='\033[1;31m'
NC='\033[0m'
REPO="https://github.com/SymbiFlow/prjtrellis"
PROJ="prjtrellis/libtrellis"
BUILDFOLDER="build_and_install_trellis"
VERSIONFILE="installed_version.txt"
TAG="latest"
INSTALL=false
INSTALL_PREFIX="default"
CLEANUP=false
# parse arguments
USAGE="$(basename "$0") [-h] [-c] [-d dir] [-i path] [-t tag] -- Clone latested tagged ${PROJ} version and build it. Optionally select the build directory and version, install binaries and cleanup setup files.
where:
-h show this help text
-c cleanup project
-d dir build files in \"dir\" (default: ${BUILDFOLDER})
-i path install binaries to path (use \"default\" to use default path)
-t tag specify version (git tag or commit hash) to pull (default: Latest tag)"
while getopts ':hi:cd:t:' OPTION; do
case $OPTION in
i) INSTALL=true
INSTALL_PREFIX="$OPTARG"
echo "-i set: Installing built binaries to $INSTALL_PREFIX"
;;
esac
done
OPTIND=1
while getopts ':hi:cd:t:' OPTION; do
case "$OPTION" in
h) echo "$USAGE"
exit
;;
c) if [ $INSTALL = false ]; then
>&2 echo -e "${RED}ERROR: -c only makes sense if the built binaries were installed before (-i)"
exit 1
fi
CLEANUP=true
echo "-c set: Removing build directory"
;;
d) echo "-d set: Using folder $OPTARG"
BUILDFOLDER="$OPTARG"
;;
t) echo "-t set: Using version $OPTARG"
TAG="$OPTARG"
;;
:) echo -e "${RED}ERROR: missing argument for -${OPTARG}\n${NC}" >&2
echo "$USAGE" >&2
exit 1
;;
\?) echo -e "${RED}ERROR: illegal option: -${OPTARG}\n${NC}" >&2
echo "$USAGE" >&2
exit 1
;;
esac
done
shift "$((OPTIND - 1))"
# This function does checkout the correct version and return the commit hash or tag name
# Parameter 1: Branch name, commit hash, tag or one of the special keywords default/latest/stable
# Parameter 2: Return variable name (commit hash or tag name)
function select_and_get_project_version {
# Stable selected: Choose latest tag if available, otherwise use default branch
if [ "$1" == "stable" ]; then
local L_TAGLIST=`git rev-list --tags --max-count=1`
# tags found?
if [ -n "$L_TAGLIST" ]; then
local L_COMMIT_HASH="`git describe --tags $L_TAGLIST`"
git checkout --recurse-submodules "$L_COMMIT_HASH"
else
git checkout --recurse-submodules $(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')
local L_COMMIT_HASH="$(git rev-parse HEAD)"
>&2 echo -e "${RED}WARNING: No git tags found, using default branch${NC}"
fi
else
# Either checkout defaut/stable branch or use custom commit hash, tag or branch name
if [ "$1" == "default" ] || [ "$1" == "latest" ]; then
git checkout --recurse-submodules $(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')
local L_COMMIT_HASH="$(git rev-parse HEAD)"
else
# Check if $1 contains a valid tag and use it as the version if it does
git checkout --recurse-submodules "$1"
local L_COMMIT_HASH="$(git rev-parse HEAD)"
for CUR_TAG in `git tag --list`; do
if [ "$CUR_TAG" == "$1" ]; then
L_COMMIT_HASH="$1"
break
fi
done
fi
fi
# Apply return value
eval "$2=\"$L_COMMIT_HASH\""
}
# exit when any command fails
set -e
# require sudo
if [[ $UID != 0 ]]; then
echo -e "${RED}Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# Cleanup files if the programm was shutdown unexpectedly
trap 'echo -e "${RED}ERROR: Script was terminated unexpectedly, cleaning up files..." && pushd -0 > /dev/null && rm -rf $BUILDFOLDER' INT TERM
# fetch specified version
if [ ! -d $BUILDFOLDER ]; then
mkdir $BUILDFOLDER
fi
pushd $BUILDFOLDER > /dev/null
if [ ! -d "$PROJ" ]; then
git clone --recursive "$REPO" "${PROJ%%/*}"
fi
pushd $PROJ > /dev/null
select_and_get_project_version "$TAG" "COMMIT_HASH"
# build and install if wanted
if [ "$INSTALL_PREFIX" == "default" ]; then
cmake -DCMAKE_INSTALL_PREFIX=/usr .
else
cmake -DCMAKE_INSTALL_PREFIX="$INSTALL_PREFIX" .
fi
make -j$(nproc)
if [ $INSTALL = true ]; then
make install
fi
# return to first folder and store version
pushd -0 > /dev/null
echo "${PROJ##*/}: $COMMIT_HASH" >> "$VERSIONFILE"
# cleanup if wanted
if [ $CLEANUP = true ]; then
rm -rf $BUILDFOLDER
fi
|
6.13.2. install_trellis_essentials.sh¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Jun. 25 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# require sudo
if [[ $UID != 0 ]]; then
echo "Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# exit when any command fails
set -e
# required tools
TOOLS="build-essential clang cmake python3 python3-dev libboost-all-dev git"
# install and upgrade tools
apt-get update
apt-get install -y $TOOLS
apt-get install --only-upgrade -y $TOOLS
|