• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2#
3# Copyright (C) 2011 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#
17# Build the host version of the sed executable and place it
18# at the right location
19
20PROGDIR=$(dirname $0)
21. $PROGDIR/prebuilt-common.sh
22
23PROGRAM_PARAMETERS=""
24PROGRAM_DESCRIPTION=\
25"Rebuild the host sed tool used by the NDK."
26
27register_try64_option
28register_canadian_option
29register_jobs_option
30
31NDK_DIR=$ANDROID_NDK_ROOT
32register_var_option "--ndk-dir=<path>" NDK_DIR "Specify NDK install directory"
33
34PACKAGE_DIR=
35register_var_option "--package-dir=<path>" PACKAGE_DIR "Archive to package directory"
36
37GNUMAKE=make
38register_var_option "--make=<path>" GNUMAKE "Specify GNU Make program"
39
40extract_parameters "$@"
41
42SUBDIR=$(get_prebuilt_host_exec sed)
43OUT=$NDK_DIR/$(get_prebuilt_host_exec sed)
44
45SED_VERSION=4.2.1
46SED_SRCDIR=$ANDROID_NDK_ROOT/sources/host-tools/sed-$SED_VERSION
47if [ ! -d "$SED_SRCDIR" ]; then
48    echo "ERROR: Can't find sed-$SED_VERSION source tree: $SED_SRCDIR"
49    exit 1
50fi
51
52log "Using sources from: $SED_SRCDIR"
53
54prepare_abi_configure_build
55prepare_host_build
56
57BUILD_DIR=$NDK_TMPDIR
58
59log "Configuring the build"
60mkdir -p $BUILD_DIR && rm -rf $BUILD_DIR/*
61prepare_canadian_toolchain $BUILD_DIR
62cd $BUILD_DIR &&
63CFLAGS=$HOST_CFLAGS" -O2 -s" &&
64export CC CFLAGS &&
65run $SED_SRCDIR/configure \
66    --disable-nls \
67    --disable-rpath \
68    --disable-i18n \
69    --disable-acl \
70    --host=$ABI_CONFIGURE_HOST \
71    --build=$ABI_CONFIGURE_BUILD
72fail_panic "Failed to configure the sed-$SED_VERSION build!"
73
74log "Building sed (lib/ and sed/ only)"
75run $GNUMAKE -j $NUM_JOBS -C lib
76run $GNUMAKE -j $NUM_JOBS -C sed
77fail_panic "Failed to build the sed-$SED_VERSION executable!"
78
79log "Copying executable to prebuilt location"
80run mkdir -p $(dirname "$OUT") && cp sed/$(get_host_exec_name sed) $OUT
81fail_panic "Could not copy executable to: $OUT"
82
83if [ "$PACKAGE_DIR" ]; then
84    ARCHIVE=ndk-sed-$HOST_TAG.tar.bz2
85    dump "Packaging: $ARCHIVE"
86    mkdir -p "$PACKAGE_DIR" &&
87    pack_archive "$PACKAGE_DIR/$ARCHIVE" "$NDK_DIR" "$SUBDIR"
88    fail_panic "Could not package archive: $PACKAGE_DIR/$ARCHIVE"
89fi
90
91log "Cleaning up"
92rm -rf $BUILD_DIR
93
94log "Done."
95
96