Android.mk revision 247dc91889ffc8b71fc3371edba9d834afab96ab
1LOCAL_PATH := $(call my-dir)
2
3# Make everything depend on any changes to included makefiles.
4libc_common_additional_dependencies := $(LOCAL_PATH)/Android.mk
5
6# Load config for TARGET_ARCH
7my_2nd_arch_prefix :=
8include $(LOCAL_PATH)/arch-$(TARGET_ARCH)/$(TARGET_ARCH).mk
9libc_common_additional_dependencies += \
10    $(LOCAL_PATH)/arch-$(TARGET_ARCH)/$(TARGET_ARCH).mk
11
12
13ifdef TARGET_2ND_ARCH
14# Load config for TARGET_2ND_ARCH
15my_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX)
16include $(LOCAL_PATH)/arch-$(TARGET_2ND_ARCH)/$(TARGET_2ND_ARCH).mk
17my_2nd_arch_prefix :=
18libc_common_additional_dependencies += \
19    $(LOCAL_PATH)/arch-$(TARGET_2ND_ARCH)/$(TARGET_2ND_ARCH).mk
20endif
21
22# crt obj files
23# ========================================================
24# crtbrand.c needs <stdint.h> and a #define for the platform SDK version.
25libc_crt_target_cflags := \
26    -I$(LOCAL_PATH)/include \
27    -DPLATFORM_SDK_VERSION=$(PLATFORM_SDK_VERSION) \
28
29my_2nd_arch_prefix :=
30include $(LOCAL_PATH)/crt.mk
31ifdef TARGET_2ND_ARCH
32my_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX)
33include $(LOCAL_PATH)/crt.mk
34my_2nd_arch_prefix :=
35endif
36
37# Define the common source files for all the libc instances
38# =========================================================
39libc_common_src_files := \
40    bionic/arc4random.c \
41    bionic/bindresvport.c \
42    bionic/clearenv.c \
43    bionic/daemon.c \
44    bionic/err.c \
45    bionic/ether_aton.c \
46    bionic/ether_ntoa.c \
47    bionic/fdprintf.c \
48    bionic/ftime.c \
49    bionic/fts.c \
50    bionic/getdtablesize.c \
51    bionic/gethostname.c \
52    bionic/getpriority.c \
53    bionic/getpt.c \
54    bionic/if_indextoname.c \
55    bionic/if_nametoindex.c \
56    bionic/initgroups.c \
57    bionic/ioctl.c \
58    bionic/isatty.c \
59    bionic/issetugid.c \
60    bionic/md5.c \
61    bionic/memmem.c \
62    bionic/pathconf.c \
63    bionic/ptsname.c \
64    bionic/ptsname_r.c \
65    bionic/pututline.c \
66    bionic/sched_cpualloc.c \
67    bionic/sched_cpucount.c \
68    bionic/semaphore.c \
69    bionic/sigblock.c \
70    bionic/siginterrupt.c \
71    bionic/sigsetmask.c \
72    bionic/strntoimax.c \
73    bionic/strntoumax.c \
74    bionic/strtotimeval.c \
75    bionic/system_properties_compat.c \
76    bionic/tcgetpgrp.c \
77    bionic/tcsetpgrp.c \
78    bionic/time64.c \
79    bionic/unlockpt.c \
80    stdio/asprintf.c \
81    stdio/findfp.c \
82    stdio/fprintf.c \
83    stdio/fread.c \
84    stdio/freopen.c \
85    stdio/fvwrite.c \
86    stdio/snprintf.c\
87    stdio/sprintf.c \
88    stdio/sscanf.c \
89    stdio/vfprintf.c \
90    stdio/vfscanf.c \
91    stdio/vsscanf.c \
92    stdlib/atexit.c \
93    stdlib/ctype_.c \
94    stdlib/getenv.c \
95    stdlib/putenv.c \
96    stdlib/setenv.c \
97    stdlib/strtod.c \
98    unistd/syslog.c \
99    unistd/time.c \
100
101# Fortify implementations of libc functions.
102libc_common_src_files += \
103    bionic/__FD_chk.cpp \
104    bionic/__fgets_chk.cpp \
105    bionic/__memmove_chk.cpp \
106    bionic/__read_chk.cpp \
107    bionic/__recvfrom_chk.cpp \
108    bionic/__strchr_chk.cpp \
109    bionic/__strlcat_chk.cpp \
110    bionic/__strlcpy_chk.cpp \
111    bionic/__strlen_chk.cpp \
112    bionic/__strncat_chk.cpp \
113    bionic/__strncpy_chk.cpp \
114    bionic/__strrchr_chk.cpp \
115    bionic/__umask_chk.cpp \
116    bionic/__vsnprintf_chk.cpp \
117    bionic/__vsprintf_chk.cpp \
118
119libc_bionic_src_files := \
120    bionic/abort.cpp \
121    bionic/access.cpp \
122    bionic/assert.cpp \
123    bionic/__bionic_name_mem.cpp \
124    bionic/bionic_time_conversions.cpp \
125    bionic/brk.cpp \
126    bionic/chmod.cpp \
127    bionic/chown.cpp \
128    bionic/clone.cpp \
129    bionic/dirent.cpp \
130    bionic/dup2.cpp \
131    bionic/epoll_create.cpp \
132    bionic/epoll_pwait.cpp \
133    bionic/epoll_wait.cpp \
134    bionic/__errno.cpp \
135    bionic/eventfd_read.cpp \
136    bionic/eventfd_write.cpp \
137    bionic/ffs.cpp \
138    bionic/flockfile.cpp \
139    bionic/fork.cpp \
140    bionic/futimens.cpp \
141    bionic/getauxval.cpp \
142    bionic/getcwd.cpp \
143    bionic/getpgrp.cpp \
144    bionic/inotify_init.cpp \
145    bionic/lchown.cpp \
146    bionic/lfs64_support.cpp \
147    bionic/libc_init_common.cpp \
148    bionic/libc_logging.cpp \
149    bionic/libgen.cpp \
150    bionic/link.cpp \
151    bionic/lstat.cpp \
152    bionic/mkdir.cpp \
153    bionic/mkfifo.cpp \
154    bionic/mknod.cpp \
155    bionic/open.cpp \
156    bionic/pause.cpp \
157    bionic/pipe.cpp \
158    bionic/poll.cpp \
159    bionic/posix_fallocate.cpp \
160    bionic/posix_timers.cpp \
161    bionic/pthread_atfork.cpp \
162    bionic/pthread_attr.cpp \
163    bionic/pthread_cond.cpp \
164    bionic/pthread_create.cpp \
165    bionic/pthread_detach.cpp \
166    bionic/pthread_equal.cpp \
167    bionic/pthread_exit.cpp \
168    bionic/pthread_getcpuclockid.cpp \
169    bionic/pthread_getschedparam.cpp \
170    bionic/pthread_internals.cpp \
171    bionic/pthread_join.cpp \
172    bionic/pthread_key.cpp \
173    bionic/pthread_kill.cpp \
174    bionic/pthread_mutex.cpp \
175    bionic/pthread_once.cpp \
176    bionic/pthread_rwlock.cpp \
177    bionic/pthread_self.cpp \
178    bionic/pthread_setname_np.cpp \
179    bionic/pthread_setschedparam.cpp \
180    bionic/pthread_sigmask.cpp \
181    bionic/ptrace.cpp \
182    bionic/raise.cpp \
183    bionic/readlink.cpp \
184    bionic/reboot.cpp \
185    bionic/recv.cpp \
186    bionic/rename.cpp \
187    bionic/rmdir.cpp \
188    bionic/sbrk.cpp \
189    bionic/scandir.cpp \
190    bionic/sched_getaffinity.cpp \
191    bionic/sched_getcpu.cpp \
192    bionic/send.cpp \
193    bionic/setegid.cpp \
194    bionic/__set_errno.cpp \
195    bionic/seteuid.cpp \
196    bionic/setpgrp.cpp \
197    bionic/setlocale.cpp \
198    bionic/sigaction.cpp \
199    bionic/sigaddset.cpp \
200    bionic/sigdelset.cpp \
201    bionic/sigemptyset.cpp \
202    bionic/sigfillset.cpp \
203    bionic/sigismember.cpp \
204    bionic/signal.cpp \
205    bionic/signalfd.cpp \
206    bionic/sigpending.cpp \
207    bionic/sigprocmask.cpp \
208    bionic/sigsuspend.cpp \
209    bionic/sigwait.cpp \
210    bionic/stat.cpp \
211    bionic/statvfs.cpp \
212    bionic/strerror.cpp \
213    bionic/strerror_r.cpp \
214    bionic/strsignal.cpp \
215    bionic/stubs.cpp \
216    bionic/symlink.cpp \
217    bionic/sysconf.cpp \
218    bionic/system_properties.cpp \
219    bionic/sys_siglist.c \
220    bionic/sys_signame.c \
221    bionic/tdestroy.cpp \
222    bionic/thread_atexit.cpp \
223    bionic/tmpfile.cpp \
224    bionic/umount.cpp \
225    bionic/unlink.cpp \
226    bionic/utimes.cpp \
227    bionic/wait.cpp \
228    bionic/wchar.cpp \
229
230libc_upstream_freebsd_src_files := \
231    upstream-freebsd/lib/libc/gen/ldexp.c \
232    upstream-freebsd/lib/libc/gen/sleep.c \
233    upstream-freebsd/lib/libc/gen/usleep.c \
234    upstream-freebsd/lib/libc/stdio/fclose.c \
235    upstream-freebsd/lib/libc/stdio/flags.c \
236    upstream-freebsd/lib/libc/stdio/fopen.c \
237    upstream-freebsd/lib/libc/stdio/fwrite.c \
238    upstream-freebsd/lib/libc/stdio/makebuf.c \
239    upstream-freebsd/lib/libc/stdio/mktemp.c \
240    upstream-freebsd/lib/libc/stdio/putw.c \
241    upstream-freebsd/lib/libc/stdio/setvbuf.c \
242    upstream-freebsd/lib/libc/stdio/wsetup.c \
243    upstream-freebsd/lib/libc/stdlib/abs.c \
244    upstream-freebsd/lib/libc/stdlib/getopt_long.c \
245    upstream-freebsd/lib/libc/stdlib/imaxabs.c \
246    upstream-freebsd/lib/libc/stdlib/imaxdiv.c \
247    upstream-freebsd/lib/libc/stdlib/labs.c \
248    upstream-freebsd/lib/libc/stdlib/llabs.c \
249    upstream-freebsd/lib/libc/stdlib/qsort.c \
250    upstream-freebsd/lib/libc/stdlib/realpath.c \
251    upstream-freebsd/lib/libc/string/wcpcpy.c \
252    upstream-freebsd/lib/libc/string/wcpncpy.c \
253    upstream-freebsd/lib/libc/string/wcscasecmp.c \
254    upstream-freebsd/lib/libc/string/wcscspn.c \
255    upstream-freebsd/lib/libc/string/wcsdup.c \
256    upstream-freebsd/lib/libc/string/wcslcat.c \
257    upstream-freebsd/lib/libc/string/wcsncasecmp.c \
258    upstream-freebsd/lib/libc/string/wcsncat.c \
259    upstream-freebsd/lib/libc/string/wcsncmp.c \
260    upstream-freebsd/lib/libc/string/wcsncpy.c \
261    upstream-freebsd/lib/libc/string/wcsnlen.c \
262    upstream-freebsd/lib/libc/string/wcspbrk.c \
263    upstream-freebsd/lib/libc/string/wcsspn.c \
264    upstream-freebsd/lib/libc/string/wcsstr.c \
265    upstream-freebsd/lib/libc/string/wcstok.c \
266    upstream-freebsd/lib/libc/string/wmemchr.c \
267    upstream-freebsd/lib/libc/string/wmemcpy.c \
268    upstream-freebsd/lib/libc/string/wmemmove.c \
269    upstream-freebsd/lib/libc/string/wmemset.c \
270
271libc_upstream_netbsd_src_files := \
272    upstream-netbsd/common/lib/libc/hash/sha1/sha1.c \
273    upstream-netbsd/common/lib/libc/inet/inet_addr.c \
274    upstream-netbsd/lib/libc/gen/ftw.c \
275    upstream-netbsd/lib/libc/gen/nftw.c \
276    upstream-netbsd/lib/libc/gen/nice.c \
277    upstream-netbsd/lib/libc/gen/popen.c \
278    upstream-netbsd/lib/libc/gen/psignal.c \
279    upstream-netbsd/lib/libc/gen/setjmperr.c \
280    upstream-netbsd/lib/libc/gen/utime.c \
281    upstream-netbsd/lib/libc/gen/utmp.c \
282    upstream-netbsd/lib/libc/inet/inet_ntoa.c \
283    upstream-netbsd/lib/libc/inet/inet_ntop.c \
284    upstream-netbsd/lib/libc/inet/inet_pton.c \
285    upstream-netbsd/lib/libc/isc/ev_streams.c \
286    upstream-netbsd/lib/libc/isc/ev_timers.c \
287    upstream-netbsd/lib/libc/regex/regcomp.c \
288    upstream-netbsd/lib/libc/regex/regerror.c \
289    upstream-netbsd/lib/libc/regex/regexec.c \
290    upstream-netbsd/lib/libc/regex/regfree.c \
291    upstream-netbsd/lib/libc/stdlib/bsearch.c \
292    upstream-netbsd/lib/libc/stdlib/div.c \
293    upstream-netbsd/lib/libc/stdlib/drand48.c \
294    upstream-netbsd/lib/libc/stdlib/erand48.c \
295    upstream-netbsd/lib/libc/stdlib/exit.c \
296    upstream-netbsd/lib/libc/stdlib/jrand48.c \
297    upstream-netbsd/lib/libc/stdlib/ldiv.c \
298    upstream-netbsd/lib/libc/stdlib/lldiv.c \
299    upstream-netbsd/lib/libc/stdlib/lrand48.c \
300    upstream-netbsd/lib/libc/stdlib/mrand48.c \
301    upstream-netbsd/lib/libc/stdlib/nrand48.c \
302    upstream-netbsd/lib/libc/stdlib/_rand48.c \
303    upstream-netbsd/lib/libc/stdlib/seed48.c \
304    upstream-netbsd/lib/libc/stdlib/srand48.c \
305    upstream-netbsd/lib/libc/stdlib/tdelete.c \
306    upstream-netbsd/lib/libc/stdlib/tfind.c \
307    upstream-netbsd/lib/libc/stdlib/tsearch.c \
308    upstream-netbsd/lib/libc/string/memccpy.c \
309    upstream-netbsd/lib/libc/string/strcasestr.c \
310    upstream-netbsd/lib/libc/string/strcoll.c \
311    upstream-netbsd/lib/libc/string/strxfrm.c \
312    upstream-netbsd/lib/libc/thread-stub/__isthreaded.c \
313    upstream-netbsd/lib/libc/unistd/killpg.c \
314
315libc_upstream_openbsd_src_files := \
316    upstream-openbsd/lib/libc/gen/alarm.c \
317    upstream-openbsd/lib/libc/gen/exec.c \
318    upstream-openbsd/lib/libc/gen/fnmatch.c \
319    upstream-openbsd/lib/libc/gen/ftok.c \
320    upstream-openbsd/lib/libc/gen/getprogname.c \
321    upstream-openbsd/lib/libc/gen/setprogname.c \
322    upstream-openbsd/lib/libc/gen/tolower_.c \
323    upstream-openbsd/lib/libc/gen/toupper_.c \
324    upstream-openbsd/lib/libc/locale/wcscoll.c \
325    upstream-openbsd/lib/libc/string/strstr.c \
326    upstream-openbsd/lib/libc/string/strsep.c \
327    upstream-openbsd/lib/libc/string/wcslcpy.c \
328    upstream-openbsd/lib/libc/string/strcasecmp.c \
329    upstream-openbsd/lib/libc/string/strdup.c \
330    upstream-openbsd/lib/libc/string/strcspn.c \
331    upstream-openbsd/lib/libc/string/strtok.c \
332    upstream-openbsd/lib/libc/string/strpbrk.c \
333    upstream-openbsd/lib/libc/string/strspn.c \
334    upstream-openbsd/lib/libc/string/wcswidth.c \
335    upstream-openbsd/lib/libc/string/strndup.c \
336    upstream-openbsd/lib/libc/stdio/ungetc.c \
337    upstream-openbsd/lib/libc/stdio/vsnprintf.c \
338    upstream-openbsd/lib/libc/stdio/tmpnam.c \
339    upstream-openbsd/lib/libc/stdio/setbuffer.c \
340    upstream-openbsd/lib/libc/stdio/fsetpos.c \
341    upstream-openbsd/lib/libc/stdio/setbuf.c \
342    upstream-openbsd/lib/libc/stdio/vprintf.c \
343    upstream-openbsd/lib/libc/stdio/perror.c \
344    upstream-openbsd/lib/libc/stdio/remove.c \
345    upstream-openbsd/lib/libc/stdio/getc.c \
346    upstream-openbsd/lib/libc/stdio/funopen.c \
347    upstream-openbsd/lib/libc/stdio/ferror.c \
348    upstream-openbsd/lib/libc/stdio/putchar.c \
349    upstream-openbsd/lib/libc/stdio/vscanf.c \
350    upstream-openbsd/lib/libc/stdio/fflush.c \
351    upstream-openbsd/lib/libc/stdio/fpurge.c \
352    upstream-openbsd/lib/libc/stdio/fputs.c \
353    upstream-openbsd/lib/libc/stdio/tempnam.c \
354    upstream-openbsd/lib/libc/stdio/printf.c \
355    upstream-openbsd/lib/libc/stdio/fileno.c \
356    upstream-openbsd/lib/libc/stdio/stdio.c \
357    upstream-openbsd/lib/libc/stdio/getdelim.c \
358    upstream-openbsd/lib/libc/stdio/fseek.c \
359    upstream-openbsd/lib/libc/stdio/fputc.c \
360    upstream-openbsd/lib/libc/stdio/fgetln.c \
361    upstream-openbsd/lib/libc/stdio/fdopen.c \
362    upstream-openbsd/lib/libc/stdio/fgets.c \
363    upstream-openbsd/lib/libc/stdio/fgetc.c \
364    upstream-openbsd/lib/libc/stdio/feof.c \
365    upstream-openbsd/lib/libc/stdio/vasprintf.c \
366    upstream-openbsd/lib/libc/stdio/refill.c \
367    upstream-openbsd/lib/libc/stdio/getline.c \
368    upstream-openbsd/lib/libc/stdio/rewind.c \
369    upstream-openbsd/lib/libc/stdio/wbuf.c \
370    upstream-openbsd/lib/libc/stdio/gets.c \
371    upstream-openbsd/lib/libc/stdio/fgetpos.c \
372    upstream-openbsd/lib/libc/stdio/fscanf.c \
373    upstream-openbsd/lib/libc/stdio/putc.c \
374    upstream-openbsd/lib/libc/stdio/vsprintf.c \
375    upstream-openbsd/lib/libc/stdio/rget.c \
376    upstream-openbsd/lib/libc/stdio/clrerr.c \
377    upstream-openbsd/lib/libc/stdio/scanf.c \
378    upstream-openbsd/lib/libc/stdio/puts.c \
379    upstream-openbsd/lib/libc/stdio/getchar.c \
380    upstream-openbsd/lib/libc/stdio/ftell.c \
381    upstream-openbsd/lib/libc/stdio/fwalk.c \
382    upstream-openbsd/lib/libc/stdlib/strtoul.c \
383    upstream-openbsd/lib/libc/stdlib/strtoull.c \
384    upstream-openbsd/lib/libc/stdlib/atoi.c \
385    upstream-openbsd/lib/libc/stdlib/atoll.c \
386    upstream-openbsd/lib/libc/stdlib/atol.c \
387    upstream-openbsd/lib/libc/stdlib/strtoimax.c \
388    upstream-openbsd/lib/libc/stdlib/strtoumax.c \
389    upstream-openbsd/lib/libc/stdlib/strtoll.c \
390    upstream-openbsd/lib/libc/stdlib/strtol.c \
391    upstream-openbsd/lib/libc/stdlib/system.c \
392    upstream-openbsd/lib/libc/locale/wcsxfrm.c \
393
394libc_arch_static_src_files := \
395    bionic/dl_iterate_phdr_static.cpp \
396
397# Define some common cflags
398# ========================================================
399libc_common_cflags := \
400    -DANDROID_CHANGES \
401    -D_LIBC=1 \
402    -Wall -Wextra \
403
404# Try to catch typical 32-bit assumptions that break with 64-bit pointers.
405libc_common_cflags += \
406    -Werror=pointer-to-int-cast \
407    -Werror=int-to-pointer-cast \
408    -Werror=type-limits \
409
410ifeq ($(strip $(DEBUG_BIONIC_LIBC)),true)
411  libc_common_cflags += -DDEBUG
412endif
413
414# To customize dlmalloc's alignment, set BOARD_MALLOC_ALIGNMENT in
415# the appropriate BoardConfig.mk file.
416#
417ifneq ($(BOARD_MALLOC_ALIGNMENT),)
418  libc_common_cflags += -DMALLOC_ALIGNMENT=$(BOARD_MALLOC_ALIGNMENT)
419endif
420
421# Define ANDROID_SMP appropriately.
422ifeq ($(TARGET_CPU_SMP),true)
423    libc_common_cflags += -DANDROID_SMP=1
424else
425    libc_common_cflags += -DANDROID_SMP=0
426endif
427
428# Define some common conlyflags
429libc_common_conlyflags := \
430    -std=gnu99
431
432# Define some common cppflags
433libc_common_cppflags := \
434    -std=gnu++11
435
436# Define some common includes
437# ========================================================
438libc_common_c_includes := \
439    $(LOCAL_PATH)/stdlib  \
440    $(LOCAL_PATH)/string  \
441    $(LOCAL_PATH)/stdio   \
442    external/safe-iop/include
443
444# ========================================================
445# Add in the arch-specific flags.
446# Must be called with $(eval).
447# $(1): the LOCAL_ variable name
448# $(2): the bionic variable name to pull in
449define patch-up-arch-specific-flags
450$(1)_$(TARGET_ARCH) += $($(2)_$(TARGET_ARCH))
451ifdef TARGET_2ND_ARCH
452$(1)_$(TARGET_2ND_ARCH) += $($(2)_$(TARGET_2ND_ARCH))
453endif
454endef
455
456
457# ========================================================
458# libc_stack_protector.a - stack protector code
459# ========================================================
460#
461# The stack protector code needs to be compiled
462# with -fno-stack-protector, since it modifies the
463# stack canary.
464
465include $(CLEAR_VARS)
466
467LOCAL_SRC_FILES := bionic/__stack_chk_fail.cpp
468LOCAL_CFLAGS := $(libc_common_cflags) -fno-stack-protector -Werror
469LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
470LOCAL_CPPFLAGS := $(libc_common_cppflags)
471LOCAL_C_INCLUDES := $(libc_common_c_includes)
472LOCAL_MODULE := libc_stack_protector
473LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
474LOCAL_SYSTEM_SHARED_LIBRARIES :=
475
476$(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags))
477include $(BUILD_STATIC_LIBRARY)
478
479
480# ========================================================
481# libc_tzcode.a - upstream 'tzcode' code
482# ========================================================
483
484include $(CLEAR_VARS)
485
486LOCAL_SRC_FILES := $(call all-c-files-under,tzcode)
487LOCAL_CFLAGS := \
488    $(libc_common_cflags) \
489    -DSTD_INSPIRED=1 \
490    -DTZDIR=\"/system/usr/share/zoneinfo\" \
491    -DTM_GMTOFF=tm_gmtoff \
492    -DUSG_COMPAT=1
493LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
494LOCAL_CPPFLAGS := $(libc_common_cppflags)
495LOCAL_C_INCLUDES := $(libc_common_c_includes)
496LOCAL_MODULE := libc_tzcode
497LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
498LOCAL_SYSTEM_SHARED_LIBRARIES :=
499
500$(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags))
501include $(BUILD_STATIC_LIBRARY)
502
503
504# ========================================================
505# libc_dns.a - modified NetBSD DNS code
506# ========================================================
507
508include $(CLEAR_VARS)
509
510LOCAL_SRC_FILES := $(call all-c-files-under,dns)
511LOCAL_CFLAGS := \
512    $(libc_common_cflags) \
513    -DINET6 \
514    -I$(LOCAL_PATH)/dns/include \
515    -I$(LOCAL_PATH)/private \
516    -I$(LOCAL_PATH)/upstream-netbsd/lib/libc/include \
517    -include upstream-netbsd/netbsd-compat.h
518LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
519LOCAL_CPPFLAGS := $(libc_common_cppflags)
520LOCAL_C_INCLUDES := $(libc_common_c_includes)
521LOCAL_MODULE := libc_dns
522LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
523LOCAL_SYSTEM_SHARED_LIBRARIES :=
524
525$(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags))
526include $(BUILD_STATIC_LIBRARY)
527
528
529# ========================================================
530# libc_freebsd.a - upstream FreeBSD C library code
531# ========================================================
532#
533# These files are built with the freebsd-compat.h header file
534# automatically included.
535
536include $(CLEAR_VARS)
537
538LOCAL_SRC_FILES := $(libc_upstream_freebsd_src_files)
539LOCAL_CFLAGS := \
540    $(libc_common_cflags) \
541    -I$(LOCAL_PATH)/upstream-freebsd \
542    -I$(LOCAL_PATH)/upstream-freebsd/libc/include \
543    -include upstream-freebsd/freebsd-compat.h
544LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
545LOCAL_CPPFLAGS := $(libc_common_cppflags)
546LOCAL_C_INCLUDES := $(libc_common_c_includes)
547LOCAL_MODULE := libc_freebsd
548LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
549LOCAL_SYSTEM_SHARED_LIBRARIES :=
550
551$(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags))
552include $(BUILD_STATIC_LIBRARY)
553
554
555# ========================================================
556# libc_netbsd.a - upstream NetBSD C library code
557# ========================================================
558#
559# These files are built with the netbsd-compat.h header file
560# automatically included.
561
562include $(CLEAR_VARS)
563
564LOCAL_SRC_FILES := $(libc_upstream_netbsd_src_files)
565LOCAL_CFLAGS := \
566    $(libc_common_cflags) \
567    -DPOSIX_MISTAKE \
568    -I$(LOCAL_PATH)/upstream-netbsd \
569    -I$(LOCAL_PATH)/upstream-netbsd/lib/libc/include \
570    -include upstream-netbsd/netbsd-compat.h
571LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
572LOCAL_CPPFLAGS := $(libc_common_cppflags)
573LOCAL_C_INCLUDES := $(libc_common_c_includes)
574LOCAL_MODULE := libc_netbsd
575LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
576LOCAL_SYSTEM_SHARED_LIBRARIES :=
577
578$(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags))
579include $(BUILD_STATIC_LIBRARY)
580
581
582# ========================================================
583# libc_openbsd.a - upstream OpenBSD C library code
584# ========================================================
585#
586# These files are built with the openbsd-compat.h header file
587# automatically included.
588
589include $(CLEAR_VARS)
590
591LOCAL_SRC_FILES := $(libc_upstream_openbsd_src_files)
592LOCAL_CFLAGS := \
593    $(libc_common_cflags) \
594    -I$(LOCAL_PATH)/upstream-openbsd \
595    -I$(LOCAL_PATH)/upstream-openbsd/lib/libc/include \
596    -include upstream-openbsd/openbsd-compat.h
597LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
598LOCAL_CPPFLAGS := $(libc_common_cppflags)
599LOCAL_C_INCLUDES := $(libc_common_c_includes)
600LOCAL_MODULE := libc_openbsd
601LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
602LOCAL_SYSTEM_SHARED_LIBRARIES :=
603
604$(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags))
605include $(BUILD_STATIC_LIBRARY)
606
607
608# ========================================================
609# libc_bionic.a - home-grown C library code
610# ========================================================
611
612include $(CLEAR_VARS)
613
614LOCAL_SRC_FILES := $(libc_bionic_src_files)
615LOCAL_CFLAGS := $(libc_common_cflags) -Werror
616LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
617LOCAL_CPPFLAGS := $(libc_common_cppflags)
618LOCAL_C_INCLUDES := $(libc_common_c_includes)
619LOCAL_MODULE := libc_bionic
620LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
621LOCAL_SYSTEM_SHARED_LIBRARIES :=
622
623# Set -DPTHREAD_DEBUG_ENABLED=true to enable support for pthread deadlock prediction.
624# Since this code is experimental it is disabled by default.
625LOCAL_CFLAGS += -DPTHREAD_DEBUG_ENABLED=false
626
627ifeq ($(TARGET_USES_LOGD),true)
628LOCAL_CFLAGS += -DTARGET_USES_LOGD
629endif
630
631$(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags))
632$(eval $(call patch-up-arch-specific-flags,LOCAL_SRC_FILES,libc_bionic_src_files))
633include $(BUILD_STATIC_LIBRARY)
634
635
636# ========================================================
637# libc_syscalls.a
638# ========================================================
639
640include $(CLEAR_VARS)
641
642LOCAL_SRC_FILES_$(TARGET_ARCH) := $(call all-S-files-under,arch-$(TARGET_ARCH)/syscalls)
643ifdef TARGET_2ND_ARCH
644LOCAL_SRC_FILES_$(TARGET_2ND_ARCH) := $(call all-S-files-under,arch-$(TARGET_2ND_ARCH)/syscalls)
645endif
646LOCAL_MODULE := libc_syscalls
647LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
648LOCAL_SYSTEM_SHARED_LIBRARIES :=
649
650include $(BUILD_STATIC_LIBRARY)
651
652
653# ========================================================
654# libc_common.a
655# ========================================================
656
657include $(CLEAR_VARS)
658
659LOCAL_SRC_FILES := $(libc_common_src_files)
660LOCAL_CFLAGS := $(libc_common_cflags)
661LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
662LOCAL_CPPFLAGS := $(libc_common_cppflags)
663LOCAL_C_INCLUDES := $(libc_common_c_includes)
664LOCAL_MODULE := libc_common
665LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
666LOCAL_WHOLE_STATIC_LIBRARIES := \
667    libc_bionic \
668    libc_dns \
669    libc_freebsd \
670    libc_netbsd \
671    libc_openbsd \
672    libc_stack_protector \
673    libc_syscalls \
674    libc_tzcode \
675
676LOCAL_SYSTEM_SHARED_LIBRARIES :=
677
678# TODO: split out the asflags.
679LOCAL_ASFLAGS := $(LOCAL_CFLAGS)
680
681$(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags))
682$(eval $(call patch-up-arch-specific-flags,LOCAL_SRC_FILES,libc_common_src_files))
683$(eval $(call patch-up-arch-specific-flags,LOCAL_ASFLAGS,LOCAL_CFLAGS))
684include $(BUILD_STATIC_LIBRARY)
685
686
687# ========================================================
688# libc_nomalloc.a
689# ========================================================
690#
691# This is a version of the static C library that does not
692# include malloc. It's useful in situations when the user wants
693# to provide their own malloc implementation, or wants to
694# explicitly disallow the use of the use of malloc,
695# such as in the dynamic loader.
696
697include $(CLEAR_VARS)
698
699LOCAL_SRC_FILES := \
700    $(libc_arch_static_src_files) \
701    $(libc_static_common_src_files) \
702    bionic/libc_init_static.cpp
703
704LOCAL_C_INCLUDES := $(libc_common_c_includes)
705LOCAL_CFLAGS := $(libc_common_cflags) \
706                -DLIBC_STATIC
707LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
708LOCAL_CPPFLAGS := $(libc_common_cppflags)
709
710LOCAL_MODULE := libc_nomalloc
711LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
712LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
713LOCAL_SYSTEM_SHARED_LIBRARIES :=
714
715$(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags))
716$(eval $(call patch-up-arch-specific-flags,LOCAL_SRC_FILES,libc_arch_static_src_files))
717include $(BUILD_STATIC_LIBRARY)
718
719
720# ========================================================
721# libc.a
722# ========================================================
723include $(CLEAR_VARS)
724
725LOCAL_SRC_FILES := \
726    $(libc_arch_static_src_files) \
727    $(libc_static_common_src_files) \
728    bionic/dlmalloc.c \
729    bionic/malloc_debug_common.cpp \
730    bionic/libc_init_static.cpp \
731
732LOCAL_CFLAGS := $(libc_common_cflags) \
733                -DLIBC_STATIC
734LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
735LOCAL_CPPFLAGS := $(libc_common_cppflags)
736LOCAL_C_INCLUDES := $(libc_common_c_includes)
737LOCAL_MODULE := libc
738LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
739LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
740LOCAL_SYSTEM_SHARED_LIBRARIES :=
741
742$(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags))
743$(eval $(call patch-up-arch-specific-flags,LOCAL_SRC_FILES,libc_arch_static_src_files))
744include $(BUILD_STATIC_LIBRARY)
745
746
747# ========================================================
748# libc.so
749# ========================================================
750include $(CLEAR_VARS)
751
752LOCAL_CFLAGS := $(libc_common_cflags)
753LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
754LOCAL_CPPFLAGS := $(libc_common_cppflags)
755LOCAL_C_INCLUDES := $(libc_common_c_includes)
756
757LOCAL_SRC_FILES := \
758    $(libc_arch_dynamic_src_files) \
759    $(libc_static_common_src_files) \
760    bionic/dlmalloc.c \
761    bionic/malloc_debug_common.cpp \
762    bionic/debug_mapinfo.cpp \
763    bionic/debug_stacktrace.cpp \
764    bionic/pthread_debug.cpp \
765    bionic/libc_init_dynamic.cpp \
766
767LOCAL_MODULE:= libc
768LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
769LOCAL_REQUIRED_MODULES := tzdata
770
771# WARNING: The only library libc.so should depend on is libdl.so!  If you add other libraries,
772# make sure to add -Wl,--exclude-libs=libgcc.a to the LOCAL_LDFLAGS for those libraries.  This
773# ensures that symbols that are pulled into those new libraries from libgcc.a are not declared
774# external; if that were the case, then libc would not pull those symbols from libgcc.a as it
775# should, instead relying on the external symbols from the dependent libraries.  That would
776# create an "cloaked" dependency on libgcc.a in libc though the libraries, which is not what
777# you wanted!
778
779LOCAL_SHARED_LIBRARIES := libdl
780LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
781LOCAL_SYSTEM_SHARED_LIBRARIES :=
782
783$(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags))
784$(eval $(call patch-up-arch-specific-flags,LOCAL_SRC_FILES,libc_arch_dynamic_src_files))
785$(eval $(call patch-up-arch-specific-flags,LOCAL_SRC_FILES,libc_static_common_src_files))
786# special for arm
787LOCAL_NO_CRT_arm := true
788LOCAL_CFLAGS_arm += -DCRT_LEGACY_WORKAROUND
789LOCAL_SRC_FILES_arm += \
790    arch-common/bionic/crtbegin_so.c \
791    arch-arm/bionic/atexit_legacy.c \
792    arch-common/bionic/crtend_so.S
793
794include $(BUILD_SHARED_LIBRARY)
795
796
797# For all builds, except for the -user build we will enable memory
798# allocation checking (including memory leaks, buffer overwrites, etc.)
799# Note that all these checks are also controlled by env. settings
800# that can enable, or disable specific checks. Note also that some of
801# the checks are available only in emulator and are implemeted in
802# libc_malloc_qemu_instrumented.so.
803ifneq ($(TARGET_BUILD_VARIANT),user)
804
805# ========================================================
806# libc_malloc_debug_leak.so
807# ========================================================
808include $(CLEAR_VARS)
809
810LOCAL_CFLAGS := \
811    $(libc_common_cflags) \
812    -DMALLOC_LEAK_CHECK
813LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
814LOCAL_CPPFLAGS := $(libc_common_cppflags)
815
816LOCAL_C_INCLUDES := $(libc_common_c_includes)
817
818LOCAL_SRC_FILES := \
819    bionic/debug_mapinfo.cpp \
820    bionic/debug_stacktrace.cpp \
821    bionic/malloc_debug_leak.cpp \
822    bionic/malloc_debug_check.cpp \
823
824LOCAL_MODULE:= libc_malloc_debug_leak
825LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
826
827LOCAL_SHARED_LIBRARIES := libc libdl
828LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
829LOCAL_SYSTEM_SHARED_LIBRARIES :=
830LOCAL_ALLOW_UNDEFINED_SYMBOLS := true
831
832# Don't install on release build
833LOCAL_MODULE_TAGS := eng debug
834
835$(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags))
836include $(BUILD_SHARED_LIBRARY)
837
838
839# ========================================================
840# libc_malloc_debug_qemu.so
841# ========================================================
842include $(CLEAR_VARS)
843
844LOCAL_CFLAGS := \
845    $(libc_common_cflags) \
846    -DMALLOC_QEMU_INSTRUMENT
847LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
848LOCAL_CPPFLAGS := $(libc_common_cppflags)
849
850LOCAL_C_INCLUDES := $(libc_common_c_includes)
851
852LOCAL_SRC_FILES := \
853    bionic/malloc_debug_qemu.cpp
854
855LOCAL_MODULE:= libc_malloc_debug_qemu
856LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
857
858LOCAL_SHARED_LIBRARIES := libc libdl
859LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
860LOCAL_SYSTEM_SHARED_LIBRARIES :=
861
862# Don't install on release build
863LOCAL_MODULE_TAGS := eng debug
864
865$(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags))
866include $(BUILD_SHARED_LIBRARY)
867
868endif  #!user
869
870
871# ========================================================
872include $(call all-makefiles-under,$(LOCAL_PATH))
873