Android.mk revision cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8
1LOCAL_PATH:= $(call my-dir) 2 3include $(LOCAL_PATH)/arch-$(TARGET_ARCH)/syscalls.mk 4 5# Define the common source files for all the libc instances 6# ========================================================= 7libc_common_src_files := \ 8 $(syscall_src) \ 9 unistd/abort.c \ 10 unistd/alarm.c \ 11 unistd/brk.c \ 12 unistd/daemon.c \ 13 unistd/eventfd.c \ 14 unistd/exec.c \ 15 unistd/fcntl.c \ 16 unistd/fnmatch.c \ 17 unistd/fstatfs.c \ 18 unistd/ftime.c \ 19 unistd/ftok.c \ 20 unistd/getcwd.c \ 21 unistd/getdtablesize.c \ 22 unistd/gethostname.c \ 23 unistd/getopt_long.c \ 24 unistd/getpgrp.c \ 25 unistd/getpriority.c \ 26 unistd/getpt.c \ 27 unistd/initgroups.c \ 28 unistd/isatty.c \ 29 unistd/issetugid.c \ 30 unistd/killpg.c \ 31 unistd/lseek64.c \ 32 unistd/mmap.c \ 33 unistd/open.c \ 34 unistd/openat.c \ 35 unistd/opendir.c \ 36 unistd/pathconf.c \ 37 unistd/perror.c \ 38 unistd/popen.c \ 39 unistd/pread.c \ 40 unistd/pselect.c \ 41 unistd/ptsname.c \ 42 unistd/ptsname_r.c \ 43 unistd/pwrite.c \ 44 unistd/raise.c \ 45 unistd/reboot.c \ 46 unistd/recv.c \ 47 unistd/sbrk.c \ 48 unistd/send.c \ 49 unistd/setegid.c \ 50 unistd/setuid.c \ 51 unistd/seteuid.c \ 52 unistd/setreuid.c \ 53 unistd/setresuid.c \ 54 unistd/setpgrp.c \ 55 unistd/sigblock.c \ 56 unistd/siginterrupt.c \ 57 unistd/siglist.c \ 58 unistd/signal.c \ 59 unistd/signame.c \ 60 unistd/sigsetmask.c \ 61 unistd/sigsuspend.c \ 62 unistd/sigwait.c \ 63 unistd/sleep.c \ 64 unistd/statfs.c \ 65 unistd/strsignal.c \ 66 unistd/syslog.c \ 67 unistd/system.c \ 68 unistd/tcgetpgrp.c \ 69 unistd/tcsetpgrp.c \ 70 unistd/time.c \ 71 unistd/umount.c \ 72 unistd/unlockpt.c \ 73 unistd/usleep.c \ 74 unistd/wait.c \ 75 stdio/asprintf.c \ 76 stdio/clrerr.c \ 77 stdio/fclose.c \ 78 stdio/fdopen.c \ 79 stdio/feof.c \ 80 stdio/ferror.c \ 81 stdio/fflush.c \ 82 stdio/fgetc.c \ 83 stdio/fgetln.c \ 84 stdio/fgetpos.c \ 85 stdio/fgets.c \ 86 stdio/fileno.c \ 87 stdio/findfp.c \ 88 stdio/flags.c \ 89 stdio/flockfile.c \ 90 stdio/fopen.c \ 91 stdio/fprintf.c \ 92 stdio/fpurge.c \ 93 stdio/fputc.c \ 94 stdio/fputs.c \ 95 stdio/fread.c \ 96 stdio/freopen.c \ 97 stdio/fscanf.c \ 98 stdio/fseek.c \ 99 stdio/fsetpos.c \ 100 stdio/ftell.c \ 101 stdio/funopen.c \ 102 stdio/fvwrite.c \ 103 stdio/fwalk.c \ 104 stdio/fwrite.c \ 105 stdio/getc.c \ 106 stdio/getchar.c \ 107 stdio/gets.c \ 108 stdio/makebuf.c \ 109 stdio/mktemp.c \ 110 stdio/printf.c \ 111 stdio/putc.c \ 112 stdio/putchar.c \ 113 stdio/puts.c \ 114 stdio/putw.c \ 115 stdio/refill.c \ 116 stdio/remove.c \ 117 stdio/rewind.c \ 118 stdio/rget.c \ 119 stdio/scanf.c \ 120 stdio/setbuf.c \ 121 stdio/setbuffer.c \ 122 stdio/setvbuf.c \ 123 stdio/snprintf.c\ 124 stdio/sprintf.c \ 125 stdio/sscanf.c \ 126 stdio/stdio.c \ 127 stdio/tempnam.c \ 128 stdio/tmpfile.c \ 129 stdio/tmpnam.c \ 130 stdio/ungetc.c \ 131 stdio/vasprintf.c \ 132 stdio/vfprintf.c \ 133 stdio/vfscanf.c \ 134 stdio/vprintf.c \ 135 stdio/vsnprintf.c \ 136 stdio/vsprintf.c \ 137 stdio/vscanf.c \ 138 stdio/vsscanf.c \ 139 stdio/wbuf.c \ 140 stdio/wsetup.c \ 141 stdio/__fgets_chk.c \ 142 stdio/__snprintf_chk.c \ 143 stdio/__sprintf_chk.c \ 144 stdio/__vsnprintf_chk.c \ 145 stdio/__vsprintf_chk.c \ 146 stdlib/_rand48.c \ 147 stdlib/assert.c \ 148 stdlib/atexit.c \ 149 stdlib/atoi.c \ 150 stdlib/atol.c \ 151 stdlib/atoll.c \ 152 stdlib/bsearch.c \ 153 stdlib/ctype_.c \ 154 stdlib/div.c \ 155 stdlib/exit.c \ 156 stdlib/getenv.c \ 157 stdlib/jrand48.c \ 158 stdlib/ldiv.c \ 159 stdlib/lldiv.c \ 160 stdlib/locale.c \ 161 stdlib/lrand48.c \ 162 stdlib/mrand48.c \ 163 stdlib/nrand48.c \ 164 stdlib/putenv.c \ 165 stdlib/qsort.c \ 166 stdlib/seed48.c \ 167 stdlib/setenv.c \ 168 stdlib/setjmperr.c \ 169 stdlib/srand48.c \ 170 stdlib/strntoimax.c \ 171 stdlib/strntoumax.c \ 172 stdlib/strtod.c \ 173 stdlib/strtoimax.c \ 174 stdlib/strtol.c \ 175 stdlib/strtoll.c \ 176 stdlib/strtoul.c \ 177 stdlib/strtoull.c \ 178 stdlib/strtoumax.c \ 179 stdlib/tolower_.c \ 180 stdlib/toupper_.c \ 181 stdlib/wchar.c \ 182 string/index.c \ 183 string/memccpy.c \ 184 string/memchr.c \ 185 string/memmem.c \ 186 string/memrchr.c \ 187 string/memswap.c \ 188 string/strcasecmp.c \ 189 string/strcasestr.c \ 190 string/strcat.c \ 191 string/strchr.c \ 192 string/strcoll.c \ 193 string/strcspn.c \ 194 string/strdup.c \ 195 string/strerror.c \ 196 string/strerror_r.c \ 197 string/strlcat.c \ 198 string/strlcpy.c \ 199 string/strncat.c \ 200 string/strncpy.c \ 201 string/strndup.c \ 202 string/strnlen.c \ 203 string/strpbrk.c \ 204 string/strrchr.c \ 205 string/strsep.c \ 206 string/strspn.c \ 207 string/strstr.c \ 208 string/strtok.c \ 209 string/strtotimeval.c \ 210 string/__memcpy_chk.c \ 211 string/__memmove_chk.c \ 212 string/__memset_chk.c \ 213 string/__strcat_chk.c \ 214 string/__strcpy_chk.c \ 215 string/__strlcat_chk.c \ 216 string/__strlcpy_chk.c \ 217 string/__strlen_chk.c \ 218 string/__strncat_chk.c \ 219 string/__strncpy_chk.c \ 220 wchar/wcpcpy.c \ 221 wchar/wcpncpy.c \ 222 wchar/wcscasecmp.c \ 223 wchar/wcscat.c \ 224 wchar/wcschr.c \ 225 wchar/wcscmp.c \ 226 wchar/wcscoll.c \ 227 wchar/wcscpy.c \ 228 wchar/wcscspn.c \ 229 wchar/wcsdup.c \ 230 wchar/wcslcat.c \ 231 wchar/wcslcpy.c \ 232 wchar/wcslen.c \ 233 wchar/wcsncasecmp.c \ 234 wchar/wcsncat.c \ 235 wchar/wcsncmp.c \ 236 wchar/wcsncpy.c \ 237 wchar/wcsnlen.c \ 238 wchar/wcspbrk.c \ 239 wchar/wcsrchr.c \ 240 wchar/wcsspn.c \ 241 wchar/wcsstr.c \ 242 wchar/wcstok.c \ 243 wchar/wcswidth.c \ 244 wchar/wcsxfrm.c \ 245 wchar/wmemchr.c \ 246 wchar/wmemcmp.c \ 247 wchar/wmemcpy.c \ 248 wchar/wmemmove.c \ 249 wchar/wmemset.c \ 250 inet/bindresvport.c \ 251 inet/inet_addr.c \ 252 inet/inet_aton.c \ 253 inet/inet_ntoa.c \ 254 inet/inet_ntop.c \ 255 inet/inet_pton.c \ 256 inet/ether_aton.c \ 257 inet/ether_ntoa.c \ 258 tzcode/asctime.c \ 259 tzcode/difftime.c \ 260 tzcode/localtime.c \ 261 tzcode/strftime.c \ 262 tzcode/strptime.c \ 263 bionic/__set_errno.c \ 264 bionic/cpuacct.c \ 265 bionic/arc4random.c \ 266 bionic/basename.c \ 267 bionic/basename_r.c \ 268 bionic/clearenv.c \ 269 bionic/dirname.c \ 270 bionic/dirname_r.c \ 271 bionic/drand48.c \ 272 bionic/erand48.c \ 273 bionic/err.c \ 274 bionic/fdprintf.c \ 275 bionic/fork.c \ 276 bionic/fts.c \ 277 bionic/if_nametoindex.c \ 278 bionic/if_indextoname.c \ 279 bionic/ioctl.c \ 280 bionic/ldexp.c \ 281 bionic/libc_init_common.c \ 282 bionic/logd_write.c \ 283 bionic/md5.c \ 284 bionic/memmove_words.c \ 285 bionic/pututline.c \ 286 bionic/realpath.c \ 287 bionic/sched_getaffinity.c \ 288 bionic/sched_getcpu.c \ 289 bionic/sched_cpualloc.c \ 290 bionic/sched_cpucount.c \ 291 bionic/semaphore.c \ 292 bionic/sha1.c \ 293 bionic/stubs.cpp \ 294 bionic/system_properties.c \ 295 bionic/tdestroy.c \ 296 bionic/time64.c \ 297 bionic/thread_atexit.c \ 298 bionic/utime.c \ 299 bionic/utmp.c \ 300 netbsd/gethnamaddr.c \ 301 netbsd/isc/ev_timers.c \ 302 netbsd/isc/ev_streams.c \ 303 netbsd/inet/nsap_addr.c \ 304 netbsd/resolv/__dn_comp.c \ 305 netbsd/resolv/__res_close.c \ 306 netbsd/resolv/__res_send.c \ 307 netbsd/resolv/herror.c \ 308 netbsd/resolv/res_comp.c \ 309 netbsd/resolv/res_data.c \ 310 netbsd/resolv/res_debug.c \ 311 netbsd/resolv/res_init.c \ 312 netbsd/resolv/res_mkquery.c \ 313 netbsd/resolv/res_query.c \ 314 netbsd/resolv/res_send.c \ 315 netbsd/resolv/res_state.c \ 316 netbsd/resolv/res_cache.c \ 317 netbsd/net/nsdispatch.c \ 318 netbsd/net/getaddrinfo.c \ 319 netbsd/net/getnameinfo.c \ 320 netbsd/net/getservbyname.c \ 321 netbsd/net/getservent.c \ 322 netbsd/net/base64.c \ 323 netbsd/net/getservbyport.c \ 324 netbsd/nameser/ns_name.c \ 325 netbsd/nameser/ns_parse.c \ 326 netbsd/nameser/ns_ttl.c \ 327 netbsd/nameser/ns_netint.c \ 328 netbsd/nameser/ns_print.c \ 329 netbsd/nameser/ns_samedomain.c \ 330 331libc_upstream_netbsd_src_files := \ 332 upstream-netbsd/libc/compat-43/creat.c \ 333 upstream-netbsd/libc/gen/nice.c \ 334 upstream-netbsd/libc/regex/regcomp.c \ 335 upstream-netbsd/libc/regex/regerror.c \ 336 upstream-netbsd/libc/regex/regexec.c \ 337 upstream-netbsd/libc/regex/regfree.c \ 338 upstream-netbsd/libc/stdlib/tdelete.c \ 339 upstream-netbsd/libc/stdlib/tfind.c \ 340 upstream-netbsd/libc/stdlib/tsearch.c \ 341 upstream-netbsd/libc/string/strxfrm.c \ 342 343# The following files are common, but must be compiled 344# with different C flags when building a static C library. 345# 346# The reason for this is the implementation of __get_tls() 347# that will differ between the shared and static versions 348# of the library. 349# 350# See comments in private/bionic_tls.h for more details. 351# 352# NOTE: bionic/pthread.c is added later to this list 353# because it needs special handling on ARM, see 354# below. 355# 356libc_static_common_src_files := \ 357 unistd/sysconf.c \ 358 bionic/__errno.c \ 359 360# Architecture specific source files go here 361# ========================================================= 362ifeq ($(TARGET_ARCH),arm) 363libc_common_src_files += \ 364 bionic/bionic_clone.c \ 365 arch-arm/bionic/__get_pc.S \ 366 arch-arm/bionic/__get_sp.S \ 367 arch-arm/bionic/_exit_with_stack_teardown.S \ 368 arch-arm/bionic/_setjmp.S \ 369 arch-arm/bionic/abort_arm.S \ 370 arch-arm/bionic/atomics_arm.c \ 371 arch-arm/bionic/clone.S \ 372 arch-arm/bionic/eabi.c \ 373 arch-arm/bionic/ffs.S \ 374 arch-arm/bionic/futex_arm.S \ 375 arch-arm/bionic/kill.S \ 376 arch-arm/bionic/libgcc_compat.c \ 377 arch-arm/bionic/tkill.S \ 378 arch-arm/bionic/tgkill.S \ 379 arch-arm/bionic/memcmp.S \ 380 arch-arm/bionic/memcmp16.S \ 381 arch-arm/bionic/memcpy.S \ 382 arch-arm/bionic/memset.S \ 383 arch-arm/bionic/setjmp.S \ 384 arch-arm/bionic/sigsetjmp.S \ 385 arch-arm/bionic/strlen.c.arm \ 386 arch-arm/bionic/strcpy.S \ 387 arch-arm/bionic/strcmp.S \ 388 arch-arm/bionic/syscall.S \ 389 string/memmove.c.arm \ 390 string/bcopy.c \ 391 string/strncmp.c \ 392 unistd/socketcalls.c 393 394# These files need to be arm so that gdbserver 395# can set breakpoints in them without messing 396# up any thumb code. 397libc_common_src_files += \ 398 bionic/pthread-atfork.c.arm \ 399 bionic/pthread-rwlocks.c.arm \ 400 bionic/pthread-timers.c.arm \ 401 bionic/ptrace.c.arm 402 403libc_static_common_src_files += \ 404 bionic/pthread.c.arm \ 405 406# these are used by the static and dynamic versions of the libc 407# respectively 408libc_arch_static_src_files := \ 409 arch-arm/bionic/exidx_static.c 410 411libc_arch_dynamic_src_files := \ 412 arch-arm/bionic/exidx_dynamic.c 413endif # arm 414 415ifeq ($(TARGET_ARCH),x86) 416libc_common_src_files += \ 417 arch-x86/bionic/__get_sp.S \ 418 arch-x86/bionic/__get_tls.c \ 419 arch-x86/bionic/__set_tls.c \ 420 arch-x86/bionic/clone.S \ 421 arch-x86/bionic/_exit_with_stack_teardown.S \ 422 arch-x86/bionic/futex_x86.S \ 423 arch-x86/bionic/setjmp.S \ 424 arch-x86/bionic/_setjmp.S \ 425 arch-x86/bionic/sigsetjmp.S \ 426 arch-x86/bionic/vfork.S \ 427 arch-x86/bionic/syscall.S \ 428 arch-x86/string/bcopy_wrapper.S \ 429 arch-x86/string/memcpy_wrapper.S \ 430 arch-x86/string/memmove_wrapper.S \ 431 arch-x86/string/bzero_wrapper.S \ 432 arch-x86/string/memcmp_wrapper.S \ 433 arch-x86/string/memset_wrapper.S \ 434 arch-x86/string/strcmp_wrapper.S \ 435 arch-x86/string/strncmp_wrapper.S \ 436 arch-x86/string/strlen_wrapper.S \ 437 string/strcpy.c \ 438 bionic/pthread-atfork.c \ 439 bionic/pthread-rwlocks.c \ 440 bionic/pthread-timers.c \ 441 bionic/ptrace.c 442 443libc_static_common_src_files += \ 444 bionic/pthread.c \ 445 446libc_arch_static_src_files := \ 447 bionic/dl_iterate_phdr_static.c 448 449libc_arch_dynamic_src_files := 450endif # x86 451 452ifeq ($(TARGET_ARCH),mips) 453libc_common_src_files += \ 454 bionic/bionic_clone.c \ 455 arch-mips/bionic/__get_sp.S \ 456 arch-mips/bionic/__get_tls.c \ 457 arch-mips/bionic/__set_tls.c \ 458 arch-mips/bionic/_exit_with_stack_teardown.S \ 459 arch-mips/bionic/_setjmp.S \ 460 arch-mips/bionic/futex_mips.S \ 461 arch-mips/bionic/bzero.S \ 462 arch-mips/bionic/cacheflush.c \ 463 arch-mips/bionic/clone.S \ 464 arch-mips/bionic/ffs.S \ 465 arch-mips/bionic/memcmp16.S \ 466 arch-mips/bionic/memmove.c \ 467 arch-mips/bionic/pipe.S \ 468 arch-mips/bionic/setjmp.S \ 469 arch-mips/bionic/sigsetjmp.S \ 470 arch-mips/bionic/vfork.S 471 472libc_common_src_files += \ 473 arch-mips/string/memset.S \ 474 arch-mips/string/memcpy.S \ 475 arch-mips/string/mips_strlen.c 476 477libc_common_src_files += \ 478 string/bcopy.c \ 479 string/memcmp.c \ 480 string/strcmp.c \ 481 string/strcpy.c \ 482 string/strncmp.c 483 484libc_common_src_files += \ 485 bionic/pthread-atfork.c \ 486 bionic/pthread-rwlocks.c \ 487 bionic/pthread-timers.c \ 488 bionic/ptrace.c 489 490libc_static_common_src_files += \ 491 bionic/pthread.c 492 493libc_arch_static_src_files := \ 494 bionic/dl_iterate_phdr_static.c 495 496libc_arch_dynamic_src_files := 497endif # mips 498 499# Define some common cflags 500# ======================================================== 501libc_common_cflags := \ 502 -DWITH_ERRLIST \ 503 -DANDROID_CHANGES \ 504 -DUSE_LOCKS \ 505 -DREALLOC_ZERO_BYTES_FREES \ 506 -D_LIBC=1 \ 507 -DFLOATING_POINT \ 508 -DINET6 \ 509 -I$(LOCAL_PATH)/private \ 510 -DUSE_DL_PREFIX \ 511 -DPOSIX_MISTAKE \ 512 -DLOG_ON_HEAP_ERROR \ 513 -std=gnu99 514 515# these macro definitions are required to implement the 516# 'timezone' and 'daylight' global variables, as well as 517# properly update the 'tm_gmtoff' field in 'struct tm'. 518# 519libc_common_cflags += \ 520 -DTM_GMTOFF=tm_gmtoff \ 521 -DUSG_COMPAT=1 522 523ifeq ($(strip $(DEBUG_BIONIC_LIBC)),true) 524 libc_common_cflags += -DDEBUG 525endif 526 527# To customize dlmalloc's alignment, set BOARD_MALLOC_ALIGNMENT in 528# the appropriate BoardConfig.mk file. 529# 530ifneq ($(BOARD_MALLOC_ALIGNMENT),) 531 libc_common_cflags += -DMALLOC_ALIGNMENT=$(BOARD_MALLOC_ALIGNMENT) 532endif 533 534ifeq ($(TARGET_ARCH),arm) 535 libc_common_cflags += -DSOFTFLOAT 536 libc_common_cflags += -fstrict-aliasing 537 libc_crt_target_cflags := -mthumb-interwork 538 # 539 # Define HAVE_ARM_TLS_REGISTER macro to indicate to the C library 540 # that it should access the hardware TLS register directly in 541 # private/bionic_tls.h 542 # 543 # The value must match your kernel configuration 544 # 545 ifeq ($(ARCH_ARM_HAVE_TLS_REGISTER),true) 546 libc_common_cflags += -DHAVE_ARM_TLS_REGISTER 547 endif 548 # 549 # Define HAVE_32_BYTE_CACHE_LINES to indicate to C 550 # library it should use to 32-byte version of memcpy, and not 551 # the 64-byte version. 552 # 553 ifeq ($(ARCH_ARM_HAVE_32_BYTE_CACHE_LINES),true) 554 libc_common_cflags += -DHAVE_32_BYTE_CACHE_LINE 555 endif 556 ifeq ($(ARCH_ARM_USE_NON_NEON_MEMCPY),true) 557 libc_common_cflags += -DARCH_ARM_USE_NON_NEON_MEMCPY 558 endif 559endif # !arm 560 561ifeq ($(TARGET_ARCH),x86) 562 libc_common_cflags += -DSOFTFLOAT 563 libc_crt_target_cflags := 564 ifeq ($(ARCH_X86_HAVE_SSE2),true) 565 libc_crt_target_cflags += -DUSE_SSE2=1 566 endif 567 ifeq ($(ARCH_X86_HAVE_SSSE3),true) 568 libc_crt_target_cflags += -DUSE_SSSE3=1 569 endif 570endif # x86 571 572ifeq ($(TARGET_ARCH),mips) 573 ifneq ($(ARCH_MIPS_HAS_FPU),true) 574 libc_common_cflags += -DSOFTFLOAT 575 endif 576 libc_common_cflags += -fstrict-aliasing 577 libc_crt_target_cflags := $(TARGET_GLOBAL_CFLAGS) 578endif # mips 579 580# Define ANDROID_SMP appropriately. 581ifeq ($(TARGET_CPU_SMP),true) 582 libc_common_cflags += -DANDROID_SMP=1 583else 584 libc_common_cflags += -DANDROID_SMP=0 585endif 586 587# crtbrand.c needs <stdint.h> and a #define for the platform SDK version. 588libc_crt_target_cflags += \ 589 -I$(LOCAL_PATH)/include \ 590 -DPLATFORM_SDK_VERSION=$(PLATFORM_SDK_VERSION) 591 592ifeq ($(TARGET_ARCH),arm) 593 libc_crt_target_cflags += -DCRT_LEGACY_WORKAROUND 594endif 595 596# Define some common includes 597# ======================================================== 598libc_common_c_includes := \ 599 $(LOCAL_PATH)/stdlib \ 600 $(LOCAL_PATH)/string \ 601 $(LOCAL_PATH)/stdio \ 602 external/safe-iop/include 603 604# Needed to access private/__dso_handle.h from 605# crtbegin_xxx.S and crtend_xxx.S 606libc_crt_target_cflags += \ 607 -I$(LOCAL_PATH)/private \ 608 -I$(LOCAL_PATH)/arch-$(TARGET_ARCH)/include 609 610# Define the libc run-time (crt) support object files that must be built, 611# which are needed to build all other objects (shared/static libs and 612# executables) 613# ========================================================================== 614# ARM, MIPS, and x86 all need crtbegin_so/crtend_so. 615# 616# For x86, the .init section must point to a function that calls all 617# entries in the .ctors section. (on ARM this is done through the 618# .init_array section instead). 619# 620# For all the platforms, the .fini_array section must point to a function 621# that will call __cxa_finalize(&__dso_handle) in order to ensure that 622# static C++ destructors are properly called on dlclose(). 623# 624ifeq ($(TARGET_ARCH),arm) 625 libc_crtstart_extension := c 626 libc_crt_target_so_cflags := 627endif 628ifeq ($(TARGET_ARCH),mips) 629 libc_crtstart_extension := S 630 libc_crt_target_so_cflags := -fPIC 631endif 632ifeq ($(TARGET_ARCH),x86) 633 libc_crtstart_extension := S 634 libc_crt_target_so_cflags := -fPIC 635endif 636ifeq ($(libc_crtstart_extension),) 637 $(error $(TARGET_ARCH) not supported) 638endif 639libc_crt_target_so_cflags += $(libc_crt_target_cflags) 640libc_crt_target_crtstart_file := $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin.$(libc_crtstart_extension) 641libc_crt_target_crtstart_so_file := $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin_so.$(libc_crtstart_extension) 642 643# See the comment in crtbrand.c for the reason why we need to generate 644# crtbrand.s before generating crtbrand.o. 645GEN := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbrand.s 646$(GEN): $(LOCAL_PATH)/bionic/crtbrand.c 647 @mkdir -p $(dir $@) 648 $(TARGET_CC) $(libc_crt_target_so_cflags) -S -o $@ $< 649 sed -i -e '/\.note\.ABI-tag/s/progbits/note/' $@ 650ALL_GENERATED_SOURCES += $(GEN) 651 652GEN := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbrand.o 653$(GEN): $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbrand.s 654 @mkdir -p $(dir $@) 655 $(TARGET_CC) $(libc_crt_target_so_cflags) -o $@ -c $< 656ALL_GENERATED_SOURCES += $(GEN) 657 658GEN := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_so.o 659$(GEN): $(libc_crt_target_crtstart_so_file) 660 @mkdir -p $(dir $@) 661 $(TARGET_CC) $(libc_crt_target_so_cflags) -o $@ -c $< 662ALL_GENERATED_SOURCES += $(GEN) 663 664GEN := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_so.o 665$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtend_so.S 666 @mkdir -p $(dir $@) 667 $(TARGET_CC) $(libc_crt_target_so_cflags) -o $@ -c $< 668ALL_GENERATED_SOURCES += $(GEN) 669 670GEN := $(TARGET_OUT_SHARED_LIBRARIES)/crtbegin_so.o 671$(GEN): $(libc_crt_target_crtstart_so_file) 672 @mkdir -p $(dir $@) 673 $(TARGET_CC) $(libc_crt_target_so_cflags) -o $@ -c $< 674ALL_GENERATED_SOURCES += $(GEN) 675 676GEN := $(TARGET_OUT_SHARED_LIBRARIES)/crtend_so.o 677$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtend_so.S 678 @mkdir -p $(dir $@) 679 $(TARGET_CC) $(libc_crt_target_so_cflags) -o $@ -c $< 680ALL_GENERATED_SOURCES += $(GEN) 681 682 683GEN := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_static1.o 684$(GEN): $(libc_crt_target_crtstart_file) 685 @mkdir -p $(dir $@) 686 $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $< 687ALL_GENERATED_SOURCES += $(GEN) 688 689GEN := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_static.o 690$(GEN): $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_static1.o $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbrand.o 691 @mkdir -p $(dir $@) 692 $(TARGET_LD) -r -o $@ $^ 693ALL_GENERATED_SOURCES += $(GEN) 694 695GEN := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_dynamic1.o 696$(GEN): $(libc_crt_target_crtstart_file) 697 @mkdir -p $(dir $@) 698 $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $< 699ALL_GENERATED_SOURCES += $(GEN) 700 701GEN := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_dynamic.o 702$(GEN): $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_dynamic1.o $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbrand.o 703 @mkdir -p $(dir $@) 704 $(TARGET_LD) -r -o $@ $^ 705ALL_GENERATED_SOURCES += $(GEN) 706 707# We rename crtend.o to crtend_android.o to avoid a 708# name clash between gcc and bionic. 709GEN := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_android.o 710$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtend.S 711 @mkdir -p $(dir $@) 712 $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $< 713ALL_GENERATED_SOURCES += $(GEN) 714 715 716# To enable malloc leak check for statically linked programs, add 717# "WITH_MALLOC_CHECK_LIBC_A := true" to buildspec.mk 718WITH_MALLOC_CHECK_LIBC_A := $(strip $(WITH_MALLOC_CHECK_LIBC_A)) 719 720# ======================================================== 721# libbionic_ssp.a - stack protector code 722# ======================================================== 723# 724# The stack protector code needs to be compiled 725# with -fno-stack-protector, since it modifies the 726# stack canary. 727 728include $(CLEAR_VARS) 729 730LOCAL_SRC_FILES := bionic/ssp.c 731LOCAL_CFLAGS := $(libc_common_cflags) -fno-stack-protector 732LOCAL_C_INCLUDES := $(libc_common_c_includes) 733LOCAL_MODULE := libbionic_ssp 734LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 735LOCAL_SYSTEM_SHARED_LIBRARIES := 736 737include $(BUILD_STATIC_LIBRARY) 738 739 740# ======================================================== 741# libc_netbsd.a - upstream NetBSD C library code 742# ======================================================== 743# 744# These files are built with the netbsd-compat.h header file 745# automatically included. 746 747include $(CLEAR_VARS) 748 749LOCAL_SRC_FILES := $(libc_upstream_netbsd_src_files) 750LOCAL_CFLAGS := \ 751 $(libc_common_cflags) \ 752 -I$(LOCAL_PATH)/upstream-netbsd \ 753 -include upstream-netbsd/netbsd-compat.h 754LOCAL_C_INCLUDES := $(libc_common_c_includes) 755LOCAL_MODULE := libc_netbsd 756LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 757LOCAL_SYSTEM_SHARED_LIBRARIES := 758 759include $(BUILD_STATIC_LIBRARY) 760 761 762# ======================================================== 763# libc_common.a 764# ======================================================== 765 766include $(CLEAR_VARS) 767 768LOCAL_SRC_FILES := $(libc_common_src_files) 769LOCAL_CFLAGS := $(libc_common_cflags) 770ifeq ($(TARGET_ARCH),arm) 771 LOCAL_CFLAGS += -DCRT_LEGACY_WORKAROUND 772endif 773LOCAL_C_INCLUDES := $(libc_common_c_includes) 774LOCAL_MODULE := libc_common 775LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 776LOCAL_WHOLE_STATIC_LIBRARIES := libbionic_ssp libc_netbsd 777LOCAL_SYSTEM_SHARED_LIBRARIES := 778 779include $(BUILD_STATIC_LIBRARY) 780 781 782# ======================================================== 783# libc_nomalloc.a 784# ======================================================== 785# 786# This is a version of the static C library that does not 787# include malloc. It's useful in situations when calling 788# the user wants to provide their own malloc implementation, 789# or wants to explicitly disallow the use of the use of malloc, 790# like the dynamic loader. 791 792include $(CLEAR_VARS) 793 794LOCAL_SRC_FILES := \ 795 $(libc_arch_static_src_files) \ 796 $(libc_static_common_src_files) \ 797 bionic/libc_init_static.c 798 799LOCAL_C_INCLUDES := $(libc_common_c_includes) 800LOCAL_CFLAGS := $(libc_common_cflags) \ 801 -DLIBC_STATIC 802 803LOCAL_MODULE := libc_nomalloc 804LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 805LOCAL_WHOLE_STATIC_LIBRARIES := libc_common 806LOCAL_SYSTEM_SHARED_LIBRARIES := 807 808include $(BUILD_STATIC_LIBRARY) 809 810 811# ======================================================== 812# libc.a 813# ======================================================== 814include $(CLEAR_VARS) 815 816LOCAL_SRC_FILES := \ 817 $(libc_arch_static_src_files) \ 818 $(libc_static_common_src_files) \ 819 bionic/dlmalloc.c \ 820 bionic/malloc_debug_common.c \ 821 bionic/libc_init_static.c 822 823LOCAL_CFLAGS := $(libc_common_cflags) \ 824 -DLIBC_STATIC 825LOCAL_C_INCLUDES := $(libc_common_c_includes) 826LOCAL_MODULE := libc 827LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 828LOCAL_WHOLE_STATIC_LIBRARIES := libc_common 829LOCAL_SYSTEM_SHARED_LIBRARIES := 830 831include $(BUILD_STATIC_LIBRARY) 832 833 834# ======================================================== 835# libc.so 836# ======================================================== 837include $(CLEAR_VARS) 838 839# pthread deadlock prediction: 840# set -DPTHREAD_DEBUG -DPTHREAD_DEBUG_ENABLED=1 to enable support for 841# pthread deadlock prediction. 842# Since this code is experimental it is disabled by default. 843# see libc/bionic/pthread_debug.c for details 844 845LOCAL_CFLAGS := $(libc_common_cflags) -DPTHREAD_DEBUG -DPTHREAD_DEBUG_ENABLED=0 846LOCAL_C_INCLUDES := $(libc_common_c_includes) 847 848LOCAL_SRC_FILES := \ 849 $(libc_arch_dynamic_src_files) \ 850 $(libc_static_common_src_files) \ 851 bionic/dlmalloc.c \ 852 bionic/malloc_debug_common.c \ 853 bionic/pthread_debug.c \ 854 bionic/libc_init_dynamic.c 855 856LOCAL_MODULE:= libc 857LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 858 859# WARNING: The only library libc.so should depend on is libdl.so! If you add other libraries, 860# make sure to add -Wl,--exclude-libs=libgcc.a to the LOCAL_LDFLAGS for those libraries. This 861# ensures that symbols that are pulled into those new libraries from libgcc.a are not declared 862# external; if that were the case, then libc would not pull those symbols from libgcc.a as it 863# should, instead relying on the external symbols from the dependent libraries. That would 864# create an "cloaked" dependency on libgcc.a in libc though the libraries, which is not what 865# you wanted! 866 867LOCAL_SHARED_LIBRARIES := libdl 868LOCAL_WHOLE_STATIC_LIBRARIES := libc_common 869LOCAL_SYSTEM_SHARED_LIBRARIES := 870 871include $(BUILD_SHARED_LIBRARY) 872 873 874# For all builds, except for the -user build we will enable memory 875# allocation checking (including memory leaks, buffer overwrites, etc.) 876# Note that all these checks are also controlled by env. settings 877# that can enable, or disable specific checks. Note also that some of 878# the checks are available only in emulator and are implemeted in 879# libc_malloc_qemu_instrumented.so. 880ifneq ($(TARGET_BUILD_VARIANT),user) 881 882# ======================================================== 883# libc_malloc_debug_leak.so 884# ======================================================== 885include $(CLEAR_VARS) 886 887LOCAL_CFLAGS := \ 888 $(libc_common_cflags) \ 889 -DMALLOC_LEAK_CHECK 890 891LOCAL_C_INCLUDES := $(libc_common_c_includes) 892 893LOCAL_SRC_FILES := \ 894 bionic/malloc_debug_leak.c \ 895 bionic/malloc_debug_check.c \ 896 bionic/malloc_debug_check_mapinfo.c \ 897 bionic/malloc_debug_stacktrace.c 898 899LOCAL_MODULE:= libc_malloc_debug_leak 900LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 901 902LOCAL_SHARED_LIBRARIES := libc 903LOCAL_WHOLE_STATIC_LIBRARIES := libc_common 904LOCAL_SYSTEM_SHARED_LIBRARIES := 905LOCAL_ALLOW_UNDEFINED_SYMBOLS := true 906 907# Don't install on release build 908LOCAL_MODULE_TAGS := eng debug 909 910include $(BUILD_SHARED_LIBRARY) 911 912 913# ======================================================== 914# libc_malloc_debug_qemu.so 915# ======================================================== 916include $(CLEAR_VARS) 917 918LOCAL_CFLAGS := \ 919 $(libc_common_cflags) \ 920 -DMALLOC_QEMU_INSTRUMENT 921 922LOCAL_C_INCLUDES := $(libc_common_c_includes) 923 924LOCAL_SRC_FILES := \ 925 bionic/malloc_debug_qemu.c 926 927LOCAL_MODULE:= libc_malloc_debug_qemu 928LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 929 930LOCAL_SHARED_LIBRARIES := libc libdl 931LOCAL_WHOLE_STATIC_LIBRARIES := libc_common 932LOCAL_SYSTEM_SHARED_LIBRARIES := 933 934# Don't install on release build 935LOCAL_MODULE_TAGS := eng debug 936 937include $(BUILD_SHARED_LIBRARY) 938 939endif #!user 940 941 942# ======================================================== 943include $(call all-makefiles-under,$(LOCAL_PATH)) 944