eclipse/Makefile

69 lines
2.1 KiB
Makefile

# Copyright (C) 2023-2024 Umorpha Systems
# SPDX-License-Identifier: AGPL-3.0-or-later
all: build
.PHONY: all
go_build_flags = -trimpath -tags=libsqlite3
go_programs := $(sort $(patsubst cmd/%/,%,$(wildcard cmd/*/)))
.DELETE_ON_ERROR:
.NOTINTERMEDIATE:
# Generate #####################################################################
generate/files = COPYING.txt
COPYING.txt:
curl https://www.gnu.org/licenses/agpl-3.0.txt >$@
generate: $(generate/files)
generate-clean:
rm -f -- $(generate/files)
.PHONY: generate generate-clean
# Build ########################################################################
build: $(addprefix bin/,$(go_programs))
.PHONY: build
bin:
mkdir $@
$(foreach p,$(go_programs),bin/.$p.stamp): bin/.%.stamp: cmd/% generate
go build $(go_build_flags) -o $@ ./$<
$(foreach p,$(go_programs),bin/$p): bin/%: bin/.%.stamp
@if cmp -s $< $@; then echo $@: already up to date; else PS4=; set -x; cp -f $< $@; fi
# Install ######################################################################
DESTDIR ?=
prefix ?= /usr/local
exec_prefix ?= $(prefix)
bindir ?= $(exec_prefix)/bin
libdir ?= $(exec_prefix)/lib
systemdunitdir ?= $(libdir)/systemd/system
sysusersdir ?= $(libdir)/sysusers.d
install/files = $(addprefix $(DESTDIR)$(bindir)/,$(go_programs))
install/files += $(DESTDIR)$(systemdunitdir)/eclipse-httpd.socket
install/files += $(DESTDIR)$(systemdunitdir)/eclipse-httpd.service
install/files += $(DESTDIR)$(systemdunitdir)/eclipse-trigger.timer
install/files += $(DESTDIR)$(systemdunitdir)/eclipse-trigger.service
install/files += $(DESTDIR)$(sysusersdir)/eclipse.conf
install: $(install/files)
uninstall:
rm -f -- $(install/files)
.PHONY: install uninstall
$(addprefix $(DESTDIR)$(bindir)/,$(go_programs)): $(DESTDIR)$(bindir)/%: bin/%
install -Dm755 $< $@
$(DESTDIR)$(sysusersdir)/eclipse.conf: etc/sysusers.conf
install -Dm644 $< $@
$(DESTDIR)$(systemdunitdir)/%.socket: etc/%.socket
install -Dm644 $< $@
$(DESTDIR)$(systemdunitdir)/%.timer: etc/%.timer
install -Dm644 $< $@
$(DESTDIR)$(systemdunitdir)/%.service: etc/%.service
<$< sed 's|@bindir@|$(bindir)|g' | install -Dm644 /dev/stdin $@