blob: c507457118f4295fec8a8579f57894610c4b0d97 [file] [log] [blame]
The Android Open Source Project1dc9e472009-03-03 19:28:35 -08001LOCAL_PATH:= $(call my-dir)
2
3include $(LOCAL_PATH)/arch-$(TARGET_ARCH)/syscalls.mk
Dima Zavinca122b02009-05-27 10:52:37 -07004
5# Define the common source files for all the libc instances
6# =========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -08007libc_common_src_files := \
8 $(syscall_src) \
9 unistd/abort.c \
10 unistd/alarm.c \
11 unistd/brk.c \
12 unistd/creat.c \
13 unistd/daemon.c \
David 'Digit' Turnerdefd1622010-09-26 22:29:14 +020014 unistd/eventfd.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080015 unistd/exec.c \
16 unistd/fcntl.c \
17 unistd/fnmatch.c \
David 'Digit' Turnerab8b5412010-07-08 16:52:27 -070018 unistd/fstatfs.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080019 unistd/ftime.c \
20 unistd/ftok.c \
21 unistd/getcwd.c \
22 unistd/getdtablesize.c \
23 unistd/gethostname.c \
24 unistd/getopt_long.c \
25 unistd/getpgrp.c \
26 unistd/getpriority.c \
27 unistd/getpt.c \
28 unistd/initgroups.c \
29 unistd/isatty.c \
30 unistd/issetugid.c \
Colin Cross8c59d962010-01-13 16:39:26 -080031 unistd/killpg.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080032 unistd/lseek64.c \
33 unistd/mmap.c \
34 unistd/nice.c \
35 unistd/open.c \
36 unistd/openat.c \
37 unistd/opendir.c \
38 unistd/pathconf.c \
39 unistd/perror.c \
40 unistd/popen.c \
41 unistd/pread.c \
42 unistd/pselect.c \
43 unistd/ptsname.c \
44 unistd/ptsname_r.c \
45 unistd/pwrite.c \
46 unistd/raise.c \
47 unistd/reboot.c \
48 unistd/recv.c \
49 unistd/sbrk.c \
50 unistd/send.c \
51 unistd/setegid.c \
Mike Chan9f691562010-03-02 10:55:58 -080052 unistd/setuid.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080053 unistd/seteuid.c \
Mike Chan9f691562010-03-02 10:55:58 -080054 unistd/setreuid.c \
55 unistd/setresuid.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080056 unistd/setpgrp.c \
57 unistd/sigblock.c \
58 unistd/siginterrupt.c \
59 unistd/siglist.c \
60 unistd/signal.c \
Thorsten Glaser92b10af2009-10-02 15:39:00 +020061 unistd/signame.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080062 unistd/sigsetmask.c \
63 unistd/sigsuspend.c \
64 unistd/sigwait.c \
65 unistd/sleep.c \
66 unistd/statfs.c \
67 unistd/strsignal.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080068 unistd/syslog.c \
69 unistd/system.c \
70 unistd/tcgetpgrp.c \
71 unistd/tcsetpgrp.c \
72 unistd/time.c \
73 unistd/umount.c \
74 unistd/unlockpt.c \
75 unistd/usleep.c \
76 unistd/wait.c \
77 stdio/asprintf.c \
78 stdio/clrerr.c \
79 stdio/fclose.c \
80 stdio/fdopen.c \
81 stdio/feof.c \
82 stdio/ferror.c \
83 stdio/fflush.c \
84 stdio/fgetc.c \
85 stdio/fgetln.c \
86 stdio/fgetpos.c \
87 stdio/fgets.c \
88 stdio/fileno.c \
89 stdio/findfp.c \
90 stdio/flags.c \
91 stdio/flockfile.c \
92 stdio/fopen.c \
93 stdio/fprintf.c \
94 stdio/fpurge.c \
95 stdio/fputc.c \
96 stdio/fputs.c \
97 stdio/fread.c \
98 stdio/freopen.c \
99 stdio/fscanf.c \
100 stdio/fseek.c \
101 stdio/fsetpos.c \
102 stdio/ftell.c \
103 stdio/funopen.c \
104 stdio/fvwrite.c \
105 stdio/fwalk.c \
106 stdio/fwrite.c \
107 stdio/getc.c \
108 stdio/getchar.c \
109 stdio/gets.c \
110 stdio/makebuf.c \
111 stdio/mktemp.c \
112 stdio/printf.c \
113 stdio/putc.c \
114 stdio/putchar.c \
115 stdio/puts.c \
116 stdio/putw.c \
117 stdio/refill.c \
118 stdio/remove.c \
119 stdio/rewind.c \
120 stdio/rget.c \
121 stdio/scanf.c \
122 stdio/setbuf.c \
123 stdio/setbuffer.c \
124 stdio/setvbuf.c \
125 stdio/snprintf.c\
126 stdio/sprintf.c \
127 stdio/sscanf.c \
128 stdio/stdio.c \
129 stdio/tempnam.c \
130 stdio/tmpfile.c \
131 stdio/tmpnam.c \
132 stdio/ungetc.c \
133 stdio/vasprintf.c \
134 stdio/vfprintf.c \
135 stdio/vfscanf.c \
136 stdio/vprintf.c \
137 stdio/vsnprintf.c \
138 stdio/vsprintf.c \
139 stdio/vscanf.c \
140 stdio/vsscanf.c \
141 stdio/wbuf.c \
142 stdio/wsetup.c \
Nick Kralevichcffdf662012-06-11 15:50:57 -0700143 stdio/__snprintf_chk.c \
144 stdio/__vsnprintf_chk.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800145 stdlib/_rand48.c \
146 stdlib/assert.c \
147 stdlib/atexit.c \
148 stdlib/atoi.c \
149 stdlib/atol.c \
150 stdlib/atoll.c \
151 stdlib/bsearch.c \
152 stdlib/ctype_.c \
153 stdlib/div.c \
154 stdlib/exit.c \
155 stdlib/getenv.c \
156 stdlib/jrand48.c \
157 stdlib/ldiv.c \
158 stdlib/lldiv.c \
159 stdlib/locale.c \
160 stdlib/lrand48.c \
161 stdlib/mrand48.c \
162 stdlib/nrand48.c \
163 stdlib/putenv.c \
164 stdlib/qsort.c \
165 stdlib/seed48.c \
166 stdlib/setenv.c \
167 stdlib/setjmperr.c \
168 stdlib/srand48.c \
169 stdlib/strntoimax.c \
170 stdlib/strntoumax.c \
171 stdlib/strtod.c \
172 stdlib/strtoimax.c \
173 stdlib/strtol.c \
174 stdlib/strtoll.c \
175 stdlib/strtoul.c \
176 stdlib/strtoull.c \
177 stdlib/strtoumax.c \
178 stdlib/tolower_.c \
179 stdlib/toupper_.c \
180 stdlib/wchar.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800181 string/index.c \
182 string/memccpy.c \
183 string/memchr.c \
184 string/memmem.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800185 string/memrchr.c \
186 string/memswap.c \
187 string/strcasecmp.c \
188 string/strcasestr.c \
189 string/strcat.c \
190 string/strchr.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800191 string/strcoll.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800192 string/strcspn.c \
193 string/strdup.c \
194 string/strerror.c \
195 string/strerror_r.c \
196 string/strlcat.c \
197 string/strlcpy.c \
198 string/strncat.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800199 string/strncpy.c \
200 string/strndup.c \
201 string/strnlen.c \
202 string/strpbrk.c \
203 string/strrchr.c \
204 string/strsep.c \
205 string/strspn.c \
206 string/strstr.c \
207 string/strtok.c \
208 string/strtotimeval.c \
209 string/strxfrm.c \
Nick Kralevich0a230152012-06-04 15:20:25 -0700210 string/__memcpy_chk.c \
211 string/__memmove_chk.c \
Nick Kralevich71a18dd2012-06-07 14:01:26 -0700212 string/__memset_chk.c \
Nick Kralevich0a230152012-06-04 15:20:25 -0700213 string/__strcat_chk.c \
214 string/__strcpy_chk.c \
215 string/__strncat_chk.c \
216 string/__strncpy_chk.c \
David 'Digit' Turner3527fd62010-06-14 17:18:35 -0700217 wchar/wcpcpy.c \
218 wchar/wcpncpy.c \
219 wchar/wcscasecmp.c \
220 wchar/wcscat.c \
221 wchar/wcschr.c \
222 wchar/wcscmp.c \
223 wchar/wcscoll.c \
224 wchar/wcscpy.c \
225 wchar/wcscspn.c \
226 wchar/wcsdup.c \
227 wchar/wcslcat.c \
228 wchar/wcslcpy.c \
229 wchar/wcslen.c \
230 wchar/wcsncasecmp.c \
231 wchar/wcsncat.c \
232 wchar/wcsncmp.c \
233 wchar/wcsncpy.c \
234 wchar/wcsnlen.c \
235 wchar/wcspbrk.c \
236 wchar/wcsrchr.c \
237 wchar/wcsspn.c \
238 wchar/wcsstr.c \
239 wchar/wcstok.c \
240 wchar/wcswidth.c \
Kristian Monsen70465612010-06-16 14:51:52 +0100241 wchar/wcsxfrm.c \
David 'Digit' Turner3527fd62010-06-14 17:18:35 -0700242 wchar/wmemchr.c \
Kristian Monsen70465612010-06-16 14:51:52 +0100243 wchar/wmemcmp.c \
David 'Digit' Turner3527fd62010-06-14 17:18:35 -0700244 wchar/wmemcpy.c \
245 wchar/wmemmove.c \
246 wchar/wmemset.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800247 inet/bindresvport.c \
248 inet/inet_addr.c \
249 inet/inet_aton.c \
250 inet/inet_ntoa.c \
251 inet/inet_ntop.c \
252 inet/inet_pton.c \
Szymon Jakubczak41e533a2010-06-09 15:53:28 -0400253 inet/ether_aton.c \
254 inet/ether_ntoa.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800255 tzcode/asctime.c \
256 tzcode/difftime.c \
257 tzcode/localtime.c \
258 tzcode/strftime.c \
259 tzcode/strptime.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800260 bionic/__set_errno.c \
Mike Chan9f691562010-03-02 10:55:58 -0800261 bionic/cpuacct.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800262 bionic/arc4random.c \
263 bionic/basename.c \
264 bionic/basename_r.c \
Colin Crossfc10b242010-01-13 17:48:34 -0800265 bionic/clearenv.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800266 bionic/dirname.c \
267 bionic/dirname_r.c \
268 bionic/drand48.c \
269 bionic/erand48.c \
Colin Cross64ceac32010-01-13 21:19:52 -0800270 bionic/err.c \
Colin Crossfc10b242010-01-13 17:48:34 -0800271 bionic/fdprintf.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800272 bionic/fork.c \
Colin Cross64ceac32010-01-13 21:19:52 -0800273 bionic/fts.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800274 bionic/if_nametoindex.c \
275 bionic/if_indextoname.c \
276 bionic/ioctl.c \
277 bionic/ldexp.c \
278 bionic/libc_init_common.c \
279 bionic/logd_write.c \
280 bionic/md5.c \
Andy McFadden4ce737f2011-02-04 14:45:57 -0800281 bionic/memmove_words.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800282 bionic/pututline.c \
283 bionic/realpath.c \
David 'Digit' Turner72e6fd42010-12-03 18:04:01 +0100284 bionic/sched_getaffinity.c \
285 bionic/sched_getcpu.c \
286 bionic/sched_cpualloc.c \
287 bionic/sched_cpucount.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800288 bionic/semaphore.c \
289 bionic/sha1.c \
290 bionic/ssp.c \
291 bionic/stubs.c \
292 bionic/system_properties.c \
Ben Cheng21eab512012-03-13 23:04:57 -0700293 bionic/tdelete.c \
294 bionic/tdestroy.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800295 bionic/time64.c \
Ben Cheng21eab512012-03-13 23:04:57 -0700296 bionic/tfind.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800297 bionic/thread_atexit.c \
Ben Cheng21eab512012-03-13 23:04:57 -0700298 bionic/tsearch.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800299 bionic/utime.c \
300 bionic/utmp.c \
301 netbsd/gethnamaddr.c \
302 netbsd/isc/ev_timers.c \
303 netbsd/isc/ev_streams.c \
304 netbsd/inet/nsap_addr.c \
305 netbsd/resolv/__dn_comp.c \
306 netbsd/resolv/__res_close.c \
307 netbsd/resolv/__res_send.c \
308 netbsd/resolv/herror.c \
309 netbsd/resolv/res_comp.c \
310 netbsd/resolv/res_data.c \
311 netbsd/resolv/res_debug.c \
312 netbsd/resolv/res_init.c \
313 netbsd/resolv/res_mkquery.c \
314 netbsd/resolv/res_query.c \
315 netbsd/resolv/res_send.c \
Shin-ichiro KAWASAKI10093272009-09-28 16:11:39 +0900316 netbsd/resolv/res_state.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800317 netbsd/resolv/res_cache.c \
318 netbsd/net/nsdispatch.c \
319 netbsd/net/getaddrinfo.c \
320 netbsd/net/getnameinfo.c \
321 netbsd/net/getservbyname.c \
322 netbsd/net/getservent.c \
323 netbsd/net/base64.c \
324 netbsd/net/getservbyport.c \
325 netbsd/nameser/ns_name.c \
326 netbsd/nameser/ns_parse.c \
327 netbsd/nameser/ns_ttl.c \
328 netbsd/nameser/ns_netint.c \
329 netbsd/nameser/ns_print.c \
Colin Cross4fa7b102010-01-12 18:59:25 -0800330 netbsd/nameser/ns_samedomain.c \
331 regex/regcomp.c \
332 regex/regerror.c \
333 regex/regexec.c \
334 regex/regfree.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800335
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700336# The following files are common, but must be compiled
337# with different C flags when building a static C library.
338#
339# The reason for this is the implementation of __get_tls()
340# that will differ between the shared and static versions
341# of the library.
342#
343# See comments in private/bionic_tls.h for more details.
344#
345# NOTE: bionic/pthread.c is added later to this list
346# because it needs special handling on ARM, see
347# below.
348#
349libc_static_common_src_files := \
350 unistd/sysconf.c \
351 bionic/__errno.c \
352
Dima Zavinca122b02009-05-27 10:52:37 -0700353# Architecture specific source files go here
354# =========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800355ifeq ($(TARGET_ARCH),arm)
356libc_common_src_files += \
David 'Digit' Turner97cf7f32010-01-22 18:59:05 -0800357 bionic/bionic_clone.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800358 arch-arm/bionic/__get_pc.S \
359 arch-arm/bionic/__get_sp.S \
360 arch-arm/bionic/_exit_with_stack_teardown.S \
361 arch-arm/bionic/_setjmp.S \
Ben Cheng017f4382012-05-08 13:36:37 -0700362 arch-arm/bionic/abort_arm.S \
David 'Digit' Turner0fec6b92011-11-16 17:37:15 +0100363 arch-arm/bionic/atomics_arm.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800364 arch-arm/bionic/clone.S \
David 'Digit' Turner6a9b8882010-06-18 14:47:22 -0700365 arch-arm/bionic/eabi.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800366 arch-arm/bionic/ffs.S \
David 'Digit' Turner0fec6b92011-11-16 17:37:15 +0100367 arch-arm/bionic/futex_arm.S \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800368 arch-arm/bionic/kill.S \
David 'Digit' Turner2a7ad972009-09-29 14:43:38 -0700369 arch-arm/bionic/libgcc_compat.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800370 arch-arm/bionic/tkill.S \
Jeff Brown10c8ce52011-11-18 15:17:07 -0800371 arch-arm/bionic/tgkill.S \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800372 arch-arm/bionic/memcmp.S \
373 arch-arm/bionic/memcmp16.S \
374 arch-arm/bionic/memcpy.S \
375 arch-arm/bionic/memset.S \
376 arch-arm/bionic/setjmp.S \
377 arch-arm/bionic/sigsetjmp.S \
378 arch-arm/bionic/strlen.c.arm \
Jim Huang73c04b32010-08-10 17:23:39 +0800379 arch-arm/bionic/strcpy.S \
Jim Huangf50e9be2011-04-20 15:35:04 +0800380 arch-arm/bionic/strcmp.S \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800381 arch-arm/bionic/syscall.S \
Shin-ichiro KAWASAKI10093272009-09-28 16:11:39 +0900382 string/memmove.c.arm \
Bruce Beare8ff1a272010-03-04 11:03:37 -0800383 string/bcopy.c \
Bruce Beare8ff1a272010-03-04 11:03:37 -0800384 string/strncmp.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800385 unistd/socketcalls.c
386
387# These files need to be arm so that gdbserver
388# can set breakpoints in them without messing
389# up any thumb code.
390libc_common_src_files += \
Matt Fischer4f086ae2010-06-25 14:36:39 -0500391 bionic/pthread-atfork.c.arm \
David 'Digit' Turner8a1d2cf2010-05-11 16:39:22 -0700392 bionic/pthread-rwlocks.c.arm \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800393 bionic/pthread-timers.c.arm \
394 bionic/ptrace.c.arm
Dima Zavinca122b02009-05-27 10:52:37 -0700395
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700396libc_static_common_src_files += \
397 bionic/pthread.c.arm \
398
Dima Zavinca122b02009-05-27 10:52:37 -0700399# these are used by the static and dynamic versions of the libc
400# respectively
401libc_arch_static_src_files := \
402 arch-arm/bionic/exidx_static.c
403
404libc_arch_dynamic_src_files := \
405 arch-arm/bionic/exidx_dynamic.c
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800406else # !arm
407
408ifeq ($(TARGET_ARCH),x86)
409libc_common_src_files += \
410 arch-x86/bionic/__get_sp.S \
411 arch-x86/bionic/__get_tls.c \
412 arch-x86/bionic/__set_tls.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800413 arch-x86/bionic/clone.S \
414 arch-x86/bionic/_exit_with_stack_teardown.S \
David 'Digit' Turner0fec6b92011-11-16 17:37:15 +0100415 arch-x86/bionic/futex_x86.S \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800416 arch-x86/bionic/setjmp.S \
417 arch-x86/bionic/_setjmp.S \
Chih-Wei Huang18635d92010-12-14 17:55:23 +0800418 arch-x86/bionic/sigsetjmp.S \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800419 arch-x86/bionic/vfork.S \
Bruce Beare3c543e12010-03-04 10:29:38 -0800420 arch-x86/bionic/syscall.S \
Bruce Beare8ff1a272010-03-04 11:03:37 -0800421 arch-x86/string/bcopy_wrapper.S \
422 arch-x86/string/memcpy_wrapper.S \
423 arch-x86/string/memmove_wrapper.S \
424 arch-x86/string/bzero_wrapper.S \
425 arch-x86/string/memcmp_wrapper.S \
426 arch-x86/string/memset_wrapper.S \
427 arch-x86/string/strcmp_wrapper.S \
428 arch-x86/string/strncmp_wrapper.S \
Bruce Beare124a5422010-10-11 12:24:41 -0700429 arch-x86/string/strlen_wrapper.S \
Jim Huang73c04b32010-08-10 17:23:39 +0800430 string/strcpy.c \
Matt Fischer4f086ae2010-06-25 14:36:39 -0500431 bionic/pthread-atfork.c \
David 'Digit' Turner8a1d2cf2010-05-11 16:39:22 -0700432 bionic/pthread-rwlocks.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800433 bionic/pthread-timers.c \
434 bionic/ptrace.c
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800435
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700436libc_static_common_src_files += \
437 bionic/pthread.c \
438
Dima Zavinca122b02009-05-27 10:52:37 -0700439# this is needed for static versions of libc
440libc_arch_static_src_files := \
441 arch-x86/bionic/dl_iterate_phdr_static.c
442
443libc_arch_dynamic_src_files :=
Shin-ichiro KAWASAKI10093272009-09-28 16:11:39 +0900444else # !x86
445
Shin-ichiro KAWASAKI10093272009-09-28 16:11:39 +0900446endif # !x86
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800447endif # !arm
448
Dima Zavinca122b02009-05-27 10:52:37 -0700449# Define some common cflags
450# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800451libc_common_cflags := \
Elliott Hughes470631e2012-06-06 10:32:56 -0700452 -DWITH_ERRLIST \
453 -DANDROID_CHANGES \
454 -DUSE_LOCKS \
455 -DREALLOC_ZERO_BYTES_FREES \
456 -D_LIBC=1 \
457 -DSOFTFLOAT \
458 -DFLOATING_POINT \
459 -DINET6 \
460 -I$(LOCAL_PATH)/private \
461 -DUSE_DL_PREFIX \
462 -DPOSIX_MISTAKE \
463 -DLOG_ON_HEAP_ERROR \
464 -std=gnu99
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800465
David 'Digit' Turnerd7ed1ae2010-03-05 14:17:35 -0800466# these macro definitions are required to implement the
467# 'timezone' and 'daylight' global variables, as well as
468# properly update the 'tm_gmtoff' field in 'struct tm'.
469#
470libc_common_cflags += \
471 -DTM_GMTOFF=tm_gmtoff \
472 -DUSG_COMPAT=1
473
Dave Bortd2c9dcc2009-04-23 15:50:03 -0700474ifeq ($(strip $(DEBUG_BIONIC_LIBC)),true)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800475 libc_common_cflags += -DDEBUG
476endif
477
Jack Ren2fd81ef2011-11-19 09:48:03 +0800478# To customize dlmalloc's alignment, set BOARD_MALLOC_ALIGNMENT in
479# the appropriate BoardConfig.mk file.
480#
481ifneq ($(BOARD_MALLOC_ALIGNMENT),)
482 libc_common_cflags += -DMALLOC_ALIGNMENT=$(BOARD_MALLOC_ALIGNMENT)
483endif
484
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800485ifeq ($(TARGET_ARCH),arm)
486 libc_common_cflags += -fstrict-aliasing
Dima Zavinca122b02009-05-27 10:52:37 -0700487 libc_crt_target_cflags := -mthumb-interwork
David 'Digit' Turner4a05d122009-09-18 13:35:05 -0700488 #
489 # Define HAVE_ARM_TLS_REGISTER macro to indicate to the C library
490 # that it should access the hardware TLS register directly in
491 # private/bionic_tls.h
492 #
493 # The value must match your kernel configuration
494 #
495 ifeq ($(ARCH_ARM_HAVE_TLS_REGISTER),true)
496 libc_common_cflags += -DHAVE_ARM_TLS_REGISTER
497 endif
Henrik Smidingfe6338d2010-09-15 16:08:03 +0200498 #
499 # Define HAVE_32_BYTE_CACHE_LINES to indicate to C
500 # library it should use to 32-byte version of memcpy, and not
501 # the 64-byte version.
502 #
503 ifeq ($(ARCH_ARM_HAVE_32_BYTE_CACHE_LINES),true)
504 libc_common_cflags += -DHAVE_32_BYTE_CACHE_LINE
505 endif
Prajakta Gudadhe08e72d02012-05-07 14:17:44 -0700506 ifeq ($(ARCH_ARM_USE_NON_NEON_MEMCPY),true)
507 libc_common_cflags += -DARCH_ARM_USE_NON_NEON_MEMCPY
508 endif
Dima Zavinca122b02009-05-27 10:52:37 -0700509else # !arm
510 ifeq ($(TARGET_ARCH),x86)
Bruce Beareaf96d4d2011-12-09 13:52:19 -0800511 libc_crt_target_cflags :=
David 'Digit' Turnera5cb76b2011-12-14 18:23:40 +0100512 ifeq ($(ARCH_X86_HAVE_SSE2),true)
513 libc_crt_target_cflags += -DUSE_SSE2=1
514 endif
515 ifeq ($(ARCH_X86_HAVE_SSSE3),true)
516 libc_crt_target_cflags += -DUSE_SSSE3=1
517 endif
Dima Zavinca122b02009-05-27 10:52:37 -0700518 endif # x86
519endif # !arm
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800520
Andy McFaddenfcd00eb2010-05-28 13:31:45 -0700521# Define ANDROID_SMP appropriately.
522ifeq ($(TARGET_CPU_SMP),true)
523 libc_common_cflags += -DANDROID_SMP=1
524else
525 libc_common_cflags += -DANDROID_SMP=0
526endif
527
Nick Kralevich9d403262012-05-31 11:40:10 -0700528# Needed to access private/__dso_handle.h from
529# crtbegin_xxx.c and crtend_xxx.c
David 'Digit' Turner6a9b8882010-06-18 14:47:22 -0700530#
531libc_crt_target_cflags += -I$(LOCAL_PATH)/private
Andy McFaddenfcd00eb2010-05-28 13:31:45 -0700532
Bruce Beare39640842011-06-20 10:29:50 -0700533ifeq ($(TARGET_ARCH),arm)
534libc_crt_target_cflags += -DCRT_LEGACY_WORKAROUND
535endif
536
Dima Zavinca122b02009-05-27 10:52:37 -0700537# Define some common includes
538# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800539libc_common_c_includes := \
540 $(LOCAL_PATH)/stdlib \
541 $(LOCAL_PATH)/string \
Nick Kralevich76656af2012-06-07 16:30:02 -0700542 $(LOCAL_PATH)/stdio \
543 external/safe-iop/include
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800544
Nick Kralevich9d403262012-05-31 11:40:10 -0700545# Needed to access private/__dso_handle.h from
David 'Digit' Turner3b43f872010-07-01 23:09:28 -0700546# crtbegin_xxx.S and crtend_xxx.S
547#
Kenny Root03273f82012-04-10 17:24:24 -0700548libc_crt_target_cflags += -I$(LOCAL_PATH)/private -I$(LOCAL_PATH)/arch-$(TARGET_ARCH)/include
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800549
Dima Zavinca122b02009-05-27 10:52:37 -0700550# Define the libc run-time (crt) support object files that must be built,
551# which are needed to build all other objects (shared/static libs and
552# executables)
553# ==========================================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800554
David 'Digit' Turner6a9b8882010-06-18 14:47:22 -0700555ifneq ($(filter arm x86,$(TARGET_ARCH)),)
556# ARM and x86 need crtbegin_so/crtend_so.
557#
558# For x86, the .init section must point to a function that calls all
559# entries in the .ctors section. (on ARM this is done through the
560# .init_array section instead).
561#
562# For both platforms, the .fini_array section must point to a function
563# that will call __cxa_finalize(&__dso_handle) in order to ensure that
564# static C++ destructors are properly called on dlclose().
565#
David 'Digit' Turner2d2dbd32011-06-25 17:26:38 +0200566
567libc_crt_target_so_cflags := $(libc_crt_target_cflags)
Nick Kralevich9d403262012-05-31 11:40:10 -0700568libc_crt_target_crtstart_file := $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin.c
569libc_crt_target_crtstart_so_file := $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin_so.c
David 'Digit' Turner2d2dbd32011-06-25 17:26:38 +0200570ifeq ($(TARGET_ARCH),x86)
571 # This flag must be added for x86 targets, but not for ARM
572 libc_crt_target_so_cflags += -fPIC
Nick Kralevich9d403262012-05-31 11:40:10 -0700573 libc_crt_target_crtstart_file := $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin.S
574 libc_crt_target_crtstart_so_file := $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin_so.S
David 'Digit' Turner2d2dbd32011-06-25 17:26:38 +0200575endif
Ying Wangfc9e5252012-05-15 15:15:11 -0700576GEN := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_so.o
Nick Kralevich9d403262012-05-31 11:40:10 -0700577$(GEN): $(libc_crt_target_crtstart_so_file)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800578 @mkdir -p $(dir $@)
David 'Digit' Turner2d2dbd32011-06-25 17:26:38 +0200579 $(TARGET_CC) $(libc_crt_target_so_cflags) -o $@ -c $<
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800580ALL_GENERATED_SOURCES += $(GEN)
581
Ying Wangfc9e5252012-05-15 15:15:11 -0700582GEN := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_so.o
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800583$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtend_so.S
584 @mkdir -p $(dir $@)
David 'Digit' Turner2d2dbd32011-06-25 17:26:38 +0200585 $(TARGET_CC) $(libc_crt_target_so_cflags) -o $@ -c $<
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800586ALL_GENERATED_SOURCES += $(GEN)
David 'Digit' Turner2d2dbd32011-06-25 17:26:38 +0200587endif # TARGET_ARCH == x86 || TARGET_ARCH == arm
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800588
Dima Zavinca122b02009-05-27 10:52:37 -0700589
Ying Wangfc9e5252012-05-15 15:15:11 -0700590GEN := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_static.o
Nick Kralevich9d403262012-05-31 11:40:10 -0700591$(GEN): $(libc_crt_target_crtstart_file)
Dima Zavinca122b02009-05-27 10:52:37 -0700592 @mkdir -p $(dir $@)
593 $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $<
594ALL_GENERATED_SOURCES += $(GEN)
595
Ying Wangfc9e5252012-05-15 15:15:11 -0700596GEN := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_dynamic.o
Nick Kralevich9d403262012-05-31 11:40:10 -0700597$(GEN): $(libc_crt_target_crtstart_file)
Dima Zavinca122b02009-05-27 10:52:37 -0700598 @mkdir -p $(dir $@)
599 $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $<
600ALL_GENERATED_SOURCES += $(GEN)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800601
602
Dima Zavinca122b02009-05-27 10:52:37 -0700603# We rename crtend.o to crtend_android.o to avoid a
604# name clash between gcc and bionic.
Ying Wangfc9e5252012-05-15 15:15:11 -0700605GEN := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_android.o
Dima Zavinca122b02009-05-27 10:52:37 -0700606$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtend.S
607 @mkdir -p $(dir $@)
608 $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $<
609ALL_GENERATED_SOURCES += $(GEN)
610
611
612# To enable malloc leak check for statically linked programs, add
613# "WITH_MALLOC_CHECK_LIBC_A := true" to buildspec.mk
614WITH_MALLOC_CHECK_LIBC_A := $(strip $(WITH_MALLOC_CHECK_LIBC_A))
615
616# ========================================================
617# libc_common.a
618# ========================================================
619include $(CLEAR_VARS)
620
621LOCAL_SRC_FILES := $(libc_common_src_files)
622LOCAL_CFLAGS := $(libc_common_cflags)
Bruce Beare39640842011-06-20 10:29:50 -0700623ifeq ($(TARGET_ARCH),arm)
624LOCAL_CFLAGS += -DCRT_LEGACY_WORKAROUND
625endif
Dima Zavinca122b02009-05-27 10:52:37 -0700626LOCAL_C_INCLUDES := $(libc_common_c_includes)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800627LOCAL_MODULE := libc_common
628LOCAL_SYSTEM_SHARED_LIBRARIES :=
629
630include $(BUILD_STATIC_LIBRARY)
631
632
Dima Zavinca122b02009-05-27 10:52:37 -0700633# ========================================================
Dima Zavin49e55332009-05-27 10:52:37 -0700634# libc_nomalloc.a
635# ========================================================
636#
637# This is a version of the static C library that does not
638# include malloc. It's useful in situations when calling
639# the user wants to provide their own malloc implementation,
640# or wants to explicitly disallow the use of the use of malloc,
641# like the dynamic loader.
642
643include $(CLEAR_VARS)
644
645LOCAL_SRC_FILES := \
646 $(libc_arch_static_src_files) \
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700647 $(libc_static_common_src_files) \
Dima Zavin49e55332009-05-27 10:52:37 -0700648 bionic/libc_init_static.c
649
650LOCAL_C_INCLUDES := $(libc_common_c_includes)
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700651LOCAL_CFLAGS := $(libc_common_cflags) \
652 -DLIBC_STATIC
Dima Zavin49e55332009-05-27 10:52:37 -0700653
654LOCAL_MODULE := libc_nomalloc
655LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
656LOCAL_SYSTEM_SHARED_LIBRARIES :=
657
658include $(BUILD_STATIC_LIBRARY)
659
660
661# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800662# libc.a
663# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800664include $(CLEAR_VARS)
665
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800666LOCAL_SRC_FILES := \
Dima Zavinca122b02009-05-27 10:52:37 -0700667 $(libc_arch_static_src_files) \
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700668 $(libc_static_common_src_files) \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800669 bionic/dlmalloc.c \
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800670 bionic/malloc_debug_common.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800671 bionic/libc_init_static.c
672
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800673LOCAL_CFLAGS := $(libc_common_cflags) \
674 -DLIBC_STATIC
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800675LOCAL_C_INCLUDES := $(libc_common_c_includes)
Dima Zavinca122b02009-05-27 10:52:37 -0700676LOCAL_MODULE := libc
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800677LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800678LOCAL_SYSTEM_SHARED_LIBRARIES :=
679
680include $(BUILD_STATIC_LIBRARY)
681
682
Dima Zavinca122b02009-05-27 10:52:37 -0700683# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800684# libc.so
685# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800686include $(CLEAR_VARS)
687
Mathias Agopian7c0c3792011-09-05 23:54:55 -0700688# pthread deadlock prediction:
689# set -DPTHREAD_DEBUG -DPTHREAD_DEBUG_ENABLED=1 to enable support for
690# pthread deadlock prediction.
691# Since this code is experimental it is disabled by default.
692# see libc/bionic/pthread_debug.c for details
693
694LOCAL_CFLAGS := $(libc_common_cflags) -DPTHREAD_DEBUG -DPTHREAD_DEBUG_ENABLED=0
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800695LOCAL_C_INCLUDES := $(libc_common_c_includes)
696
697LOCAL_SRC_FILES := \
Dima Zavinca122b02009-05-27 10:52:37 -0700698 $(libc_arch_dynamic_src_files) \
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700699 $(libc_static_common_src_files) \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800700 bionic/dlmalloc.c \
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800701 bionic/malloc_debug_common.c \
Mathias Agopian7c0c3792011-09-05 23:54:55 -0700702 bionic/pthread_debug.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800703 bionic/libc_init_dynamic.c
704
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800705LOCAL_MODULE:= libc
706
707# WARNING: The only library libc.so should depend on is libdl.so! If you add other libraries,
708# make sure to add -Wl,--exclude-libs=libgcc.a to the LOCAL_LDFLAGS for those libraries. This
709# ensures that symbols that are pulled into those new libraries from libgcc.a are not declared
710# external; if that were the case, then libc would not pull those symbols from libgcc.a as it
711# should, instead relying on the external symbols from the dependent libraries. That would
712# create an "cloaked" dependency on libgcc.a in libc though the libraries, which is not what
713# you wanted!
714
715LOCAL_SHARED_LIBRARIES := libdl
716LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
717LOCAL_SYSTEM_SHARED_LIBRARIES :=
718
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800719include $(BUILD_SHARED_LIBRARY)
720
721
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800722# For all builds, except for the -user build we will enable memory
723# allocation checking (including memory leaks, buffer overwrites, etc.)
724# Note that all these checks are also controlled by env. settings
725# that can enable, or disable specific checks. Note also that some of
726# the checks are available only in emulator and are implemeted in
727# libc_malloc_qemu_instrumented.so.
728ifneq ($(TARGET_BUILD_VARIANT),user)
729
Dima Zavinca122b02009-05-27 10:52:37 -0700730# ========================================================
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800731# libc_malloc_debug_leak.so
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800732# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800733include $(CLEAR_VARS)
734
Dima Zavinca122b02009-05-27 10:52:37 -0700735LOCAL_CFLAGS := \
736 $(libc_common_cflags) \
737 -DMALLOC_LEAK_CHECK
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800738
739LOCAL_C_INCLUDES := $(libc_common_c_includes)
740
741LOCAL_SRC_FILES := \
Iliyan Malcheve1dd3c22012-05-29 14:22:42 -0700742 bionic/malloc_debug_leak.c \
743 bionic/malloc_debug_check.c \
744 bionic/malloc_debug_check_mapinfo.c \
745 bionic/malloc_debug_stacktrace.c
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800746
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800747LOCAL_MODULE:= libc_malloc_debug_leak
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800748
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800749LOCAL_SHARED_LIBRARIES := libc
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800750LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
751LOCAL_SYSTEM_SHARED_LIBRARIES :=
Bruce Beareaa46fa22010-07-08 14:47:50 -0700752LOCAL_ALLOW_UNDEFINED_SYMBOLS := true
Iliyan Malchev36807042011-03-14 14:02:05 -0700753
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800754# Don't install on release build
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800755LOCAL_MODULE_TAGS := eng debug
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800756
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800757include $(BUILD_SHARED_LIBRARY)
758
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800759
760# ========================================================
761# libc_malloc_debug_qemu.so
762# ========================================================
763include $(CLEAR_VARS)
764
765LOCAL_CFLAGS := \
766 $(libc_common_cflags) \
767 -DMALLOC_QEMU_INSTRUMENT
768
769LOCAL_C_INCLUDES := $(libc_common_c_includes)
770
771LOCAL_SRC_FILES := \
772 bionic/malloc_debug_qemu.c
773
774LOCAL_MODULE:= libc_malloc_debug_qemu
775
Mathias Agopian7c0c3792011-09-05 23:54:55 -0700776LOCAL_SHARED_LIBRARIES := libc libdl
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800777LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
778LOCAL_SYSTEM_SHARED_LIBRARIES :=
Iliyan Malchev36807042011-03-14 14:02:05 -0700779
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800780# Don't install on release build
781LOCAL_MODULE_TAGS := eng debug
782
783include $(BUILD_SHARED_LIBRARY)
784
785endif #!user
786
787
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800788# ========================================================
789include $(call all-makefiles-under,$(LOCAL_PATH))