Add elfutils to the distribution
authorBarret Rhoden <brho@cs.berkeley.edu>
Wed, 25 May 2016 20:25:21 +0000 (16:25 -0400)
committerBarret Rhoden <brho@cs.berkeley.edu>
Thu, 16 Jun 2016 15:48:38 +0000 (11:48 -0400)
Perf will depend on this.  We don't have a way to express that dependency
yet, but at least we'll build the library before building perf when you do
a make apps-install.

Note that elfutils isn't added to our codebase - just a Makefile that will
build it and drop it in your sysroot.

You'll need to make fill-kfs after building this, just like any other
shared library (e.g. glibc).

Oh, this also accidentally gave us readelf and a bunch of other tools that
should run natively.  Right now, they are installed to the sysroot/usr/bin
instead of kern/kfs/bin.  We probably don't want an extra 11 MB for tools
we won't use yet.

I attempted to have make depend on $(build-dir)/Makefile instead of
config.  This would work for a clean repo, but later we'd have issues.
If we had successfully configured, then did something that caused a
reconfig, make would get confused.  It would see that
$(build-dir)/Makefile existed, then it would rebuild build-dir, removing
the Makefile.  It would skip the config step, since it thought that
build-dir was older than Makefile, for whatever reason.  i.e.

Prerequisite `elfutils-0.164' is older than target `elfutils-0.164/Makefile'.
No need to remake target `elfutils-0.164/Makefile'.

If someone has a nice fix, then we can change it.  Until then, every
time we make, we'll also have to configure.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
Makefile
tools/dev-libs/elfutils/.gitignore [new file with mode: 0644]
tools/dev-libs/elfutils/Makefile [new file with mode: 0644]
tools/dev-libs/elfutils/akaros-patches/0.164/001_config_sub.patch [new file with mode: 0644]
tools/dev-libs/elfutils/akaros-patches/0.164/002_user_regs.patch [new file with mode: 0644]

index 37e23a9..1f6e62c 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -684,12 +684,14 @@ PHONY +=  apps-install
 apps-install: $(app-dirs-install)
        @$(call make_as_parent, -C tools/apps/busybox)
        @$(call make_as_parent, -C tools/apps/ipconfig install)
+       @$(call make_as_parent, -C tools/dev-libs/elfutils install)
        @$(call make_as_parent, -C tools/profile/perf install)
 
 PHONY += apps-clean
 apps-clean: $(app-dirs-clean)
        @$(call make_as_parent, -C tools/apps/busybox clean)
        @$(call make_as_parent, -C tools/apps/ipconfig clean)
+       @$(call make_as_parent, -C tools/dev-libs/elfutils clean)
        @$(call make_as_parent, -C tools/profile/perf clean)
 
 # Cross Compiler
diff --git a/tools/dev-libs/elfutils/.gitignore b/tools/dev-libs/elfutils/.gitignore
new file mode 100644 (file)
index 0000000..0f101fb
--- /dev/null
@@ -0,0 +1 @@
+elfutils-*
diff --git a/tools/dev-libs/elfutils/Makefile b/tools/dev-libs/elfutils/Makefile
new file mode 100644 (file)
index 0000000..83b16c1
--- /dev/null
@@ -0,0 +1,66 @@
+# Copyright (c) 2016 Google Inc
+# Barret Rhoden <brho@cs.berkeley.edu>
+# See LICENSE for details.
+#
+# Makefile for elfutils
+#
+# Most of this is not specific to this library.  You can copy the bulk of it,
+# modify the variables at the top, and maybe change the configure/make commands
+# to suit your package.
+
+include ../../Makefrag
+
+########## Package-specific variables
+# 0.165 needs glibc > 2.22 and zlib
+version := 0.164
+build-dir = elfutils-$(version)
+tarball = elfutils-$(version).tar.bz2
+fetch-url = https://fedorahosted.org/releases/e/l/elfutils/$(version)/$(tarball)
+config-opts = --host=$(AKAROS_PREFIX) \
+              --without-zlib \
+              --prefix=$(AKAROS_SYSROOT)/usr
+
+########## Generic Infrastructure
+
+PHONY := all
+all: make
+
+%.tar.bz2 %.tar.gz %.tbz:
+       $(Q)wget $(fetch-url)
+
+akaros-patches := $(sort $(wildcard akaros-patches/$(version)/*))
+
+$(build-dir): $(tarball) $(akaros-patches)
+       $(Q)rm -rf $@
+       tar -xf $<
+       $(Q)cd $@ &&                                                               \
+       for i in $(akaros-patches); do                                             \
+               patch -p1 < ../$$i;                                                    \
+       done
+
+PHONY += config
+$(build-dir)/Makefile config: $(build-dir)
+       $(Q)cd $(build-dir) && ./configure $(config-opts)
+
+PHONY += make
+make: config
+       $(Q)$(MAKE) -C $(build-dir) all
+
+PHONY += install
+install: make
+       $(Q)$(MAKE) -C $(build-dir) install
+
+PHONY += clean
+clean:
+       $(Q)[ -d $(build-dir) ] &&                                                 \
+           [ -f $(build-dir)/Makefile ] &&                                        \
+           $(MAKE) -C $(build-dir) clean || true
+
+PHONY += mrproper
+mrproper:
+       $(Q)[ -d $(build-dir) ] &&                                                 \
+           [ -f $(build-dir)/Makefile ] &&                                        \
+           $(MAKE) -C $(build-dir) uninstall || true
+       $(Q)rm -rf $(build-dir)
+
+.PHONY: $(PHONY)
diff --git a/tools/dev-libs/elfutils/akaros-patches/0.164/001_config_sub.patch b/tools/dev-libs/elfutils/akaros-patches/0.164/001_config_sub.patch
new file mode 100644 (file)
index 0000000..9098194
--- /dev/null
@@ -0,0 +1,32 @@
+--- a/config/config.sub        2016-05-03 09:58:04.771992109 -0400
++++ b/config/config.sub        2016-05-25 18:37:58.194322815 -0400
+@@ -140,6 +140,9 @@
+ ### recognize some manufacturers as not being operating systems, so we
+ ### can provide default operating systems below.
+ case $os in
++      -akaros*)
++              os=-akaros
++              ;;
+       -sun*os*)
+               # Prevent following clause from handling this invalid input.
+               ;;
+@@ -1346,6 +1333,9 @@
+       # First match some system type aliases
+       # that might get confused with valid system types.
+       # -solaris* is a basic system type, with this one exception.
++      -akaros*)
++              os=-akaros
++              ;;
+       -auroraux)
+               os=-auroraux
+               ;;
+@@ -1728,6 +1721,9 @@
+ case $basic_machine in
+       *-unknown)
+               case $os in
++                      -akaros*)
++                              vendor=ucb
++                              ;;
+                       -riscix*)
+                               vendor=acorn
+                               ;;
diff --git a/tools/dev-libs/elfutils/akaros-patches/0.164/002_user_regs.patch b/tools/dev-libs/elfutils/akaros-patches/0.164/002_user_regs.patch
new file mode 100644 (file)
index 0000000..a5be2d4
--- /dev/null
@@ -0,0 +1,12 @@
+diff -ur elfutils-0.164-orig/backends/x86_64_initreg.c elfutils-0.164/backends/x86_64_initreg.c
+--- elfutils-0.164-orig/backends/x86_64_initreg.c      2016-05-26 10:35:41.119818980 -0400
++++ elfutils-0.164/backends/x86_64_initreg.c   2016-05-26 10:36:01.639902408 -0400
+@@ -31,7 +31,7 @@
+ #endif
+ #include <stdlib.h>
+-#ifdef __x86_64__
++#if defined(__x86_64__) && defined(__linux__)
+ # include <sys/user.h>
+ # include <sys/ptrace.h>
+ #endif