summaryrefslogtreecommitdiffstats
path: root/GNUmakefile
blob: 29b94867d641004ea66f409250254ea2f9eecf6f (plain) (blame)
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
# Copyright 2021-2024 Alejandro Colomar <alx@kernel.org>
# SPDX-License-Identifier: LGPL-3.0-or-later WITH LGPL-3.0-linking-exception


BASH        := bash
SHELL       := /usr/bin/env
.SHELLFLAGS := -S '$(BASH) -Eeuo pipefail -c'


MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
MAKEFLAGS += --no-builtin-variables


srcdir      := .
builddir    := .tmp
DATAROOTDIR := $(srcdir)/share
MAKEFILEDIR := $(DATAROOTDIR)/mk


.DEFAULT_GOAL := build


.PHONY: all
all: lint build check dist
	@:


.PHONY: help
help:
	$(info	Targets:)
	$(info	)
	$(info	all			Alias for "lint build check dist")
	$(info	)
	$(info	clean			Remove $$(builddir))
	$(info	)
	$(info	build (.DEFAULT_GOAL)	Wrapper for "build-lib build-dev")
	$(info	build-deps		Build the .d files)
	$(info	build-dev		Wrapper for build-dev-* targets)
	$(info	build-dev-src		Copy the source files)
	$(info	build-dev-pc		Build the pc(5) file)
	$(info	build-lib		Wrapper for build-lib-* targets)
	$(info	build-lib-shared	Build the shared library)
	$(info	build-lib-static	Build the static library)
	$(info	build-obj		Alias for "build-obj-as")
	$(info	build-obj-pch		Precompile headers)
	$(info	build-obj-cpp		Preprocess source TUs)
	$(info	build-obj-cc		Compile TUs)
	$(info	build-obj-as		Assemble TUs)
	$(info	)
	$(info	lint			Alias for "lint-c")
	$(info	lint-c			Wrapper for lint-c-* targets)
	$(info	lint-c-checkpatch	Lint C files with checkpatch(1))
	$(info	lint-c-clang-tidy	Lint C files with clang-tidy(1))
	$(info	lint-c-cppcheck		Lint C files with cppcheck(1))
	$(info	lint-c-cpplint		Lint C files with cpplint(1))
	$(info	lint-c-iwyu		Lint C files with iwyu(1))
	$(info	)
	$(info	check			Check the built library)
	$(info	)
	$(info	install			Wrapper for install-* targets)
	$(info	install-dev		Wrapper for install-dev-* targets)
	$(info	install-dev-include	Install header files (.h))
	$(info	install-dev-pc		Install pc(5) file)
	$(info	install-lib		Wrapper for install-lib-* targets)
	$(info	install-lib-shared	Install shared library (.so))
	$(info	install-lib-static	Install static library (.a))
	$(info	install-man		Install manual pages)
	$(info	)
	$(info	installcheck		Check the installed library)
	$(info	)
	$(info	dist			Wrapper for dist-* targets)
	$(info	dist-tar		Create a release tarball)
	$(info	dist-z			Wrapper for dist-z-* targets)
	$(info	dist-z-bz2		Create a compressed tarball (.tar.bz2))
	$(info	dist-z-gz		Create a compressed tarball (.tar.gz))
	$(info	dist-z-lz		Create a compressed tarball (.tar.lz))
	$(info	dist-z-xz		Create a compressed tarball (.tar.xz))
	$(info	)
	$(info	help			Print this help)
	$(info	help-variables		Print available variables, and default values)
	$(info	)
	$(info	nothing			Make nothing.  It's useful for debug purposes)
	$(info	)


.SECONDEXPANSION:


MK_ := $(wildcard $(addprefix $(MAKEFILEDIR)/, *.mk */*.mk))
MK  := $(srcdir)/GNUmakefile $(MK_)
include $(MK_)
$(MK):: ;


.PHONY: help-variables
help-variables:
	$(info	DISTVERSION	$$(git describe))
	$(info	DISTNAME	$(libname)-$$DISTVERSION)
	$(info	)
	$(info	HIDE_ERR	Define to empty string to debug some errors)
	$(info	)
	$(info	# Directory variables:)
	$(info	)
	$(info	builddir	.tmp)
	$(info	DESTDIR)
	$(info	prefix		/usr/local)
	$(info	exec_prefix	$$prefix)
	$(info	datarootdir	$$prefix/share)
	$(info	includedir	$$prefix/include)
	$(info	libdir		$$exec_prefix/lib)
	$(info	mandir		$$datarootdir/man)
	$(info	man{3,...}dir	$$mandir/man{3,...})
	$(info	pcdir		$$libdir/pkgconfig)
	$(info	)
	$(info	# Command variables (and flags):)
	$(info	)
	$(info	BASH)
	$(info	CP, CUT, ECHO, INSTALL, LN, RM, SORT, TAC, TOUCH)
	$(info	INSTALL_DATA, INSTALL_DIR, INSTALL_PROGRAM)
	$(info	FIND, XARGS)
	$(info	GREP)
	$(info	SED)
	$(info	GIT)
	$(info	)
	$(info	PKGCONF, PKG_CONFIG	{EXTRA_,}PKGCONFFLAGS)
	$(info	)
	$(info	CPP			{EXTRA_,}CPPFLAGS)
	$(info	CC			{EXTRA_,}CCFLAGS)
	$(info	AS			{EXTRA_,}ASFLAGS)
	$(info	LD			{EXTRA_,}LDFLAGS, {EXTRA_,}LDLIBS)
	$(info	AR			{EXTRA_,}ARFLAGS)
	$(info	)
	$(info	CHECKPATCH		{EXTRA_,}CHECKPATCHFLAGS)
	$(info	CLANG_TIDY		{EXTRA_,}CLANG_TIDYFLAGS)
	$(info	CPPCHECK		{EXTRA_,}CPPCHECKFLAGS)
	$(info	CPPLINT			{EXTRA_,}CPPLINTFLAGS)
	$(info	IWYU			{EXTRA_,}IWYUFLAGS)
	$(info	)
	$(info	TAR			{EXTRA_,}TARFLAGS)
	$(info	BZIP2			{EXTRA_,}BZIP2FLAGS)
	$(info	GZIP			{EXTRA_,}GZIPFLAGS)
	$(info	LZIP			{EXTRA_,}LZIPFLAGS)
	$(info	XZ			{EXTRA_,}XZFLAGS)
	$(info	)


.PHONY: nothing
nothing:;


.DELETE_ON_ERROR:


FORCE:


include $(_TU_h_d)
include $(_TU_c_d)