aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-03-21 23:33:22 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-03-21 23:33:22 -0400
commitf8e2916712ee6e979f6d88e1e5d467539be51097 (patch)
tree41b3949cce78afe0772efeaf8a6ae042da16f8ca
parente717f9f6aaaedf2fa0b8c6dac2aaae5bc5ad8c30 (diff)
Added autoinstaller for deps
-rw-r--r--Makefile5
-rw-r--r--README.md6
-rwxr-xr-xinstall_dependencies.sh68
3 files changed, 76 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 5e759dff..ae985542 100644
--- a/Makefile
+++ b/Makefile
@@ -81,6 +81,9 @@ examples: examples/commands/commands examples/base64/base64 examples/ini/ini exa
examples/http examples/threads examples/tomodeps examples/tomo-install examples/wrap examples/pthreads examples/colorful
./build/tomo examples/learnxiny.tm
+deps:
+ ./install_dependencies.sh
+
install: build/tomo build/libtomo.so
mkdir -p -m 755 "$(PREFIX)/man/man1" "$(PREFIX)/bin" "$(PREFIX)/include/tomo" "$(PREFIX)/lib" "$(PREFIX)/share/tomo/modules"
cp -v src/stdlib/*.h "$(PREFIX)/include/tomo/"
@@ -93,4 +96,4 @@ uninstall:
rm -rvf "$(PREFIX)/bin/tomo" "$(PREFIX)/include/tomo" "$(PREFIX)/lib/libtomo.so" "$(PREFIX)/share/tomo"; \
.SUFFIXES:
-.PHONY: all clean install uninstall test tags examples
+.PHONY: all clean install uninstall test tags examples deps
diff --git a/README.md b/README.md
index 59ea2abe..98dc31b2 100644
--- a/README.md
+++ b/README.md
@@ -95,8 +95,10 @@ Tomo has a very small set of dependencies:
- [Binutils](https://www.gnu.org/software/binutils/) for stack traces.
- and libc/libm, which should definitely already be installed.
-The Boehm GC, libunistring, and binutils should be available on your package
-manager of choice (for example, `pacman -S gc libunistring binutils`).
+If you're feeling incautious, you can run `make deps` or
+`./install_dependencies.sh` to install all the necessary dependencies. I can't
+guarantee this works on all platforms, but has a reasonably high chance of
+success.
## Building
diff --git a/install_dependencies.sh b/install_dependencies.sh
new file mode 100755
index 00000000..27d04416
--- /dev/null
+++ b/install_dependencies.sh
@@ -0,0 +1,68 @@
+#!/bin/sh
+
+if command -v doas >/dev/null 2>&1; then
+ SUDO="doas"
+elif command -v sudo >/dev/null 2>&1; then
+ SUDO="sudo"
+else
+ echo "Neither doas nor sudo found." >&2
+ exit 1
+fi
+
+# Manually specify package manager:
+if [ -n "$1" ]; then
+ PKG_MGR="$1"
+# Autodetect package manager:
+elif command -v apt >/dev/null 2>&1; then
+ PKG_MGR="apt"
+elif command -v dnf >/dev/null 2>&1; then
+ PKG_MGR="dnf"
+elif command -v yay >/dev/null 2>&1; then
+ PKG_MGR="yay"
+elif command -v paru >/dev/null 2>&1; then
+ PKG_MGR="paru"
+elif command -v pacman >/dev/null 2>&1; then
+ PKG_MGR="pacman"
+elif command -v xbps-install >/dev/null 2>&1; then
+ PKG_MGR="xbps"
+elif command -v pkg_add >/dev/null 2>&1; then
+ PKG_MGR="pkg_add"
+elif command -v pkg >/dev/null 2>&1; then
+ PKG_MGR="freebsd-pkg"
+elif command -v brew >/dev/null 2>&1; then
+ PKG_MGR="brew"
+elif command -v port >/dev/null 2>&1; then
+ PKG_MGR="macports"
+elif command -v zypper >/dev/null 2>&1; then
+ PKG_MGR="zypper"
+elif command -v nix-env >/dev/null 2>&1; then
+ PKG_MGR="nix"
+elif command -v spack >/dev/null 2>&1; then
+ PKG_MGR="spack"
+elif command -v conda >/dev/null 2>&1; then
+ PKG_MGR="conda"
+else
+ echo "Unsupported package manager" >&2
+ exit 1
+fi
+
+# Install packages
+case "$PKG_MGR" in
+ apt) $SUDO apt install libgc-dev libunistring-dev binutils patchelf libgmp-dev ;;
+ dnf) $SUDO dnf install gc-devel libunistring-devel binutils patchelf gmp-devel ;;
+ pacman) $SUDO pacman -S gc libunistring binutils patchelf gmp ;;
+ yay|paru) $PKG_MGR -S gc libunistring binutils patchelf gmp ;;
+ xbps) $SUDO xbps-install -S gc libunistring binutils patchelf gmp ;;
+ pkg_add) $SUDO pkg_add boehm-gc libunistring binutils patchelf gmp ;;
+ freebsd-pkg) $SUDO pkg install boehm-gc libunistring binutils patchelf gmp ;;
+ brew) brew install bdw-gc libunistring binutils patchelf gmp ;;
+ macports) $SUDO port install boehm-gc libunistring binutils patchelf gmp ;;
+ zypper) $SUDO zypper install gc-devel libunistring-devel binutils patchelf gmp-devel ;;
+ nix) nix-env -iA nixpkgs.boehm-gc nixpkgs.libunistring nixpkgs.binutils nixpkgs.patchelf nixpkgs.gmp ;;
+ spack) spack install boehm-gc libunistring binutils patchelf gmp ;;
+ conda) conda install boehm-gc libunistring binutils patchelf gmp ;;
+ *)
+ echo "Unknown package manager: $PKG_MGR" >&2
+ exit 1
+ ;;
+esac