• 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 awk 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 awk tool used by the NDK."
26
27register_try64_option
28register_mingw_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 awk)
43OUT=$NDK_DIR/$SUBDIR
44
45AWK_VERSION=20071023
46AWK_SRCDIR=$ANDROID_NDK_ROOT/sources/host-tools/nawk-$AWK_VERSION
47if [ ! -d "$AWK_SRCDIR" ]; then
48    echo "ERROR: Can't find sed-$AWK_VERSION source tree: $AWK_SRCDIR"
49    exit 1
50fi
51
52log "Using sources from: $AWK_SRCDIR"
53
54prepare_host_build
55
56BUILD_DIR=$NDK_TMPDIR
57BUILD_MINGW=
58if [ "$MINGW" = "yes" ]; then
59  BUILD_MINGW=yes
60fi
61
62log "Configuring the build"
63mkdir -p $BUILD_DIR && rm -rf $BUILD_DIR/*
64log "Building $HOST_TAG awk"
65export HOST_CC="$CC" &&
66run $GNUMAKE \
67    -C "$AWK_SRCDIR" \
68    -j $NUM_JOBS \
69    BUILD_DIR="$BUILD_DIR" \
70    MINGW="$BUILD_MINGW"
71fail_panic "Failed to build the sed-$AWK_VERSION executable!"
72
73log "Copying executable to prebuilt location"
74run mkdir -p $(dirname "$OUT") && cp "$BUILD_DIR/$(get_host_exec_name ndk-awk)" "$OUT"
75fail_panic "Could not copy executable to: $OUT"
76
77if [ "$PACKAGE_DIR" ]; then
78    ARCHIVE=ndk-awk-$HOST_TAG.tar.bz2
79    dump "Packaging: $ARCHIVE"
80    mkdir -p "$PACKAGE_DIR" &&
81    pack_archive "$PACKAGE_DIR/$ARCHIVE" "$NDK_DIR" "$SUBDIR"
82    fail_panic "Could not package archive: $PACKAGE_DIR/$ARCHIVE"
83fi
84
85log "Cleaning up"
86rm -rf $BUILD_DIR
87
88log "Done."
89
90