-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
165 lines (149 loc) · 5.13 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#
# Copyright (C) 2006-2010 Dmitry V. Levin <[email protected]>
# Copyright (C) 2006-2018 Alexey Gladkov <[email protected]>
# Copyright (C) 2006,2009 Alexey I. Froloff <[email protected]>
# Copyright (C) 2006-2007 Sergey Vlasov <[email protected]>
# Copyright (C) 2021 Gleb Fotengauer-Malinovskiy <[email protected]>
#
# Makefile for the gear project.
#
# This file 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; either version 2 of the License, or
# (at your option) any later version.
#
# 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, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
#
PROJECT = gear
VERSION = $(shell sed '/^Version: */!d;s///;q' gear.spec)
PROGRAMS = \
describe-specfile \
gear \
gear-buildreq \
gear-changelog \
gear-commit \
gear-create-tag \
gear-edit-spec \
gear-hsh \
gear-hsh-build \
gear-import \
gear-merge \
gear-mock \
gear-remote \
gear-remote-hsh \
gear-remote-rpm \
gear-rpm \
gear-srpmimport \
gear-store-tags \
gear-update \
#
HELPERS = \
gear-changelog-deb \
gear-changelog-gnu \
gear-changelog-rpm \
gear-command-hasher \
gear-command-mock \
gear-command-remote-build \
gear-command-rpmbuild \
gear-command-tar \
gear-update-src-cpio \
gear-update-src-cpio.bz2 \
gear-update-src-cpio.gz \
gear-update-src-cpio.xz \
gear-update-src-cpio.zst \
gear-update-src-dir \
gear-update-src-gem \
gear-update-src-tar \
gear-update-src-zip \
#
FUNCTIONS = \
gear-sh-functions \
gear-update-sh-functions \
gear-utils-sh-functions \
#
DATAFILES = gear-import-rules
MAN1PAGES = $(PROGRAMS:=.1)
MAN5PAGES = gear-rules.5 gear-merge-rules.5 gear-changelog-rules.5 \
gear-import-rules.5
MANPAGES = $(MAN1PAGES) $(MAN5PAGES)
HTMLPAGES = $(MANPAGES:=.html)
TARGETS = gear-sh-functions gear-import $(MANPAGES)
bindir = /usr/bin
datadir = /usr/share
geardatadir = $(datadir)/$(PROJECT)
mandir = $(datadir)/man
man1dir = $(mandir)/man1
man5dir = $(mandir)/man5
DESTDIR =
CP = cp -a
HELP2MAN1 = env PATH=":$$PATH" help2man -N -s1 -S '$(PROJECT) $(VERSION)'
INSTALL = install
LN_S = ln -s
MAN2HTML = man2html -r
MKDIR_P = mkdir -p
TOUCH_R = touch -r
CHMOD = chmod
.PHONY: all check install verify clean
all: $(TARGETS)
$(MAN1PAGES): gear-sh-functions gear-utils-sh-functions
$(MAN7PAGES):
%: %.in
sed \
-e 's,@VERSION@,$(VERSION),g' \
-e 's,@geardatadir@,$(geardatadir),g' \
<$< >$@
$(TOUCH_R) $< $@
chmod --reference=$< $@
%.1: % %.1.inc gear-sh-functions gear-utils-sh-functions
$(HELP2MAN1) -i [email protected] ./$< >$@
%.html: %
$(MAN2HTML) $< >$@
sed -i -e '/^Content-type: /d' -e '/^Time: /d' -e '/index\.html/d' \
-e 's|HREF="\.\./man./gear|HREF="gear|g' \
-e 's|<A HREF="\.\./man./[^/]\+\.html">\([^<]\+\)</A>|\1|g' \
-e 's|<A HREF="mailto:[^"]\+">\([^@<]\+@[^<]\+\)</A>|\1|' \
-e 's|\(@altlinux\)\.[a-z]\+|\1|' \
-e 's|.*\(man2html\).*|\1|' \
$@
html: $(HTMLPAGES)
check: tests/run
cd tests && ./run
install: all
$(MKDIR_P) -m755 $(DESTDIR)$(bindir)
$(CHMOD) 644 $(FUNCTIONS)
$(CP) $(FUNCTIONS) $(DESTDIR)$(bindir)/
$(CHMOD) 755 $(PROGRAMS) $(HELPERS)
$(CP) $(PROGRAMS) $(HELPERS) $(DESTDIR)$(bindir)/
$(MKDIR_P) -m755 $(DESTDIR)$(man1dir)
$(INSTALL) -p -m644 $(MAN1PAGES) $(DESTDIR)$(man1dir)/
$(MKDIR_P) -m755 $(DESTDIR)$(man5dir)
$(INSTALL) -p -m644 $(MAN5PAGES) $(DESTDIR)$(man5dir)/
$(MKDIR_P) -m755 $(DESTDIR)$(geardatadir)
$(INSTALL) -p -m644 $(DATAFILES) $(DESTDIR)$(geardatadir)/
# See https://github.com/koalaman/shellcheck/wiki/SC1090 for more information.
SHELLCHECK_EXCLUDE =
SHELLCHECK_EXCLUDE += SC1090 # ShellCheck is not able to include sourced files from paths that are determined at runtime.
SHELLCHECK_EXCLUDE += SC1091 # ShellCheck, for whichever reason, is not able to access the source file.
SHELLCHECK_EXCLUDE += SC2004 # $/${} is unnecessary on arithmetic variables.
SHELLCHECK_EXCLUDE += SC2015 # Note that A && B || C is not if-then-else.
SHELLCHECK_EXCLUDE += SC2034 # Variable appears unused. Verify it or export it.
SHELLCHECK_EXCLUDE += SC2035 # Use ./*glob* or -- *glob* so names with dashes won't become options.
SHELLCHECK_EXCLUDE += SC2086 # Double quote to prevent globbing and word splitting.
SHELLCHECK_EXCLUDE += SC2103 # Use a ( subshell ) to avoid having to cd back.
SHELLCHECK_EXCLUDE += SC2119 # Use foo "$@" if function's $1 should mean script's $1.
SHELLCHECK_EXCLUDE += SC2120 # function references arguments, but none are ever passed.
SHELLCHECK_EXCLUDE += SC2154 # var is referenced but not assigned.
SHELLCHECK_EXCLUDE += SC2163 # export takes a variable name, but you give it an expanded variable instead.
verify: $(FUNCTIONS) $(PROGRAMS) $(HELPERS)
exclude="$$(printf '%s,' $(SHELLCHECK_EXCLUDE))"; \
exclude="$${exclude%,}"; \
shellcheck -s bash $${exclude:+-e $$exclude} $^
clean:
$(RM) $(TARGETS) $(HTMLPAGES) *~