aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: 33b5f76b5e7460ce773ab9180502642d22c827ff (plain)
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
# =====================================================================
#  spdx-license-identifier: ISC
#  glitch top-level makefile
# =====================================================================

MAKE      := make
MAKEID    := $(shell ${MAKE} --version | head -n1)
MAKEFLAGS += -rR --no-print-directory

ARCH := $(shell sed -nE "s/CONFIG_ARCH_(.+)=y/\1/p" .config)

.PHONY: all help info run doc clean test valgrind
all: Makefile.config
	@${MAKE} -f Makefile.all

help:
	@echo "info:     show current configuration"
	@echo "all:      build kernel image"
	@echo "run:      run kernel image in qemu"
	@echo "test:     run all tests"
	@echo "valgrind: run all tests in valgrind"

info: Makefile.config
	@echo "- make:"
	@echo "    MAKE:      ${MAKE}"
	@echo "    MAKEID:    ${MAKEID}"
	@echo "    MAKEFLAGS: ${MAKEFLAGS}"
	@${MAKE} -f Makefile.all $@

run: Makefile.config
	@${MAKE} -f Makefile.all $@

doc: doxygen.config
	doxygen $<

clean:
	@${MAKE} -C lib clean
	@${MAKE} -C ${ARCH} clean
	@${MAKE} -C devices clean
	@${MAKE} -C src clean

test:
	@echo " -> Running tests in src"
	@make -C src test > /dev/null
	@echo " -> Running tests in lib"
	@make -C lib test > /dev/null

valgrind:
	@echo " -> Running valgrind on tests in lib"
	@make -C lib valgrind &> /dev/null
	@echo " -> Running valgrind on tests in src"
	@make -C src valgrind &> /dev/null

# configure targets
.config: Kconfig
	@alldefconfig

Makefile.config: .config ${ARCH}/toolchain.mk
	@echo -e '## This is a generated file, manual edits might be lost' > Makefile.config
	@echo -e '\n## .config' >> Makefile.config
	@cat .config >> Makefile.config
	@echo -e '\n## toolchain.mk' >> Makefile.config
	@cat ${ARCH}/toolchain.mk >> Makefile.config