2022-03-18 14:48:59 +00:00
|
|
|
-include environ.inc
|
2022-03-27 05:45:44 +00:00
|
|
|
.PHONY: help deps dev build install image release test clean clean-all
|
2022-03-18 14:48:59 +00:00
|
|
|
|
|
|
|
export CGO_ENABLED=0
|
2023-01-14 00:27:14 +00:00
|
|
|
VERSION=$(shell git describe --abbrev=0 --tags 2>/dev/null || echo "$VERSION")
|
|
|
|
COMMIT=$(shell git rev-parse --short HEAD || echo "$COMMIT")
|
2022-03-18 14:48:59 +00:00
|
|
|
BRANCH=$(shell git rev-parse --abbrev-ref HEAD)
|
2023-01-14 00:27:14 +00:00
|
|
|
BUILD=$(shell git show -s --pretty=format:%cI)
|
|
|
|
GOCMD=go
|
2022-03-18 14:48:59 +00:00
|
|
|
GOCMD=go
|
|
|
|
|
|
|
|
DESTDIR=/usr/local/bin
|
|
|
|
|
2022-03-21 04:37:31 +00:00
|
|
|
ifeq ($(BRANCH), master)
|
2022-03-21 23:38:03 +00:00
|
|
|
IMAGE := prologic/saltyim
|
2022-03-18 14:48:59 +00:00
|
|
|
TAG := latest
|
|
|
|
else
|
2022-03-21 23:38:03 +00:00
|
|
|
IMAGE := prologic/saltyim
|
2022-03-18 14:48:59 +00:00
|
|
|
TAG := dev
|
|
|
|
endif
|
|
|
|
|
2022-03-22 14:30:38 +00:00
|
|
|
all: help
|
2022-03-18 14:48:59 +00:00
|
|
|
|
2022-03-22 14:30:38 +00:00
|
|
|
.PHONY: help
|
|
|
|
|
|
|
|
help: ## Show this help message
|
|
|
|
@echo "salty.im - secure, easy, self-hosted messaging"
|
|
|
|
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[$$()% a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
|
|
|
|
|
|
|
|
preflight: ## Run preflight checks to ensure you have the right build tools
|
2022-03-18 14:48:59 +00:00
|
|
|
@./preflight.sh
|
|
|
|
|
2022-03-22 14:30:38 +00:00
|
|
|
deps: ## Install any dependencies required
|
2022-03-29 22:06:06 +00:00
|
|
|
@$(GOCMD) install github.com/jsha/minica@latest
|
2022-04-02 02:59:39 +00:00
|
|
|
@$(GOCMD) install github.com/coredns/coredns@latest
|
2022-03-18 14:48:59 +00:00
|
|
|
|
2022-04-15 08:11:46 +00:00
|
|
|
certs/minica-key.pem:
|
|
|
|
@/bin/sh -c 'cd certs && minica --domains "home.arpa,*.home.arpa"'
|
|
|
|
|
|
|
|
certs: certs/minica-key.pem certs/minica.pem certs/home.arpa/key.pem certs/home.arpa/cert.pem
|
2022-03-29 22:06:06 +00:00
|
|
|
|
2022-04-02 02:59:39 +00:00
|
|
|
dev : DEBUG=1
|
2023-04-23 09:31:43 +00:00
|
|
|
dev : certs ## Build debug version of salty-chat (CLI and TUI) and saltyd (Broker)
|
2022-04-02 02:59:39 +00:00
|
|
|
@CGO_ENABLED=1 $(GOCMD) build ./cmd/salty-chat/...
|
2022-03-28 21:49:01 +00:00
|
|
|
@CGO_ENABLED=1 $(GOCMD) build -tags "embed" ./cmd/saltyd/...
|
2022-04-02 02:59:39 +00:00
|
|
|
@./saltyd -D -b :https --tls \
|
2022-04-15 08:11:46 +00:00
|
|
|
--tls-key ./certs/home.arpa/key.pem \
|
|
|
|
--tls-cert ./certs/home.arpa/cert.pem
|
2022-03-28 21:49:01 +00:00
|
|
|
|
2022-03-22 14:30:38 +00:00
|
|
|
cli: ## Build the salty-chat command-line client and tui
|
2023-01-11 22:58:07 +00:00
|
|
|
ifeq ($(DEBUG), 1)
|
|
|
|
@echo "Building in debug mode..."
|
|
|
|
@$(GOCMD) build -tags "netgo static_build" -installsuffix netgo \
|
2023-01-14 00:27:14 +00:00
|
|
|
-ldflags "\
|
|
|
|
-X $(shell go list).Version=$(VERSION) \
|
|
|
|
-X $(shell go list).Commit=$(COMMIT) \
|
|
|
|
-X $(shell go list).Build=$(BUILD) \
|
|
|
|
" \
|
2023-01-11 22:58:07 +00:00
|
|
|
./cmd/salty-chat/
|
|
|
|
else
|
2022-03-18 14:48:59 +00:00
|
|
|
@$(GOCMD) build -tags "netgo static_build" -installsuffix netgo \
|
|
|
|
-ldflags "-w \
|
|
|
|
-X $(shell go list).Version=$(VERSION) \
|
2023-01-14 00:27:14 +00:00
|
|
|
-X $(shell go list).Commit=$(COMMIT) \
|
|
|
|
-X $(shell go list).Build=$(BUILD) \
|
|
|
|
" \
|
2022-03-18 14:48:59 +00:00
|
|
|
./cmd/salty-chat/
|
2023-01-11 22:58:07 +00:00
|
|
|
endif
|
2022-03-18 14:48:59 +00:00
|
|
|
|
2023-04-23 09:31:43 +00:00
|
|
|
server: generate ## Build the saltyd broker
|
2023-01-11 22:58:07 +00:00
|
|
|
ifeq ($(DEBUG), 1)
|
|
|
|
@echo "Building in debug mode..."
|
|
|
|
@$(GOCMD) build -tags "embed netgo static_build" -installsuffix netgo \
|
2023-01-14 00:27:14 +00:00
|
|
|
-ldflags "\
|
|
|
|
-X $(shell go list).Version=$(VERSION) \
|
|
|
|
-X $(shell go list).Commit=$(COMMIT) \
|
|
|
|
-X $(shell go list).Build=$(BUILD) \
|
|
|
|
" \
|
2023-01-11 22:58:07 +00:00
|
|
|
./cmd/saltyd/
|
|
|
|
else
|
2022-03-21 22:27:35 +00:00
|
|
|
@$(GOCMD) build -tags "embed netgo static_build" -installsuffix netgo \
|
|
|
|
-ldflags "-w \
|
|
|
|
-X $(shell go list).Version=$(VERSION) \
|
2023-01-14 00:27:14 +00:00
|
|
|
-X $(shell go list).Commit=$(COMMIT) \
|
|
|
|
-X $(shell go list).Build=$(BUILD) \
|
|
|
|
" \
|
2022-03-21 22:27:35 +00:00
|
|
|
./cmd/saltyd/
|
2023-01-11 22:58:07 +00:00
|
|
|
endif
|
2022-03-21 22:27:35 +00:00
|
|
|
|
2022-03-22 14:30:38 +00:00
|
|
|
build: cli server ## Build the cli and the server
|
2022-03-18 14:48:59 +00:00
|
|
|
|
2022-03-22 14:30:38 +00:00
|
|
|
generate: ## Genereate any code required by the build
|
2022-03-18 14:48:59 +00:00
|
|
|
@if [ x"$(DEBUG)" = x"1" ]; then \
|
|
|
|
echo 'Running in debug mode...'; \
|
|
|
|
fi
|
2022-03-22 15:20:40 +00:00
|
|
|
|
2022-03-22 14:30:38 +00:00
|
|
|
install: build ## Install salty-chat (cli) and saltyd (server) to $DESTDIR
|
2022-03-18 14:48:59 +00:00
|
|
|
@install -D -m 755 salty-chat $(DESTDIR)/salty-chat
|
2022-03-21 23:38:03 +00:00
|
|
|
@install -D -m 755 saltyd $(DESTDIR)/saltyd
|
2022-03-18 14:48:59 +00:00
|
|
|
|
|
|
|
ifeq ($(PUBLISH), 1)
|
2022-03-22 14:30:38 +00:00
|
|
|
image: generate ## Build the Docker image
|
2023-01-14 00:27:14 +00:00
|
|
|
@docker buildx build \
|
|
|
|
--build-arg VERSION="$(VERSION)" \
|
|
|
|
--build-arg COMMIT="$(COMMIT)" \
|
|
|
|
--build-arg BUILD="$(BUILD)" \
|
|
|
|
--platform linux/amd64,linux/arm64 --push -t $(IMAGE):$(TAG) .
|
2022-03-18 14:48:59 +00:00
|
|
|
else
|
|
|
|
image: generate
|
2023-01-14 00:27:14 +00:00
|
|
|
@docker build \
|
|
|
|
--build-arg VERSION="$(VERSION)" \
|
|
|
|
--build-arg COMMIT="$(COMMIT)" \
|
|
|
|
--build-arg BUILD="$(BUILD)" \
|
|
|
|
-t $(IMAGE):$(TAG) .
|
2022-03-18 14:48:59 +00:00
|
|
|
endif
|
|
|
|
|
2022-03-22 14:30:38 +00:00
|
|
|
release: generate ## Release a new version to Gitea
|
2022-03-18 14:48:59 +00:00
|
|
|
@./tools/release.sh
|
|
|
|
|
2022-03-22 14:30:38 +00:00
|
|
|
fmt: ## Format sources fiels
|
2022-03-18 14:48:59 +00:00
|
|
|
@$(GOCMD) fmt ./...
|
|
|
|
|
2022-03-22 14:30:38 +00:00
|
|
|
test: ## Run test suite
|
2023-01-27 23:14:03 +00:00
|
|
|
@CGO_ENABLED=1 $(GOCMD) test -failfast -shuffle on -race -cover -coverprofile=coverage.out ./...
|
2022-03-18 14:48:59 +00:00
|
|
|
|
2022-03-27 05:45:44 +00:00
|
|
|
clean: ## Remove untracked files
|
2022-03-28 21:49:01 +00:00
|
|
|
@git clean -f -d -x -e certs
|
2022-03-27 05:45:44 +00:00
|
|
|
|
|
|
|
clean-all: ## Remove untracked and Git ignores files
|
2022-03-18 14:48:59 +00:00
|
|
|
@git clean -f -d -X
|