1#
2# Copyright (C) 2011 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#      http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16#  This file contains various shell function definitions that can be
17#  used to either build a static and shared libraries from sources, or
18#  generate a Makefile to do it in parallel.
19#
20
21_BUILD_TAB=$(echo " " | tr ' ' '\t')
22
23builder_command ()
24{
25    if [ -z "$_BUILD_MK" ]; then
26        echo "$@"
27        "$@"
28    else
29        echo "${_BUILD_TAB}$@" >> $_BUILD_MK
30    fi
31}
32
33
34builder_log ()
35{
36    if [ "$_BUILD_MK" ]; then
37        echo "${_BUILD_TAB}echo $@" >> $_BUILD_MK
38    else
39        log "$@"
40    fi
41}
42
43# $1: Build directory
44# $2: Optional Makefile name
45builder_begin ()
46{
47    _BUILD_DIR_NEW=
48    _BUILD_DIR=$1
49    if [ ! -d "$_BUILD_DIR" ]; then
50        mkdir -p "$_BUILD_DIR"
51        fail_panic "Can't create build directory: $_BUILD_DIR"
52        _BUILD_DIR_NEW=true
53    else
54        rm -rf "$_BUILD_DIR/*"
55        fail_panic "Can't cleanup build directory: $_BUILD_DIR"
56    fi
57    _BUILD_TARGETS=
58    _BUILD_PREFIX=
59    _BUILD_MK=$2
60    if [ -n "$_BUILD_MK" ]; then
61        log "Creating temporary build Makefile: $_BUILD_MK"
62        rm -f $_BUILD_MK &&
63        echo "# Auto-generated by $0 - do not edit!" > $_BUILD_MK
64        echo ".PHONY: all" >> $_BUILD_MK
65        echo "all:" >> $_BUILD_MK
66    fi
67
68    builder_begin_module
69}
70
71# $1: Variable name
72# out: Variable value
73_builder_varval ()
74{
75    eval echo "\$$1"
76}
77
78_builder_varadd ()
79{
80    local _varname="$1"
81    local _varval="$(_builder_varval $_varname)"
82    shift
83    if [ -z "$_varval" ]; then
84        eval $_varname=\"$@\"
85    else
86        eval $_varname=\$$_varname\" $@\"
87    fi
88}
89
90
91builder_set_prefix ()
92{
93    _BUILD_PREFIX="$@"
94}
95
96builder_begin_module ()
97{
98    _BUILD_CC=
99    _BUILD_CXX=
100    _BUILD_AR=
101    _BUILD_C_INCLUDES=
102    _BUILD_CFLAGS=
103    _BUILD_CXXFLAGS=
104    _BUILD_LDFLAGS_BEGIN_SO=
105    _BUILD_LDFLAGS_END_SO=
106    _BUILD_LDFLAGS_BEGIN_EXE=
107    _BUILD_LDFLAGS_END_EXE=
108    _BUILD_LDFLAGS=
109    _BUILD_BINPREFIX=
110    _BUILD_DSTDIR=
111    _BUILD_SRCDIR=.
112    _BUILD_OBJECTS=
113    _BUILD_STATIC_LIBRARIES=
114    _BUILD_SHARED_LIBRARIES=
115    _BUILD_COMPILER_RUNTIME_LDFLAGS=-lgcc
116}
117
118builder_set_binprefix ()
119{
120    _BUILD_BINPREFIX=$1
121    _BUILD_CC=${1}gcc
122    _BUILD_CXX=${1}g++
123    _BUILD_AR=${1}ar
124}
125
126builder_set_binprefix_llvm ()
127{
128    _BUILD_BINPREFIX=$1
129    _BUILD_CC=${1}/clang
130    _BUILD_CXX=${1}/clang++
131    _BUILD_AR=${2}ar
132}
133
134builder_set_builddir ()
135{
136    _BUILD_DIR=$1
137}
138
139builder_set_srcdir ()
140{
141    _BUILD_SRCDIR=$1
142}
143
144builder_set_dstdir ()
145{
146    _BUILD_DSTDIR=$1
147}
148
149builder_ldflags ()
150{
151    _builder_varadd _BUILD_LDFLAGS "$@"
152}
153
154builder_ldflags_exe ()
155{
156    _builder_varadd _BUILD_LDFLAGS_EXE "$@"
157}
158
159builder_cflags ()
160{
161    _builder_varadd _BUILD_CFLAGS "$@"
162}
163
164builder_cxxflags ()
165{
166    _builder_varadd _BUILD_CXXFLAGS "$@"
167}
168
169builder_c_includes ()
170{
171    _builder_varadd _BUILD_C_INCLUDES "$@"
172}
173
174# $1: optional var to hold the original cflags before reset
175builder_reset_cflags ()
176{
177    local _varname="$1"
178    if [ -n "$_varname" ] ; then
179        eval $_varname=\"$_BUILD_CFLAGS\"
180    fi
181    _BUILD_CFLAGS=
182}
183
184# $1: optional var to hold the original cxxflags before reset
185builder_reset_cxxflags ()
186{
187    local _varname="$1"
188    if [ -n "$_varname" ] ; then
189        eval $_varname=\"$_BUILD_CXXFLAGS\"
190    fi
191    _BUILD_CXXFLAGS=
192}
193
194# $1: optional var to hold the original c_includes before reset
195builder_reset_c_includes ()
196{
197    local _varname="$1"
198    if [ -n "$_varname" ] ; then
199        eval $_varname=\"$_BUILD_C_INCLUDES\"
200    fi
201    _BUILD_C_INCLUDES=
202}
203
204builder_compiler_runtime_ldflags ()
205{
206    _BUILD_COMPILER_RUNTIME_LDFLAGS=$1
207}
208
209builder_link_with ()
210{
211    local LIB
212    for LIB; do
213        case $LIB in
214            *.a)
215                _builder_varadd _BUILD_STATIC_LIBRARIES $LIB
216                ;;
217            *.so)
218                _builder_varadd _BUILD_SHARED_LIBRARIES $LIB
219                ;;
220            *)
221                echo "ERROR: Unknown link library extension: $LIB"
222                exit 1
223        esac
224    done
225}
226
227builder_sources ()
228{
229    local src srcfull obj cc cflags text
230    if [ -z "$_BUILD_DIR" ]; then
231        panic "Build directory not set!"
232    fi
233    if [ -z "$_BUILD_CC" ]; then
234        _BUILD_CC=${CC:-gcc}
235    fi
236    if [ -z "$_BUILD_CXX" ]; then
237        _BUILD_CXX=${CXX:-g++}
238    fi
239    for src in "$@"; do
240        srcfull=$_BUILD_SRCDIR/$src
241        if [ ! -f "$srcfull" ]; then
242            echo "ERROR: Missing source file: $srcfull"
243            exit 1
244        fi
245        obj=$src
246        cflags=""
247        for inc in $_BUILD_C_INCLUDES; do
248            cflags=$cflags" -I$inc"
249        done
250        cflags=$cflags" -I$_BUILD_SRCDIR"
251        case $obj in
252            *.c)
253                obj=${obj%%.c}
254                text="C"
255                cc=$_BUILD_CC
256                cflags="$cflags $_BUILD_CFLAGS"
257                ;;
258            *.cpp)
259                obj=${obj%%.cpp}
260                text="C++"
261                cc=$_BUILD_CXX
262                cflags="$cflags $_BUILD_CXXFLAGS"
263                ;;
264            *.cc)
265                obj=${obj%%.cc}
266                text="C++"
267                cc=$_BUILD_CXX
268                cflags="$cflags $_BUILD_CXXFLAGS"
269                ;;
270            *.S|*.s)
271                obj=${obj%%.$obj}
272                text="ASM"
273                cc=$_BUILD_CC
274                cflags="$cflags $_BUILD_CFLAGS"
275                ;;
276            *)
277                echo "Unknown source file extension: $obj"
278                exit 1
279                ;;
280        esac
281
282        # Source file path can include ../ path items, ensure
283        # that the generated object do not back up the output
284        # directory by translating them to __/
285        obj=$(echo "$obj" | tr '../' '__/')
286
287        # Ensure we have unwind tables in the generated machine code
288        # This is useful to get good stack traces
289        cflags=$cflags" -funwind-tables"
290
291        obj=$_BUILD_DIR/$obj.o
292        if [ "$_BUILD_MK" ]; then
293            echo "$obj: $srcfull" >> $_BUILD_MK
294        fi
295        builder_log "${_BUILD_PREFIX}$text: $src"
296        builder_command mkdir -p $(dirname "$obj")
297        builder_command $NDK_CCACHE $cc -c -o "$obj" "$srcfull" $cflags
298        fail_panic "Could not compile ${_BUILD_PREFIX}$src"
299        _BUILD_OBJECTS=$_BUILD_OBJECTS" $obj"
300    done
301}
302
303builder_static_library ()
304{
305    local lib libname arflags
306    libname=$1
307    if [ -z "$_BUILD_DSTDIR" ]; then
308        panic "Destination directory not set"
309    fi
310    lib=$_BUILD_DSTDIR/$libname
311    lib=${lib%%.a}.a
312    if [ "$_BUILD_MK" ]; then
313        _BUILD_TARGETS=$_BUILD_TARGETS" $lib"
314        echo "$lib: $_BUILD_OBJECTS" >> $_BUILD_MK
315    fi
316    if [ -z "${_BUILD_AR}" ]; then
317        _BUILD_AR=${AR:-ar}
318    fi
319    builder_log "${_BUILD_PREFIX}Archive: $libname"
320    rm -f "$lib"
321    arflags="crs"
322    case $HOST_TAG in
323        darwin*)
324            # XCode 'ar' doesn't support D flag
325            ;;
326        *)
327            arflags="${arflags}D"
328            ;;
329    esac
330    builder_command ${_BUILD_AR} $arflags "$lib" "$_BUILD_OBJECTS"
331    fail_panic "Could not archive ${_BUILD_PREFIX}$libname objects!"
332}
333
334builder_host_static_library ()
335{
336    local lib libname
337    libname=$1
338    if [ -z "$_BUILD_DSTDIR" ]; then
339        panic "Destination directory not set"
340    fi
341    lib=$_BUILD_DSTDIR/$libname
342    lib=${lib%%.a}.a
343    if [ "$_BUILD_MK" ]; then
344        _BUILD_TARGETS=$_BUILD_TARGETS" $lib"
345        echo "$lib: $_BUILD_OBJECTS" >> $_BUILD_MK
346    fi
347    if [ -z "$BUILD_AR" ]; then
348        _BUILD_AR=${AR:-ar}
349    fi
350    builder_log "${_BUILD_PREFIX}Archive: $libname"
351    rm -f "$lib"
352    builder_command ${_BUILD_AR} crsD "$lib" "$_BUILD_OBJECTS"
353    fail_panic "Could not archive ${_BUILD_PREFIX}$libname objects!"
354}
355
356builder_shared_library ()
357{
358    local lib libname suffix libm
359    libname=$1
360    suffix=$2
361    armeabi_v7a_float_abi=$3
362
363    if [ -z "$suffix" ]; then
364        suffix=".so"
365    fi
366    libm="-lm"
367    if [ "$armeabi_v7a_float_abi" = "hard" ]; then
368        libm="-lm_hard"
369    fi
370    lib=$_BUILD_DSTDIR/$libname
371    lib=${lib%%${suffix}}${suffix}
372    if [ "$_BUILD_MK" ]; then
373        _BUILD_TARGETS=$_BUILD_TARGETS" $lib"
374        echo "$lib: $_BUILD_OBJECTS" >> $_BUILD_MK
375    fi
376    builder_log "${_BUILD_PREFIX}SharedLibrary: $libname"
377
378    # Important: -lgcc must appear after objects and static libraries,
379    #            but before shared libraries for Android. It doesn't hurt
380    #            for other platforms.
381    #            Also $libm must come before -lc because bionic libc
382    #            accidentally exports a soft-float version of ldexp.
383    builder_command ${_BUILD_CXX} \
384        -Wl,-soname,$(basename $lib) \
385        -Wl,-shared \
386        $_BUILD_LDFLAGS_BEGIN_SO \
387        $_BUILD_OBJECTS \
388        $_BUILD_STATIC_LIBRARIES \
389        $_BUILD_COMPILER_RUNTIME_LDFLAGS \
390        $_BUILD_SHARED_LIBRARIES \
391        $libm -lc \
392        $_BUILD_LDFLAGS \
393        $_BUILD_LDFLAGS_END_SO \
394        -o $lib
395    fail_panic "Could not create ${_BUILD_PREFIX}shared library $libname"
396}
397
398# Same as builder_shared_library, but do not link the default libs
399builder_nostdlib_shared_library ()
400{
401    local lib libname suffix
402    libname=$1
403    suffix=$2
404    if [ -z "$suffix" ]; then
405        suffix=".so"
406    fi
407    lib=$_BUILD_DSTDIR/$libname
408    lib=${lib%%${suffix}}${suffix}
409    if [ "$_BUILD_MK" ]; then
410        _BUILD_TARGETS=$_BUILD_TARGETS" $lib"
411        echo "$lib: $_BUILD_OBJECTS" >> $_BUILD_MK
412    fi
413    builder_log "${_BUILD_PREFIX}SharedLibrary: $libname"
414
415    builder_command ${_BUILD_CXX} \
416        -Wl,-soname,$(basename $lib) \
417        -Wl,-shared \
418        $_BUILD_LDFLAGS_BEGIN_SO \
419        $_BUILD_OBJECTS \
420        $_BUILD_STATIC_LIBRARIES \
421        $_BUILD_SHARED_LIBRARIES \
422        $_BUILD_LDFLAGS \
423        $_BUILD_LDFLAGS_END_SO \
424        -o $lib
425    fail_panic "Could not create ${_BUILD_PREFIX}shared library $libname"
426}
427
428builder_host_shared_library ()
429{
430    local lib libname
431    libname=$1
432    lib=$_BUILD_DSTDIR/$libname
433    lib=${lib%%.so}.so
434    if [ "$_BUILD_MK" ]; then
435        _BUILD_TARGETS=$_BUILD_TARGETS" $lib"
436        echo "$lib: $_BUILD_OBJECTS" >> $_BUILD_MK
437    fi
438    builder_log "${_BUILD_PREFIX}SharedLibrary: $libname"
439
440    if [ -z "$_BUILD_CXX" ]; then
441        _BUILD_CXX=${CXX:-g++}
442    fi
443
444    # Important: -lgcc must appear after objects and static libraries,
445    #            but before shared libraries for Android. It doesn't hurt
446    #            for other platforms.
447    builder_command ${_BUILD_CXX} \
448        -shared -s \
449        $_BUILD_OBJECTS \
450        $_BUILD_STATIC_LIBRARIES \
451        $_BUILD_SHARED_LIBRARIES \
452        $_BUILD_LDFLAGS \
453        -o $lib
454    fail_panic "Could not create ${_BUILD_PREFIX}shared library $libname"
455}
456
457builder_host_executable ()
458{
459    local exe exename
460    exename=$1
461    exe=$_BUILD_DSTDIR/$exename$HOST_EXE
462    if [ "$_BUILD_MK" ]; then
463        _BUILD_TARGETS=$_BUILD_TARGETS" $exe"
464        echo "$exe: $_BUILD_OBJECTS" >> $_BUILD_MK
465    fi
466    builder_log "${_BUILD_PREFIX}Executable: $exename$HOST_EXE"
467
468    if [ -z "$_BUILD_CXX" ]; then
469        _BUILD_CXX=${CXX:-g++}
470    fi
471
472    # Important: -lgcc must appear after objects and static libraries,
473    #            but before shared libraries for Android. It doesn't hurt
474    #            for other platforms.
475    builder_command ${_BUILD_CXX} \
476        -s \
477        $_BUILD_OBJECTS \
478        $_BUILD_STATIC_LIBRARIES \
479        $_BUILD_SHARED_LIBRARIES \
480        $_BUILD_LDFLAGS \
481        -o $exe
482    fail_panic "Could not create ${_BUILD_PREFIX}executable $libname"
483}
484
485
486builder_end ()
487{
488    if [ "$_BUILD_MK" ]; then
489        echo "all: $_BUILD_TARGETS" >> $_BUILD_MK
490        run make -j$NUM_JOBS -f $_BUILD_MK
491        fail_panic "Could not build project!"
492    fi
493
494    if [ "$_BUILD_DIR_NEW" ]; then
495        log "Cleaning up build directory: $_BUILD_DIR"
496        rm -rf "$_BUILD_DIR"
497        _BUILD_DIR_NEW=
498    fi
499}
500
501# Same as builder_begin, but to target Android with a specific ABI
502# $1: ABI name (e.g. armeabi)
503# $2: Build directory
504# $3: Gcc version
505# $4: Optional llvm version
506# $5: Optional Makefile name
507# $6: Platform (android-X)
508builder_begin_android ()
509{
510    local ABI BUILDDIR LLVM_VERSION MAKEFILE
511    local ARCH SYSROOT LDIR FLAGS
512    local CRTBEGIN_SO_O CRTEND_SO_O CRTBEGIN_EXE_SO CRTEND_SO_O
513    local BINPREFIX GCC_TOOLCHAIN LLVM_TRIPLE GCC_VERSION
514    local SCRATCH_FLAGS PLATFORM
515    local PREBUILT_NDK=$ANDROID_BUILD_TOP/prebuilts/ndk/current
516    if [ -z "$ANDROID_BUILD_TOP" ]; then
517        panic "ANDROID_BUILD_TOP is not defined!"
518    elif [ ! -d "$PREBUILT_NDK/platforms" ]; then
519        panic "Missing directory: $PREBUILT_NDK/platforms"
520    fi
521    ABI=$1
522    BUILDDIR=$2
523    GCC_VERSION=$3
524    LLVM_VERSION=$4
525    MAKEFILE=$5
526    ARCH=$(convert_abi_to_arch $ABI)
527    PLATFORM=$6
528
529    if [ -n "$LLVM_VERSION" ]; then
530        # override GCC_VERSION to pick $DEFAULT_LLVM_GCC??_VERSION instead
531        if [ "$ABI" != "${ABI%%64*}" ]; then
532            GCC_VERSION=$DEFAULT_LLVM_GCC64_VERSION
533        else
534            GCC_VERSION=$DEFAULT_LLVM_GCC32_VERSION
535        fi
536    fi
537    for TAG in $HOST_TAG $HOST_TAG32; do
538        BINPREFIX=$ANDROID_BUILD_TOP/prebuilts/ndk/current/$(get_toolchain_binprefix_for_arch $ARCH $GCC_VERSION $TAG)
539        if [ -f ${BINPREFIX}gcc ]; then
540            break;
541        fi
542    done
543    if [ -n "$LLVM_VERSION" ]; then
544        GCC_TOOLCHAIN=`dirname $BINPREFIX`
545        GCC_TOOLCHAIN=`dirname $GCC_TOOLCHAIN`
546        LLVM_BINPREFIX=$(get_llvm_toolchain_binprefix $LLVM_VERSION $TAG)
547    fi
548
549    if [ -z "$PLATFORM" ]; then
550      SYSROOT=$PREBUILT_NDK/$(get_default_platform_sysroot_for_arch $ARCH)
551    else
552      SYSROOT=$PREBUILT_NDK/platforms/$PLATFORM/arch-$ARCH
553    fi
554    LDIR=$SYSROOT"/usr/"$(get_default_libdir_for_abi $ABI)
555
556    CRTBEGIN_EXE_O=$LDIR/crtbegin_dynamic.o
557    CRTEND_EXE_O=$LDIR/crtend_android.o
558
559    CRTBEGIN_SO_O=$LDIR/crtbegin_so.o
560    CRTEND_SO_O=$LDIR/crtend_so.o
561    if [ ! -f "$CRTBEGIN_SO_O" ]; then
562        CRTBEGIN_SO_O=$CRTBEGIN_EXE_O
563    fi
564    if [ ! -f "$CRTEND_SO_O" ]; then
565        CRTEND_SO_O=$CRTEND_EXE_O
566    fi
567
568    builder_begin "$BUILDDIR" "$MAKEFILE"
569    builder_set_prefix "$ABI "
570    if [ -z "$LLVM_VERSION" ]; then
571        builder_set_binprefix "$BINPREFIX"
572    else
573        builder_set_binprefix_llvm "$LLVM_BINPREFIX" "$BINPREFIX"
574        case $ABI in
575            armeabi)
576                LLVM_TRIPLE=armv5te-none-linux-androideabi
577                ;;
578            armeabi-v7a|armeabi-v7a-hard)
579                LLVM_TRIPLE=armv7-none-linux-androideabi
580                ;;
581            arm64-v8a)
582                LLVM_TRIPLE=aarch64-none-linux-android
583                ;;
584            x86)
585                LLVM_TRIPLE=i686-none-linux-android
586                ;;
587            x86_64)
588                LLVM_TRIPLE=x86_64-none-linux-android
589                ;;
590            mips|mips32r6)
591                LLVM_TRIPLE=mipsel-none-linux-android
592                ;;
593            mips64)
594                LLVM_TRIPLE=mips64el-none-linux-android
595                ;;
596        esac
597        SCRATCH_FLAGS="-target $LLVM_TRIPLE $FLAGS"
598        builder_ldflags "$SCRATCH_FLAGS"
599        if [ "$LLVM_VERSION" \> "3.4" ]; then
600            # Turn off integrated-as for clang >= 3.5 due to ill-formed object it produces
601            # involving inline-assembly .pushsection/.popsection which crashes ld.gold
602            # BUG=18589643
603            SCRATCH_FLAGS="$SCRATCH_FLAGS -fno-integrated-as"
604        fi
605        builder_cflags  "$SCRATCH_FLAGS"
606        builder_cxxflags "$SCRATCH_FLAGS"
607        if [ ! -z $GCC_TOOLCHAIN ]; then
608            SCRATCH_FLAGS="-gcc-toolchain $GCC_TOOLCHAIN"
609            builder_cflags "$SCRATCH_FLAGS"
610            builder_cxxflags "$SCRATCH_FLAGS"
611            builder_ldflags "$SCRATCH_FLAGS"
612        fi
613    fi
614
615    SCRATCH_FLAGS="--sysroot=$SYSROOT"
616    builder_cflags "$SCRATCH_FLAGS"
617    builder_cxxflags "$SCRATCH_FLAGS"
618
619    SCRATCH_FLAGS="--sysroot=$SYSROOT -nostdlib"
620    _BUILD_LDFLAGS_BEGIN_SO="$SCRATCH_FLAGS $CRTBEGIN_SO_O"
621    _BUILD_LDFLAGS_BEGIN_EXE="$SCRATCH_FLAGS $CRTBEGIN_EXE_O"
622
623    _BUILD_LDFLAGS_END_SO="$CRTEND_SO_O"
624    _BUILD_LDFLAGS_END_EXE="$CRTEND_EXE_O"
625
626    case $ABI in
627        armeabi)
628            if [ -z "$LLVM_VERSION" ]; then
629                # add -minline-thumb1-jumptable such that gabi++/stlport/libc++ can be linked
630                # with compiler-rt where helpers __gnu_thumb1_case_* (in libgcc.a) don't exist
631                SCRATCH_FLAGS="-minline-thumb1-jumptable"
632                builder_cflags "$SCRATCH_FLAGS"
633                builder_cxxflags "$SCRATCH_FLAGS"
634            else
635                builder_cflags ""
636                builder_cxxflags ""
637            fi
638            ;;
639        armeabi-v7a|armeabi-v7a-hard)
640            SCRATCH_FLAGS="-march=armv7-a -mfpu=vfpv3-d16"
641            builder_cflags "$SCRATCH_FLAGS"
642            builder_cxxflags "$SCRATCH_FLAGS"
643            builder_ldflags "-march=armv7-a -Wl,--fix-cortex-a8"
644            if [ "$ABI" != "armeabi-v7a-hard" ]; then
645                SCRATCH_FLAGS="-mfloat-abi=softfp"
646                builder_cflags "$SCRATCH_FLAGS"
647                builder_cxxflags "$SCRATCH_FLAGS"
648            else
649                SCRATCH_FLAGS="-mhard-float -D_NDK_MATH_NO_SOFTFP=1"
650                builder_cflags "$SCRATCH_FLAGS"
651                builder_cxxflags "$SCRATCH_FLAGS"
652                builder_ldflags "-Wl,--no-warn-mismatch -lm_hard"
653            fi
654            ;;
655    esac
656}
657
658# $1: Build directory
659# $2: Optional Makefile name
660builder_begin_host ()
661{
662    prepare_host_build
663    builder_begin "$1" "$2"
664    builder_set_prefix "$HOST_TAG "
665}
666