commit 3aba0e6617424b26c77a922b0f27d7261c7ac2e9 parent 9c559d9658cb363e5b4bb9a50ee21591490545ff Author: Sean Enck <sean@ttypty.com> Date: Mon, 19 Jul 2021 19:18:00 -0400 use configure script to help generate makefile Diffstat:
| M | .gitignore | | | 1 | + |
| D | Makefile | | | 13 | ------------- |
| A | configure | | | 77 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
3 files changed, 78 insertions(+), 13 deletions(-)
diff --git a/.gitignore b/.gitignore @@ -1 +1,2 @@ bin/ +Makefile diff --git a/Makefile b/Makefile @@ -1,13 +0,0 @@ -BIN := bin/ -FLAGS := -ldflags '-linkmode external -extldflags $(LDFLAGS) -w' -trimpath -buildmode=pie -mod=readonly -modcacherw -FILES := lb lb-bash lb-diff lb-rekey lb-stats lb-pwgen lb-rw lb-totp -TARGET := $(addprefix $(BIN),$(FILES)) - -all: $(TARGET) - -$(TARGET) : $(shell find . -type f -name "*.go") go.* - go build -o $@ $(FLAGS) cmd/$(shell basename $@ | sed 's/lb-//g')/main.go - -clean: - rm -rf $(BIN) - mkdir -p $(BIN) diff --git a/configure b/configure @@ -0,0 +1,77 @@ +#!/bin/bash + +BASH_ON=1 +TOTP_ON=1 +PWGEN_ON=1 +STATS_ON=1 +DIFF_ON=1 +APPS=(lb lb-rekey lb-rw) +BIN_PATH="bin/" + +for i in "$@"; do + case $i in + --disable-bash-completions) + BASH_ON=0 + shift + ;; + --disable-totp) + TOTP_ON=0 + shift + ;; + --disable-pwgen) + PWGEN_ON=0 + shift + ;; + --disable-git) + STATS_ON=0 + DIFF_ON=0 + shift + ;; + *) + ;; + esac +done + +if [ $BASH_ON -eq 1 ]; then + APPS+=(lb-bash) +fi +if [ $TOTP_ON -eq 1 ]; then + APPS+=(lb-totp) +fi +if [ $PWGEN_ON -eq 1 ]; then + APPS+=(lb-pwgen) +fi +if [ $STATS_ON -eq 1 ]; then + APPS+=(lb-stats) +fi +if [ $DIFF_ON -eq 1 ]; then + APPS+=(lb-diff) +fi + +_generate() { + local binapps app cnt binapp + binapps=() + for app in ${APPS[@]}; do + binapps+=($BIN_PATH$app) + done + echo "# Autogenerated file +FLAGS := -ldflags '-linkmode external -extldflags \$(LDFLAGS) -w' -trimpath -buildmode=pie -mod=readonly -modcacherw + +all: ${binapps[@]} + +clean: + rm -rf $BIN_PATH +" + + cnt=0 + for binapp in ${binapps[@]}; do + app=${APPS[$cnt]} + app=$(echo $app | sed 's/lb-//g') + cnt=$((cnt+1)) + echo "$binapp: \$(shell find . -type f -name '*.go') go.*" + echo " go build -o $binapp \$(FLAGS) cmd/$app/main.go" + echo + done +} + +_generate | sed 's/^ /\t/g' > Makefile