1 #!/bin/sh 2 # 3 # Copyright (C) 2013 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 shell script is used to rebuild one of the NDK C++ STL 18 # implementations from sources. To use it: 19 # 20 # - Define CXX_STL to one of 'gabi++', 'stlport' or 'libc++' 21 # - Run it. 22 # 23 24 # include common function and variable definitions 25 . `dirname $0`/prebuilt-common.sh 26 . `dirname $0`/builder-funcs.sh 27 28 CXX_STL_LIST="gabi++ stlport libc++" 29 30 PROGRAM_PARAMETERS="" 31 32 PROGRAM_DESCRIPTION=\ 33 "Rebuild one of the following NDK C++ runtimes: $CXX_STL_LIST. 34 35 This script is called when pacakging a new NDK release. It will simply 36 rebuild the static and shared libraries of a given C++ runtime from 37 sources. 38 39 Use the --stl=<name> option to specify which runtime you want to rebuild. 40 41 This requires a temporary NDK installation containing platforms and 42 toolchain binaries for all target architectures. 43 44 By default, this will try with the current NDK directory, unless 45 you use the --ndk-dir=<path> option. 46 47 If you want to use clang to rebuild the binaries, please use 48 --llvm-version=<ver> option. 49 50 The output will be placed in appropriate sub-directories of 51 <ndk>/sources/cxx-stl/$CXX_STL_SUBDIR, but you can override this with 52 the --out-dir=<path> option. 53 " 54 55 CXX_STL= 56 register_var_option "--stl=<name>" CXX_STL "Select C++ runtime to rebuild." 57 58 PACKAGE_DIR= 59 register_var_option "--package-dir=<path>" PACKAGE_DIR "Put prebuilt tarballs into <path>." 60 61 NDK_DIR= 62 register_var_option "--ndk-dir=<path>" NDK_DIR "Specify NDK root path for the build." 63 64 BUILD_DIR= 65 OPTION_BUILD_DIR= 66 register_var_option "--build-dir=<path>" OPTION_BUILD_DIR "Specify temporary build dir." 67 68 OUT_DIR= 69 register_var_option "--out-dir=<path>" OUT_DIR "Specify output directory directly." 70 71 ABIS="$PREBUILT_ABIS" 72 register_var_option "--abis=<list>" ABIS "Specify list of target ABIs." 73 74 NO_MAKEFILE= 75 register_var_option "--no-makefile" NO_MAKEFILE "Do not use makefile to speed-up build" 76 77 VISIBLE_STATIC= 78 register_var_option "--visible-static" VISIBLE_STATIC "Do not use hidden visibility for the static library" 79 80 WITH_DEBUG_INFO= 81 register_var_option "--with-debug-info" WITH_DEBUG_INFO "Build with -g. STL is still built with optimization but with debug info" 82 83 EXPLICIT_COMPILER_VERSION= 84 85 GCC_VERSION= 86 register_option "--gcc-version=<ver>" do_gcc_version "Specify GCC version" 87 do_gcc_version() { 88 GCC_VERSION=$1 89 EXPLICIT_COMPILER_VERSION=true 90 } 91 92 LLVM_VERSION= 93 register_option "--llvm-version=<ver>" do_llvm_version "Specify LLVM version" 94 do_llvm_version() { 95 LLVM_VERSION=$1 96 EXPLICIT_COMPILER_VERSION=true 97 } 98 99 register_jobs_option 100 101 extract_parameters "$@" 102 103 if [ -n "${LLVM_VERSION}" -a -n "${GCC_VERSION}" ]; then 104 panic "Cannot set both LLVM_VERSION and GCC_VERSION. Make up your mind!" 105 fi 106 107 ABIS=$(commas_to_spaces $ABIS) 108 UNKNOWN_ABIS= 109 if [ "$ABIS" = "${ABIS%%64*}" ]; then 110 UNKNOWN_ABIS="$(filter_out "$PREBUILT_ABIS" "$ABIS" )" 111 if [ -n "$UNKNOWN_ABIS" ] && [ -n "$(find_ndk_unknown_archs)" ]; then 112 ABIS="$(filter_out "$UNKNOWN_ABIS" "$ABIS")" 113 ABIS="$ABIS $(find_ndk_unknown_archs)" 114 fi 115 fi 116 117 # Handle NDK_DIR 118 if [ -z "$NDK_DIR" ] ; then 119 NDK_DIR=$ANDROID_NDK_ROOT 120 log "Auto-config: --ndk-dir=$NDK_DIR" 121 else 122 if [ ! -d "$NDK_DIR" ]; then 123 panic "NDK directory does not exist: $NDK_DIR" 124 fi 125 fi 126 127 # Handle OUT_DIR 128 if [ -z "$OUT_DIR" ] ; then 129 OUT_DIR=$ANDROID_NDK_ROOT 130 log "Auto-config: --out-dir=$OUT_DIR" 131 else 132 mkdir -p "$OUT_DIR" 133 fail_panic "Could not create directory: $OUT_DIR" 134 fi 135 136 # Check that --stl=<name> is used with one of the supported runtime names. 137 if [ -z "$CXX_STL" ]; then 138 panic "Please use --stl=<name> to select a C++ runtime to rebuild." 139 fi 140 141 # Derive runtime, and normalize CXX_STL 142 CXX_SUPPORT_LIB=gabi++ 143 case $CXX_STL in 144 gabi++) 145 ;; 146 stlport) 147 ;; 148 libc++) 149 CXX_SUPPORT_LIB=gabi++ # libc++abi 150 ;; 151 libc++-libc++abi) 152 CXX_SUPPORT_LIB=libc++abi 153 CXX_STL=libc++ 154 ;; 155 libc++-gabi++) 156 CXX_SUPPORT_LIB=gabi++ 157 CXX_STL=libc++ 158 ;; 159 *) 160 panic "Invalid --stl value ('$CXX_STL'), please use one of: $CXX_STL_LIST." 161 ;; 162 esac 163 164 if [ -z "$OPTION_BUILD_DIR" ]; then 165 BUILD_DIR=$NDK_TMPDIR/build-$CXX_STL 166 else 167 BUILD_DIR=$OPTION_BUILD_DIR 168 fi 169 rm -rf "$BUILD_DIR" 170 mkdir -p "$BUILD_DIR" 171 fail_panic "Could not create build directory: $BUILD_DIR" 172 173 # Location of the various C++ runtime source trees. Use symlink from 174 # $BUILD_DIR instead of $NDK which may contain full path of builder's working dir 175 176 rm -f $BUILD_DIR/ndk 177 ln -sf $ANDROID_NDK_ROOT $BUILD_DIR/ndk 178 179 GABIXX_SRCDIR=$BUILD_DIR/ndk/$GABIXX_SUBDIR 180 STLPORT_SRCDIR=$BUILD_DIR/ndk/$STLPORT_SUBDIR 181 LIBCXX_SRCDIR=$BUILD_DIR/ndk/$LIBCXX_SUBDIR 182 LIBCXXABI_SRCDIR=$BUILD_DIR/ndk/$LIBCXXABI_SUBDIR 183 184 if [ "$CXX_SUPPORT_LIB" = "gabi++" ]; then 185 LIBCXX_INCLUDES="-I$LIBCXX_SRCDIR/libcxx/include -I$ANDROID_NDK_ROOT/sources/android/support/include -I$GABIXX_SRCDIR/include" 186 elif [ "$CXX_SUPPORT_LIB" = "libc++abi" ]; then 187 LIBCXX_INCLUDES="-I$LIBCXX_SRCDIR/libcxx/include -I$ANDROID_NDK_ROOT/sources/android/support/include -I$LIBCXXABI_SRCDIR/include" 188 else 189 panic "Unknown CXX_SUPPORT_LIB: $CXX_SUPPORT_LIB" 190 fi 191 192 COMMON_C_CXX_FLAGS="-fPIC -O2 -ffunction-sections -fdata-sections" 193 COMMON_CXXFLAGS="-fexceptions -frtti -fuse-cxa-atexit" 194 195 if [ "$WITH_DEBUG_INFO" ]; then 196 COMMON_C_CXX_FLAGS="$COMMON_C_CXX_FLAGS -g" 197 fi 198 199 if [ "$CXX_STL" = "libc++" ]; then 200 # Use clang to build libc++ by default. 201 if [ "$EXPLICIT_COMPILER_VERSION" != "true" ]; then 202 LLVM_VERSION=$DEFAULT_LLVM_VERSION 203 fi 204 fi 205 206 # Determine GAbi++ build parameters. Note that GAbi++ is also built as part 207 # of STLport and Libc++, in slightly different ways. 208 if [ "$CXX_SUPPORT_LIB" = "gabi++" ]; then 209 if [ "$CXX_STL" = "libc++" ]; then 210 GABIXX_INCLUDES="$LIBCXX_INCLUDES" 211 GABIXX_CXXFLAGS="$GABIXX_CXXFLAGS -DLIBCXXABI=1" 212 else 213 GABIXX_INCLUDES="-I$GABIXX_SRCDIR/include" 214 fi 215 GABIXX_CFLAGS="$COMMON_C_CXX_FLAGS $GABIXX_INCLUDES" 216 GABIXX_CXXFLAGS="$GABIXX_CXXFLAGS $GABIXX_CFLAGS $COMMON_CXXFLAGS" 217 GABIXX_SOURCES=$(cd $ANDROID_NDK_ROOT/$GABIXX_SUBDIR && ls src/*.cc) 218 GABIXX_LDFLAGS="-ldl" 219 fi 220 221 # Determine STLport build parameters 222 STLPORT_CFLAGS="$COMMON_C_CXX_FLAGS -DGNU_SOURCE -I$STLPORT_SRCDIR/stlport $GABIXX_INCLUDES" 223 STLPORT_CXXFLAGS="$STLPORT_CFLAGS $COMMON_CXXFLAGS" 224 STLPORT_SOURCES=\ 225 "src/dll_main.cpp \ 226 src/fstream.cpp \ 227 src/strstream.cpp \ 228 src/sstream.cpp \ 229 src/ios.cpp \ 230 src/stdio_streambuf.cpp \ 231 src/istream.cpp \ 232 src/ostream.cpp \ 233 src/iostream.cpp \ 234 src/codecvt.cpp \ 235 src/collate.cpp \ 236 src/ctype.cpp \ 237 src/monetary.cpp \ 238 src/num_get.cpp \ 239 src/num_put.cpp \ 240 src/num_get_float.cpp \ 241 src/num_put_float.cpp \ 242 src/numpunct.cpp \ 243 src/time_facets.cpp \ 244 src/messages.cpp \ 245 src/locale.cpp \ 246 src/locale_impl.cpp \ 247 src/locale_catalog.cpp \ 248 src/facets_byname.cpp \ 249 src/complex.cpp \ 250 src/complex_io.cpp \ 251 src/complex_trig.cpp \ 252 src/string.cpp \ 253 src/bitset.cpp \ 254 src/allocators.cpp \ 255 src/c_locale.c \ 256 src/cxa.c" 257 258 # Determine Libc++ build parameters 259 LIBCXX_LINKER_SCRIPT=export_symbols.txt 260 LIBCXX_CFLAGS="$COMMON_C_CXX_FLAGS $LIBCXX_INCLUDES -Drestrict=__restrict__" 261 LIBCXX_CXXFLAGS="$LIBCXX_CFLAGS -DLIBCXXABI=1 -std=c++11" 262 LIBCXX_LDFLAGS="-Wl,--version-script,\$_BUILD_SRCDIR/$LIBCXX_LINKER_SCRIPT" 263 LIBCXX_SOURCES=\ 264 "libcxx/src/algorithm.cpp \ 265 libcxx/src/bind.cpp \ 266 libcxx/src/chrono.cpp \ 267 libcxx/src/condition_variable.cpp \ 268 libcxx/src/debug.cpp \ 269 libcxx/src/exception.cpp \ 270 libcxx/src/future.cpp \ 271 libcxx/src/hash.cpp \ 272 libcxx/src/ios.cpp \ 273 libcxx/src/iostream.cpp \ 274 libcxx/src/locale.cpp \ 275 libcxx/src/memory.cpp \ 276 libcxx/src/mutex.cpp \ 277 libcxx/src/new.cpp \ 278 libcxx/src/optional.cpp \ 279 libcxx/src/random.cpp \ 280 libcxx/src/regex.cpp \ 281 libcxx/src/shared_mutex.cpp \ 282 libcxx/src/stdexcept.cpp \ 283 libcxx/src/string.cpp \ 284 libcxx/src/strstream.cpp \ 285 libcxx/src/system_error.cpp \ 286 libcxx/src/thread.cpp \ 287 libcxx/src/typeinfo.cpp \ 288 libcxx/src/utility.cpp \ 289 libcxx/src/valarray.cpp \ 290 libcxx/src/support/android/locale_android.cpp \ 291 " 292 293 LIBCXXABI_SOURCES=\ 294 "../llvm-libc++abi/libcxxabi/src/abort_message.cpp \ 295 ../llvm-libc++abi/libcxxabi/src/cxa_aux_runtime.cpp \ 296 ../llvm-libc++abi/libcxxabi/src/cxa_default_handlers.cpp \ 297 ../llvm-libc++abi/libcxxabi/src/cxa_demangle.cpp \ 298 ../llvm-libc++abi/libcxxabi/src/cxa_exception.cpp \ 299 ../llvm-libc++abi/libcxxabi/src/cxa_exception_storage.cpp \ 300 ../llvm-libc++abi/libcxxabi/src/cxa_guard.cpp \ 301 ../llvm-libc++abi/libcxxabi/src/cxa_handlers.cpp \ 302 ../llvm-libc++abi/libcxxabi/src/cxa_new_delete.cpp \ 303 ../llvm-libc++abi/libcxxabi/src/cxa_personality.cpp \ 304 ../llvm-libc++abi/libcxxabi/src/cxa_unexpected.cpp \ 305 ../llvm-libc++abi/libcxxabi/src/cxa_vector.cpp \ 306 ../llvm-libc++abi/libcxxabi/src/cxa_virtual.cpp \ 307 ../llvm-libc++abi/libcxxabi/src/exception.cpp \ 308 ../llvm-libc++abi/libcxxabi/src/private_typeinfo.cpp \ 309 ../llvm-libc++abi/libcxxabi/src/stdexcept.cpp \ 310 ../llvm-libc++abi/libcxxabi/src/typeinfo.cpp \ 311 ../llvm-libc++abi/libcxxabi/src/Unwind/libunwind.cpp \ 312 ../llvm-libc++abi/libcxxabi/src/Unwind/Unwind-EHABI.cpp \ 313 ../llvm-libc++abi/libcxxabi/src/Unwind/UnwindLevel1.c \ 314 ../llvm-libc++abi/libcxxabi/src/Unwind/UnwindLevel1-gcc-ext.c \ 315 ../llvm-libc++abi/libcxxabi/src/Unwind/UnwindRegistersRestore.S \ 316 ../llvm-libc++abi/libcxxabi/src/Unwind/UnwindRegistersSave.S \ 317 " 318 319 # android/support files for libc++ 320 SUPPORT32_SOURCES=\ 321 "../../android/support/src/libdl_support.c \ 322 ../../android/support/src/locale_support.c \ 323 ../../android/support/src/math_support.c \ 324 ../../android/support/src/stdlib_support.c \ 325 ../../android/support/src/wchar_support.c \ 326 ../../android/support/src/locale/duplocale.c \ 327 ../../android/support/src/locale/freelocale.c \ 328 ../../android/support/src/locale/localeconv.c \ 329 ../../android/support/src/locale/newlocale.c \ 330 ../../android/support/src/locale/uselocale.c \ 331 ../../android/support/src/stdio/fscanf.c \ 332 ../../android/support/src/stdio/scanf.c \ 333 ../../android/support/src/stdio/sscanf.c \ 334 ../../android/support/src/stdio/stdio_impl.c \ 335 ../../android/support/src/stdio/strtod.c \ 336 ../../android/support/src/stdio/vfprintf.c \ 337 ../../android/support/src/stdio/vfscanf.c \ 338 ../../android/support/src/stdio/vfwprintf.c \ 339 ../../android/support/src/stdio/vscanf.c \ 340 ../../android/support/src/stdio/vsscanf.c \ 341 ../../android/support/src/msun/e_log2.c \ 342 ../../android/support/src/msun/e_log2f.c \ 343 ../../android/support/src/msun/s_nan.c \ 344 ../../android/support/src/musl-multibyte/btowc.c \ 345 ../../android/support/src/musl-multibyte/internal.c \ 346 ../../android/support/src/musl-multibyte/mblen.c \ 347 ../../android/support/src/musl-multibyte/mbrlen.c \ 348 ../../android/support/src/musl-multibyte/mbrtowc.c \ 349 ../../android/support/src/musl-multibyte/mbsinit.c \ 350 ../../android/support/src/musl-multibyte/mbsnrtowcs.c \ 351 ../../android/support/src/musl-multibyte/mbsrtowcs.c \ 352 ../../android/support/src/musl-multibyte/mbstowcs.c \ 353 ../../android/support/src/musl-multibyte/mbtowc.c \ 354 ../../android/support/src/musl-multibyte/wcrtomb.c \ 355 ../../android/support/src/musl-multibyte/wcsnrtombs.c \ 356 ../../android/support/src/musl-multibyte/wcsrtombs.c \ 357 ../../android/support/src/musl-multibyte/wcstombs.c \ 358 ../../android/support/src/musl-multibyte/wctob.c \ 359 ../../android/support/src/musl-multibyte/wctomb.c \ 360 ../../android/support/src/musl-ctype/iswalnum.c \ 361 ../../android/support/src/musl-ctype/iswalpha.c \ 362 ../../android/support/src/musl-ctype/iswblank.c \ 363 ../../android/support/src/musl-ctype/iswcntrl.c \ 364 ../../android/support/src/musl-ctype/iswctype.c \ 365 ../../android/support/src/musl-ctype/iswdigit.c \ 366 ../../android/support/src/musl-ctype/iswgraph.c \ 367 ../../android/support/src/musl-ctype/iswlower.c \ 368 ../../android/support/src/musl-ctype/iswprint.c \ 369 ../../android/support/src/musl-ctype/iswpunct.c \ 370 ../../android/support/src/musl-ctype/iswspace.c \ 371 ../../android/support/src/musl-ctype/iswupper.c \ 372 ../../android/support/src/musl-ctype/iswxdigit.c \ 373 ../../android/support/src/musl-ctype/isxdigit.c \ 374 ../../android/support/src/musl-ctype/towctrans.c \ 375 ../../android/support/src/musl-ctype/wcswidth.c \ 376 ../../android/support/src/musl-ctype/wctrans.c \ 377 ../../android/support/src/musl-ctype/wcwidth.c \ 378 ../../android/support/src/musl-locale/catclose.c \ 379 ../../android/support/src/musl-locale/catgets.c \ 380 ../../android/support/src/musl-locale/catopen.c \ 381 ../../android/support/src/musl-locale/iconv.c \ 382 ../../android/support/src/musl-locale/intl.c \ 383 ../../android/support/src/musl-locale/isalnum_l.c \ 384 ../../android/support/src/musl-locale/isalpha_l.c \ 385 ../../android/support/src/musl-locale/isblank_l.c \ 386 ../../android/support/src/musl-locale/iscntrl_l.c \ 387 ../../android/support/src/musl-locale/isdigit_l.c \ 388 ../../android/support/src/musl-locale/isgraph_l.c \ 389 ../../android/support/src/musl-locale/islower_l.c \ 390 ../../android/support/src/musl-locale/isprint_l.c \ 391 ../../android/support/src/musl-locale/ispunct_l.c \ 392 ../../android/support/src/musl-locale/isspace_l.c \ 393 ../../android/support/src/musl-locale/isupper_l.c \ 394 ../../android/support/src/musl-locale/iswalnum_l.c \ 395 ../../android/support/src/musl-locale/iswalpha_l.c \ 396 ../../android/support/src/musl-locale/iswblank_l.c \ 397 ../../android/support/src/musl-locale/iswcntrl_l.c \ 398 ../../android/support/src/musl-locale/iswctype_l.c \ 399 ../../android/support/src/musl-locale/iswdigit_l.c \ 400 ../../android/support/src/musl-locale/iswgraph_l.c \ 401 ../../android/support/src/musl-locale/iswlower_l.c \ 402 ../../android/support/src/musl-locale/iswprint_l.c \ 403 ../../android/support/src/musl-locale/iswpunct_l.c \ 404 ../../android/support/src/musl-locale/iswspace_l.c \ 405 ../../android/support/src/musl-locale/iswupper_l.c \ 406 ../../android/support/src/musl-locale/iswxdigit_l.c \ 407 ../../android/support/src/musl-locale/isxdigit_l.c \ 408 ../../android/support/src/musl-locale/langinfo.c \ 409 ../../android/support/src/musl-locale/strcasecmp_l.c \ 410 ../../android/support/src/musl-locale/strcoll.c \ 411 ../../android/support/src/musl-locale/strerror_l.c \ 412 ../../android/support/src/musl-locale/strfmon.c \ 413 ../../android/support/src/musl-locale/strftime_l.c \ 414 ../../android/support/src/musl-locale/strncasecmp_l.c \ 415 ../../android/support/src/musl-locale/strxfrm.c \ 416 ../../android/support/src/musl-locale/tolower_l.c \ 417 ../../android/support/src/musl-locale/toupper_l.c \ 418 ../../android/support/src/musl-locale/towctrans_l.c \ 419 ../../android/support/src/musl-locale/towlower_l.c \ 420 ../../android/support/src/musl-locale/towupper_l.c \ 421 ../../android/support/src/musl-locale/wcscoll.c \ 422 ../../android/support/src/musl-locale/wcsxfrm.c \ 423 ../../android/support/src/musl-locale/wctrans_l.c \ 424 ../../android/support/src/musl-locale/wctype_l.c \ 425 ../../android/support/src/musl-math/frexpf.c \ 426 ../../android/support/src/musl-math/frexpl.c \ 427 ../../android/support/src/musl-math/frexp.c \ 428 ../../android/support/src/musl-stdio/swprintf.c \ 429 ../../android/support/src/musl-stdio/vwprintf.c \ 430 ../../android/support/src/musl-stdio/wprintf.c \ 431 ../../android/support/src/musl-stdio/printf.c \ 432 ../../android/support/src/musl-stdio/snprintf.c \ 433 ../../android/support/src/musl-stdio/sprintf.c \ 434 ../../android/support/src/musl-stdio/vprintf.c \ 435 ../../android/support/src/musl-stdio/vsprintf.c \ 436 ../../android/support/src/wcstox/intscan.c \ 437 ../../android/support/src/wcstox/floatscan.c \ 438 ../../android/support/src/wcstox/shgetc.c \ 439 ../../android/support/src/wcstox/wcstod.c \ 440 ../../android/support/src/wcstox/wcstol.c \ 441 " 442 # Replaces broken implementations in x86 libm.so 443 SUPPORT32_SOURCES_x86=\ 444 "../../android/support/src/musl-math/scalbln.c \ 445 ../../android/support/src/musl-math/scalblnf.c \ 446 ../../android/support/src/musl-math/scalblnl.c \ 447 ../../android/support/src/musl-math/scalbnl.c \ 448 " 449 450 # android/support files for libc++ 451 SUPPORT64_SOURCES=\ 452 "../../android/support/src/locale_support.c \ 453 ../../android/support/src/musl-locale/catclose.c \ 454 ../../android/support/src/musl-locale/catgets.c \ 455 ../../android/support/src/musl-locale/catopen.c \ 456 ../../android/support/src/musl-locale/isdigit_l.c \ 457 ../../android/support/src/musl-locale/islower_l.c \ 458 ../../android/support/src/musl-locale/isupper_l.c \ 459 ../../android/support/src/musl-locale/iswalpha_l.c \ 460 ../../android/support/src/musl-locale/iswblank_l.c \ 461 ../../android/support/src/musl-locale/iswcntrl_l.c \ 462 ../../android/support/src/musl-locale/iswdigit_l.c \ 463 ../../android/support/src/musl-locale/iswlower_l.c \ 464 ../../android/support/src/musl-locale/iswprint_l.c \ 465 ../../android/support/src/musl-locale/iswpunct_l.c \ 466 ../../android/support/src/musl-locale/iswspace_l.c \ 467 ../../android/support/src/musl-locale/iswupper_l.c \ 468 ../../android/support/src/musl-locale/iswxdigit_l.c \ 469 ../../android/support/src/musl-locale/isxdigit_l.c \ 470 ../../android/support/src/musl-locale/strcoll_l.c \ 471 ../../android/support/src/musl-locale/strftime_l.c \ 472 ../../android/support/src/musl-locale/strxfrm_l.c \ 473 ../../android/support/src/musl-locale/tolower_l.c \ 474 ../../android/support/src/musl-locale/toupper_l.c \ 475 ../../android/support/src/musl-locale/towlower_l.c \ 476 ../../android/support/src/musl-locale/towupper_l.c \ 477 ../../android/support/src/musl-locale/wcscoll_l.c \ 478 ../../android/support/src/musl-locale/wcsxfrm_l.c \ 479 " 480 481 # If the --no-makefile flag is not used, we're going to put all build 482 # commands in a temporary Makefile that we will be able to invoke with 483 # -j$NUM_JOBS to build stuff in parallel. 484 # 485 if [ -z "$NO_MAKEFILE" ]; then 486 MAKEFILE=$BUILD_DIR/Makefile 487 else 488 MAKEFILE= 489 fi 490 491 # Define a few common variables based on parameters. 492 case $CXX_STL in 493 gabi++) 494 CXX_STL_LIB=libgabi++ 495 CXX_STL_SUBDIR=$GABIXX_SUBDIR 496 CXX_STL_SRCDIR=$GABIXX_SRCDIR 497 CXX_STL_CFLAGS=$GABIXX_CFLAGS 498 CXX_STL_CXXFLAGS=$GABIXX_CXXFLAGS 499 CXX_STL_LDFLAGS=$GABIXX_LDFLAGS 500 CXX_STL_SOURCES=$GABIXX_SOURCES 501 CXX_STL_PACKAGE=gabixx 502 ;; 503 stlport) 504 CXX_STL_LIB=libstlport 505 CXX_STL_SUBDIR=$STLPORT_SUBDIR 506 CXX_STL_SRCDIR=$STLPORT_SRCDIR 507 CXX_STL_CFLAGS=$STLPORT_CFLAGS 508 CXX_STL_CXXFLAGS=$STLPORT_CXXFLAGS 509 CXX_STL_LDFLAGS=$STLPORT_LDFLAGS 510 CXX_STL_SOURCES=$STLPORT_SOURCES 511 CXX_STL_PACKAGE=stlport 512 ;; 513 libc++) 514 CXX_STL_LIB=libc++ 515 CXX_STL_SUBDIR=$LIBCXX_SUBDIR 516 CXX_STL_SRCDIR=$LIBCXX_SRCDIR 517 CXX_STL_CFLAGS=$LIBCXX_CFLAGS 518 CXX_STL_CXXFLAGS=$LIBCXX_CXXFLAGS 519 CXX_STL_LDFLAGS=$LIBCXX_LDFLAGS 520 CXX_STL_SOURCES=$LIBCXX_SOURCES 521 CXX_STL_PACKAGE=libcxx 522 ;; 523 *) 524 panic "Internal error: Unknown STL name '$CXX_STL'" 525 ;; 526 esac 527 528 # By default, all static libraries include hidden ELF symbols, except 529 # if one uses the --visible-static option. 530 if [ -z "$VISIBLE_STATIC" ]; then 531 STATIC_CXXFLAGS="-fvisibility=hidden -fvisibility-inlines-hidden" 532 else 533 STATIC_CXXFLAGS= 534 fi 535 SHARED_CXXFLAGS= 536 537 # build_stl_libs_for_abi 538 # $1: ABI 539 # $2: build directory 540 # $3: build type: "static" or "shared" 541 # $4: installation directory 542 # $5: (optional) thumb 543 build_stl_libs_for_abi () 544 { 545 local ARCH BINPREFIX SYSROOT 546 local ABI=$1 547 local THUMB="$5" 548 local BUILDDIR="$2"/$THUMB 549 local TYPE="$3" 550 local DSTDIR="$4" 551 local FLOAT_ABI="" 552 local DEFAULT_CFLAGS DEFAULT_CXXFLAGS 553 local SRC OBJ OBJECTS EXTRA_CFLAGS EXTRA_CXXFLAGS EXTRA_LDFLAGS LIB_SUFFIX GCCVER 554 555 EXTRA_CFLAGS="" 556 EXTRA_CXXFLAGS="" 557 EXTRA_LDFLAGS="" 558 if [ "$ABI" = "armeabi-v7a-hard" ]; then 559 EXTRA_CFLAGS="-mhard-float -D_NDK_MATH_NO_SOFTFP=1" 560 EXTRA_CXXFLAGS="-mhard-float -D_NDK_MATH_NO_SOFTFP=1" 561 EXTRA_LDFLAGS="-Wl,--no-warn-mismatch -lm_hard" 562 FLOAT_ABI="hard" 563 fi 564 565 if [ -n "$THUMB" ]; then 566 EXTRA_CFLAGS="$EXTRA_CFLAGS -mthumb" 567 EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS -mthumb" 568 fi 569 570 if [ "$TYPE" = "static" -a -z "$VISIBLE_STATIC" ]; then 571 EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $STATIC_CXXFLAGS" 572 else 573 EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $SHARED_CXXFLAGS" 574 fi 575 576 DSTDIR=$DSTDIR/$CXX_STL_SUBDIR/libs/$ABI/$THUMB 577 LIB_SUFFIX="$(get_lib_suffix_for_abi $ABI)" 578 579 mkdir -p "$BUILDDIR" 580 mkdir -p "$DSTDIR" 581 582 if [ -n "$GCC_VERSION" ]; then 583 GCCVER=$GCC_VERSION 584 EXTRA_CFLAGS="$EXTRA_CFLAGS -std=c99" 585 else 586 ARCH=$(convert_abi_to_arch $ABI) 587 GCCVER=$(get_default_gcc_version_for_arch $ARCH) 588 fi 589 590 # libc++ built with clang (for ABI armeabi-only) produces 591 # libc++_shared.so and libc++_static.a with undefined __atomic_fetch_add_4 592 # Add -latomic. 593 if [ -n "$LLVM_VERSION" -a "$CXX_STL_LIB" = "libc++" -a "$ABI" = "armeabi" ]; then 594 # EHABI tables were added as experimental flags in llvm 3.4. In 3.5, these 595 # are now the defaults and the flags have been removed. Add these flags 596 # explicitly only for llvm 3.4. 597 if [ "$LLVM_VERSION" = "3.4" ]; then 598 EXTRA_CFLAGS="${EXTRA_CFLAGS} -mllvm -arm-enable-ehabi-descriptors \ 599 -mllvm -arm-enable-ehabi" 600 EXTRA_CXXFLAGS="${EXTRA_CXXFLAGS} -mllvm -arm-enable-ehabi-descriptors \ 601 -mllvm -arm-enable-ehabi" 602 fi 603 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -latomic" 604 fi 605 606 builder_begin_android $ABI "$BUILDDIR" "$GCCVER" "$LLVM_VERSION" "$MAKEFILE" 607 608 builder_set_dstdir "$DSTDIR" 609 builder_reset_cflags DEFAULT_CFLAGS 610 builder_reset_cxxflags DEFAULT_CXXFLAGS 611 612 if [ "$CXX_SUPPORT_LIB" = "gabi++" ]; then 613 builder_set_srcdir "$GABIXX_SRCDIR" 614 builder_cflags "$DEFAULT_CFLAGS $GABIXX_CFLAGS $EXTRA_CFLAGS" 615 builder_cxxflags "$DEFAULT_CXXFLAGS $GABIXX_CXXFLAGS $EXTRA_CXXFLAGS" 616 builder_ldflags "$GABIXX_LDFLAGS $EXTRA_LDFLAGS" 617 if [ "$(find_ndk_unknown_archs)" != "$ABI" ]; then 618 builder_sources $GABIXX_SOURCES 619 elif [ "$CXX_STL" = "gabi++" ]; then 620 log "Could not build gabi++ with unknown arch!" 621 exit 1 622 else 623 builder_sources src/delete.cc src/new.cc 624 fi 625 fi 626 627 # Build the runtime sources, except if we're only building GAbi++ 628 if [ "$CXX_STL" != "gabi++" ]; then 629 builder_set_srcdir "$CXX_STL_SRCDIR" 630 builder_reset_cflags 631 builder_cflags "$DEFAULT_CFLAGS $CXX_STL_CFLAGS $EXTRA_CFLAGS" 632 builder_reset_cxxflags 633 builder_cxxflags "$DEFAULT_CXXFLAGS $CXX_STL_CXXFLAGS $EXTRA_CXXFLAGS" 634 builder_ldflags "$CXX_STL_LDFLAGS $EXTRA_LDFLAGS" 635 builder_sources $CXX_STL_SOURCES 636 if [ "$CXX_SUPPORT_LIB" == "libc++abi" ]; then 637 builder_sources $LIBCXXABI_SOURCES 638 builder_ldflags "-ldl" 639 fi 640 if [ "$CXX_STL" = "libc++" ]; then 641 if [ "$ABI" = "${ABI%%64*}" ]; then 642 if [ "$ABI" = "x86" ]; then 643 builder_sources $SUPPORT32_SOURCES $SUPPORT32_SOURCES_x86 644 else 645 builder_sources $SUPPORT32_SOURCES 646 fi 647 else 648 builder_sources $SUPPORT64_SOURCES 649 fi 650 fi 651 fi 652 653 if [ "$TYPE" = "static" ]; then 654 log "Building $DSTDIR/${CXX_STL_LIB}_static.a" 655 builder_static_library ${CXX_STL_LIB}_static 656 else 657 log "Building $DSTDIR/${CXX_STL_LIB}_shared${LIB_SUFFIX}" 658 if [ "$(find_ndk_unknown_archs)" != "$ABI" ]; then 659 builder_shared_library ${CXX_STL_LIB}_shared $LIB_SUFFIX "$FLOAT_ABI" 660 else 661 builder_ldflags "-lm -lc" 662 builder_nostdlib_shared_library ${CXX_STL_LIB}_shared $LIB_SUFFIX # Don't use libgcc 663 fi 664 fi 665 666 builder_end 667 } 668 669 for ABI in $ABIS; do 670 build_stl_libs_for_abi $ABI "$BUILD_DIR/$ABI/shared" "shared" "$OUT_DIR" 671 build_stl_libs_for_abi $ABI "$BUILD_DIR/$ABI/static" "static" "$OUT_DIR" 672 # build thumb version of libraries for 32-bit arm 673 if [ "$ABI" != "${ABI%%arm*}" -a "$ABI" = "${ABI%%64*}" ] ; then 674 build_stl_libs_for_abi $ABI "$BUILD_DIR/$ABI/shared" "shared" "$OUT_DIR" thumb 675 build_stl_libs_for_abi $ABI "$BUILD_DIR/$ABI/static" "static" "$OUT_DIR" thumb 676 fi 677 done 678 679 # If needed, package files into tarballs 680 if [ -n "$PACKAGE_DIR" ] ; then 681 for ABI in $ABIS; do 682 FILES="" 683 LIB_SUFFIX="$(get_lib_suffix_for_abi $ABI)" 684 for LIB in ${CXX_STL_LIB}_static.a ${CXX_STL_LIB}_shared${LIB_SUFFIX}; do 685 if [ -d "$CXX_STL_SUBDIR/libs/$ABI/thumb" ]; then 686 FILES="$FILES $CXX_STL_SUBDIR/libs/$ABI/thumb/$LIB" 687 fi 688 FILES="$FILES $CXX_STL_SUBDIR/libs/$ABI/$LIB" 689 done 690 PACKAGE="$PACKAGE_DIR/${CXX_STL_PACKAGE}-libs-$ABI" 691 if [ "$WITH_DEBUG_INFO" ]; then 692 PACKAGE="${PACKAGE}-g" 693 fi 694 PACKAGE="${PACKAGE}.tar.bz2" 695 log "Packaging: $PACKAGE" 696 pack_archive "$PACKAGE" "$OUT_DIR" "$FILES" 697 fail_panic "Could not package $ABI $CXX_STL binaries!" 698 dump "Packaging: $PACKAGE" 699 done 700 fi 701 702 if [ -z "$OPTION_BUILD_DIR" ]; then 703 log "Cleaning up..." 704 rm -rf $BUILD_DIR 705 else 706 log "Don't forget to cleanup: $BUILD_DIR" 707 fi 708 709 log "Done!" 710