#!/bin/sh set -euC check_command () { echo -n "Checking for command $1 ... " if command -v "$1" >/dev/null then echo 'found!' else echo 'not available!'; exit 1 fi } check_perl_deps () { for d in "$@" do echo -n "Checking for perl module $d ... " if perl -Ilib -e "use $d;" then echo 'found!' else echo 'not available!'; exit 1 fi done } check_node_module () { echo -n "Checking for node module $1 ... " if [ -d "node_modules/$1" ] then echo 'found!' else echo 'not available!'; exit 1 fi } check_ninja_version () { ninja_file="$(mktemp -t jwm-build-XXXXXXXX)" echo "ninja_required_version = $1" >>"$ninja_file" echo -n "Checking ninja version at least $1 ... " if ninja -f "$ninja_file" >/dev/null then echo 'sufficient!' else echo 'inadequate!'; exit 1 fi rm "$ninja_file" } if readlink /bin/init | grep -q systemd then JWM_INIT=systemd fi allargs="$*" while getopts 'c:d:e:i:hm:p:' opt do case $opt in (e) JWM_MAILDIR_EXTRACTOR="$OPTARG";; (m) JWM_MODE="$OPTARG";; (c) JWM_LOGIN_SCHEME="$OPTARG";; (d) DESTDIR="$OPTARG";; (p) PREFIX="$OPTARG";; (i) JWM_INIT="$OPTARG";; (h) t="$(printf '\t')" expand -t 37 <&2; exit; } JWM_EXTRACTRS_DIR=extract check_command cargo MAILDIR_EXTRACTOR_BIN=bin/jwebmail-extract ;; esac export LOGIN_SCHEME="$JWM_LOGIN_SCHEME" export CONFARGS="$allargs" export MAILDIR_EXTRACTOR_NAME="$JWM_MAILDIR_EXTRACTOR" export MAILDIR_EXTRACTOR_BIN export JWM_EXTRACTRS_DIR export JWM_MODE export JWM_INIT export DESTDIR export PREFIX perl -pe 's/@(\w+)@/$ENV{$1}/ga' lib/JWebmail/Config.pm.in >|lib/JWebmail/Config.pm sh confninja.sh >|build.ninja