File: Makefile

package info (click to toggle)
debcraft 0.7.0
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 348 kB
  • sloc: sh: 1,967; makefile: 47
file content (72 lines) | stat: -rw-r--r-- 2,795 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/make -f
# SPDX-FileCopyrightText: 2023-2025 Otto Kekäläinen <otto@debian.org>
#
# SPDX-License-Identifier: GPL-3.0-or-later

# Ensure errors are emitted past the pipes to tee
SHELL=/bin/bash -o pipefail

DESTDIR:=tmp

all: build install

build-depends:
	@echo "Check all build dependencies are present"
	@help2man --version | head -n 1

test-depends:
	@echo "Check all test dependencies are present"
	@echo -n "Codespell version: "
	@codespell --version
	@echo $$(shellcheck --version | head -n 2)

build: manpage build-depends

# @TODO: Use '--include manpage-extras' to include additional info or write the
# README.md as ronn or Pandoc compatible Markdown and convert README.md to man
# page instead of --help (and the --help instead could run 'man --pager=cat
# debcraft'). See
# https://manpages.ubuntu.com/manpages/noble/en/man7/ronn-format.7.html and
# https://eddieantonio.ca/blog/2015/12/18/authoring-manpages-in-markdown-with-pandoc/
manpage:
	@echo "Generate man page for Debcraft"
	mkdir --verbose --parents $(DESTDIR)/usr/share/man/man1
	help2man \
		--name "Easy, fast and secure way to build Debian packages" \
		--section 1 \
		--manual "Debcraft usage" \
		--output $(DESTDIR)/usr/share/man/man1/debcraft.1 \
		--no-info \
		./debcraft.sh
	# Filter out inclusion of DEB_BUILD_OPTIONS in static Makefile.
	sed -i -e 's@ (currently DEB_BUILD_OPTIONS=.*)\.@.@g' \
		$(DESTDIR)/usr/share/man/man1/debcraft.1

install: build
	install -v -p -D debcraft.sh $(DESTDIR)/usr/bin/debcraft
	install -v -p -D --mode=0644 bash-completion/debcraft-completion.sh $(DESTDIR)/usr/share/bash-completion/completions/debcraft
	# install -v -p -D --target-directory=$(DESTDIR)/usr/share/debcraft src/*
	# GNU 'install' does not support subdirectories, so use regular 'cp' instead
	cp -a src $(DESTDIR)/usr/share/debcraft

install-local:
	@echo "Installing Debcraft as symlinc at ~/bin/debcraft"
	mkdir -p ~/.local/bin
	mkdir -p ~/.local/share/bash-completion/completions
	ln --force --symbolic --verbose ${PWD}/debcraft.sh ~/.local/bin/debcraft
	ln --force --symbolic --verbose ${PWD}/bash-completion/debcraft-completion.sh ~/.local/share/bash-completion/completions/debcraft

test: test-static test-debcraft

# All generic static tests that don't need Debcraft to actually run
# @TODO: Evaluate using '-o all' to run extra validation (https://github.com/koalaman/shellcheck/wiki/Optional)
# @TODO: podman build --validate Containerfile?
test-static: test-depends
	@echo "Running static tests"
	codespell --interactive=0 --check-filenames --check-hidden --skip=.git
	shellcheck -x --shell=bash $(shell grep -Irnw -e '^#!.*/bash' | sort -u |cut -d ':' -f 1 | xargs)

# Run Debcraft and ensure it behaves as expected
test-debcraft:
	@echo "Running Debcraft tests"
	tests/debcraft-tests.sh