-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
105 lines (92 loc) · 3.36 KB
/
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/usr/bin/env make
#
# jailtime version 0.8
# Copyright (c)2015-2020 Christian Blichmann
#
# Makefile for POSIX compatible systems
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
# Source Configuration
version = 0.8
c_year ?= $(shell date +%Y)
go_package = blichmann.eu/code/jailtime
go_programs = jailtime
source_only_tgz = ../jailtime_$(version).orig.tar.xz
# Directories
this_dir := $(patsubst %/,%,$(dir $(abspath $(lastword $(MAKEFILE_LIST)))))
bin_dir := $(this_dir)/bin
export GOBIN := $(bin_dir)
binaries := $(addprefix $(bin_dir)/,$(go_programs))
sources := $(wildcard $(shell (unset GOPATH; go list -f '{{.Dir}}/*.go' ./...)))
.PHONY: all
all: $(binaries)
.PHONY: clean
clean:
@echo " [Clean] Removing build artifacts"
@rm -f $(binaries) || true
@rmdir "$(bin_dir)" || true
$(binaries): $(sources)
@echo " [Build] $@"
@(unset GOPATH; go install -tags "$(TAGS)" $(go_package)/...)
.PHONY: test
test:
@echo " [Test]"
@(unset GOPATH; go test ./...)
$(source_only_tgz): clean
@echo " [Archive] $@"
@tar -C "$(this_dir)" -caf "$@" \
--transform=s,^,jailtime-$(version)/, \
--exclude=.git/* --exclude=.git \
--exclude=debian/* --exclude=debian \
"--exclude=$@" \
--exclude-vcs-ignores \
.??* *
.PHONY: updatesourcemeta
updatesourcemeta:
@echo " [Update] Version and copyright"
@for i in \
$(sources) \
$(this_dir)/debian/copyright \
$(this_dir)/debian/rules \
$(this_dir)/man/*.[1-9] \
$(this_dir)/examples/*.jailspec \
$(this_dir)/LICENSE \
$(this_dir)/Makefile \
$(this_dir)/README.md; \
do \
[ -f $$i ] && sed -i \
-e 's/\(jailtime version\) [0-9]\+\.[0-9]\+/\1 $(version)/' \
-e 's/\(Copyright (c)[0-9]\+\)-[0-9]\+/\1-$(c_year)/' \
$$i; \
done
# Create a source tarball without the debian/ subdirectory
.PHONY: debsource
debsource: $(source_only_tgz)
# debuild signs the package iff DEBFULLNAME, DEBEMAIL and DEB_SIGN_KEYID are
# set. Note that if the GPG key includes an alias, it must match the latest
# entry in debian/changelog.
deb: debsource $(binaries)
@echo " [Debuild] Building package"
@debuild
.PHONY: debclean
debclean: clean
@echo " [Deb-Clean] Removing artifacts"
@debuild -- clean