|
1 |
| -# To build external modules, you must have a prebuilt kernel available |
2 |
| -# that contains the configuration and header files used in the build. |
3 |
| -# go in the kernel directory and do a |
4 |
| -# make oldconfig; make scripts; make prepare |
5 |
| -# or make defconfig; make scripts; make prepare |
6 |
| -# |
| 1 | +all: netmap drivers |
7 | 2 |
|
| 3 | +netmap drivers: netmap.mak |
8 | 4 |
|
| 5 | +-include netmap.mak |
9 | 6 |
|
10 |
| -# list of objects for this module |
11 |
| -# |
12 |
| -# objects whose source file is in ../sys/dev/netmap |
13 |
| -remoteobjs := netmap.o netmap_mem2.o \ |
14 |
| - netmap_generic.o netmap_mbq.o netmap_vale.o \ |
15 |
| - netmap_offloadings.o netmap_pipe.o \ |
16 |
| - netmap_monitor.o |
17 |
| -# all objects |
18 |
| -netmap_lin-objs := $(remoteobjs) netmap_linux.o |
| 7 | +COMPAT_ARGS=$(if $(KSRC),--kernel-dir=$(KSRC),)\ |
| 8 | + $(if $(SRC),--kernel-sources=$(SRC),)\ |
| 9 | + $(if $(NODRIVERS),--no-drivers) |
19 | 10 |
|
20 |
| -obj-$(CONFIG_NETMAP) = netmap_lin.o |
21 |
| - |
22 |
| -ifndef NODRIVERS |
23 |
| -# list of modules to be built (actually also forcedeth and r8169) |
24 |
| -MOD_LIST:= CONFIG_E1000=m CONFIG_E1000E=m \ |
25 |
| - CONFIG_IXGBE=m CONFIG_IGB=m \ |
26 |
| - CONFIG_BNX2X=m CONFIG_MLX4=m \ |
27 |
| - CONFIG_VIRTIO_NET=m |
28 |
| -obj-m += $(O_DRIVERS) |
29 |
| -GET_DRIVERS := get-drivers |
30 |
| -else |
31 |
| -MOD_LIST:= |
32 |
| -endif |
33 |
| - |
34 |
| -# DRIVER_SRCS names of the driver sources is only used to |
35 |
| -# clean files that we copied. |
36 |
| -DRIVER_SRCS = r8169.c forcedeth.c e1000/ e1000e/ ixgbe/ igb/ |
37 |
| -DRIVER_SRCS += bnx2x/ mellanox/ mlx4/ virtio_net.c |
38 |
| - |
39 |
| -# _DRV_SUBDIRS contains the subdirs with driver sources. |
40 |
| -# In old linuxes everything is under drivers/net, newer versions |
41 |
| -# have them in source/drivers/net/ethernet/$(manufacturer) |
42 |
| - |
43 |
| -_DRV_SUBDIRS= nvidia realtek intel broadcom . .. |
44 |
| - |
45 |
| -# The following commands are needed to build the modules as out-of-tree, |
46 |
| -# in fact the kernel sources path must be specified. |
47 |
| - |
48 |
| -PWD ?= $(CURDIR) |
49 |
| -M:=$(PWD) |
50 |
| - |
51 |
| -# Additional compile flags (e.g. header location) |
52 |
| -EXTRA_CFLAGS := -I$(M) -I$(M)/../sys -I$(M)/../sys/dev -DCONFIG_NETMAP |
53 |
| -EXTRA_CFLAGS += -Wno-unused-but-set-variable |
54 |
| - |
55 |
| -# We use KSRC for the kernel configuration and sources. |
56 |
| -# If the sources are elsewhere, then use SRC to point to them. |
57 |
| -KSRC ?= /lib/modules/$(shell uname -r)/build |
58 |
| -SRC ?= $(KSRC) |
59 |
| - |
60 |
| -# extract version number. |
61 |
| -# version.h can be in two different places. |
62 |
| -# NOTE- A.B.C translates to aXXYY where XXYY are hex |
63 |
| -LIN_VER = $(shell V=linux/version.h; G=. ; \ |
64 |
| - [ -f $(KSRC)/include/$${V} ] || G=generated/uapi ;\ |
65 |
| - grep LINUX_VERSION_CODE $(KSRC)/include/$${G}/linux/version.h | \ |
66 |
| - awk '{printf "%03x%02x", $$3/256, $$3%256} ') |
67 |
| - |
68 |
| -patcheslink := $(shell \ |
69 |
| - [ -L $(PWD)/patches ] || \ |
70 |
| - { rm $(PWD)/patches; ln -s final-patches $(PWD)/patches; }) |
71 |
| - |
72 |
| -# produce a list of applicable patches for this version |
73 |
| -PATCHES := $(shell \ |
74 |
| - cd $(PWD)/patches; ls diff--* | awk -v v=$(LIN_VER) -F -- \ |
75 |
| - '{ if ((!$$3 || $$3 <= v"") && (!$$4 || v"" < $$4)) print $$0; }') |
76 |
| - |
77 |
| -# source drivers to copy. Names derived from the patches |
78 |
| -S_DRIVERS := $(shell \ |
79 |
| - cd $(PWD)/patches; ls diff--* | awk -v v=$(LIN_VER) -F -- \ |
80 |
| - '{ if ((!$$3 || $$3 <= v"") && (!$$4 || v"" < $$4)) print $$2 }' ) |
81 |
| - |
82 |
| -# actual drivers after copy and patch |
83 |
| -DRIVERS = $(shell [ "$(PATCHES)" != "" ] && ls -dAp \ |
84 |
| - `echo $(PATCHES:diff--%=%) | sed -r 's/--[0-9a-f-]+//g'` 2> /dev/null) |
85 |
| - |
86 |
| -# Compile v1000 (vhost porting to e1000) only if |
87 |
| -# the LIN_VER >= 3.8.0, because we don't want to deal |
88 |
| -# with backporting problems for v1000. |
89 |
| -ifeq ($(word 1, $(sort 30800 $(LIN_VER))), 30800) |
90 |
| -CONFIG_V1000:=m |
91 |
| -else |
92 |
| -CONFIG_V1000:=n |
93 |
| -endif |
94 |
| - |
95 |
| -CONFIG_V1000:=n # force disable by now |
96 |
| - |
97 |
| -obj-$(CONFIG_V1000) += vhost-port/ |
98 |
| - |
99 |
| - |
100 |
| -all: build |
101 |
| - |
102 |
| -build: $(GET_DRIVERS) |
103 |
| - $(MAKE) -C $(KSRC) M=$(PWD) CONFIG_NETMAP=m $(MOD_LIST) \ |
104 |
| - EXTRA_CFLAGS='$(EXTRA_CFLAGS)' \ |
105 |
| - O_DRIVERS="$(DRIVERS:%.c=%.o)" modules |
106 |
| - @ls -l `find . -name \*.ko` |
107 |
| - |
108 |
| - |
109 |
| -test: |
110 |
| - @echo "version $(LIN_VER)" |
111 |
| - @echo "patches $(PATCHES)" |
112 |
| - @echo "drivers $(DRIVERS)" |
113 |
| - |
114 |
| -clean: |
115 |
| - -@ $(MAKE) -C $(KSRC) M=$(PWD) clean 2> /dev/null |
116 |
| - -@ (rm -rf $(DRIVER_SRCS) *.orig *.rej *.ko *.o .*.d \ |
117 |
| - .tmp_versions *.mod.c modules.order \ |
118 |
| - Module.symvers .*.cmd get-drivers ) |
119 |
| - |
120 |
| -# the source is not here so we need to specify a dependency |
121 |
| -define remote_template |
122 |
| -$$(obj)/$(1): $$(M)/../sys/dev/netmap/$(1:.o=.c) |
123 |
| - $$(call cmd,cc_o_c) |
124 |
| - $$(call cmd,modversions) |
125 |
| -endef |
126 |
| -$(foreach o,$(remoteobjs),$(eval $(call remote_template,$(o)))) |
127 |
| - |
128 |
| -#-- copy and patch initial files |
129 |
| -# The location changes depending on the OS version, so ... |
130 |
| -get-drivers: |
131 |
| - -@( \ |
132 |
| - if [ -d "$(DRIVER_SRC)" ] ; then \ |
133 |
| - cd "$(DRIVER_SRC)"; s=.; what="`ls -dp *`" ; \ |
134 |
| - else \ |
135 |
| - cd $(SRC); [ -d source ] && cd source ; \ |
136 |
| - cd drivers/net; s=. ; \ |
137 |
| - [ -d ethernet ] && cd ethernet && s="$(_DRV_SUBDIRS)" ; \ |
138 |
| - what="$(S_DRIVERS)" ; \ |
139 |
| - fi ; \ |
140 |
| - echo "LIN_VER $(LIN_VER)" ; \ |
141 |
| - [ "$${what}" = "" ] && echo "-- NO DRIVERS --" && return; \ |
142 |
| - echo "---- Building from `pwd`"; \ |
143 |
| - echo "---- copying $${what} ---" ; \ |
144 |
| - what="$${what} cnic_if.h"; \ |
145 |
| - for i in $$s; do (cd $$i ; \ |
146 |
| - echo " From `pwd` :"; \ |
147 |
| - ls -ldp $${what} 2> /dev/null | sed 's/^/ /' ; \ |
148 |
| - cp -Rp $${what} $(PWD) 2>/dev/null ); \ |
149 |
| - done ; \ |
150 |
| - cd $(PWD) ; \ |
151 |
| - for i in $(PATCHES) ; \ |
152 |
| - do echo "** patch with $$i"; \ |
153 |
| - patch --posix --quiet --force -p1 < patches/$$i; \ |
154 |
| - done ; \ |
155 |
| - echo "Building the following drivers: $(S_DRIVERS)" ) |
156 |
| - @touch get-drivers |
157 |
| - |
158 |
| - |
159 |
| -test3: |
160 |
| - @echo "from $(PATCHES) -- to $(MYDRIVERS)" |
161 |
| - @echo "Drivers is $(DRIVERS)" |
162 |
| - @echo "Actually have `ls -d $(DRIVERS) 2> /dev/null`" |
163 |
| - |
164 |
| -# compute the diffs for the original files |
165 |
| -diffs: |
166 |
| - @for i in `find . -name \*.orig`; do \ |
167 |
| - diff -urp $$i $${i%.orig} ; \ |
168 |
| - done |
169 |
| - |
170 |
| -apps: |
171 |
| - (cd ../examples; $(MAKE)) |
172 |
| - |
173 |
| -+%: |
174 |
| - @echo $($*) |
| 11 | +netmap.mak: |
| 12 | + @echo 'The new way to build netmap is to run the provided configure script first,' |
| 13 | + @echo 'followed by make.' |
| 14 | + @echo 'We run configure for you now, with compatible arguments, and restart make.' |
| 15 | + @echo 'Please run configure again if this is not what you want.' |
| 16 | + ./configure $(COMPAT_ARGS) |
0 commit comments