blob: 3630eb5d6805a773abf26745578923e5d3e8c729 [file] [log] [blame]
Matthias Maennichf7d7e4d2019-03-26 11:46:24 +00001#!/bin/bash -e
2
3# Copyright (C) 2019 The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
Matthias Maennich2f2937c2019-06-10 14:41:49 +010017ELFUTILS_VERSION=elfutils-0.176
Matthias Maennich798d9a92019-07-09 23:15:42 +010018ABIGAIL_VERSION=d7ae619f
Matthias Maennichf7d7e4d2019-03-26 11:46:24 +000019
20NUM_CORES=$(cat /proc/cpuinfo | grep -c proc)
21BASE_DIR=$(readlink -f $(dirname $0))
22OUT_DIR="${BASE_DIR}/abigail-inst/${ABIGAIL_VERSION}"
Matthias Maennich2f2937c2019-06-10 14:41:49 +010023
24ELFUTILS_SRC="${BASE_DIR}/elfutils-src"
Matthias Maennichf7d7e4d2019-03-26 11:46:24 +000025LIBABIGAIL_SRC="${BASE_DIR}/abigail-src"
26
27# Check output dir.
28if [ -e "${OUT_DIR}" ]; then
29 echo "WARN: ${OUT_DIR} exists. Press enter to continue or Ctrl-C to abort."
30 read
31fi
32
Matthias Maennich2f2937c2019-06-10 14:41:49 +010033PACKAGES="autoconf libtool libxml2-dev pkg-config python3"
Matthias Maennichf7d7e4d2019-03-26 11:46:24 +000034# Install the dependencies.
Greg Kroah-Hartman9344e8a2019-07-12 10:29:15 +020035if ! ( hash dpkg 2>/dev/null ); then
36 echo "WARN: not running on a Debian compatible system!"
37 echo " Please be sure you have the required packages installed on"
38 echo " your system before continuing."
39 echo ""
40 echo " The list of required packages is, at the minimum:"
41 echo " ${PACKAGES}"
42 echo " but some distributions may require more."
43 echo " You are on your own here, be careful."
44 echo ""
45 echo "Press enter to continue or Ctrl-C to abort."
46 read
47elif ! dpkg -s ${PACKAGES} > /dev/null 2>&1 ; then
48 set -x
Matthias Maennich02963ac2019-04-15 07:46:55 +010049 sudo apt-get install --yes ${PACKAGES}
Matthias Maennichbd5e1662019-04-02 11:39:29 +010050fi
Greg Kroah-Hartman9344e8a2019-07-12 10:29:15 +020051set -x
Matthias Maennichf7d7e4d2019-03-26 11:46:24 +000052
Matthias Maennich2f2937c2019-06-10 14:41:49 +010053# Acquire elfutils sources
54if [ ! -d "${ELFUTILS_SRC}" ]; then
55 git clone git://sourceware.org/git/elfutils.git "${ELFUTILS_SRC}"
56else
57 git -C ${ELFUTILS_SRC} fetch
Matthias Maennich7dcb7862019-04-09 15:01:48 +010058fi
59
Matthias Maennich2f2937c2019-06-10 14:41:49 +010060git -C ${ELFUTILS_SRC} checkout ${ELFUTILS_VERSION}
61
62# Build elfutils
63pushd "${ELFUTILS_SRC}"
64 #git clean -dfx
65 autoreconf -i --force
66 mkdir -p build/
67 pushd build/
68 ../configure --prefix="${OUT_DIR}" --enable-maintainer-mode
69 make -j${NUM_CORES}
70 make -j${NUM_CORES} install
71 popd
72popd
73
74# Acquire libabigail sources
Matthias Maennichf7d7e4d2019-03-26 11:46:24 +000075if [ ! -d "${LIBABIGAIL_SRC}" ]; then
76 git clone git://sourceware.org/git/libabigail.git "${LIBABIGAIL_SRC}"
77else
78 git -C ${LIBABIGAIL_SRC} fetch
79fi
80
Matthias Maennich25062fc2019-05-29 12:54:46 +010081git -C ${LIBABIGAIL_SRC} checkout ${ABIGAIL_VERSION}
Matthias Maennichf7d7e4d2019-03-26 11:46:24 +000082
83# Build libabigail
84pushd "${LIBABIGAIL_SRC}"
85 #git clean -dfx
86 autoreconf -i --force
87 mkdir -p build/
88 pushd build/
Matthias Maennich2f2937c2019-06-10 14:41:49 +010089 ../configure --prefix="${OUT_DIR}" \
90 --enable-cxx11=yes \
91 --disable-shared \
92 "CPPFLAGS=-I${OUT_DIR}/include" \
93 "LDFLAGS=-L${OUT_DIR}/lib"
94 make -j${NUM_CORES}
95 make -j${NUM_CORES} install
Matthias Maennichf7d7e4d2019-03-26 11:46:24 +000096 popd
97popd
98
99set +x
100
101echo
102echo "Note: Export following environment before running the executables:"
103echo
104echo "export PATH=\"${OUT_DIR}/bin:\${PATH}\""
Matthias Maennichbc48ccb2019-06-25 15:34:36 +0100105echo "export LD_LIBRARY_PATH=\"${OUT_DIR}/lib:${OUT_DIR}/lib/elfutils:\${LD_LIBRARY_PATH}\""
Matthias Maennichf7d7e4d2019-03-26 11:46:24 +0000106echo
107echo