blob: 3e85a09c2d37a4d0c9aedc03ce60ad533c2b91b0 [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 Maennich28987022019-06-17 11:44:06 +010018ABIGAIL_VERSION=2651a362
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
33set -x
34
Matthias Maennich2f2937c2019-06-10 14:41:49 +010035PACKAGES="autoconf libtool libxml2-dev pkg-config python3"
Matthias Maennichf7d7e4d2019-03-26 11:46:24 +000036# Install the dependencies.
Matthias Maennichbd5e1662019-04-02 11:39:29 +010037if ! dpkg -s ${PACKAGES} > /dev/null 2>&1 ; then
Matthias Maennich02963ac2019-04-15 07:46:55 +010038 sudo apt-get install --yes ${PACKAGES}
Matthias Maennichbd5e1662019-04-02 11:39:29 +010039fi
Matthias Maennichf7d7e4d2019-03-26 11:46:24 +000040
Matthias Maennich2f2937c2019-06-10 14:41:49 +010041# Acquire elfutils sources
42if [ ! -d "${ELFUTILS_SRC}" ]; then
43 git clone git://sourceware.org/git/elfutils.git "${ELFUTILS_SRC}"
44else
45 git -C ${ELFUTILS_SRC} fetch
Matthias Maennich7dcb7862019-04-09 15:01:48 +010046fi
47
Matthias Maennich2f2937c2019-06-10 14:41:49 +010048git -C ${ELFUTILS_SRC} checkout ${ELFUTILS_VERSION}
49
50# Build elfutils
51pushd "${ELFUTILS_SRC}"
52 #git clean -dfx
53 autoreconf -i --force
54 mkdir -p build/
55 pushd build/
56 ../configure --prefix="${OUT_DIR}" --enable-maintainer-mode
57 make -j${NUM_CORES}
58 make -j${NUM_CORES} install
59 popd
60popd
61
62# Acquire libabigail sources
Matthias Maennichf7d7e4d2019-03-26 11:46:24 +000063if [ ! -d "${LIBABIGAIL_SRC}" ]; then
64 git clone git://sourceware.org/git/libabigail.git "${LIBABIGAIL_SRC}"
65else
66 git -C ${LIBABIGAIL_SRC} fetch
67fi
68
Matthias Maennich25062fc2019-05-29 12:54:46 +010069git -C ${LIBABIGAIL_SRC} checkout ${ABIGAIL_VERSION}
Matthias Maennichf7d7e4d2019-03-26 11:46:24 +000070
71# Build libabigail
72pushd "${LIBABIGAIL_SRC}"
73 #git clean -dfx
74 autoreconf -i --force
75 mkdir -p build/
76 pushd build/
Matthias Maennich2f2937c2019-06-10 14:41:49 +010077 ../configure --prefix="${OUT_DIR}" \
78 --enable-cxx11=yes \
79 --disable-shared \
80 "CPPFLAGS=-I${OUT_DIR}/include" \
81 "LDFLAGS=-L${OUT_DIR}/lib"
82 make -j${NUM_CORES}
83 make -j${NUM_CORES} install
Matthias Maennichf7d7e4d2019-03-26 11:46:24 +000084 popd
85popd
86
87set +x
88
89echo
90echo "Note: Export following environment before running the executables:"
91echo
92echo "export PATH=\"${OUT_DIR}/bin:\${PATH}\""
Matthias Maennichbc48ccb2019-06-25 15:34:36 +010093echo "export LD_LIBRARY_PATH=\"${OUT_DIR}/lib:${OUT_DIR}/lib/elfutils:\${LD_LIBRARY_PATH}\""
Matthias Maennichf7d7e4d2019-03-26 11:46:24 +000094echo
95echo