aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Tuomi <jans.tuomi@gmail.com>2024-01-29 12:05:01 +0200
committerJan Tuomi <jans.tuomi@gmail.com>2024-01-29 12:05:01 +0200
commit86c49fea3e615f9b67b646417ad3786fd0dde2c0 (patch)
tree79c1589473a389d349568ebfb3b73824f94b3ff2
parent092a811a554b0978e94f6c56d4ed2ace3d0bc519 (diff)
Add Makefile, remove build.sh
-rw-r--r--Makefile32
-rw-r--r--README.md27
-rwxr-xr-xbuild.sh31
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
+
diff --git a/README.md b/README.md
index d3e2c39..9651fd1 100644
--- a/README.md
+++ b/README.md
@@ -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