-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·49 lines (41 loc) · 1.09 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·49 lines (41 loc) · 1.09 KB
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
#!/bin/sh
set -e
REPO="https://github.com/phyothant-dev/PT-Programming-Language.git"
INSTALL_DIR="/usr/local/bin"
TMPDIR=""
cleanup() {
[ -n "$TMPDIR" ] && rm -rf "$TMPDIR"
}
trap cleanup EXIT
# Check for git
if ! command -v git >/dev/null 2>&1; then
echo "Error: git is required. Please install git first."
exit 1
fi
# Check for a C++17 compiler
if command -v g++ >/dev/null 2>&1; then
CXX=g++
elif command -v clang++ >/dev/null 2>&1; then
CXX=clang++
else
echo "Error: No C++17 compiler found. Please install g++ or clang++."
exit 1
fi
echo "Cloning PT repository..."
TMPDIR=$(mktemp -d)
git clone --depth 1 "$REPO" "$TMPDIR/pt"
echo "Building PT..."
cd "$TMPDIR/pt"
make CXX="$CXX"
echo "Installing to $INSTALL_DIR..."
if [ -w "$INSTALL_DIR" ] 2>/dev/null; then
install -m 755 pt "$INSTALL_DIR/pt"
else
echo "Need sudo to install to $INSTALL_DIR"
sudo install -d "$INSTALL_DIR"
sudo install -m 755 pt "$INSTALL_DIR/pt"
fi
echo ""
echo "PT installed successfully! Run 'pt' to start the REPL."
echo " pt script.pt — run a file"
echo " pt — interactive REPL"