diff options
| author | Jan Tuomi <jans.tuomi@gmail.com> | 2024-01-29 12:05:01 +0200 |
|---|---|---|
| committer | Jan Tuomi <jans.tuomi@gmail.com> | 2024-01-29 12:05:01 +0200 |
| commit | 86c49fea3e615f9b67b646417ad3786fd0dde2c0 (patch) | |
| tree | 79c1589473a389d349568ebfb3b73824f94b3ff2 | |
| parent | 092a811a554b0978e94f6c56d4ed2ace3d0bc519 (diff) | |
Add Makefile, remove build.sh
| -rw-r--r-- | Makefile | 32 | ||||
| -rw-r--r-- | README.md | 27 | ||||
| -rwxr-xr-x | build.sh | 31 |
3 files changed, 43 insertions, 47 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..5d91c64 --- /dev/null +++ b/Makefile @@ -0,0 +1,32 @@ +# Compiler and source definitions +CC = csc +CFLAGS = -O3 -static +SRC = desmoctl.scm +BIN = build/desmoctl + +# Default PREFIX for install, can be overridden +PREFIX ?= /usr/bin/ + +# Default target +all: $(BIN) + +# Rule for building the binary +$(BIN): $(SRC) + mkdir -p build + $(CC) $(CFLAGS) -o $(BIN) $(SRC) + chmod +x $(BIN) + +# Install target +install: + cp $(BIN) $(PREFIX) + +# Dependency installation target +deps: + chicken-install -from-list requirements.list + +# Clean target +clean: + rm -rf build + +.PHONY: all install deps clean + @@ -6,25 +6,16 @@ A tool for controlling a desmofylakas cluster written in Chicken Scheme. Install [Chicken Scheme](https://wiki.call-cc.org/platforms). -Install dependencies: - - chicken-install -from-list requirements.list - -In addition to Chicken dependencies, you need to have these available in PATH: +You also need to have these available in PATH: tar + make -## Building and running - -Run the tool in the interpreter: - - # Set DEBUG=1 to show debug prints - # Set INLINE_TESTS=1 to run unit tests before execution - csi -s run.scm - -Compile a statically linked binary for production: +Install dependencies, build and install to your preferred location: - ./build.sh + make deps + make + PREFIX=$HOME/.local/bin/ make install ## Usage @@ -32,7 +23,11 @@ See `desmoctl help`. ## Development -When adding new modules, add the module names to `modules.list`. The defined module name must match the filename. +Run the tool in the interpreter: + + # Set DEBUG=1 to show debug prints + # Set INLINE_TESTS=1 to run unit tests before execution + csi -s run.scm ## Copyright diff --git a/build.sh b/build.sh deleted file mode 100755 index 0b865b0..0000000 --- a/build.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash - -# if the first flag is -h or --help, then show usage -if [[ $1 == "-h" || $1 == "--help" ]]; then - echo "Usage: build.sh [OPTION]" - echo "Builds the desmoctl binary." - echo "" - echo "Options:" - echo " -h, --help Show this help message" - echo " -d, --debug Enable debugging" - exit 0 -fi - -BUILD_DIR=build - -# if the first flag is --debug or -d, then set CHICKEN_DEBUGGER=localhost:9999 and add -d3 to CSC_FLAGS -if [[ $1 == "--debug" || $1 == "-d" ]]; then - export CHICKEN_DEBUGGER=localhost:9999 - export CSC_FLAGS="-d3" -else - export CHICKEN_DEBUGGER= - export CSC_FLAGS=-O3 -fi - -set -euxo pipefail - -mkdir -p ${BUILD_DIR} -cd ${BUILD_DIR} - -csc ${CSC_FLAGS} -o desmoctl -static ../desmoctl.scm -chmod +x desmoctl |
