#!/bin/sh H_FILE="regexis024_build_system.h" SH_TEMP_FILE="regexis024_build_system.sh" if [ \! \( -f "$H_FILE" \) -o \! \( -f "$SH_TEMP_FILE" \) ]; then echo "Change cwd to root of build system source code root directory"; exit 1; fi usage(){ echo "Usage: ./install.sh [installation root]" } if [ $# -gt 1 ]; then usage; exit 1; fi INST_ROOT="/usr" if [ $# -ge 1 ]; then INST_ROOT="$1"; fi INST_ROOT="$(realpath "$INST_ROOT")" install -d "$INST_ROOT/include" if [ $? != 0 ]; then echo "Can't install IR/bin directory"; exit 1; fi install "$H_FILE" "$INST_ROOT/include/" if [ $? != 0 ]; then echo "Can't copy $H_FILE"; exit 1; fi I_DIR="$INST_ROOT/include" escape4shell(){ echo "$1" | sed -e "s/'/'\\\\''/g; 1s/^/'/; \$s/\$/'/" } SH_TEMPLATE="$(cat "$SH_TEMP_FILE")" SH_TEMPLATE="${SH_TEMPLATE/"i_dir=99999"/"id_dir=$(escape4shell "$I_DIR")"}" install -d "$INST_ROOT/bin" if [ $? != 0 ]; then echo "Failed to install IR/bin directory"; exit 1; fi echo "$SH_TEMPLATE" > "$INST_ROOT/bin/$SH_TEMP_FILE" if [ $? != 0 ]; then echo "Can't paste generated $SH_TEMP_FILE"; exit 1 fi chmod +x "$INST_ROOT/bin/$SH_TEMP_FILE" if [ $? != 0 ]; then echo "Can't chmod +x on .sh script in IR/bin"; exit 1 fi