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 # This script is used to rebuild the host 'ndk-stack' tool from the 18 # sources under sources/host-tools/ndk-stack. 19 # 20 # Note: The tool is installed under prebuilt/$HOST_TAG/bin/ndk-stack 21 # by default. 22 # 23 PROGDIR=$(dirname $0) 24 . $PROGDIR/prebuilt-common.sh 25 26 PROGRAM_PARAMETERS="" 27 PROGRAM_DESCRIPTION=\ 28 "This script is used to rebuild the host ndk-stack binary program." 29 30 register_jobs_option 31 32 BUILD_DIR= 33 register_var_option "--build-dir=<path>" BUILD_DIR "Specify build directory" 34 35 NDK_DIR=$ANDROID_NDK_ROOT 36 register_var_option "--ndk-dir=<path>" NDK_DIR "Place binary in NDK installation path" 37 38 GNUMAKE= 39 register_var_option "--make=<path>" GNUMAKE "Specify GNU Make program" 40 41 DEBUG= 42 register_var_option "--debug" DEBUG "Build debug version" 43 44 PACKAGE_DIR= 45 register_var_option "--package-dir=<path>" PACKAGE_DIR "Archive binary into specific directory" 46 47 register_mingw_option 48 register_try64_option 49 50 extract_parameters "$@" 51 52 prepare_host_build 53 54 # Choose a build directory if not specified by --build-dir 55 if [ -z "$BUILD_DIR" ]; then 56 BUILD_DIR=$NDK_TMPDIR/build-ndk-stack 57 log "Auto-config: --build-dir=$BUILD_DIR" 58 fi 59 60 OUT=$NDK_DIR/$(get_host_exec_name ndk-stack) 61 62 # GNU Make 63 if [ -z "$GNUMAKE" ]; then 64 GNUMAKE=make 65 log "Auto-config: --make=$GNUMAKE" 66 fi 67 68 if [ "$PACKAGE_DIR" ]; then 69 mkdir -p "$PACKAGE_DIR" 70 fail_panic "Could not create package directory: $PACKAGE_DIR" 71 fi 72 73 PROGNAME=ndk-stack 74 if [ "$MINGW" = "yes" ]; then 75 PROGNAME=$PROGNAME.exe 76 fi 77 78 # Create output directory 79 mkdir -p $(dirname $OUT) 80 if [ $? != 0 ]; then 81 echo "ERROR: Could not create output directory: $(dirname $OUT)" 82 exit 1 83 fi 84 85 SRCDIR=$ANDROID_NDK_ROOT/sources/host-tools/ndk-stack 86 87 # Let's roll 88 run $GNUMAKE -C $SRCDIR -f $SRCDIR/GNUMakefile \ 89 -B -j$NUM_JOBS \ 90 PROGNAME="$OUT" \ 91 BUILD_DIR="$BUILD_DIR" \ 92 CC="$CXX" CXX="$CXX" \ 93 STRIP="$STRIP" \ 94 DEBUG=$DEBUG 95 96 if [ $? != 0 ]; then 97 echo "ERROR: Could not build host program!" 98 exit 1 99 fi 100 101 if [ "$PACKAGE_DIR" ]; then 102 ARCHIVE=ndk-stack-$HOST_TAG.tar.bz2 103 SUBDIR=$(get_host_exec_name ndk-stack $HOST_TAG) 104 dump "Packaging: $ARCHIVE" 105 pack_archive "$PACKAGE_DIR/$ARCHIVE" "$NDK_DIR" "$SUBDIR" 106 fail_panic "Could not create package: $PACKAGE_DIR/$ARCHIVE from $OUT" 107 fi 108 109 log "Done!" 110 exit 0 111