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