From patchwork Tue Apr 23 18:35:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 13640556 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9DC411420A8; Tue, 23 Apr 2024 18:35:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713897352; cv=none; b=AeK7GlUs80mTzlqP0UmopQLse0WdO+BBMzOgZWzVFRgyH+vkXSzROWOtpqT4g8AjVkDwNZVv6jNqOX1wCqT61O3+gepq6aEgXZ2kKAo9Nw4L4AK8N60/IdmxV1suwlI9KolpPVPOyjeoQzNSY8ETwGbCz1dqXEMt3Y4VHDJBvkk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713897352; c=relaxed/simple; bh=VAWU1PNulVK6IrSoDcMmfCG+WwNrpOQsTXkWrjjLLxA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=k9hNjwHXZ6xgfDIyIXI3V6Eb5Qx1nzid9aSThtShBkQckATluIwntU6ikYjNSBm7UINjvN0vRQ8+XD7oN4UPKZgMAwtKkioT5blhCFta3jR6vRHPxWXffu1Z62HRstGG9jadBInfvolqZjfsF/i5NI2klLOgaHxrVzvlDptfhWQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=uI11Pq6M; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="uI11Pq6M" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0FFB1C32781; Tue, 23 Apr 2024 18:35:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713897352; bh=VAWU1PNulVK6IrSoDcMmfCG+WwNrpOQsTXkWrjjLLxA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uI11Pq6M8MCVirry+w9cSegnSm+JXY6YgEsjYNL0vW0Y0lv5lkhFcJniY+jz1LoSu Bh6gsPhZJjxXb9bmp6o0JxljPYVDveZvqU8CPTW37dqbaFPxiMB8Lnf8DN2CWjdeGs kQTprwuF8+U9T+nUJwjqAER0IC/0Bzc+NAxSSC7dN83tg4GbufYPZKc3gvFZnVDQ7Q HJhgYyLDud0rGjTmnvemvOu5TgscboIqF6XG05xfTQgdoRhxsvun7ulKfJJd7+zjOo 1PTB+orU9//Vs9EWOdq7lZeRTgjwzTafX2A0L4527+pRg9Vh+kqHQW1PBCQwH3+lrE 59YH4pDFGOCvg== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com, bpf@vger.kernel.org, Jakub Kicinski Subject: [PATCH net-next 2/2] selftests: net: extract BPF building logic from the Makefile Date: Tue, 23 Apr 2024 11:35:42 -0700 Message-ID: <20240423183542.3807234-3-kuba@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240423183542.3807234-1-kuba@kernel.org> References: <20240423183542.3807234-1-kuba@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org The BPF sample building code looks a little bit spaghetti-ish so move it out to its own Makefile snippet. Similar in the spirit to how we include lib.mk. libynl will soon get a similar snippet. There is a small change hiding in the move, the relative paths (../../.., ../.. etc) are replaced with variables from lib.mk such as top_srcdir and selfdir. Signed-off-by: Jakub Kicinski --- tools/testing/selftests/net/Makefile | 53 +--------------------------- tools/testing/selftests/net/bpf.mk | 53 ++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 52 deletions(-) create mode 100644 tools/testing/selftests/net/bpf.mk diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile index c388308ff517..5befca249452 100644 --- a/tools/testing/selftests/net/Makefile +++ b/tools/testing/selftests/net/Makefile @@ -108,55 +108,4 @@ $(OUTPUT)/tcp_inq: LDLIBS += -lpthread $(OUTPUT)/bind_bhash: LDLIBS += -lpthread $(OUTPUT)/io_uring_zerocopy_tx: CFLAGS += -I../../../include/ -# Rules to generate bpf objs -CLANG ?= clang -SCRATCH_DIR := $(OUTPUT)/tools -BUILD_DIR := $(SCRATCH_DIR)/build -BPFDIR := $(abspath ../../../lib/bpf) -APIDIR := $(abspath ../../../include/uapi) - -CCINCLUDE += -I../bpf -CCINCLUDE += -I../../../../usr/include/ -CCINCLUDE += -I$(SCRATCH_DIR)/include - -BPFOBJ := $(BUILD_DIR)/libbpf/libbpf.a - -MAKE_DIRS := $(BUILD_DIR)/libbpf -$(MAKE_DIRS): - $(call msg,MKDIR,,$@) - $(Q)mkdir -p $@ - -# Get Clang's default includes on this system, as opposed to those seen by -# '--target=bpf'. This fixes "missing" files on some architectures/distros, -# such as asm/byteorder.h, asm/socket.h, asm/sockios.h, sys/cdefs.h etc. -# -# Use '-idirafter': Don't interfere with include mechanics except where the -# build would have failed anyways. -define get_sys_includes -$(shell $(1) $(2) -v -E - &1 \ - | sed -n '/<...> search starts here:/,/End of search list./{ s| \(/.*\)|-idirafter \1|p }') \ -$(shell $(1) $(2) -dM -E - &1 \ + | sed -n '/<...> search starts here:/,/End of search list./{ s| \(/.*\)|-idirafter \1|p }') \ +$(shell $(1) $(2) -dM -E -