-
Notifications
You must be signed in to change notification settings - Fork 549
Expand file tree
/
Copy pathnetmap.mak.in
More file actions
191 lines (154 loc) · 5.9 KB
/
netmap.mak.in
File metadata and controls
191 lines (154 loc) · 5.9 KB
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# To build external modules, you must have a prebuilt kernel available
# that contains the configuration and header files used in the build.
# go in the kernel directory and do a
# make oldconfig; make scripts; make prepare
# or make defconfig; make scripts; make prepare
#
MODNAME:=@MODNAME@
SUBSYS:=@SUBSYS@
SRCDIR:=@SRCDIR@
BUILDDIR:=@BUILDDIR@
DEBUG:=@DEBUG@
VALE_ZERO_COPY:=@VALE_ZERO_COPY@
# The following commands are needed to build the modules as out-of-tree,
# in fact the kernel sources path must be specified.
# subsystem flags
SUBSYS_FLAGS = $(foreach s,$(SUBSYS),-DCONFIG_NETMAP_$(shell echo $s|tr a-z- A-Z_))
# Additional compile flags (e.g. header location)
EXTRA_CFLAGS := -I$(BUILDDIR) -I$(SRCDIR) -I$(SRCDIR)/../sys -I$(SRCDIR)/../sys/dev -DCONFIG_NETMAP
EXTRA_CFLAGS += -Wno-unused-but-set-variable
EXTRA_CFLAGS += $(if $(DEBUG),-g)
EXTRA_CFLAGS += $(SUBSYS_FLAGS)
# We use KSRC for the kernel configuration and sources.
# If the sources are elsewhere, then use SRC to point to them.
KSRC = @KSRC@
SRC = @SRC@
KOPTS = @KOPTS@
MODPATH = @MODPATH@
LIN_VER = @LIN_VER@
MOD_LIST := @MOD_LIST@
PATCHES = @PATCHES@
S_DRIVERS = @S_DRIVERS@
E_DRIVERS = @E_DRIVERS@
DRVSUFFIX = @DRVSUFFIX@
UTILS = @UTILS@
ifeq (1,$(VALE_ZERO_COPY))
EXTRA_CFLAGS += -DVALE_ZERO_COPY
endif
ifeq (,$(DRVSUFFIX))
else
EXTRA_CFLAGS += -DNETMAP_DRIVER_SUFFIX=$(DRVSUFFIX)
endif
# actual drivers after copy and patch
DRIVERS = $(shell [ -n "$(S_DRIVERS)" ] && ls -dAp $(S_DRIVERS) 2> /dev/null)
# external drivers after copy and patch
DRIVERS_EXT = $(shell [ -n "$(E_DRIVERS)" ] && ls -dAp $(E_DRIVERS) 2> /dev/null)
COMMON_OPTS=-C $(KSRC) M=$(BUILDDIR) EXTRA_CFLAGS='$(EXTRA_CFLAGS)' $(KOPTS) modules
define common_driver
get-$(1):
$($(1)@fetch)
$($(1)@src)
$(foreach p,$($(1)@patch),patch --quiet --force -p1 < $(p);)
$($(1)@prepare)
$(if $($(1)@build),,$(if $(filter-out %.c,$(1)),mv $(1)/Makefile $(1)/orig.mak || mv $(1)/Kbuild $(1)/orig.mak; cp drv-subdir.mak $(1)/Makefile,))
touch get-$(1)
distclean-$(1):
-$($(1)@distclean)
rm -rf $(1) get-$(1)
endef
define external_driver
build-$(1): get-$(1) netmap.ko
if [ -d $(1) ] && [ -e Module.symvers ]; then cp Module.symvers $(1); fi
+$($(1)@build)
clean-$(1):
-$($(1)@clean)
install-$(1): install-netmap
$($(1)@install)
endef
.PHONY: $(foreach d,$(E_DRIVERS),build-$(d) clean-$(1) install-$(1)) netmap.ko
all: $(S_DRIVERS:%=get-%) netmap.ko $(E_DRIVERS:%=build-%) apps utils
netmap.ko:
$(MAKE) $(COMMON_OPTS) CONFIG_NETMAP=m $(MOD_LIST) O_DRIVERS="$(patsubst %.c,%.o,$(filter-out $(DRIVERS_EXT),$(DRIVERS)))" NETMAP_DRIVER_SUFFIX=$(DRVSUFFIX)
-include extdrv-versions.mak
-include default-config.mak
-include config.mak
-include drivers.mak
$(foreach d,$(S_DRIVERS),$(eval $(call common_driver,$(d))))
$(foreach d,$(E_DRIVERS),$(eval $(call external_driver,$(d))))
.PHONY: install install-netmap install-apps install-headers install-docs
install: install-netmap $(E_DRIVERS:%=install-%) install-apps install-headers install-docs
install-netmap:
$(MAKE) -C $(KSRC) M=$(BUILDDIR) CONFIG_NETMAP=m $(MOD_LIST) \
O_DRIVERS="$(DRIVERS:%.c=%.o)" \
$(KOPTS) \
NETMAP_DRIVER_SUFFIX=$(DRVSUFFIX) \
$(if $(MODPATH),INSTALL_MOD_PATH=$(MODPATH)) \
modules_install
clean: $(E_DRIVERS:%=clean-%) clean-apps clean-utils
-@ $(MAKE) -C $(KSRC) M=$(BUILDDIR) clean 2> /dev/null
APPS_LIST=@APPS_LIST@
APPS_CC=@APPS_CC@
APPS_LD=@APPS_LD@
PREFIX=@PREFIX@
DESTDIR?=@DESTDIR@
APPS_BUILD=$(APPS_LIST:%=build-app-%)
APPS_INSTALL=$(APPS_LIST:%=install-app-%)
apps: $(APPS_BUILD)
install-apps: $(APPS_INSTALL)
clean-apps: $(APPS_LIST:%=clean-app-%)
.PHONY: apps $(APPS_BUILD) install-apps $(APPS_INSTALL)
define apps_actions
build-app-$(1):
+$(MAKE) -C build-apps/$(1) SRCDIR=$(SRCDIR)/.. CC="$(APPS_CC)" LD="$(APPS_LD)"
install-app-$(1):
$(MAKE) -C build-apps/$(1) install SRCDIR=$(SRCDIR)/.. DESTDIR="$(abspath $(DESTDIR))" PREFIX="$(PREFIX)"
clean-app-$(1):
$(MAKE) -C build-apps/$(1) clean SRCDIR=$(SRCDIR)/..
endef
$(foreach a,$(APPS_LIST),$(eval $(call apps_actions,$(a))))
+%:
@echo '$($*)'
ifeq (,$(UTILS))
utils:
install-utils:
clean-utils:
intest:
unitest:
else
.PHONY: utils
utils:
+$(MAKE) -C build-utils SRCDIR=$(SRCDIR)/.. CC="$(APPS_CC)" LD="$(APPS_LD)" SUBSYS_FLAGS="$(SUBSYS_FLAGS)"
install-utils:
$(MAKE) -C build-utils install SRCDIR=$(SRCDIR)/.. DESTDIR="$(abspath $(DESTDIR))" PREFIX="$(PREFIX)"
clean-utils:
$(MAKE) -C build-utils clean SRCDIR=$(SRCDIR)/..
intest: utils
$(SRCDIR)/../utils/randomized_tests
unitest: utils
build-utils/ctrl-api-test
endif
INCLUDE_PREFIX := $(if $(filter-out /,$(PREFIX)),$(PREFIX),/usr)
install-headers:
install -m 0644 -D $(SRCDIR)/../sys/net/netmap.h $(DESTDIR)/$(INCLUDE_PREFIX)/include/net/netmap.h
install -m 0644 -D $(SRCDIR)/../sys/net/netmap_user.h $(DESTDIR)/$(INCLUDE_PREFIX)/include/net/netmap_user.h
install -m 0644 -D $(SRCDIR)/../sys/net/netmap_virt.h $(DESTDIR)/$(INCLUDE_PREFIX)/include/net/netmap_virt.h
install -m 0644 -D $(SRCDIR)/../sys/net/netmap_legacy.h $(DESTDIR)/$(INCLUDE_PREFIX)/include/net/netmap_legacy.h
MAN_PREFIX := $(INCLUDE_PREFIX)
install-docs:
install -D -m 644 $(SRCDIR)/../share/man/man4/netmap.4 $(DESTDIR)/$(MAN_PREFIX)/share/man/man4/netmap.4
install -D -m 644 $(SRCDIR)/../share/man/man4/vale.4 $(DESTDIR)/$(MAN_PREFIX)/share/man/man4/vale.4
install -D -m 644 $(SRCDIR)/../share/man/man4/ptnet.4 $(DESTDIR)/$(MAN_PREFIX)/share/man/man4/ptnet.4
distclean: clean $(S_DRIVERS:%=distclean-%)
rm -f config.status config.log netmap_linux_config.h \
patches drivers.mak Kbuild netmap.mak default-config.mak \
extdrv-versions.mak
rm -rf netmap-tmpdir
rm -f *.orig *.rej
if [ -L GNUmakefile ]; then rm GNUmakefile; fi
if [ -L drv-subdir.mak ]; then rm drv-subdir.mak; fi
if [ -L read-vars.mak ]; then rm read-vars.mak; fi
if [ -L tests ]; then rm tests; fi
rm -rf build-apps
rm -rf build-utils
format:
clang-format -i -style=file $(shell git ls-files "utils/*.[ch]" "apps/*.[ch]" "extra/*.[ch]" "LINUX/*.[ch]" "WINDOWS/*.[ch]" "sys/*.[ch]")