76 lines
2.1 KiB
Makefile
76 lines
2.1 KiB
Makefile
# YetAnotherToDoList
|
|
# Copyright © 2023 gilex-dev gilex-dev@proton.me
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, version 3.
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
project:=YetAnotherToDoList
|
|
goPackage:=somepi.ddns.net/gitea/gilex-dev/YetAnotherToDoList/globals
|
|
|
|
INSTALL_DIR?=$$HOME/.local/bin
|
|
BUILD_FLAGS?=
|
|
RUN_FLAGS?=
|
|
|
|
commitHash=$(shell git rev-parse --short HEAD)
|
|
ifneq ($(shell git status --porcelain),)
|
|
# working directory not clean
|
|
commitHash:=$(commitHash)*
|
|
endif
|
|
|
|
latestTag:=$(shell git describe --abbrev=0 --tags 2> /dev/null)# suppress possible error
|
|
|
|
ifeq ($(shell git tag --points-at HEAD),)
|
|
# current commit has no tag
|
|
ifeq ($(latestTag),)
|
|
# no previous tag exists
|
|
latestTag=unknown
|
|
else
|
|
# found a tag before HEAD
|
|
latestTag:=$(latestTag)*
|
|
endif
|
|
endif
|
|
|
|
.PHONY: all
|
|
all: install
|
|
|
|
.PHONY: build
|
|
build:
|
|
go build $(BUILD_FLAGS) -ldflags="-X '$(goPackage).Version=$(latestTag)' -X '$(goPackage).CommitHash=$(commitHash)'" -o $(project) .
|
|
|
|
.PHONY: run
|
|
run:
|
|
go run $(BUILD_FLAGS) -ldflags="-X '$(goPackage).Version=$(latestTag)' -X '$(goPackage).CommitHash=$(commitHash)'" . $(RUN_FLAGS)
|
|
|
|
$(project): build
|
|
|
|
.PHONY: frontend
|
|
frontend:
|
|
cd frontend && pnpm run build
|
|
|
|
.PHONY: install
|
|
install: $(project)
|
|
install $(project) $(INSTALL_DIR)
|
|
@echo -e "\nIf you want to add shell completion, see INSTALL.md"
|
|
|
|
.PHONY: uninstall
|
|
uninstall:
|
|
@-rm $(INSTALL_DIR)/$(project)
|
|
|
|
.PHONY: info
|
|
info:
|
|
$(info project=$(project))
|
|
$(info goPackage=$(goPackage))
|
|
$(info latestTag=$(latestTag))
|
|
$(info commitHash=$(commitHash))
|
|
$(info BUILD_FLAGS=$(BUILD_FLAGS))
|
|
$(info INSTALL_DIR=$(INSTALL_DIR))
|
|
@echo -e "\nSee INSTALL.md for usage"
|