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