abi/bootstrap: build elfutils from source as well

The elfutils version used may make a difference for the produced abi
results. Hence, also build them from scratch.

Change-Id: Id96276746907d69470da00157569d455bc353c1f
Signed-off-by: Matthias Maennich <maennich@google.com>
diff --git a/abi/.gitignore b/abi/.gitignore
index 6ddc8a7..cbfa6e6 100644
--- a/abi/.gitignore
+++ b/abi/.gitignore
@@ -1,3 +1,4 @@
 abigail-*
+elfutils-*
 *.pyc
 __pycache__
diff --git a/abi/bootstrap b/abi/bootstrap
index dace036..bad822e 100755
--- a/abi/bootstrap
+++ b/abi/bootstrap
@@ -14,11 +14,14 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+ELFUTILS_VERSION=elfutils-0.176
 ABIGAIL_VERSION=fb70149c
 
 NUM_CORES=$(cat /proc/cpuinfo | grep -c proc)
 BASE_DIR=$(readlink -f $(dirname $0))
 OUT_DIR="${BASE_DIR}/abigail-inst/${ABIGAIL_VERSION}"
+
+ELFUTILS_SRC="${BASE_DIR}/elfutils-src"
 LIBABIGAIL_SRC="${BASE_DIR}/abigail-src"
 
 # Check output dir.
@@ -29,19 +32,34 @@
 
 set -x
 
-PACKAGES="autoconf elfutils libtool libxml2-dev libdw-dev pkg-config python3"
+PACKAGES="autoconf libtool libxml2-dev pkg-config python3"
 # Install the dependencies.
 if ! dpkg -s ${PACKAGES} > /dev/null 2>&1 ; then
     sudo apt-get install --yes ${PACKAGES}
 fi
 
-# Assert minimum package versions
-if ! dpkg --compare-versions \
-    $(dpkg-query --showformat='${Version}' --show libdw-dev) ge 0.165 ; then
-  echo "ERROR: Minimum version of v0.165 for libdw-dev not met!"
-  exit 1
+# Acquire elfutils sources
+if [ ! -d "${ELFUTILS_SRC}" ]; then
+  git clone git://sourceware.org/git/elfutils.git "${ELFUTILS_SRC}"
+else
+  git -C ${ELFUTILS_SRC} fetch
 fi
 
+git -C ${ELFUTILS_SRC} checkout ${ELFUTILS_VERSION}
+
+# Build elfutils
+pushd "${ELFUTILS_SRC}"
+  #git clean -dfx
+  autoreconf -i --force
+  mkdir -p build/
+  pushd build/
+    ../configure --prefix="${OUT_DIR}" --enable-maintainer-mode
+    make -j${NUM_CORES}
+    make -j${NUM_CORES} install
+  popd
+popd
+
+# Acquire libabigail sources
 if [ ! -d "${LIBABIGAIL_SRC}" ]; then
   git clone git://sourceware.org/git/libabigail.git "${LIBABIGAIL_SRC}"
 else
@@ -56,9 +74,13 @@
   autoreconf -i --force
   mkdir -p build/
   pushd build/
-    ../configure --prefix="${OUT_DIR}" --enable-cxx11=yes --disable-shared
-#    make -j${NUM_CORES}
-    make -j${NUM_CORES} install-exec
+    ../configure --prefix="${OUT_DIR}"           \
+                 --enable-cxx11=yes              \
+                 --disable-shared                \
+                 "CPPFLAGS=-I${OUT_DIR}/include" \
+                 "LDFLAGS=-L${OUT_DIR}/lib"
+    make -j${NUM_CORES}
+    make -j${NUM_CORES} install
   popd
 popd
 
@@ -68,5 +90,6 @@
 echo "Note: Export following environment before running the executables:"
 echo
 echo "export PATH=\"${OUT_DIR}/bin:\${PATH}\""
+echo "export LD_LIBRARY_PATH=\"${OUT_DIR}/lib:\${LD_LIBRARY_PATH}\""
 echo
 echo