forked from rpminspect/rpminspect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGNUmakefile
255 lines (215 loc) · 9.13 KB
/
GNUmakefile
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
# This GNU make Makefile is intended as a helper. meson is used for
# the actual build and configuration, but this Makefile provides some
# useful targets for development and release purposes. Type "gmake
# help" for more details. It is called GNUmakefile to indicate it
# requires GNU make because we do build and test on BSD platforms.
# Allow calling environment overrides to commands used in this
# GNUmakefile. Defaults are below.
# The 'realpath' command may be installed under a different name, in
# which case the calling environment can set the REALPATH variable to
# the command to use. For example, on NetBSD you need to install
# coreutils from pkgsrc and the command will be installed as
# /usr/pkg/bin/grealpath.
ifeq ($(shell uname 2>/dev/null),NetBSD)
REALPATH ?= grealpath
endif
REALPATH ?= realpath
NINJA ?= ninja
MESON ?= meson
PYTHON ?= python3
# Core directories
MESON_BUILD_DIR = build
topdir := $(shell $(REALPATH) $(dir $(lastword $(MAKEFILE_LIST))))
# Project information (may be an easier way to get this from meson)
PROJECT_NAME = $(shell grep ^project $(topdir)/meson.build | cut -d "'" -f 2)
PROJECT_VERSION = $(shell grep version $(topdir)/meson.build | grep -E ',$$' | cut -d "'" -f 2)
# Additional packages required to run the test suite, varies by OS
OS = $(shell $(topdir)/utils/determine-os.sh)
ifeq ($(OS),)
OS = $(error "*** unable to determine host operating system")
endif
# Handle optional architecture if specified
ifeq ($(OSDEPS_ARCH),)
OS_SUBDIR = $(OS)
else
OS_SUBDIR = $(OS).$(OSDEPS_ARCH)
endif
-include $(topdir)/osdeps/$(OS_SUBDIR)/defs.mk
ifeq ($(PKG_CMD),)
PKG_CMD = $(error "*** unable to determine host operating system package command")
endif
# Take additional command line argument as a positional parameter for
# the Makefile target
TARGET_ARG = `arg="$(filter-out $@,$(MAKECMDGOALS))" && echo $${arg:-${1}}`
# regexp of email addresses of primary authors on the project
PRIMARY_AUTHORS = [email protected]
# full path to release tarball and detached signature
# (this comes from a 'make srpm')
RELEASED_TARBALL = $(PROJECT_NAME)-$(PROJECT_VERSION).tar.gz
RELEASED_TARBALL_ASC = $(RELEASED_TARBALL).asc
# FreeBSD installs ports to /usr/local, so make sure we pick up
# libraries and headers correctly.
ifeq ($(OS),freebsd)
export CFLAGS=-I/usr/local/include
export LDFLAGS=-L/usr/local/lib
endif
all: setup
$(NINJA) -C $(MESON_BUILD_DIR) -v
setup:
$(MESON) setup $(MESON_BUILD_DIR) $(MESON_OPTIONS)
debug: setup-debug
$(NINJA) -C $(MESON_BUILD_DIR) -v
setup-debug:
$(MESON) setup $(MESON_BUILD_DIR) --werror --buildtype=debug -D python_program="$(PYTHON)" -D b_coverage=true $(MESON_OPTIONS)
# NOTE: Set QA_RPATHS=63 so that check-rpaths is disabled during the
# rpmfluff rpmbuild operations. We want to let bad DT_RPATH values
# through for the test suite so that rpminspect can catch them. The
# only way to disable check-rpaths in rpmbuild is to use this
# environment variable -or- remove the script(s) from /usr/lib/rpm.
# The environment variable is easier.
export QA_RPATHS = 63
# Make sure rpmfluff has a usable compiler. gcc is not on default
# FreeBSD installs anymore, so have it use 'clang'.
ifeq ($(OS),freebsd)
export CC = clang
endif
# To keep intermediate files and results files for each test case, set
# KEEP=y (or to any value) in the calling environment when you run
# 'make check'. For example: make check KEEP=y
check: setup
@test_name="$(call TARGET_ARG,)" ; \
if [ -z "$${test_name}" ]; then \
env $(MESON) test -C $(MESON_BUILD_DIR) -v ; \
else \
test_script="test_$${test_name}.py" ; \
if [ ! -f "$(topdir)/test/$${test_script}" ]; then \
echo "*** test/$${test_script} does not exist." >&2 ; \
exit 1 ; \
fi ; \
env RPMINSPECT=$(topdir)/build/src/rpminspect \
RPMINSPECT_YAML=$(topdir)/data/generic.yaml \
RPMINSPECT_TEST_DATA_PATH=$(topdir)/test/data \
$(PYTHON) -Bm unittest discover -v $(topdir)/test/ $${test_script} ; \
fi
flake8:
$(PYTHON) -m flake8
black:
$(PYTHON) -m black --check --diff $(topdir)/test/ $(topdir)/doc/
shellcheck:
find . -type f \( -iname "*.sh" ! -iname "find-debuginfo.sh" \) -exec shellcheck --severity=warning {} \;
gate: all
$(topdir)/utils/gate.sh $(topdir)/build/src/rpminspect
update-pot: setup
find src -type f -name "*.c" > po/POTFILES.new
find lib -type f -name "*.c" >> po/POTFILES.new
find include -type f -name "*.h" >> po/POTFILES.new
sort -u po/POTFILES.new > po/POTFILES
rm -f po/POTFILES.new
$(NINJA) -C $(MESON_BUILD_DIR) rpminspect-pot
srpm:
$(topdir)/utils/srpm.sh
copr-srpm:
$(topdir)/utils/srpm.sh -c
# This target will increment the version number, commit, tag, and
# push. Generally this is not the desired release behavior as the
# development tree is already using the upcoming release number.
new-release:
$(topdir)/utils/release.sh -A
# This target tags and pushes the current development tree.
release:
$(topdir)/utils/release.sh -t -p
# Generates content for CHANGES.md from previous tag to HEAD
announce:
@$(topdir)/utils/mkannounce.sh
# Generates changes between the two most recent stable releases,
# excluding HEAD
stable-announce:
@$(topdir)/utils/mkannounce.sh --stable
koji: srpm
@if [ ! -f $(RELEASED_TARBALL) ]; then \
echo "*** Missing $(RELEASED_TARBALL), be sure to have run 'make srpm'" >&2 ; \
exit 1 ; \
fi
@if [ ! -f $(RELEASED_TARBALL_ASC) ]; then \
echo "*** Missing $(RELEASED_TARBALL_ASC), be sure to have run 'make srpm'" >&2 ; \
exit 1 ; \
fi
$(topdir)/utils/submit-koji-builds.sh $(RELEASED_TARBALL) $(RELEASED_TARBALL_ASC) $$(basename $(topdir))
clean:
-rm -rf $(MESON_BUILD_DIR)
# Set to 'y' in the calling environment to skip the pip package
# installation in instreqs.
SKIP_PIP ?= n
instreqs:
if [ -x $(topdir)/osdeps/$(OS_SUBDIR)/pre.sh ]; then \
env OSDEPS=$(topdir)/osdeps/$(OS_SUBDIR) $(topdir)/osdeps/$(OS_SUBDIR)/pre.sh ; \
fi
if [ -f $(topdir)/osdeps/$(OS_SUBDIR)/reqs.txt ]; then \
$(PKG_CMD) $$(grep -v ^# $(topdir)/osdeps/$(OS_SUBDIR)/reqs.txt 2>/dev/null | awk 'NF' ORS=' ') ; \
fi
if [ ! "$(SKIP_PIP)" = "y" ] && [ -f $(topdir)/osdeps/$(OS_SUBDIR)/pip.txt ]; then \
$(PIP_CMD) $$(grep -v ^# $(topdir)/osdeps/$(OS_SUBDIR)/pip.txt 2>/dev/null | awk 'NF' ORS=' ') ; \
fi
if [ -x $(topdir)/osdeps/$(OS_SUBDIR)/post.sh ]; then \
env OSDEPS=$(topdir)/osdeps/$(OS_SUBDIR) $(topdir)/osdeps/$(OS_SUBDIR)/post.sh ; \
fi
authors:
echo "Primary Authors" > AUTHORS.md
echo "===============" >> AUTHORS.md
echo >> AUTHORS.md
git log --pretty="%an <%ae>" | sort -u | grep -E "$(PRIMARY_AUTHORS)" | sed -e 's|^|- |g' | sed G >> AUTHORS.md
echo >> AUTHORS.md
echo "Contributors" >> AUTHORS.md
echo "============" >> AUTHORS.md
echo >> AUTHORS.md
git log --pretty="%aN <%aE>" | sort -u | grep -vE "$(PRIMARY_AUTHORS)" | sed -e 's|^|- |g' | sed G >> AUTHORS.md
head -n $$(($$(wc -l < AUTHORS.md) - 1)) AUTHORS.md > AUTHORS.md.new
mv AUTHORS.md.new AUTHORS.md
update-uthash:
$(topdir)/utils/update-uthash.sh $(topdir)/include
help:
@echo "rpminspect helper Makefile"
@echo "The source tree uses meson(1) for building and testing, but this Makefile"
@echo "is intended as a simple helper for the common steps."
@echo
@echo " all Default target, setup tree to build and build"
@echo " debug Setup tree for debug build and build"
@echo " setup Run '$(MESON) setup $(MESON_BUILD_DIR)'"
@echo " setup-debug The counterpart to 'setup'; called by 'debug'"
@echo " check Run '$(MESON) test -C $(MESON_BUILD_DIR) -v'"
@echo " update-pot Update po/POTFILES and po/rpminspect.pot"
@echo " srpm Generate an SRPM package of the latest release"
@echo " copr-srpm Generate an SRPM package of the latest HEAD revision"
@echo " release Tag and push current tree as a release"
@echo " new-release Bump version, tag, and push current tree as a release"
@echo " koji Run 'make srpm' then 'utils/submit-koji-builds.sh'"
@echo " clean Run 'rm -rf $(MESON_BUILD_DIR)'"
@echo " instreqs Install required build and runtime packages"
@echo " authors Generate a new AUTHORS.md file"
@echo " update-uthash Update include/uthash.h from upstream"
@echo
@echo "To build:"
@echo " make"
@echo
@echo "To perform syntax and style checks:"
@echo " make shellcheck Run ShellCheck on all shell scripts"
@echo " make flake8 Run Python flake8 checks on all Python files"
@echo " make black Run Python black checks on all Python files"
@echo
@echo "To run the test suite:"
@echo " make check"
@echo
@echo "To run a single test script (e.g., test_elf.py):"
@echo " make check elf"
@echo
@echo "Make a new release on Github:"
@echo " make release # just tags and pushes"
@echo " make new-release # bumps version number, tags, and pushes"
@echo
@echo "Generate SRPM of the latest release and do all Koji builds:"
@echo " env BRANCHES=\"rawhide f31 f32 f33 epel7 epel8\" make koji"
@echo "NOTE: You must set the BRANCHES environment variable for the koji target"
@echo "otherwise it will just build for the master branch."
# Quiet errors about target arguments not being targets
%:
@true