forked from bus1/bus1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
128 lines (114 loc) · 3.46 KB
/
Makefile
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
#
# Out-of-tree Bus1 Module
# This makefile builds the out-of-tree Bus1 module and all complementary
# elements, including documentation provided alongside the module.
#
# This Makefile serves two purposes. It serves as main Makefile for this
# project, but also as entry point for the out-of-tree kernel makefile hook.
# Therefore, this makefile is split into two parts. To avoid any conflicts, we
# move fixups, etc., into separate makefiles that are called from within here.
#
#
# Kernel Makefile
# This part builds the kernel module and everything related. It uses the kbuild
# infrastructure to hook into the obj- build of the kernel.
# The Documentation cannot be added here, as the kernel doesn't support that
# for out-of-tree modules.
#
obj-$(CONFIG_BUS1) += ipc/bus1/
#
# Project Makefile
# Everything below is part of the out-of-tree module and builds the related
# tools if the kernel makefile cannot be used.
#
BUS1EXT ?= 1
KERNELVER ?= $(shell uname -r)
MODLIB := $(INSTALL_MOD_PATH)/lib/modules/$(KERNELVER)
KERNELDIR ?= $(MODLIB)/build
SHELL := /bin/bash
DEPMOD := /sbin/depmod
PWD := $(shell pwd)
EXTRA_CFLAGS += -I$(PWD)/include -DCONFIG_BUS1_TESTS=1
#
# Default Target
# By default, build the out-of-tree module and everything that belongs into the
# same build.
#
all: module
.PHONY: all
#
# Module Target
# The 'module' target maps to the default out-of-tree target of the current
# tree. This builds the obj-{y,m} contents and also any hostprogs. We need a
# fixup for cflags and configuration options. Everything else is taken directly
# from the kernel makefiles.
#
module:
@$(MAKE) -C $(KERNELDIR) \
M=$(PWD) \
BUS1EXT=$(BUS1EXT) \
EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \
CONFIG_BUS1=m \
CONFIG_BUS1_TESTS=y
.PHONY: module
#
# Documentation Target
# The out-of-tree support in the upstream makefile lacks integration with
# documentation targets. Therefore, we need a fixup makefile to make sure our
# documentation makefile works properly.
#
%docs:
@$(MAKE) -f Makefile.docs $@
#
# Test
# This builds the self-tests, as 'kselftest' does not provide any out-of-tree
# integration..
#
tests:
@$(MAKE) -C tools/testing/selftests/bus1/ \
BUS1EXT=$(BUS1EXT) \
EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \
CONFIG_BUS1=m \
CONFIG_BUS1_TESTS=y
.PHONY: tests
#
# Check
# This runs sparse as part of the build process to try to detect any common
# errors in the kernel code.
#
check:
@$(MAKE) -C $(KERNELDIR) M=$(PWD) C=2 CF="-D__CHECK_ENDIAN" \
BUS1EXT=$(BUS1EXT) \
EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \
CONFIG_BUS1=m \
CONFIG_BUS1_TESTS=y
.PHONY: check
clean:
rm -f *.o *~ core .depend .*.cmd *.ko *.mod.c
rm -f ipc/bus1/{,util/}{*.ko,*.o,.*.cmd,*.order,*.mod.c}
rm -f Module.markers Module.symvers modules.order
rm -f Documentation/bus1/{*.7,*.html}
rm -f tools/testing/selftests/bus1/*.o
rm -rf .tmp_versions Modules.symvers $(hostprogs-y)
.PHONY: clean
install: module
mkdir -p $(MODLIB)/kernel/ipc/bus1/
cp -f ipc/bus1/bus$(BUS1EXT).ko $(MODLIB)/kernel/ipc/bus1/
$(DEPMOD) -b $(INSTALL_MOD_PATH) $(KERNELVER)
.PHONY: install
uninstall:
rm -f $(MODLIB)/kernel/ipc/bus1/bus$(BUS1EXT).ko
.PHONY: uninstall
tt-prepare: module
-sudo sh -c 'dmesg -c > /dev/null'
-sudo sh -c 'rmmod bus$(BUS1EXT)'
sudo sh -c 'insmod ipc/bus1/bus$(BUS1EXT).ko'
.PHONY: tt-prepare
tt: tests tt-prepare
@$(MAKE) -C tools/testing/selftests/bus1/ \
BUS1EXT=$(BUS1EXT) \
EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \
CONFIG_BUS1=m \
CONFIG_BUS1_TESTS=y \
run_tests ; (R=$$? ; dmesg ; exit $$R)
.PHONY: tt