-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
31 lines (22 loc) · 874 Bytes
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
COREUTILS = cat cp dirname false ln mkdir mv printenv pwd rm rmdir touch true whoami
VERSION = 0.0.1
LDFLAGS = -X 'codeberg.org/whou/simpleutils/coreutils.Version=$(VERSION)'
BUILD_DIR ?= build
INSTALL_DIR ?= ~/.local/bin
BIN_PREFIX ?= su-
BIN_SUFIX =
ifeq ($(OS),Windows_NT)
BIN_SUFIX += .exe
endif
BINARIES = $(patsubst %,$(BUILD_DIR)/$(BIN_PREFIX)%$(BIN_SUFIX),$(COREUTILS))
.PHONY: build run test install
build:
@mkdir -p $(BUILD_DIR)
@$(foreach util,$(COREUTILS),echo "Compiling $(util)..."; go build -o $(BUILD_DIR)/$(BIN_PREFIX)$(util)$(BIN_SUFIX) -ldflags="$(LDFLAGS)" ./coreutils/$(util)/$(util).go;)
run:
go run coreutils/$(UTIL)/$(UTIL).go $(ARGS)
test: build
PREFIX="$(BIN_PREFIX)" BUILD_DIR="$(shell pwd)/$(BUILD_DIR)" go test ./coreutils/...
go test ./internal/...
install:
@$(foreach util,$(BINARIES),install -v -D -t $(INSTALL_DIR) $(util);)