From patchwork Thu Apr 28 12:20:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jesper Dangaard Brouer X-Patchwork-Id: 616185 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3qwbXL0tDqz9t7W for ; Thu, 28 Apr 2016 22:21:06 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753099AbcD1MVB (ORCPT ); Thu, 28 Apr 2016 08:21:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36409 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752891AbcD1MVA (ORCPT ); Thu, 28 Apr 2016 08:21:00 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3836312B24; Thu, 28 Apr 2016 12:21:00 +0000 (UTC) Received: from firesoul.localdomain (ovpn-200-34.brq.redhat.com [10.40.200.34]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u3SCKxhI005863; Thu, 28 Apr 2016 08:20:59 -0400 Received: from [192.168.42.3] (localhost [IPv6:::1]) by firesoul.localdomain (Postfix) with ESMTP id F13B630746076; Thu, 28 Apr 2016 14:20:58 +0200 (CEST) Subject: [net-next PATCH V4 2/5] samples/bpf: Makefile verify LLVM compiler avail and bpf target is supported From: Jesper Dangaard Brouer To: netdev@vger.kernel.org Cc: linux-kbuild@vger.kernel.org, bblanco@plumgrid.com, Jesper Dangaard Brouer , naveen.n.rao@linux.vnet.ibm.com, borkmann@iogearbox.net, alexei.starovoitov@gmail.com Date: Thu, 28 Apr 2016 14:20:58 +0200 Message-ID: <20160428122058.16807.38757.stgit@firesoul> In-Reply-To: <20160428121949.16807.84828.stgit@firesoul> References: <20160428121949.16807.84828.stgit@firesoul> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Make compiling samples/bpf more user friendly, by detecting if LLVM compiler tool 'llc' is available, and also detect if the 'bpf' target is available in this version of LLVM. Signed-off-by: Jesper Dangaard Brouer Acked-by: Alexei Starovoitov --- samples/bpf/Makefile | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile index 5bae9536f100..45859c99f573 100644 --- a/samples/bpf/Makefile +++ b/samples/bpf/Makefile @@ -85,6 +85,24 @@ HOSTLOADLIBES_test_overhead += -lelf -lrt # make samples/bpf/ LLC=~/git/llvm/build/bin/llc LLC ?= llc +# Verify LLVM compiler is available and bpf target is supported +.PHONY: verify_cmd_llc verify_target_bpf + +verify_cmd_llc: + @if ! (which "${LLC}" > /dev/null 2>&1); then \ + echo "*** ERROR: Cannot find LLVM tool 'llc' (${LLC})" ;\ + exit 1; \ + else true; fi + +verify_target_bpf: verify_cmd_llc + @if ! (${LLC} -march=bpf -mattr=help > /dev/null 2>&1); then \ + echo "*** ERROR: LLVM (${LLC}) does not support 'bpf' target" ;\ + echo " NOTICE: LLVM version >= 3.7.1 required" ;\ + exit 2; \ + else true; fi + +$(src)/*.c: verify_target_bpf + # asm/sysreg.h - inline assembly used by it is incompatible with llvm. # But, there is no easy way to fix it, so just exclude it since it is # useless for BPF samples.