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