1 LOCAL_PATH:= $(call my-dir)
3 include $(LOCAL_PATH)/arch-$(TARGET_ARCH)/syscalls.mk
4 libc_common_src_files := \
5 $(syscall_src) \
6 unistd/abort.c \
7 unistd/alarm.c \
8 unistd/brk.c \
9 unistd/creat.c \
10 unistd/daemon.c \
11 unistd/exec.c \
12 unistd/fcntl.c \
13 unistd/fnmatch.c \
14 unistd/ftime.c \
15 unistd/ftok.c \
16 unistd/getcwd.c \
17 unistd/getdtablesize.c \
18 unistd/gethostname.c \
19 unistd/getopt_long.c \
20 unistd/getpgrp.c \
21 unistd/getpriority.c \
22 unistd/getpt.c \
23 unistd/initgroups.c \
24 unistd/isatty.c \
25 unistd/issetugid.c \
26 unistd/lseek64.c \
27 unistd/mmap.c \
28 unistd/nice.c \
29 unistd/open.c \
30 unistd/openat.c \
31 unistd/opendir.c \
32 unistd/pathconf.c \
33 unistd/perror.c \
34 unistd/popen.c \
35 unistd/pread.c \
36 unistd/pselect.c \
37 unistd/ptsname.c \
38 unistd/ptsname_r.c \
39 unistd/pwrite.c \
40 unistd/raise.c \
41 unistd/reboot.c \
42 unistd/recv.c \
43 unistd/sbrk.c \
44 unistd/send.c \
45 unistd/setegid.c \
46 unistd/seteuid.c \
47 unistd/setpgrp.c \
48 unistd/sigblock.c \
49 unistd/siginterrupt.c \
50 unistd/siglist.c \
51 unistd/signal.c \
52 unistd/sigsetmask.c \
53 unistd/sigsuspend.c \
54 unistd/sigwait.c \
55 unistd/sleep.c \
56 unistd/statfs.c \
57 unistd/strsignal.c \
58 unistd/sysconf.c \
59 unistd/syslog.c \
60 unistd/system.c \
61 unistd/tcgetpgrp.c \
62 unistd/tcsetpgrp.c \
63 unistd/time.c \
64 unistd/umount.c \
65 unistd/unlockpt.c \
66 unistd/usleep.c \
67 unistd/wait.c \
68 stdio/asprintf.c \
69 stdio/clrerr.c \
70 stdio/fclose.c \
71 stdio/fdopen.c \
72 stdio/feof.c \
73 stdio/ferror.c \
74 stdio/fflush.c \
75 stdio/fgetc.c \
76 stdio/fgetln.c \
77 stdio/fgetpos.c \
78 stdio/fgets.c \
79 stdio/fileno.c \
80 stdio/findfp.c \
81 stdio/flags.c \
82 stdio/flockfile.c \
83 stdio/fopen.c \
84 stdio/fprintf.c \
85 stdio/fpurge.c \
86 stdio/fputc.c \
87 stdio/fputs.c \
88 stdio/fread.c \
89 stdio/freopen.c \
90 stdio/fscanf.c \
91 stdio/fseek.c \
92 stdio/fsetpos.c \
93 stdio/ftell.c \
94 stdio/funopen.c \
95 stdio/fvwrite.c \
96 stdio/fwalk.c \
97 stdio/fwrite.c \
98 stdio/getc.c \
99 stdio/getchar.c \
100 stdio/gets.c \
101 stdio/makebuf.c \
102 stdio/mktemp.c \
103 stdio/printf.c \
104 stdio/putc.c \
105 stdio/putchar.c \
106 stdio/puts.c \
107 stdio/putw.c \
108 stdio/refill.c \
109 stdio/remove.c \
110 stdio/rewind.c \
111 stdio/rget.c \
112 stdio/scanf.c \
113 stdio/setbuf.c \
114 stdio/setbuffer.c \
115 stdio/setvbuf.c \
116 stdio/snprintf.c\
117 stdio/sprintf.c \
118 stdio/sscanf.c \
119 stdio/stdio.c \
120 stdio/tempnam.c \
121 stdio/tmpfile.c \
122 stdio/tmpnam.c \
123 stdio/ungetc.c \
124 stdio/vasprintf.c \
125 stdio/vfprintf.c \
126 stdio/vfscanf.c \
127 stdio/vprintf.c \
128 stdio/vsnprintf.c \
129 stdio/vsprintf.c \
130 stdio/vscanf.c \
131 stdio/vsscanf.c \
132 stdio/wbuf.c \
133 stdio/wsetup.c \
134 stdlib/_rand48.c \
135 stdlib/assert.c \
136 stdlib/atexit.c \
137 stdlib/atoi.c \
138 stdlib/atol.c \
139 stdlib/atoll.c \
140 stdlib/bsearch.c \
141 stdlib/ctype_.c \
142 stdlib/div.c \
143 stdlib/exit.c \
144 stdlib/getenv.c \
145 stdlib/jrand48.c \
146 stdlib/ldiv.c \
147 stdlib/lldiv.c \
148 stdlib/locale.c \
149 stdlib/lrand48.c \
150 stdlib/mrand48.c \
151 stdlib/nrand48.c \
152 stdlib/putenv.c \
153 stdlib/qsort.c \
154 stdlib/seed48.c \
155 stdlib/setenv.c \
156 stdlib/setjmperr.c \
157 stdlib/srand48.c \
158 stdlib/strntoimax.c \
159 stdlib/strntoumax.c \
160 stdlib/strtod.c \
161 stdlib/strtoimax.c \
162 stdlib/strtol.c \
163 stdlib/strtoll.c \
164 stdlib/strtoul.c \
165 stdlib/strtoull.c \
166 stdlib/strtoumax.c \
167 stdlib/tolower_.c \
168 stdlib/toupper_.c \
169 stdlib/wchar.c \
170 string/bcopy.c \
171 string/index.c \
172 string/memccpy.c \
173 string/memchr.c \
174 string/memmem.c \
175 string/memmove.c.arm \
176 string/memrchr.c \
177 string/memswap.c \
178 string/strcasecmp.c \
179 string/strcasestr.c \
180 string/strcat.c \
181 string/strchr.c \
182 string/strcmp.c \
183 string/strcoll.c \
184 string/strcpy.c \
185 string/strcspn.c \
186 string/strdup.c \
187 string/strerror.c \
188 string/strerror_r.c \
189 string/strlcat.c \
190 string/strlcpy.c \
191 string/strncat.c \
192 string/strncmp.c \
193 string/strncpy.c \
194 string/strndup.c \
195 string/strnlen.c \
196 string/strpbrk.c \
197 string/strrchr.c \
198 string/strsep.c \
199 string/strspn.c \
200 string/strstr.c \
201 string/strtok.c \
202 string/strtotimeval.c \
203 string/strxfrm.c \
204 inet/bindresvport.c \
205 inet/inet_addr.c \
206 inet/inet_aton.c \
207 inet/inet_ntoa.c \
208 inet/inet_ntop.c \
209 inet/inet_pton.c \
210 tzcode/asctime.c \
211 tzcode/difftime.c \
212 tzcode/localtime.c \
213 tzcode/strftime.c \
214 tzcode/strptime.c \
215 bionic/__errno.c \
216 bionic/__set_errno.c \
217 bionic/_rand48.c \
218 bionic/arc4random.c \
219 bionic/basename.c \
220 bionic/basename_r.c \
221 bionic/dirname.c \
222 bionic/dirname_r.c \
223 bionic/drand48.c \
224 bionic/erand48.c \
225 bionic/fork.c \
226 bionic/if_nametoindex.c \
227 bionic/if_indextoname.c \
228 bionic/ioctl.c \
229 bionic/ldexp.c \
230 bionic/libc_init_common.c \
231 bionic/logd_write.c \
232 bionic/md5.c \
233 bionic/pututline.c \
234 bionic/realpath.c \
235 bionic/semaphore.c \
236 bionic/sha1.c \
237 bionic/ssp.c \
238 bionic/stubs.c \
239 bionic/system_properties.c \
240 bionic/time64.c \
241 bionic/thread_atexit.c \
242 bionic/utime.c \
243 bionic/utmp.c \
244 netbsd/gethnamaddr.c \
245 netbsd/isc/ev_timers.c \
246 netbsd/isc/ev_streams.c \
247 netbsd/inet/nsap_addr.c \
248 netbsd/resolv/__dn_comp.c \
249 netbsd/resolv/__res_close.c \
250 netbsd/resolv/__res_send.c \
251 netbsd/resolv/herror.c \
252 netbsd/resolv/res_comp.c \
253 netbsd/resolv/res_data.c \
254 netbsd/resolv/res_debug.c \
255 netbsd/resolv/res_init.c \
256 netbsd/resolv/res_mkquery.c \
257 netbsd/resolv/res_query.c \
258 netbsd/resolv/res_send.c \
259 netbsd/resolv/res_state.c.arm \
260 netbsd/resolv/res_cache.c \
261 netbsd/net/nsdispatch.c \
262 netbsd/net/getaddrinfo.c \
263 netbsd/net/getnameinfo.c \
264 netbsd/net/getservbyname.c \
265 netbsd/net/getservent.c \
266 netbsd/net/base64.c \
267 netbsd/net/getservbyport.c \
268 netbsd/nameser/ns_name.c \
269 netbsd/nameser/ns_parse.c \
270 netbsd/nameser/ns_ttl.c \
271 netbsd/nameser/ns_netint.c \
272 netbsd/nameser/ns_print.c \
273 netbsd/nameser/ns_samedomain.c
275 ifeq ($(TARGET_ARCH),arm)
276 libc_common_src_files += \
277 bionic/eabi.c \
278 arch-arm/bionic/__get_pc.S \
279 arch-arm/bionic/__get_sp.S \
280 arch-arm/bionic/_exit_with_stack_teardown.S \
281 arch-arm/bionic/_setjmp.S \
282 arch-arm/bionic/atomics_arm.S \
283 arch-arm/bionic/clone.S \
284 arch-arm/bionic/ffs.S \
285 arch-arm/bionic/kill.S \
286 arch-arm/bionic/tkill.S \
287 arch-arm/bionic/memcmp.S \
288 arch-arm/bionic/memcmp16.S \
289 arch-arm/bionic/memcpy.S \
290 arch-arm/bionic/memset.S \
291 arch-arm/bionic/setjmp.S \
292 arch-arm/bionic/sigsetjmp.S \
293 arch-arm/bionic/strlen.c.arm \
294 arch-arm/bionic/syscall.S \
295 unistd/socketcalls.c
297 # These files need to be arm so that gdbserver
298 # can set breakpoints in them without messing
299 # up any thumb code.
300 libc_common_src_files += \
301 bionic/pthread.c.arm \
302 bionic/pthread-timers.c.arm \
303 bionic/ptrace.c.arm
304 else # !arm
306 ifeq ($(TARGET_ARCH),x86)
307 libc_common_src_files += \
308 arch-x86/bionic/__get_sp.S \
309 arch-x86/bionic/__get_tls.c \
310 arch-x86/bionic/__set_tls.c \
311 arch-x86/bionic/atomics_x86.S \
312 arch-x86/bionic/clone.S \
313 arch-x86/bionic/_exit_with_stack_teardown.S \
314 arch-x86/bionic/setjmp.S \
315 arch-x86/bionic/_setjmp.S \
316 arch-x86/bionic/vfork.S \
317 arch-x86/string/bzero.S \
318 arch-x86/string/memset.S \
319 arch-x86/string/memcmp.S \
320 arch-x86/string/memcpy.S \
321 arch-x86/string/strlen.S \
322 bionic/pthread.c \
323 bionic/pthread-timers.c \
324 bionic/ptrace.c
325 endif # x86
327 endif # !arm
329 libc_common_cflags := \
330 -DWITH_ERRLIST \
331 -DANDROID_CHANGES \
332 -DUSE_LOCKS \
333 -DREALLOC_ZERO_BYTES_FREES \
334 -D_LIBC=1 \
335 -DSOFTFLOAT \
336 -DFLOATING_POINT \
337 -DNEED_PSELECT=1 \
338 -DINET6 \
339 -I$(LOCAL_PATH)/private \
341 ifeq ($(TARGET_BUILD_TYPE),debug)
342 libc_common_cflags += -DDEBUG
343 endif
345 ifeq ($(TARGET_ARCH),arm)
346 libc_common_cflags += -fstrict-aliasing
347 endif
349 libc_common_c_includes := \
350 $(LOCAL_PATH)/stdlib \
351 $(LOCAL_PATH)/string \
352 $(LOCAL_PATH)/stdio
354 # libc_common.a
355 # ========================================================
357 include $(CLEAR_VARS)
359 LOCAL_SRC_FILES := $(libc_common_src_files)
360 LOCAL_CFLAGS := $(libc_common_cflags) -DUSE_DL_PREFIX
361 LOCAL_C_INCLUDES := $(libc_common_c_includes)
363 ifneq ($(TARGET_SIMULATOR),true)
364 ifeq ($(TARGET_ARCH),arm)
365 crtend_target_cflags := -mthumb-interwork
366 else
367 ifeq ($(TARGET_ARCH),x86)
368 crtend_target_cflags := -m32
369 endif
370 endif
371 # We rename crtend.o to crtend_android.o to avoid a
372 # name clash between gcc and bionic.
373 GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_android.o
374 $(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtend.S
375 @mkdir -p $(dir $@)
376 $(TARGET_CC) $(crtend_target_cflags) -o $@ -c $<
377 ALL_GENERATED_SOURCES += $(GEN)
378 endif
381 # crtbegin_so.o/crtend_so.o
382 # These are needed for building the shared libs.
383 ifneq ($(TARGET_SIMULATOR),true)
385 ifeq ($(TARGET_ARCH),x86)
387 crt_begin_end_so_target_cflags := -m32
389 GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_so.o
390 $(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin_so.S
391 @mkdir -p $(dir $@)
392 $(TARGET_CC) $(crt_begin_end_so_target_cflags) -o $@ -c $<
393 ALL_GENERATED_SOURCES += $(GEN)
395 GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_so.o
396 $(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtend_so.S
397 @mkdir -p $(dir $@)
398 $(TARGET_CC) $(crt_begin_end_so_target_cflags) -o $@ -c $<
399 ALL_GENERATED_SOURCES += $(GEN)
401 endif # TARGET_ARCH == x86
403 endif # !TARGET_SIMULATOR
406 LOCAL_MODULE := libc_common
407 LOCAL_SYSTEM_SHARED_LIBRARIES :=
409 include $(BUILD_STATIC_LIBRARY)
412 # libc.a
413 # ========================================================
415 include $(CLEAR_VARS)
417 include $(LOCAL_PATH)/arch-$(TARGET_ARCH)/syscalls.mk
419 # To enable malloc leak check for statically linked programs, add
420 # "WITH_MALLOC_CHECK_LIBC_A := true" to device/buildspec.mk
421 WITH_MALLOC_CHECK_LIBC_A := $(strip $(WITH_MALLOC_CHECK_LIBC_A))
423 LOCAL_SRC_FILES := \
424 $(libc_common_src_files) \
425 bionic/dlmalloc.c \
426 bionic/libc_init_static.c
428 ifeq ($(WITH_MALLOC_CHECK_LIBC_A),true)
429 LOCAL_SRC_FILES += bionic/malloc_leak.c.arm
430 endif
432 ifeq ($(TARGET_ARCH),arm)
433 LOCAL_SRC_FILES += \
434 arch-arm/bionic/exidx_static.c
436 else # TARGET_ARCH != arm
438 ifeq ($(TARGET_ARCH),x86)
439 LOCAL_SRC_FILES += \
440 arch-x86/bionic/dl_iterate_phdr_static.c
441 endif
443 endif
445 ifneq ($(TARGET_SIMULATOR),true)
446 ifeq ($(TARGET_ARCH),arm)
447 crtbegin_static_target_cflags := -mthumb-interwork
448 else
449 ifeq ($(TARGET_ARCH),x86)
450 crtbegin_static_target_cflags := -m32
451 endif
452 endif
453 GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_static.o
454 $(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin_static.S
455 @mkdir -p $(dir $@)
456 $(TARGET_CC) $(crtbegin_static_target_cflags) -o $@ -c $<
457 ALL_GENERATED_SOURCES += $(GEN)
458 endif
460 LOCAL_CFLAGS := $(libc_common_cflags)
462 LOCAL_C_INCLUDES := $(libc_common_c_includes)
464 ifeq ($(WITH_MALLOC_CHECK_LIBC_A),true)
465 LOCAL_CFLAGS += -DUSE_DL_PREFIX -DMALLOC_LEAK_CHECK
466 endif
468 LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
469 LOCAL_MODULE:= libc
470 LOCAL_SYSTEM_SHARED_LIBRARIES :=
472 include $(BUILD_STATIC_LIBRARY)
475 # libc.so
476 # ========================================================
478 include $(CLEAR_VARS)
480 LOCAL_CFLAGS := $(libc_common_cflags)
482 LOCAL_CFLAGS += -DUSE_DL_PREFIX
484 LOCAL_C_INCLUDES := $(libc_common_c_includes)
486 LOCAL_SRC_FILES := \
487 bionic/dlmalloc.c \
488 bionic/malloc_leak.c.arm \
489 bionic/libc_init_dynamic.c
491 ifeq ($(TARGET_ARCH),arm)
492 LOCAL_SRC_FILES += \
493 arch-arm/bionic/exidx_dynamic.c
494 endif
496 LOCAL_MODULE:= libc
498 # WARNING: The only library libc.so should depend on is libdl.so! If you add other libraries,
499 # make sure to add -Wl,--exclude-libs=libgcc.a to the LOCAL_LDFLAGS for those libraries. This
500 # ensures that symbols that are pulled into those new libraries from libgcc.a are not declared
501 # external; if that were the case, then libc would not pull those symbols from libgcc.a as it
502 # should, instead relying on the external symbols from the dependent libraries. That would
503 # create an "cloaked" dependency on libgcc.a in libc though the libraries, which is not what
504 # you wanted!
506 LOCAL_SHARED_LIBRARIES := libdl
507 LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
508 LOCAL_SYSTEM_SHARED_LIBRARIES :=
510 ifneq ($(TARGET_SIMULATOR),true)
511 ifeq ($(TARGET_ARCH),arm)
512 crtbegin_dynamic_target_cflags := -mthumb-interwork
513 else
514 ifeq ($(TARGET_ARCH),x86)
515 crtbegin_dynamic_target_cflags := -m32
516 endif
517 endif
518 GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_dynamic.o
519 $(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin_dynamic.S
520 @mkdir -p $(dir $@)
521 $(TARGET_CC) $(crtbegin_dynamic_target_cflags) -o $@ -c $<
522 ALL_GENERATED_SOURCES += $(GEN)
523 endif
525 include $(BUILD_SHARED_LIBRARY)
528 # libc_debug.so
529 # ========================================================
531 include $(CLEAR_VARS)
533 LOCAL_CFLAGS := $(libc_common_cflags)
535 LOCAL_CFLAGS += -DUSE_DL_PREFIX -DMALLOC_LEAK_CHECK
537 LOCAL_C_INCLUDES := $(libc_common_c_includes)
539 LOCAL_SRC_FILES := \
540 bionic/dlmalloc.c \
541 bionic/malloc_leak.c.arm \
542 bionic/libc_init_dynamic.c
544 ifeq ($(TARGET_ARCH),arm)
545 LOCAL_SRC_FILES += \
546 arch-arm/bionic/exidx_dynamic.c
547 endif
549 LOCAL_MODULE:= libc_debug
551 # WARNING: The only library libc.so should depend on is libdl.so! If you add other libraries,
552 # make sure to add -Wl,--exclude-libs=libgcc.a to the LOCAL_LDFLAGS for those libraries. This
553 # ensures that symbols that are pulled into those new libraries from libgcc.a are not declared
554 # external; if that were the case, then libc would not pull those symbols from libgcc.a as it
555 # should, instead relying on the external symbols from the dependent libraries. That would
556 # create an "cloaked" dependency on libgcc.a in libc though the libraries, which is not what
557 # you wanted!
559 LOCAL_SHARED_LIBRARIES := libdl
560 LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
561 LOCAL_SYSTEM_SHARED_LIBRARIES :=
562 # Don't prelink
563 LOCAL_PRELINK_MODULE := false
564 # Don't install on release build
565 LOCAL_MODULE_TAGS := eng
567 GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_dynamic.o
568 ALL_GENERATED_SOURCES += $(GEN)
570 include $(BUILD_SHARED_LIBRARY)
572 # ========================================================
573 include $(call all-makefiles-under,$(LOCAL_PATH))