blob: bd203af95c38fd481c9fd34a2161584c6b4c6eb7 [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 \
143 stdlib/_rand48.c \
144 stdlib/assert.c \
145 stdlib/atexit.c \
146 stdlib/atoi.c \
147 stdlib/atol.c \
148 stdlib/atoll.c \
149 stdlib/bsearch.c \
150 stdlib/ctype_.c \
151 stdlib/div.c \
152 stdlib/exit.c \
153 stdlib/getenv.c \
154 stdlib/jrand48.c \
155 stdlib/ldiv.c \
156 stdlib/lldiv.c \
157 stdlib/locale.c \
158 stdlib/lrand48.c \
159 stdlib/mrand48.c \
160 stdlib/nrand48.c \
161 stdlib/putenv.c \
162 stdlib/qsort.c \
163 stdlib/seed48.c \
164 stdlib/setenv.c \
165 stdlib/setjmperr.c \
166 stdlib/srand48.c \
167 stdlib/strntoimax.c \
168 stdlib/strntoumax.c \
169 stdlib/strtod.c \
170 stdlib/strtoimax.c \
171 stdlib/strtol.c \
172 stdlib/strtoll.c \
173 stdlib/strtoul.c \
174 stdlib/strtoull.c \
175 stdlib/strtoumax.c \
176 stdlib/tolower_.c \
177 stdlib/toupper_.c \
178 stdlib/wchar.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800179 string/index.c \
180 string/memccpy.c \
181 string/memchr.c \
182 string/memmem.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800183 string/memrchr.c \
184 string/memswap.c \
185 string/strcasecmp.c \
186 string/strcasestr.c \
187 string/strcat.c \
188 string/strchr.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800189 string/strcoll.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800190 string/strcspn.c \
191 string/strdup.c \
192 string/strerror.c \
193 string/strerror_r.c \
194 string/strlcat.c \
195 string/strlcpy.c \
196 string/strncat.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800197 string/strncpy.c \
198 string/strndup.c \
199 string/strnlen.c \
200 string/strpbrk.c \
201 string/strrchr.c \
202 string/strsep.c \
203 string/strspn.c \
204 string/strstr.c \
205 string/strtok.c \
206 string/strtotimeval.c \
207 string/strxfrm.c \
David 'Digit' Turner3527fd62010-06-14 17:18:35 -0700208 wchar/wcpcpy.c \
209 wchar/wcpncpy.c \
210 wchar/wcscasecmp.c \
211 wchar/wcscat.c \
212 wchar/wcschr.c \
213 wchar/wcscmp.c \
214 wchar/wcscoll.c \
215 wchar/wcscpy.c \
216 wchar/wcscspn.c \
217 wchar/wcsdup.c \
218 wchar/wcslcat.c \
219 wchar/wcslcpy.c \
220 wchar/wcslen.c \
221 wchar/wcsncasecmp.c \
222 wchar/wcsncat.c \
223 wchar/wcsncmp.c \
224 wchar/wcsncpy.c \
225 wchar/wcsnlen.c \
226 wchar/wcspbrk.c \
227 wchar/wcsrchr.c \
228 wchar/wcsspn.c \
229 wchar/wcsstr.c \
230 wchar/wcstok.c \
231 wchar/wcswidth.c \
Kristian Monsen70465612010-06-16 14:51:52 +0100232 wchar/wcsxfrm.c \
David 'Digit' Turner3527fd62010-06-14 17:18:35 -0700233 wchar/wmemchr.c \
Kristian Monsen70465612010-06-16 14:51:52 +0100234 wchar/wmemcmp.c \
David 'Digit' Turner3527fd62010-06-14 17:18:35 -0700235 wchar/wmemcpy.c \
236 wchar/wmemmove.c \
237 wchar/wmemset.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800238 inet/bindresvport.c \
239 inet/inet_addr.c \
240 inet/inet_aton.c \
241 inet/inet_ntoa.c \
242 inet/inet_ntop.c \
243 inet/inet_pton.c \
Szymon Jakubczak41e533a2010-06-09 15:53:28 -0400244 inet/ether_aton.c \
245 inet/ether_ntoa.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800246 tzcode/asctime.c \
247 tzcode/difftime.c \
248 tzcode/localtime.c \
249 tzcode/strftime.c \
250 tzcode/strptime.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800251 bionic/__set_errno.c \
Mike Chan9f691562010-03-02 10:55:58 -0800252 bionic/cpuacct.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800253 bionic/arc4random.c \
254 bionic/basename.c \
255 bionic/basename_r.c \
Colin Crossfc10b242010-01-13 17:48:34 -0800256 bionic/clearenv.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800257 bionic/dirname.c \
258 bionic/dirname_r.c \
259 bionic/drand48.c \
260 bionic/erand48.c \
Colin Cross64ceac32010-01-13 21:19:52 -0800261 bionic/err.c \
Colin Crossfc10b242010-01-13 17:48:34 -0800262 bionic/fdprintf.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800263 bionic/fork.c \
Colin Cross64ceac32010-01-13 21:19:52 -0800264 bionic/fts.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800265 bionic/if_nametoindex.c \
266 bionic/if_indextoname.c \
267 bionic/ioctl.c \
268 bionic/ldexp.c \
269 bionic/libc_init_common.c \
270 bionic/logd_write.c \
271 bionic/md5.c \
Andy McFadden4ce737f2011-02-04 14:45:57 -0800272 bionic/memmove_words.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800273 bionic/pututline.c \
274 bionic/realpath.c \
David 'Digit' Turner72e6fd42010-12-03 18:04:01 +0100275 bionic/sched_getaffinity.c \
276 bionic/sched_getcpu.c \
277 bionic/sched_cpualloc.c \
278 bionic/sched_cpucount.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800279 bionic/semaphore.c \
280 bionic/sha1.c \
281 bionic/ssp.c \
282 bionic/stubs.c \
283 bionic/system_properties.c \
284 bionic/time64.c \
285 bionic/thread_atexit.c \
286 bionic/utime.c \
287 bionic/utmp.c \
288 netbsd/gethnamaddr.c \
289 netbsd/isc/ev_timers.c \
290 netbsd/isc/ev_streams.c \
291 netbsd/inet/nsap_addr.c \
292 netbsd/resolv/__dn_comp.c \
293 netbsd/resolv/__res_close.c \
294 netbsd/resolv/__res_send.c \
295 netbsd/resolv/herror.c \
296 netbsd/resolv/res_comp.c \
297 netbsd/resolv/res_data.c \
298 netbsd/resolv/res_debug.c \
299 netbsd/resolv/res_init.c \
300 netbsd/resolv/res_mkquery.c \
301 netbsd/resolv/res_query.c \
302 netbsd/resolv/res_send.c \
Shin-ichiro KAWASAKI10093272009-09-28 16:11:39 +0900303 netbsd/resolv/res_state.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800304 netbsd/resolv/res_cache.c \
305 netbsd/net/nsdispatch.c \
306 netbsd/net/getaddrinfo.c \
307 netbsd/net/getnameinfo.c \
308 netbsd/net/getservbyname.c \
309 netbsd/net/getservent.c \
310 netbsd/net/base64.c \
311 netbsd/net/getservbyport.c \
312 netbsd/nameser/ns_name.c \
313 netbsd/nameser/ns_parse.c \
314 netbsd/nameser/ns_ttl.c \
315 netbsd/nameser/ns_netint.c \
316 netbsd/nameser/ns_print.c \
Colin Cross4fa7b102010-01-12 18:59:25 -0800317 netbsd/nameser/ns_samedomain.c \
318 regex/regcomp.c \
319 regex/regerror.c \
320 regex/regexec.c \
321 regex/regfree.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800322
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700323# The following files are common, but must be compiled
324# with different C flags when building a static C library.
325#
326# The reason for this is the implementation of __get_tls()
327# that will differ between the shared and static versions
328# of the library.
329#
330# See comments in private/bionic_tls.h for more details.
331#
332# NOTE: bionic/pthread.c is added later to this list
333# because it needs special handling on ARM, see
334# below.
335#
336libc_static_common_src_files := \
337 unistd/sysconf.c \
338 bionic/__errno.c \
339
Dima Zavinca122b02009-05-27 10:52:37 -0700340# Architecture specific source files go here
341# =========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800342ifeq ($(TARGET_ARCH),arm)
343libc_common_src_files += \
David 'Digit' Turner97cf7f32010-01-22 18:59:05 -0800344 bionic/bionic_clone.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800345 arch-arm/bionic/__get_pc.S \
346 arch-arm/bionic/__get_sp.S \
347 arch-arm/bionic/_exit_with_stack_teardown.S \
348 arch-arm/bionic/_setjmp.S \
Ben Cheng8b11e0e2012-05-08 13:36:37 -0700349 arch-arm/bionic/abort_arm.S \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800350 arch-arm/bionic/atomics_arm.S \
351 arch-arm/bionic/clone.S \
David 'Digit' Turner6a9b8882010-06-18 14:47:22 -0700352 arch-arm/bionic/eabi.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800353 arch-arm/bionic/ffs.S \
354 arch-arm/bionic/kill.S \
David 'Digit' Turner2a7ad972009-09-29 14:43:38 -0700355 arch-arm/bionic/libgcc_compat.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800356 arch-arm/bionic/tkill.S \
357 arch-arm/bionic/memcmp.S \
358 arch-arm/bionic/memcmp16.S \
359 arch-arm/bionic/memcpy.S \
360 arch-arm/bionic/memset.S \
361 arch-arm/bionic/setjmp.S \
362 arch-arm/bionic/sigsetjmp.S \
Jim Huang73c04b32010-08-10 17:23:39 +0800363 arch-arm/bionic/strcpy.S \
Jim Huangf50e9be2011-04-20 15:35:04 +0800364 arch-arm/bionic/strcmp.S \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800365 arch-arm/bionic/syscall.S \
Bruce Beare8ff1a272010-03-04 11:03:37 -0800366 string/strncmp.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800367 unistd/socketcalls.c
Jim Huang2c8ccf22012-03-09 01:51:14 -0500368ifeq ($(ARCH_ARM_HAVE_ARMV7A),true)
369libc_common_src_files += arch-arm/bionic/strlen-armv7.S
370else
371libc_common_src_files += arch-arm/bionic/strlen.c.arm
372endif
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800373
Harshad Bhutadac8221472011-05-05 18:27:02 +0530374# Check if we want a neonized version of memmove instead of the
375# current ARM version
376ifeq ($(TARGET_USE_SCORPION_BIONIC_OPTIMIZATION),true)
377libc_common_src_files += \
378 arch-arm/bionic/memmove.S
379else # Non-Scorpion-based ARM
380libc_common_src_files += \
381 string/bcopy.c \
382 string/memmove.c.arm
383endif # !TARGET_USE_SCORPION_BIONIC_OPTIMIZATION
384
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800385# These files need to be arm so that gdbserver
386# can set breakpoints in them without messing
387# up any thumb code.
388libc_common_src_files += \
Matt Fischer4f086ae2010-06-25 14:36:39 -0500389 bionic/pthread-atfork.c.arm \
David 'Digit' Turner8a1d2cf2010-05-11 16:39:22 -0700390 bionic/pthread-rwlocks.c.arm \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800391 bionic/pthread-timers.c.arm \
392 bionic/ptrace.c.arm
Dima Zavinca122b02009-05-27 10:52:37 -0700393
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700394libc_static_common_src_files += \
395 bionic/pthread.c.arm \
396
Dima Zavinca122b02009-05-27 10:52:37 -0700397# these are used by the static and dynamic versions of the libc
398# respectively
399libc_arch_static_src_files := \
400 arch-arm/bionic/exidx_static.c
401
402libc_arch_dynamic_src_files := \
403 arch-arm/bionic/exidx_dynamic.c
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800404else # !arm
405
406ifeq ($(TARGET_ARCH),x86)
407libc_common_src_files += \
408 arch-x86/bionic/__get_sp.S \
409 arch-x86/bionic/__get_tls.c \
410 arch-x86/bionic/__set_tls.c \
411 arch-x86/bionic/atomics_x86.S \
412 arch-x86/bionic/clone.S \
413 arch-x86/bionic/_exit_with_stack_teardown.S \
414 arch-x86/bionic/setjmp.S \
415 arch-x86/bionic/_setjmp.S \
Chih-Wei Huang18635d92010-12-14 17:55:23 +0800416 arch-x86/bionic/sigsetjmp.S \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800417 arch-x86/bionic/vfork.S \
Bruce Beare3c543e12010-03-04 10:29:38 -0800418 arch-x86/bionic/syscall.S \
Bruce Beare8ff1a272010-03-04 11:03:37 -0800419 arch-x86/string/bcopy_wrapper.S \
420 arch-x86/string/memcpy_wrapper.S \
421 arch-x86/string/memmove_wrapper.S \
422 arch-x86/string/bzero_wrapper.S \
423 arch-x86/string/memcmp_wrapper.S \
424 arch-x86/string/memset_wrapper.S \
425 arch-x86/string/strcmp_wrapper.S \
426 arch-x86/string/strncmp_wrapper.S \
Bruce Beare124a5422010-10-11 12:24:41 -0700427 arch-x86/string/strlen_wrapper.S \
Jim Huang73c04b32010-08-10 17:23:39 +0800428 string/strcpy.c \
Matt Fischer4f086ae2010-06-25 14:36:39 -0500429 bionic/pthread-atfork.c \
David 'Digit' Turner8a1d2cf2010-05-11 16:39:22 -0700430 bionic/pthread-rwlocks.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800431 bionic/pthread-timers.c \
432 bionic/ptrace.c
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800433
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700434libc_static_common_src_files += \
435 bionic/pthread.c \
436
Dima Zavinca122b02009-05-27 10:52:37 -0700437# this is needed for static versions of libc
438libc_arch_static_src_files := \
439 arch-x86/bionic/dl_iterate_phdr_static.c
440
441libc_arch_dynamic_src_files :=
Shin-ichiro KAWASAKI10093272009-09-28 16:11:39 +0900442else # !x86
443
444ifeq ($(TARGET_ARCH),sh)
445libc_common_src_files += \
446 arch-sh/bionic/__get_pc.S \
447 arch-sh/bionic/__get_sp.S \
448 arch-sh/bionic/_exit_with_stack_teardown.S \
449 arch-sh/bionic/_setjmp.S \
450 arch-sh/bionic/atomics_sh.c \
451 arch-sh/bionic/atomic_cmpxchg.S \
452 arch-sh/bionic/clone.S \
453 arch-sh/bionic/pipe.S \
454 arch-sh/bionic/memcpy.S \
455 arch-sh/bionic/memset.S \
456 arch-sh/bionic/bzero.S \
457 arch-sh/bionic/setjmp.S \
458 arch-sh/bionic/sigsetjmp.S \
459 arch-sh/bionic/syscall.S \
460 arch-sh/bionic/memmove.S \
461 arch-sh/bionic/__set_tls.c \
462 arch-sh/bionic/__get_tls.c \
463 arch-sh/bionic/ffs.S \
Bruce Beare8ff1a272010-03-04 11:03:37 -0800464 string/bcopy.c \
465 string/strcmp.c \
466 string/strncmp.c \
Shin-ichiro KAWASAKI10093272009-09-28 16:11:39 +0900467 string/memcmp.c \
468 string/strlen.c \
Jim Huang73c04b32010-08-10 17:23:39 +0800469 string/strcpy.c \
Matt Fischer4f086ae2010-06-25 14:36:39 -0500470 bionic/pthread-atfork.c \
David 'Digit' Turner8a1d2cf2010-05-11 16:39:22 -0700471 bionic/pthread-rwlocks.c \
Shin-ichiro KAWASAKI10093272009-09-28 16:11:39 +0900472 bionic/pthread-timers.c \
473 bionic/ptrace.c \
474 unistd/socketcalls.c
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700475
476libc_static_common_src_files += \
477 bionic/pthread.c \
478
Shin-ichiro KAWASAKI10093272009-09-28 16:11:39 +0900479endif # sh
480
481endif # !x86
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800482endif # !arm
483
Dima Zavinca122b02009-05-27 10:52:37 -0700484# Define some common cflags
485# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800486libc_common_cflags := \
487 -DWITH_ERRLIST \
488 -DANDROID_CHANGES \
489 -DUSE_LOCKS \
490 -DREALLOC_ZERO_BYTES_FREES \
491 -D_LIBC=1 \
492 -DSOFTFLOAT \
493 -DFLOATING_POINT \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800494 -DINET6 \
495 -I$(LOCAL_PATH)/private \
Colin Cross4fa7b102010-01-12 18:59:25 -0800496 -DUSE_DL_PREFIX \
David 'Digit' Turnerc51871d2011-07-06 19:02:15 +0200497 -DPOSIX_MISTAKE \
498 -DLOG_ON_HEAP_ERROR \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800499
Ajay Dudanid196aa82012-01-01 19:56:35 -0500500ifeq ($(BOARD_USES_QCOM_HARDWARE),true)
501libc_common_cflags += -DQCOM_HARDWARE
502endif
503
David 'Digit' Turnerd7ed1ae2010-03-05 14:17:35 -0800504# these macro definitions are required to implement the
505# 'timezone' and 'daylight' global variables, as well as
506# properly update the 'tm_gmtoff' field in 'struct tm'.
507#
508libc_common_cflags += \
509 -DTM_GMTOFF=tm_gmtoff \
510 -DUSG_COMPAT=1
511
Dave Bortd2c9dcc2009-04-23 15:50:03 -0700512ifeq ($(strip $(DEBUG_BIONIC_LIBC)),true)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800513 libc_common_cflags += -DDEBUG
514endif
515
516ifeq ($(TARGET_ARCH),arm)
517 libc_common_cflags += -fstrict-aliasing
Dima Zavinca122b02009-05-27 10:52:37 -0700518 libc_crt_target_cflags := -mthumb-interwork
David 'Digit' Turner4a05d122009-09-18 13:35:05 -0700519 #
520 # Define HAVE_ARM_TLS_REGISTER macro to indicate to the C library
521 # that it should access the hardware TLS register directly in
522 # private/bionic_tls.h
523 #
524 # The value must match your kernel configuration
525 #
526 ifeq ($(ARCH_ARM_HAVE_TLS_REGISTER),true)
527 libc_common_cflags += -DHAVE_ARM_TLS_REGISTER
528 endif
Harshad Bhutadac8221472011-05-05 18:27:02 +0530529
andrew.boren6e4341b2011-11-25 18:34:55 -0700530 ifeq ($(TARGET_HAVE_TEGRA_ERRATA_657451),true)
531 libc_common_cflags += -DHAVE_TEGRA_ERRATA_657451
532 endif
Harshad Bhutadac8221472011-05-05 18:27:02 +0530533
534 # Add in defines to activate SCORPION_NEON_OPTIMIZATION
535 ifeq ($(TARGET_USE_SCORPION_BIONIC_OPTIMIZATION),true)
536 libc_common_cflags += -DSCORPION_NEON_OPTIMIZATION
537 ifeq ($(TARGET_USE_SCORPION_PLD_SET),true)
538 libc_common_cflags += -DPLDOFFS=$(TARGET_SCORPION_BIONIC_PLDOFFS)
539 libc_common_cflags += -DPLDSIZE=$(TARGET_SCORPION_BIONIC_PLDSIZE)
540 endif
541 endif
542
Chitti Babu Theegalaf554a192011-11-18 10:25:58 +0530543 ifeq ($(TARGET_CORTEX_CACHE_LINE_32),true)
544 libc_common_cflags += -DCORTEX_CACHE_LINE_32
545 endif
Dima Zavinca122b02009-05-27 10:52:37 -0700546else # !arm
547 ifeq ($(TARGET_ARCH),x86)
Bruce Beare019814d2011-12-09 13:52:19 -0800548 libc_crt_target_cflags :=
549 # TARGET_GLOBAL_CFLAGS from build/core/combo/TARGET_linux-x86.mk sets all required flags.
Dima Zavinca122b02009-05-27 10:52:37 -0700550 endif # x86
551endif # !arm
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800552
Andy McFaddenfcd00eb2010-05-28 13:31:45 -0700553# Define ANDROID_SMP appropriately.
554ifeq ($(TARGET_CPU_SMP),true)
555 libc_common_cflags += -DANDROID_SMP=1
556else
557 libc_common_cflags += -DANDROID_SMP=0
558endif
559
David 'Digit' Turner6a9b8882010-06-18 14:47:22 -0700560# Needed to access private/__dso_handle.S from
561# crtbegin_xxx.S and crtend_xxx.S
562#
563libc_crt_target_cflags += -I$(LOCAL_PATH)/private
Andy McFaddenfcd00eb2010-05-28 13:31:45 -0700564
Bruce Beare39640842011-06-20 10:29:50 -0700565ifeq ($(TARGET_ARCH),arm)
566libc_crt_target_cflags += -DCRT_LEGACY_WORKAROUND
567endif
568
Dima Zavinca122b02009-05-27 10:52:37 -0700569# Define some common includes
570# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800571libc_common_c_includes := \
572 $(LOCAL_PATH)/stdlib \
573 $(LOCAL_PATH)/string \
574 $(LOCAL_PATH)/stdio
575
David 'Digit' Turner3b43f872010-07-01 23:09:28 -0700576# Needed to access private/__dso_handle.S from
577# crtbegin_xxx.S and crtend_xxx.S
578#
579libc_crt_target_cflags += -I$(LOCAL_PATH)/private
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800580
Dima Zavinca122b02009-05-27 10:52:37 -0700581# Define the libc run-time (crt) support object files that must be built,
582# which are needed to build all other objects (shared/static libs and
583# executables)
584# ==========================================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800585
David 'Digit' Turner6a9b8882010-06-18 14:47:22 -0700586ifneq ($(filter arm x86,$(TARGET_ARCH)),)
587# ARM and x86 need crtbegin_so/crtend_so.
588#
589# For x86, the .init section must point to a function that calls all
590# entries in the .ctors section. (on ARM this is done through the
591# .init_array section instead).
592#
593# For both platforms, the .fini_array section must point to a function
594# that will call __cxa_finalize(&__dso_handle) in order to ensure that
595# static C++ destructors are properly called on dlclose().
596#
David 'Digit' Turner2d2dbd32011-06-25 17:26:38 +0200597
598libc_crt_target_so_cflags := $(libc_crt_target_cflags)
599ifeq ($(TARGET_ARCH),x86)
600 # This flag must be added for x86 targets, but not for ARM
601 libc_crt_target_so_cflags += -fPIC
602endif
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800603GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_so.o
604$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin_so.S
605 @mkdir -p $(dir $@)
David 'Digit' Turner2d2dbd32011-06-25 17:26:38 +0200606 $(TARGET_CC) $(libc_crt_target_so_cflags) -o $@ -c $<
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800607ALL_GENERATED_SOURCES += $(GEN)
608
609GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_so.o
610$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtend_so.S
611 @mkdir -p $(dir $@)
David 'Digit' Turner2d2dbd32011-06-25 17:26:38 +0200612 $(TARGET_CC) $(libc_crt_target_so_cflags) -o $@ -c $<
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800613ALL_GENERATED_SOURCES += $(GEN)
David 'Digit' Turner2d2dbd32011-06-25 17:26:38 +0200614endif # TARGET_ARCH == x86 || TARGET_ARCH == arm
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800615
Dima Zavinca122b02009-05-27 10:52:37 -0700616
617GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_static.o
618$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin_static.S
619 @mkdir -p $(dir $@)
620 $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $<
621ALL_GENERATED_SOURCES += $(GEN)
622
623GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_dynamic.o
624$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin_dynamic.S
625 @mkdir -p $(dir $@)
626 $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $<
627ALL_GENERATED_SOURCES += $(GEN)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800628
629
Dima Zavinca122b02009-05-27 10:52:37 -0700630# We rename crtend.o to crtend_android.o to avoid a
631# name clash between gcc and bionic.
632GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_android.o
633$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtend.S
634 @mkdir -p $(dir $@)
635 $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $<
636ALL_GENERATED_SOURCES += $(GEN)
637
638
639# To enable malloc leak check for statically linked programs, add
640# "WITH_MALLOC_CHECK_LIBC_A := true" to buildspec.mk
641WITH_MALLOC_CHECK_LIBC_A := $(strip $(WITH_MALLOC_CHECK_LIBC_A))
642
643# ========================================================
644# libc_common.a
645# ========================================================
646include $(CLEAR_VARS)
647
648LOCAL_SRC_FILES := $(libc_common_src_files)
649LOCAL_CFLAGS := $(libc_common_cflags)
Bruce Beare39640842011-06-20 10:29:50 -0700650ifeq ($(TARGET_ARCH),arm)
651LOCAL_CFLAGS += -DCRT_LEGACY_WORKAROUND
652endif
Dima Zavinca122b02009-05-27 10:52:37 -0700653LOCAL_C_INCLUDES := $(libc_common_c_includes)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800654LOCAL_MODULE := libc_common
655LOCAL_SYSTEM_SHARED_LIBRARIES :=
656
657include $(BUILD_STATIC_LIBRARY)
658
659
Dima Zavinca122b02009-05-27 10:52:37 -0700660# ========================================================
Dima Zavin49e55332009-05-27 10:52:37 -0700661# libc_nomalloc.a
662# ========================================================
663#
664# This is a version of the static C library that does not
665# include malloc. It's useful in situations when calling
666# the user wants to provide their own malloc implementation,
667# or wants to explicitly disallow the use of the use of malloc,
668# like the dynamic loader.
669
670include $(CLEAR_VARS)
671
672LOCAL_SRC_FILES := \
673 $(libc_arch_static_src_files) \
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700674 $(libc_static_common_src_files) \
Dima Zavin49e55332009-05-27 10:52:37 -0700675 bionic/libc_init_static.c
676
677LOCAL_C_INCLUDES := $(libc_common_c_includes)
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700678LOCAL_CFLAGS := $(libc_common_cflags) \
679 -DLIBC_STATIC
Dima Zavin49e55332009-05-27 10:52:37 -0700680
681LOCAL_MODULE := libc_nomalloc
682LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
683LOCAL_SYSTEM_SHARED_LIBRARIES :=
684
685include $(BUILD_STATIC_LIBRARY)
686
687
688# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800689# libc.a
690# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800691include $(CLEAR_VARS)
692
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800693LOCAL_SRC_FILES := \
Dima Zavinca122b02009-05-27 10:52:37 -0700694 $(libc_arch_static_src_files) \
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700695 $(libc_static_common_src_files) \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800696 bionic/dlmalloc.c \
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800697 bionic/malloc_debug_common.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800698 bionic/libc_init_static.c
699
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800700LOCAL_CFLAGS := $(libc_common_cflags) \
701 -DLIBC_STATIC
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800702LOCAL_C_INCLUDES := $(libc_common_c_includes)
Dima Zavinca122b02009-05-27 10:52:37 -0700703LOCAL_MODULE := libc
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800704LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800705LOCAL_SYSTEM_SHARED_LIBRARIES :=
706
707include $(BUILD_STATIC_LIBRARY)
708
709
Dima Zavinca122b02009-05-27 10:52:37 -0700710# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800711# libc.so
712# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800713include $(CLEAR_VARS)
714
715LOCAL_CFLAGS := $(libc_common_cflags)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800716LOCAL_C_INCLUDES := $(libc_common_c_includes)
717
718LOCAL_SRC_FILES := \
Dima Zavinca122b02009-05-27 10:52:37 -0700719 $(libc_arch_dynamic_src_files) \
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700720 $(libc_static_common_src_files) \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800721 bionic/dlmalloc.c \
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800722 bionic/malloc_debug_common.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800723 bionic/libc_init_dynamic.c
724
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800725LOCAL_MODULE:= libc
726
727# WARNING: The only library libc.so should depend on is libdl.so! If you add other libraries,
728# make sure to add -Wl,--exclude-libs=libgcc.a to the LOCAL_LDFLAGS for those libraries. This
729# ensures that symbols that are pulled into those new libraries from libgcc.a are not declared
730# external; if that were the case, then libc would not pull those symbols from libgcc.a as it
731# should, instead relying on the external symbols from the dependent libraries. That would
732# create an "cloaked" dependency on libgcc.a in libc though the libraries, which is not what
733# you wanted!
734
735LOCAL_SHARED_LIBRARIES := libdl
736LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
737LOCAL_SYSTEM_SHARED_LIBRARIES :=
738
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800739include $(BUILD_SHARED_LIBRARY)
740
741
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800742# For all builds, except for the -user build we will enable memory
743# allocation checking (including memory leaks, buffer overwrites, etc.)
744# Note that all these checks are also controlled by env. settings
745# that can enable, or disable specific checks. Note also that some of
746# the checks are available only in emulator and are implemeted in
747# libc_malloc_qemu_instrumented.so.
748ifneq ($(TARGET_BUILD_VARIANT),user)
749
Dima Zavinca122b02009-05-27 10:52:37 -0700750# ========================================================
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800751# libc_malloc_debug_leak.so
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800752# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800753include $(CLEAR_VARS)
754
Dima Zavinca122b02009-05-27 10:52:37 -0700755LOCAL_CFLAGS := \
756 $(libc_common_cflags) \
757 -DMALLOC_LEAK_CHECK
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800758
759LOCAL_C_INCLUDES := $(libc_common_c_includes)
760
761LOCAL_SRC_FILES := \
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800762 bionic/malloc_debug_leak.c
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800763
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800764LOCAL_MODULE:= libc_malloc_debug_leak
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800765
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800766LOCAL_SHARED_LIBRARIES := libc
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800767LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
768LOCAL_SYSTEM_SHARED_LIBRARIES :=
Bruce Beareaa46fa22010-07-08 14:47:50 -0700769LOCAL_ALLOW_UNDEFINED_SYMBOLS := true
Iliyan Malchev36807042011-03-14 14:02:05 -0700770
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800771# Don't install on release build
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800772LOCAL_MODULE_TAGS := eng debug
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800773
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800774include $(BUILD_SHARED_LIBRARY)
775
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800776
777# ========================================================
778# libc_malloc_debug_qemu.so
779# ========================================================
780include $(CLEAR_VARS)
781
782LOCAL_CFLAGS := \
783 $(libc_common_cflags) \
784 -DMALLOC_QEMU_INSTRUMENT
785
786LOCAL_C_INCLUDES := $(libc_common_c_includes)
787
788LOCAL_SRC_FILES := \
789 bionic/malloc_debug_qemu.c
790
791LOCAL_MODULE:= libc_malloc_debug_qemu
792
793LOCAL_SHARED_LIBRARIES := libc
794LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
795LOCAL_SYSTEM_SHARED_LIBRARIES :=
Iliyan Malchev36807042011-03-14 14:02:05 -0700796
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800797# Don't install on release build
798LOCAL_MODULE_TAGS := eng debug
799
800include $(BUILD_SHARED_LIBRARY)
801
802endif #!user
803
804
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800805# ========================================================
806include $(call all-makefiles-under,$(LOCAL_PATH))