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