2025-07-10 08:13:49 +02:00
# Strict mode
SHELL := bash
.SHELLFLAGS := -eu -o pipefail -c
.ONESHELL :
.DELETE_ON_ERROR :
2025-07-15 13:41:49 +02:00
.PHONY : all binaries build check -dist -all check -dist -archlinux check -dist -debian check -dist -fedora check -dist -rocky check -dist -ubuntu check -sign clean -all clean -dist clean -go -cache clean -package -signer cover deb dist dist -full doc freebsd gpg -sign help install install -gomarkdoc katenary manpage packager -oci -image packages pacman prepare pull rpm rpm -sign sast serve -doc show -cover tar test uninstall upx warn -docker
2025-07-10 08:13:49 +02:00
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
# Get a version string from git
2021-12-03 14:12:45 +01:00
CUR_SHA = $( shell git log -n1 --pretty= '%h' )
CUR_BRANCH = $( shell git branch --show-current)
2025-07-10 08:13:49 +02:00
VERSION = $( shell git describe --exact-match --tags $( CUR_SHA) 2>/dev/null || echo $( CUR_BRANCH) -$( CUR_SHA) ) # use by golang flags
# Go build command and environment variables for target OS and architecture
GOVERSION = 1.24
2025-07-12 09:12:12 +02:00
GO = container# container, local
2025-07-10 08:13:49 +02:00
OUTPUT = katenary
GOOS = linux
GOARCH = amd64
CGO_ENABLED = 0
PREFIX = ~/.local
2025-07-07 21:58:15 +02:00
2025-07-10 08:13:49 +02:00
# UPX compression
2025-07-07 21:58:15 +02:00
UPX_OPTS =
2025-06-15 16:02:45 +02:00
UPX ?= upx $( UPX_OPTS)
2023-12-06 15:24:02 +01:00
# List of source files
2025-07-10 08:13:49 +02:00
SOURCES = $( shell find -name "*.go" -or -name "*.tpl" -type f | grep -v -P "^./example|^./vendor" )
2023-12-06 15:24:02 +01:00
# List of binaries to build and sign
2025-07-12 09:12:12 +02:00
BINARIES = \
dist/katenary-linux-amd64\
dist/katenary-linux-arm64\
dist/katenary-darwin-amd64\
dist/katenary-freebsd-amd64\
dist/katenary-freebsd-arm64\
dist/katenary.exe\
dist/katenary-windows-setup.exe
2025-07-10 08:13:49 +02:00
## GPG
2023-12-06 15:24:02 +01:00
# List of signatures to build
ASC_BINARIES = $( patsubst %,%.asc,$( BINARIES) )
2025-07-10 08:13:49 +02:00
# GPG signer
SIGNER = metal3d@gmail.com
2023-12-06 15:24:02 +01:00
2025-07-10 08:13:49 +02:00
# Browser command to see coverage report after tests
2024-10-17 17:08:42 +02:00
BROWSER = $( shell command -v epiphany || echo xdg-open)
2022-02-16 18:32:51 +01:00
2025-08-03 14:15:35 +02:00
i n c l u d e m a k e f i l e s / b u i l d . m k
i n c l u d e m a k e f i l e s / c o n t a i n e r s . m k
i n c l u d e m a k e f i l e s / d o c . m k
i n c l u d e m a k e f i l e s / g p g . m k
i n c l u d e m a k e f i l e s / p a c k a g e r . m k
i n c l u d e m a k e f i l e s / t e s t . m k
2023-12-06 15:24:02 +01:00
all : build
2022-01-26 09:43:01 +01:00
2025-08-03 14:15:35 +02:00
# if docker is used instead of podman, we warn the user
warn-docker :
@echo -e "\033[1;31mWarning: Docker is not recommended, use Podman instead.\033[0m"
sleep 5
2021-12-01 09:09:30 +01:00
help :
2023-12-06 15:24:02 +01:00
@cat <<EOF | fold -s -w 80
2021-12-01 09:09:30 +01:00
= = = HELP = = =
To avoid you to install Go, the build is made by podman or docker.
2023-12-06 15:24:02 +01:00
Installinf ( you can use local Go by setting GO = local ) ) :
# use podman or docker to build
2021-12-01 09:09:30 +01:00
$$ make install
2023-12-06 15:24:02 +01:00
# or use local Go
$$ make install GO = local
2021-12-01 09:09:30 +01:00
This will build and install katenary inside the PREFIX( /bin) value ( default is $( PREFIX) )
2023-12-06 15:24:02 +01:00
To change the PREFIX to somewhere where only root or sudo users can save the binary, it is recommended to build before install, one more time you can use local Go by setting GO = local:
2021-12-01 09:09:30 +01:00
$$ make build
$$ sudo make install PREFIX = /usr/local
2022-02-16 18:32:51 +01:00
Katenary is statically built ( in Go) , so there is no library to install.
To build for others OS:
2022-03-31 14:12:20 +02:00
$$ make build GOOS = linux GOARCH = amd64
2022-02-16 18:32:51 +01:00
This will build the binary for linux amd64.
2022-03-31 14:12:20 +02:00
$$ make build GOOS = linux GOARCH = arm
2022-02-16 18:32:51 +01:00
This will build the binary for linux arm.
2022-03-31 14:12:20 +02:00
$$ make build GOOS = windows GOARCH = amd64
2022-02-16 18:32:51 +01:00
This will build the binary for windows amd64.
2022-03-31 14:12:20 +02:00
$$ make build GOOS = darwin GOARCH = amd64
2022-02-16 18:32:51 +01:00
This will build the binary for darwin amd64.
2022-03-31 14:12:20 +02:00
2022-02-16 18:32:51 +01:00
Or you can build all versions:
2025-07-15 13:41:49 +02:00
$$ make binaries
2021-12-01 09:09:30 +01:00
EOF
2022-04-01 10:47:58 +02:00
2025-07-07 21:58:15 +02:00
## installation and uninstallation
2025-06-15 16:02:45 +02:00
2021-12-01 09:09:30 +01:00
install : build
2023-12-06 15:24:02 +01:00
install -Dm755 katenary $( PREFIX) /bin/katenary
2021-12-01 09:09:30 +01:00
uninstall :
rm -f $( PREFIX) /bin/katenary
2025-07-07 21:58:15 +02:00
## Miscellaneous
2025-07-15 10:27:24 +02:00
clean-all : clean -dist clean -package -signer clean -go -cache
clean-dist :
2025-07-07 21:58:15 +02:00
rm -rf dist
rm -f katenary
2025-07-15 10:27:24 +02:00
clean-package-signer :
rm -f .secret.gpg .rpmmacros
clean-go-cache :
$( CTN) volume rm -f go-cache