• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# SPDX-License-Identifier: GPL-2.0
2
3undefine CFLAGS
4
5# Makefiles suck: This macro sets a default value of $(2) for the
6# variable named by $(1), unless the variable has been set by
7# environment or command line. This is necessary for CC and AR
8# because make sets default values, so the simpler ?= approach
9# won't work as expected.
10define allow-override
11  $(if $(or $(findstring environment,$(origin $(1))),\
12            $(findstring command line,$(origin $(1)))),,\
13    $(eval $(1) = $(2)))
14endef
15
16$(call allow-override,MESON,meson)
17$(call allow-override,MESON_BUILD_DIR,build)
18
19
20all: compile
21
22PHONY += compile
23compile: $(MESON_BUILD_DIR) force
24	$(MESON) compile -C $(MESON_BUILD_DIR)
25
26$(MESON_BUILD_DIR):
27	$(MESON) setup --prefix=$(prefix) $(MESON_BUILD_DIR)
28
29install: compile
30	$(MESON) install -C $(MESON_BUILD_DIR)
31
32docs: $(MESON_BUILD_DIR)
33	$(MESON) compile -C build docs
34
35PHONY += clean_meson
36clean_meson:
37	$(Q)$(RM) -rf $(MESON_BUILD_DIR)
38
39PHONY += force
40force:
41