From: Rabin Vincent <rabin.vincent@axis.com>
To: Arnaldo Carvalho de Melo <acme@kernel.org>,
Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: <linux-kernel@vger.kernel.org>, Rabin Vincent <rabinv@axis.com>
Subject: [PATCH 5/5] perf: add Makefile.deps for easier cross compiling
Date: Sun, 27 Sep 2015 20:37:59 +0200 [thread overview]
Message-ID: <1443379079-29133-5-git-send-email-rabin.vincent@axis.com> (raw)
In-Reply-To: <1443379079-29133-1-git-send-email-rabin.vincent@axis.com>
It's easy to cross-compile a minimal perf binary without any external
libraries (other than a C library of course) but if you want more of the
juicy features it quickly becomes harder. You need to either
cross-compile a bunch of libraries manually and send in the correct
paths or integrate the perf build into some external build system.
In order to make it easier for people to qucikly get up and running with
a fairly full featured cross-compiled mainline perf, provide a
Makefile.deps which will download and build the required libraries,
which can then be used in a static build of perf:
$ make ARCH=arm CROSS_COMPILE=arm-linux- -f Makefile.deps
$ make ARCH=arm CROSS_COMPILE=arm-linux- LDFLAGS="-static"
Auto-detecting system features:
... dwarf: [ on ]
... glibc: [ on ]
... gtk2: [ OFF ]
... libaudit: [ on ]
... libbfd: [ on ]
... libelf: [ on ]
... libnuma: [ OFF ]
... libperl: [ OFF ]
... libpython: [ OFF ]
... libslang: [ on ]
... libunwind: [ on ]
... libdw-dwarf-unwind: [ OFF ]
... zlib: [ on ]
... lzma: [ on ]
Signed-off-by: Rabin Vincent <rabin.vincent@axis.com>
---
tools/perf/Makefile.deps | 140 ++++++++++++++++++++++++++++++++++++++++++++++
tools/perf/Makefile.perf | 7 +++
2 files changed, 147 insertions(+)
create mode 100644 tools/perf/Makefile.deps
diff --git a/tools/perf/Makefile.deps b/tools/perf/Makefile.deps
new file mode 100644
index 0000000..157c047
--- /dev/null
+++ b/tools/perf/Makefile.deps
@@ -0,0 +1,140 @@
+LIBS += audit
+audit_BASENAME=audit-2.4.4
+audit_ARCHIVE=$(audit_BASENAME).tar.gz
+audit_URL=https://people.redhat.com/sgrubb/audit/$(audit_ARCHIVE)
+
+LIBS += bfd
+bfd_BASENAME=binutils-2.25.1
+bfd_ARCHIVE=$(bfd_BASENAME).tar.bz2
+bfd_URL=http://ftp.gnu.org/gnu/binutils/$(bfd_ARCHIVE)
+
+LIBS += bzip2
+bzip2_BASENAME=bzip2-1.0.6
+bzip2_ARCHIVE=$(bzip2_BASENAME).tar.gz
+bzip2_URL=http://www.bzip.org/1.0.6/$(bzip2_ARCHIVE)
+
+LIBS += elfutils
+elfutils_BASENAME=elfutils-0.163
+elfutils_ARCHIVE=$(elfutils_BASENAME).tar.bz2
+elfutils_URL=https://fedorahosted.org/releases/e/l/elfutils/0.163/$(elfutils_ARCHIVE)
+
+LIBS += lzma
+lzma_BASENAME=xz-5.2.1
+lzma_ARCHIVE=$(lzma_BASENAME).tar.gz
+lzma_URL=http://tukaani.org/xz/$(lzma_ARCHIVE)
+
+LIBS += slang
+slang_BASENAME=slang-2.1.4
+slang_ARCHIVE=$(slang_BASENAME).tar.bz2
+slang_URL=http://ftp.ntua.gr/pub/lang/slang/slang/v2.1/$(slang_ARCHIVE)
+
+LIBS += unwind
+unwind_BASENAME=libunwind-1.1
+unwind_ARCHIVE=$(unwind_BASENAME).tar.gz
+unwind_URL=http://download.savannah.gnu.org/releases/libunwind/$(unwind_ARCHIVE)
+
+LIBS += zlib
+zlib_BASENAME=zlib-1.2.8
+zlib_ARCHIVE=$(zlib_BASENAME).tar.gz
+zlib_URL=http://zlib.net/$(zlib_ARCHIVE)
+
+DLDIR=dl
+DEPSDIR=deps-$(ARCH)
+BUILDDIR=build-$(ARCH)
+HOST=$(shell echo $(CROSS_COMPILE) | sed 's/.$$//')
+PREFIX=$(realpath $(shell pwd))/$(DEPSDIR)
+MAKE1=$(MAKE) -j1
+
+CC=$(CROSS_COMPILE)gcc
+
+export CC
+
+.PHONY: all clean $(LIBS)
+
+all: $(LIBS)
+
+define LIB_template
+$1_DIR=$$(BUILDDIR)/$$($1_BASENAME)
+$1_EXTRACT=$$($1_DIR)/.extract
+$1_INSTALL=$$(DEPSDIR)/lib/.$1.install
+
+$$(DLDIR)/$$($1_ARCHIVE):
+ mkdir -p $$(DLDIR) && cd $$(DLDIR) && wget -N $$($1_URL)
+
+$$($1_EXTRACT): $$(DLDIR)/$$($1_ARCHIVE)
+ mkdir -p $$(BUILDDIR) && tar xf $$< -C $$(BUILDDIR)
+ touch $$@
+
+$1: $$($1_INSTALL)
+
+$1-clean:
+ rm -rf $$($1_DIR)
+endef
+
+$(foreach lib,$(LIBS),$(eval $(call LIB_template,$(lib))))
+
+$(audit_INSTALL): $(audit_EXTRACT)
+ cd $(audit_DIR) && ./configure --host=$(HOST) --prefix=$(PREFIX)
+ $(MAKE) -C $(audit_DIR)/lib
+ $(MAKE) -C $(audit_DIR)/lib install
+ touch $@
+
+CFLAGS=-I$(PREFIX)/include
+LDFLAGS=-L$(PREFIX)/lib
+
+$(bfd_INSTALL): $(zlib_INSTALL) $(bfd_EXTRACT)
+ cd $(bfd_DIR)/libiberty && ./configure --host=$(HOST) --prefix=$(PREFIX) --enable-install-libiberty
+ $(MAKE) -C $(bfd_DIR)/libiberty
+ $(MAKE) -C $(bfd_DIR)/libiberty install
+ cd $(bfd_DIR)/bfd && CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" ./configure --host=$(HOST) --prefix=$(PREFIX) --with-zlib
+ $(MAKE) -C $(bfd_DIR)/bfd
+ $(MAKE) -C $(bfd_DIR)/bfd install
+ touch $@
+
+$(bzip2_INSTALL): $(bzip2_EXTRACT)
+ $(MAKE) -C $(bzip2_DIR) clean
+ $(MAKE) CC="$(CC)" PREFIX=$(PREFIX) -C $(bzip2_DIR) -f Makefile-libbz2_so
+ mkdir -p $(DEPSDIR)/lib
+ cp -a $(bzip2_DIR)/libbz2.so* $(DEPSDIR)/lib/
+ @rm -f $(DEPSDIR)/lib/libbz2.so
+ # The dynamic library is required to prevent errors while building elfutils
+ cd $(DEPSDIR)/lib && ln -s libbz2.so.1.0 libbz2.so
+ $(MAKE) -C $(bzip2_DIR) clean
+ $(MAKE) CC="$(CC)" PREFIX=$(PREFIX) -C $(bzip2_DIR) install
+ touch $@
+
+elfutils_LDFLAGS=$(LDFLAGS) -Wl,-rpath-link $(PREFIX)/lib
+
+$(elfutils_INSTALL): $(zlib_INSTALL) $(lzma_INSTALL) $(bzip2_INSTALL) $(elfutils_EXTRACT)
+ cd $(elfutils_DIR) && CFLAGS="$(CFLAGS)" LDFLAGS="$(elfutils_LDFLAGS)" ./configure --host=$(HOST) --prefix=$(PREFIX) --with-zlib --with-bzlib --with-lzma
+ $(MAKE) -C $(elfutils_DIR)
+ $(MAKE) -C $(elfutils_DIR) install
+ touch $@
+
+$(lzma_INSTALL): $(lzma_EXTRACT)
+ cd $(lzma_DIR) && ./configure --host=$(HOST) --prefix=$(PREFIX)
+ $(MAKE) -C $(lzma_DIR)
+ $(MAKE) -C $(lzma_DIR) install
+ touch $@
+
+$(slang_INSTALL): $(slang_EXTRACT)
+ cd $(slang_DIR) && ./configure --host=$(HOST) --prefix=$(PREFIX)
+ $(MAKE1) -C $(slang_DIR)
+ $(MAKE1) -C $(slang_DIR) install-all
+ touch $@
+
+$(zlib_INSTALL): $(zlib_EXTRACT)
+ cd $(zlib_DIR) && ./configure --prefix=$(PREFIX)
+ $(MAKE) -C $(zlib_DIR)
+ $(MAKE) -C $(zlib_DIR) install
+ touch $@
+
+$(unwind_INSTALL): $(unwind_EXTRACT)
+ cd $(unwind_DIR) && ./configure --host=$(HOST) --prefix=$(PREFIX) --enable-debug --enable-debug-frame
+ cd $(unwind_DIR) && $(MAKE)
+ cd $(unwind_DIR) && $(MAKE) install
+ touch $@
+
+clean:
+ rm -rf $(BUILDDIR)
+ rm -rf $(DEPSDIR)
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index d9863cb..4d5d984 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -92,6 +92,13 @@ ifneq ($(objtree),)
#$(info Determined 'objtree' to be $(objtree))
endif
+ifeq ($(findstring -static,${LDFLAGS}),-static)
+ ifneq ($(wildcard deps-$(ARCH)/*),)
+ LDFLAGS += -L $(PWD)/deps-$(ARCH)/lib
+ EXTRA_CFLAGS += -isystem $(PWD)/deps-$(ARCH)/include
+ endif
+endif
+
ifneq ($(OUTPUT),)
#$(info Determined 'OUTPUT' to be $(OUTPUT))
# Adding $(OUTPUT) as a directory to look for source files,
--
1.7.10.4
next prev parent reply other threads:[~2015-09-27 22:32 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-27 18:37 [PATCH 1/5] perf: unwind: fix unw_word_t pointer casts Rabin Vincent
2015-09-27 18:37 ` [PATCH 2/5] perf: unwind: pass symbol source to libunwind Rabin Vincent
2015-10-12 11:24 ` Jiri Olsa
2015-10-12 12:35 ` Namhyung Kim
2015-10-13 10:51 ` Rabin Vincent
2015-09-27 18:37 ` [PATCH 3/5] perf: unwind: use debug_frame if eh_frame is unusable Rabin Vincent
2015-10-12 11:28 ` Jiri Olsa
2015-10-14 13:13 ` [tip:perf/core] perf callchain: Use " tip-bot for Rabin Vincent
2015-09-27 18:37 ` [PATCH 4/5] tools: build: fix libiberty feature detection Rabin Vincent
2015-10-12 11:35 ` Jiri Olsa
2015-10-13 11:00 ` Rabin Vincent
2015-09-27 18:37 ` Rabin Vincent [this message]
2015-10-12 11:42 ` [PATCH 5/5] perf: add Makefile.deps for easier cross compiling Jiri Olsa
2015-10-13 10:50 ` Rabin Vincent
2015-10-13 11:52 ` Jiri Olsa
2015-10-10 15:49 ` [PATCH 1/5] perf: unwind: fix unw_word_t pointer casts Rabin Vincent
2015-10-10 23:34 ` Arnaldo Carvalho de Melo
2015-10-12 8:38 ` Jiri Olsa
2015-10-14 13:14 ` [tip:perf/core] perf callchains: Fix " tip-bot for Rabin Vincent
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1443379079-29133-5-git-send-email-rabin.vincent@axis.com \
--to=rabin.vincent@axis.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=rabinv@axis.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome