Debian Codegraph @

Makefile

raw symbols SCIP
1 #!/usr/bin/make -f
2 # SPDX-FileCopyrightText: 2023-2025 Otto Kekäläinen <[email protected]g>
3 #
4 # SPDX-License-Identifier: GPL-3.0-or-later
5
6 # Ensure errors are emitted past the pipes to tee
7 SHELL=/bin/bash -o pipefail
8
9 DESTDIR:=tmp
10
11 all: build install
12
13 build-depends:
14 @echo "Check all build dependencies are present"
15 @help2man --version | head -n 1
16
17 test-depends:
18 @echo "Check all test dependencies are present"
19 @echo -n "Codespell version: "
20 @codespell --version
21 @echo $$(shellcheck --version | head -n 2)
22
23 build: manpage build-depends
24
25 # @TODO: Use '--include manpage-extras' to include additional info or write the
26 # README.md as ronn or Pandoc compatible Markdown and convert README.md to man
27 # page instead of --help (and the --help instead could run 'man --pager=cat
28 # debcraft'). See
29 # https://manpages.ubuntu.com/manpages/noble/en/man7/ronn-format.7.html and
30 # https://eddieantonio.ca/blog/2015/12/18/authoring-manpages-in-markdown-with-pandoc/
31 manpage:
32 @echo "Generate man page for Debcraft"
33 mkdir --verbose --parents $(DESTDIR)/usr/share/man/man1
34 help2man \
35 --name "Easy, fast and secure way to build Debian packages" \
36 --section 1 \
37 --manual "Debcraft usage" \
38 --output $(DESTDIR)/usr/share/man/man1/debcraft.1 \
39 --no-info \
40 ./debcraft.sh
41 # Filter out inclusion of DEB_BUILD_OPTIONS in static Makefile.
42 sed -i -e 's@ (currently DEB_BUILD_OPTIONS=.*)\.@.@g' \
43 $(DESTDIR)/usr/share/man/man1/debcraft.1
44
45 install: build
46 install -v -p -D debcraft.sh $(DESTDIR)/usr/bin/debcraft
47 install -v -p -D --mode=0644 bash-completion/debcraft-completion.sh $(DESTDIR)/usr/share/bash-completion/completions/debcraft
48 # install -v -p -D --target-directory=$(DESTDIR)/usr/share/debcraft src/*
49 # GNU 'install' does not support subdirectories, so use regular 'cp' instead
50 cp -a src $(DESTDIR)/usr/share/debcraft
51
52 install-local:
53 @echo "Installing Debcraft as symlink at ~/bin/debcraft"
54 mkdir -p ~/.local/bin
55 mkdir -p ~/.local/share/bash-completion/completions
56 ln --force --symbolic --verbose ${PWD}/debcraft.sh ~/.local/bin/debcraft
57 ln --force --symbolic --verbose ${PWD}/bash-completion/debcraft-completion.sh ~/.local/share/bash-completion/completions/debcraft
58
59 test: test-static test-debcraft
60
61 # All generic static tests that don't need Debcraft to actually run
62 # @TODO: Evaluate using '-o all' to run extra validation (https://github.com/koalaman/shellcheck/wiki/Optional)
63 # @TODO: podman build --validate Containerfile?
64 test-static: test-depends
65 @echo "Running static tests"
66 if grep --exclude Makefile --exclude Containerfile -r -E '; do|; then' *; then echo "Unnecessary semicolon use found"; exit 1; fi
67 codespell --interactive=0 --check-filenames --check-hidden --skip=.git \
68 --ignore-words-list soler
69 shellcheck -x --shell=bash $(shell grep -Irnw -e '^#!.*/bash' | sort -u |cut -d ':' -f 1 | xargs)
70
71 # Run Debcraft and ensure it behaves as expected
72 test-debcraft:
73 @echo "Running Debcraft tests"
74 tests/debcraft-tests.sh