From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760011AbbCDMhw (ORCPT ); Wed, 4 Mar 2015 07:37:52 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45561 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755386AbbCDMhv (ORCPT ); Wed, 4 Mar 2015 07:37:51 -0500 Date: Wed, 4 Mar 2015 13:37:14 +0100 From: Jiri Olsa To: Namhyung Kim Cc: Jiri Olsa , linux-kernel@vger.kernel.org, Arnaldo Carvalho de Melo , Corey Ashford , David Ahern , Ingo Molnar , Paul Mackerras , Peter Zijlstra Subject: [PATCHv2 12/14] tools build: Allow to override feature checks setup Message-ID: <20150304123714.GA7519@krava.brq.redhat.com> References: <1425392797-22572-1-git-send-email-jolsa@kernel.org> <1425392797-22572-13-git-send-email-jolsa@kernel.org> <20150304122301.GJ27046@danjae> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150304122301.GJ27046@danjae> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 04, 2015 at 09:23:01PM +0900, Namhyung Kim wrote: > On Tue, Mar 03, 2015 at 03:26:35PM +0100, Jiri Olsa wrote: > > diff --git a/tools/build/tests/features/Makefile b/tools/build/tests/features/Makefile > > new file mode 100644 > > index 000000000000..31782a1d3758 > > --- /dev/null > > +++ b/tools/build/tests/features/Makefile > > @@ -0,0 +1,23 @@ > > +all: test1 > > + > > +test1: > > + rm -f FEATURE-DUMP > > + make -f Makefile.test1 > out > > + # we should get one line with 'glibc' feature status > > + features=`cat out | grep '\.\.\.' | wc -l`; \ > > It seems this `cat | grep | wc -l` pipeline can be replaced with a > single `grep -cF ... out` command. right.. v2 attached, perf/build branch updated ;-) thanks, jirka --- Allowing to override configuration variables for feature checks. Also adding automated test and documentation. Signed-off-by: Jiri Olsa Cc: Arnaldo Carvalho de Melo Cc: Corey Ashford Cc: David Ahern Cc: Ingo Molnar Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra --- tools/build/Documentation/Feature.txt | 93 +++++++++++++++++++++++++++++++ tools/build/Makefile.feature | 4 +- tools/build/tests/features/Makefile | 23 ++++++++ tools/build/tests/features/Makefile.test1 | 16 ++++++ tools/build/tests/run.sh | 4 +- 5 files changed, 137 insertions(+), 3 deletions(-) create mode 100644 tools/build/Documentation/Feature.txt create mode 100644 tools/build/tests/features/Makefile create mode 100644 tools/build/tests/features/Makefile.test1 diff --git a/tools/build/Documentation/Feature.txt b/tools/build/Documentation/Feature.txt new file mode 100644 index 000000000000..0c75419ba803 --- /dev/null +++ b/tools/build/Documentation/Feature.txt @@ -0,0 +1,93 @@ +Feature Framework +================= +The 'feature' framework provides information for makefiles about +installed libraries and interfaces in the system. + +The 'feature' is represented by its name and simple source located +in 'tools/build/feature/test-$(name).c' file. The framework builds +each such source for configured feature and sets $(feature-$(name)) +variable to 0 or 1 if it fails or succeeds to build respectively. + +The current usage example of the feature framework is: + +--- Makefile.test + FEATURE_TESTS := glibc backtrace + FEATURE_DISPLAY := glibc + + srctree := ../../../.. + include $(srctree)/tools/build/Makefile.feature + + ifndef feature-glibc + $(error FAILED feature-glibc variable not defined) + endif + + ifndef feature-backtrace + $(error FAILED feature-backtrace variable not defined) + endif +--- + +User defines list of features to check in FEATURE_TESTS variable: + + FEATURE_TESTS := glibc backtrace + +and list of features she wishes to display in FEATURE_DISPLAY variable: + + FEATURE_DISPLAY := glibc + +then user includes Makefile.feature makefile: + + include $(srctree)/tools/build/Makefile.feature + +following output is displayed on processing of the makefile: + + $ make -f Makefile.test + + Auto-detecting system features: + ... glibc: [ on ] + +Plus following variables are defined indicating the +requested feature status: + + $(feature-glibc) + $(feature-backtrace) + +Following features are currently available for FEATURE_TESTS: + + backtrace + dwarf + fortify-source + sync-compare-and-swap + glibc + gtk2 + gtk2-infobar + libaudit + libbfd + libelf + libelf-getphdrnum + libelf-mmap + libnuma + libperl + libpython + libpython-version + libslang + libunwind + pthread-attr-setaffinity-np + stackprotector-all + timerfd + libdw-dwarf-unwind + libbabeltrace + zlib + +It's also possible to pass options for checks compilation and linking +by using following variables: + + FEATURE_CHECK_CFLAGS-$(name) + FEATURE_CHECK_LDFLAGS-$(name) + +where $(anem) represents feature name from above list. + +For example following settings will provide options for 'libunwind' +feature compilation and linking: + + FEATURE_CHECK_CFLAGS-libunwind = $(LIBUNWIND_CFLAGS) + FEATURE_CHECK_LDFLAGS-libunwind = $(LIBUNWIND_LDFLAGS) diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature index 3249fad27993..5b712ed7e4c7 100644 --- a/tools/build/Makefile.feature +++ b/tools/build/Makefile.feature @@ -27,7 +27,7 @@ endef # the rule that uses them - an example for that is the 'bionic' # feature check. ] # -FEATURE_TESTS = \ +FEATURE_TESTS ?= \ backtrace \ dwarf \ fortify-source \ @@ -53,7 +53,7 @@ FEATURE_TESTS = \ libbabeltrace \ zlib -FEATURE_DISPLAY = \ +FEATURE_DISPLAY ?= \ dwarf \ glibc \ gtk2 \ diff --git a/tools/build/tests/features/Makefile b/tools/build/tests/features/Makefile new file mode 100644 index 000000000000..cb94dda32534 --- /dev/null +++ b/tools/build/tests/features/Makefile @@ -0,0 +1,23 @@ +all: test1 + +test1: + rm -f FEATURE-DUMP + make -f Makefile.test1 > out + # we should get one line with 'glibc' feature status + features=`grep -cF ... out`; \ + if [ "$$features" != "1" ]; then echo FAILED; exit 1; fi + # we should NOT get any feature status line on second run + make -f Makefile.test1 > out + features=`grep -cF ... out`; \ + if [ "$$features" == "1" ]; then echo FAILED; exit 1; fi + # we should get both 'glibc' and 'backtrace' status lines now + make -f Makefile.test1 VF=1 > out + features=`grep -cF ... out`; \ + if [ "$$features" != "2" ]; then echo FAILED; exit 1; fi + # and fresh start without FEATURE-DUMP, expecting 'glibc' status line + rm -f FEATURE-DUMP + make -f Makefile.test1 > out + features=`grep -cF ... out`; \ + if [ "$$features" != "1" ]; then echo FAILED; exit 1; fi + # cleanup + rm -f FEATURE-DUMP out diff --git a/tools/build/tests/features/Makefile.test1 b/tools/build/tests/features/Makefile.test1 new file mode 100644 index 000000000000..101b78f777c1 --- /dev/null +++ b/tools/build/tests/features/Makefile.test1 @@ -0,0 +1,16 @@ + +FEATURE_TESTS := glibc backtrace +FEATURE_DISPLAY := glibc + +srctree := ../../../.. +include $(srctree)/tools/build/Makefile.feature + +ifndef feature-glibc + $(error FAILED feature-glibc variable not defined) +endif + +ifndef feature-backtrace + $(error FAILED feature-backtrace variable not defined) +endif + +all: diff --git a/tools/build/tests/run.sh b/tools/build/tests/run.sh index 5494f8ea7567..bd6dc8ee1830 100755 --- a/tools/build/tests/run.sh +++ b/tools/build/tests/run.sh @@ -39,4 +39,6 @@ echo -n Testing.. test_ex test_ex_suffix -echo OK +cd features && make -s -f Makefile + +if [ $? -eq 0 ]; then echo OK; fi -- 1.9.3