xref: /openbmc/linux/net/bpfilter/Makefile (revision ba61bb17)
1# SPDX-License-Identifier: GPL-2.0
2#
3# Makefile for the Linux BPFILTER layer.
4#
5
6hostprogs-y := bpfilter_umh
7bpfilter_umh-objs := main.o
8HOSTCFLAGS += -I. -Itools/include/ -Itools/include/uapi
9HOSTCC := $(CC)
10
11ifeq ($(CONFIG_BPFILTER_UMH), y)
12# builtin bpfilter_umh should be compiled with -static
13# since rootfs isn't mounted at the time of __init
14# function is called and do_execv won't find elf interpreter
15HOSTLDFLAGS += -static
16endif
17
18# a bit of elf magic to convert bpfilter_umh binary into a binary blob
19# inside bpfilter_umh.o elf file referenced by
20# _binary_net_bpfilter_bpfilter_umh_start symbol
21# which bpfilter_kern.c passes further into umh blob loader at run-time
22quiet_cmd_copy_umh = GEN $@
23      cmd_copy_umh = echo ':' > $(obj)/.bpfilter_umh.o.cmd; \
24      $(OBJCOPY) -I binary \
25          `LC_ALL=C $(OBJDUMP) -f net/bpfilter/bpfilter_umh \
26          |awk -F' |,' '/file format/{print "-O",$$NF} \
27          /^architecture:/{print "-B",$$2}'` \
28      --rename-section .data=.init.rodata $< $@
29
30$(obj)/bpfilter_umh.o: $(obj)/bpfilter_umh
31	$(call cmd,copy_umh)
32
33obj-$(CONFIG_BPFILTER_UMH) += bpfilter.o
34bpfilter-objs += bpfilter_kern.o bpfilter_umh.o
35