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