blob: 265cdb420ed41d127d258c6fe417d38ec69ad6cd [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 \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800181 string/memmem.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800182 string/memrchr.c \
183 string/memswap.c \
184 string/strcasecmp.c \
185 string/strcasestr.c \
186 string/strcat.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800187 string/strcoll.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800188 string/strcspn.c \
189 string/strdup.c \
190 string/strerror.c \
191 string/strerror_r.c \
192 string/strlcat.c \
193 string/strlcpy.c \
194 string/strncat.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800195 string/strncpy.c \
196 string/strndup.c \
197 string/strnlen.c \
198 string/strpbrk.c \
199 string/strrchr.c \
200 string/strsep.c \
201 string/strspn.c \
202 string/strstr.c \
203 string/strtok.c \
204 string/strtotimeval.c \
205 string/strxfrm.c \
David 'Digit' Turner3527fd62010-06-14 17:18:35 -0700206 wchar/wcpcpy.c \
207 wchar/wcpncpy.c \
208 wchar/wcscasecmp.c \
209 wchar/wcscat.c \
210 wchar/wcschr.c \
211 wchar/wcscmp.c \
212 wchar/wcscoll.c \
213 wchar/wcscpy.c \
214 wchar/wcscspn.c \
215 wchar/wcsdup.c \
216 wchar/wcslcat.c \
217 wchar/wcslcpy.c \
218 wchar/wcslen.c \
219 wchar/wcsncasecmp.c \
220 wchar/wcsncat.c \
221 wchar/wcsncmp.c \
222 wchar/wcsncpy.c \
223 wchar/wcsnlen.c \
224 wchar/wcspbrk.c \
225 wchar/wcsrchr.c \
226 wchar/wcsspn.c \
227 wchar/wcsstr.c \
228 wchar/wcstok.c \
229 wchar/wcswidth.c \
Kristian Monsen70465612010-06-16 14:51:52 +0100230 wchar/wcsxfrm.c \
David 'Digit' Turner3527fd62010-06-14 17:18:35 -0700231 wchar/wmemchr.c \
Kristian Monsen70465612010-06-16 14:51:52 +0100232 wchar/wmemcmp.c \
David 'Digit' Turner3527fd62010-06-14 17:18:35 -0700233 wchar/wmemcpy.c \
234 wchar/wmemmove.c \
235 wchar/wmemset.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800236 inet/bindresvport.c \
237 inet/inet_addr.c \
238 inet/inet_aton.c \
239 inet/inet_ntoa.c \
240 inet/inet_ntop.c \
241 inet/inet_pton.c \
Szymon Jakubczak41e533a2010-06-09 15:53:28 -0400242 inet/ether_aton.c \
243 inet/ether_ntoa.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800244 tzcode/asctime.c \
245 tzcode/difftime.c \
246 tzcode/localtime.c \
247 tzcode/strftime.c \
248 tzcode/strptime.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800249 bionic/__set_errno.c \
Mike Chan9f691562010-03-02 10:55:58 -0800250 bionic/cpuacct.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800251 bionic/arc4random.c \
252 bionic/basename.c \
253 bionic/basename_r.c \
Colin Crossfc10b242010-01-13 17:48:34 -0800254 bionic/clearenv.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800255 bionic/dirname.c \
256 bionic/dirname_r.c \
257 bionic/drand48.c \
258 bionic/erand48.c \
Colin Cross64ceac32010-01-13 21:19:52 -0800259 bionic/err.c \
Colin Crossfc10b242010-01-13 17:48:34 -0800260 bionic/fdprintf.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800261 bionic/fork.c \
Colin Cross64ceac32010-01-13 21:19:52 -0800262 bionic/fts.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800263 bionic/if_nametoindex.c \
264 bionic/if_indextoname.c \
265 bionic/ioctl.c \
266 bionic/ldexp.c \
267 bionic/libc_init_common.c \
268 bionic/logd_write.c \
269 bionic/md5.c \
270 bionic/pututline.c \
271 bionic/realpath.c \
David 'Digit' Turner72e6fd42010-12-03 18:04:01 +0100272 bionic/sched_getaffinity.c \
273 bionic/sched_getcpu.c \
274 bionic/sched_cpualloc.c \
275 bionic/sched_cpucount.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800276 bionic/semaphore.c \
277 bionic/sha1.c \
278 bionic/ssp.c \
279 bionic/stubs.c \
280 bionic/system_properties.c \
281 bionic/time64.c \
282 bionic/thread_atexit.c \
283 bionic/utime.c \
284 bionic/utmp.c \
285 netbsd/gethnamaddr.c \
286 netbsd/isc/ev_timers.c \
287 netbsd/isc/ev_streams.c \
288 netbsd/inet/nsap_addr.c \
289 netbsd/resolv/__dn_comp.c \
290 netbsd/resolv/__res_close.c \
291 netbsd/resolv/__res_send.c \
292 netbsd/resolv/herror.c \
293 netbsd/resolv/res_comp.c \
294 netbsd/resolv/res_data.c \
295 netbsd/resolv/res_debug.c \
296 netbsd/resolv/res_init.c \
297 netbsd/resolv/res_mkquery.c \
298 netbsd/resolv/res_query.c \
299 netbsd/resolv/res_send.c \
Shin-ichiro KAWASAKI10093272009-09-28 16:11:39 +0900300 netbsd/resolv/res_state.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800301 netbsd/resolv/res_cache.c \
302 netbsd/net/nsdispatch.c \
303 netbsd/net/getaddrinfo.c \
304 netbsd/net/getnameinfo.c \
305 netbsd/net/getservbyname.c \
306 netbsd/net/getservent.c \
307 netbsd/net/base64.c \
308 netbsd/net/getservbyport.c \
309 netbsd/nameser/ns_name.c \
310 netbsd/nameser/ns_parse.c \
311 netbsd/nameser/ns_ttl.c \
312 netbsd/nameser/ns_netint.c \
313 netbsd/nameser/ns_print.c \
Colin Cross4fa7b102010-01-12 18:59:25 -0800314 netbsd/nameser/ns_samedomain.c \
315 regex/regcomp.c \
316 regex/regerror.c \
317 regex/regexec.c \
318 regex/regfree.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800319
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700320# The following files are common, but must be compiled
321# with different C flags when building a static C library.
322#
323# The reason for this is the implementation of __get_tls()
324# that will differ between the shared and static versions
325# of the library.
326#
327# See comments in private/bionic_tls.h for more details.
328#
329# NOTE: bionic/pthread.c is added later to this list
330# because it needs special handling on ARM, see
331# below.
332#
333libc_static_common_src_files := \
334 unistd/sysconf.c \
335 bionic/__errno.c \
336
Dima Zavinca122b02009-05-27 10:52:37 -0700337# Architecture specific source files go here
338# =========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800339ifeq ($(TARGET_ARCH),arm)
340libc_common_src_files += \
David 'Digit' Turner97cf7f32010-01-22 18:59:05 -0800341 bionic/bionic_clone.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800342 arch-arm/bionic/__get_pc.S \
343 arch-arm/bionic/__get_sp.S \
344 arch-arm/bionic/_exit_with_stack_teardown.S \
345 arch-arm/bionic/_setjmp.S \
Ben Cheng8b11e0e2012-05-08 13:36:37 -0700346 arch-arm/bionic/abort_arm.S \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800347 arch-arm/bionic/atomics_arm.S \
348 arch-arm/bionic/clone.S \
David 'Digit' Turner6a9b8882010-06-18 14:47:22 -0700349 arch-arm/bionic/eabi.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800350 arch-arm/bionic/ffs.S \
351 arch-arm/bionic/kill.S \
David 'Digit' Turner2a7ad972009-09-29 14:43:38 -0700352 arch-arm/bionic/libgcc_compat.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800353 arch-arm/bionic/tkill.S \
354 arch-arm/bionic/memcmp.S \
355 arch-arm/bionic/memcmp16.S \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800356 arch-arm/bionic/setjmp.S \
357 arch-arm/bionic/sigsetjmp.S \
Jim Huangf50e9be2011-04-20 15:35:04 +0800358 arch-arm/bionic/strcmp.S \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800359 arch-arm/bionic/syscall.S \
Bruce Beare8ff1a272010-03-04 11:03:37 -0800360 string/strncmp.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800361 unistd/socketcalls.c
362
Harshad Bhutadac8221472011-05-05 18:27:02 +0530363# Check if we want a neonized version of memmove instead of the
364# current ARM version
365ifeq ($(TARGET_USE_SCORPION_BIONIC_OPTIMIZATION),true)
366libc_common_src_files += \
xkonni0e3f18c2012-06-21 03:07:53 +0200367 arch-arm/bionic/memmove.S \
368 bionic/memmove_words.c
369else
370 ifeq ($(TARGET_USE_KRAIT_BIONIC_OPTIMIZATION),true)
371 libc_common_src_files += \
Harshad Bhutadac8221472011-05-05 18:27:02 +0530372 arch-arm/bionic/memmove.S
xkonni0e3f18c2012-06-21 03:07:53 +0200373 else # Other ARM
374 libc_common_src_files += \
Harshad Bhutadac8221472011-05-05 18:27:02 +0530375 string/bcopy.c \
xkonni0e3f18c2012-06-21 03:07:53 +0200376 string/memmove.c.arm \
377 bionic/memmove_words.c
378 endif # !TARGET_USE_KRAIT_BIONIC_OPTIMIZATION
Harshad Bhutadac8221472011-05-05 18:27:02 +0530379endif # !TARGET_USE_SCORPION_BIONIC_OPTIMIZATION
380
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800381# These files need to be arm so that gdbserver
382# can set breakpoints in them without messing
383# up any thumb code.
384libc_common_src_files += \
Matt Fischer4f086ae2010-06-25 14:36:39 -0500385 bionic/pthread-atfork.c.arm \
David 'Digit' Turner8a1d2cf2010-05-11 16:39:22 -0700386 bionic/pthread-rwlocks.c.arm \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800387 bionic/pthread-timers.c.arm \
388 bionic/ptrace.c.arm
Dima Zavinca122b02009-05-27 10:52:37 -0700389
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700390libc_static_common_src_files += \
391 bionic/pthread.c.arm \
392
Dima Zavinca122b02009-05-27 10:52:37 -0700393# these are used by the static and dynamic versions of the libc
394# respectively
395libc_arch_static_src_files := \
396 arch-arm/bionic/exidx_static.c
397
398libc_arch_dynamic_src_files := \
399 arch-arm/bionic/exidx_dynamic.c
Bernhard Rosenkraenzer6fa06d72012-06-11 12:33:44 +0200400
Andrew Sutherlandc62c36b2012-06-23 19:24:45 -0500401# linaro optimized string routines are opt-in
402TARGET_USE_LINARO_STRING_ROUTINES ?= false
Andrew Sutherlandf798bdd2012-06-21 16:44:14 -0500403
404# We can only use linaro optimizations on Arm-v7a
405ifeq ($(TARGET_USE_LINARO_STRING_ROUTINES)-$(ARCH_ARM_HAVE_ARMV7A),true-true)
Bernhard Rosenkraenzer6fa06d72012-06-11 12:33:44 +0200406libc_common_src_files += \
407 arch-arm/bionic/armv7/memchr.S \
Bernhard Rosenkraenzer6fa06d72012-06-11 12:33:44 +0200408 arch-arm/bionic/armv7/strchr.S \
409 arch-arm/bionic/armv7/strcpy.c \
410 arch-arm/bionic/armv7/strlen.S
Andrew Sutherlandc62c36b2012-06-23 19:24:45 -0500411else
412libc_common_src_files += \
413 string/memchr.c \
414 string/strchr.c \
415 arch-arm/bionic/strcpy.S \
416 arch-arm/bionic/strlen.c.arm
417endif
418
419# Don't override Qcom optimizations with linaro
Andrew Sutherlandf798bdd2012-06-21 16:44:14 -0500420ifeq ($(TARGET_USE_SCORPION_BIONIC_OPTIMIZATION),true)
421libc_common_src_files += \
422 arch-arm/bionic/memcpy.S \
423 arch-arm/bionic/memset.S
Andrew Sutherlandc62c36b2012-06-23 19:24:45 -0500424else ifeq ($(TARGET_USE_KRAIT_BIONIC_OPTIMIZATION),true)
425libc_common_src_files += \
426 arch-arm/bionic/memcpy.S \
427 arch-arm/bionic/memset.S
428else ifeq ($(TARGET_USE_LINARO_STRING_ROUTINES)-$(ARCH_ARM_HAVE_ARMV7A),true-true)
Andrew Sutherlandf798bdd2012-06-21 16:44:14 -0500429libc_common_src_files += \
430 arch-arm/bionic/armv7/memcpy.S \
431 arch-arm/bionic/armv7/memset.S \
432 arch-arm/bionic/armv7/bzero.S
Andrew Sutherlandc62c36b2012-06-23 19:24:45 -0500433else # No mem optimizations
Bernhard Rosenkraenzer6fa06d72012-06-11 12:33:44 +0200434libc_common_src_files += \
Bernhard Rosenkraenzer6fa06d72012-06-11 12:33:44 +0200435 arch-arm/bionic/memcpy.S \
Andrew Sutherlandc62c36b2012-06-23 19:24:45 -0500436 arch-arm/bionic/memset.S
Bernhard Rosenkraenzer6fa06d72012-06-11 12:33:44 +0200437endif
438
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800439else # !arm
440
Bernhard Rosenkraenzer6fa06d72012-06-11 12:33:44 +0200441libc_common_src_files += \
442 string/memchr.c \
443 string/strchr.c
444
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800445ifeq ($(TARGET_ARCH),x86)
446libc_common_src_files += \
447 arch-x86/bionic/__get_sp.S \
448 arch-x86/bionic/__get_tls.c \
449 arch-x86/bionic/__set_tls.c \
450 arch-x86/bionic/atomics_x86.S \
451 arch-x86/bionic/clone.S \
452 arch-x86/bionic/_exit_with_stack_teardown.S \
453 arch-x86/bionic/setjmp.S \
454 arch-x86/bionic/_setjmp.S \
Chih-Wei Huang18635d92010-12-14 17:55:23 +0800455 arch-x86/bionic/sigsetjmp.S \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800456 arch-x86/bionic/vfork.S \
Bruce Beare3c543e12010-03-04 10:29:38 -0800457 arch-x86/bionic/syscall.S \
Bruce Beare8ff1a272010-03-04 11:03:37 -0800458 arch-x86/string/bcopy_wrapper.S \
459 arch-x86/string/memcpy_wrapper.S \
460 arch-x86/string/memmove_wrapper.S \
461 arch-x86/string/bzero_wrapper.S \
462 arch-x86/string/memcmp_wrapper.S \
463 arch-x86/string/memset_wrapper.S \
464 arch-x86/string/strcmp_wrapper.S \
465 arch-x86/string/strncmp_wrapper.S \
Bruce Beare124a5422010-10-11 12:24:41 -0700466 arch-x86/string/strlen_wrapper.S \
Jim Huang73c04b32010-08-10 17:23:39 +0800467 string/strcpy.c \
Matt Fischer4f086ae2010-06-25 14:36:39 -0500468 bionic/pthread-atfork.c \
David 'Digit' Turner8a1d2cf2010-05-11 16:39:22 -0700469 bionic/pthread-rwlocks.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800470 bionic/pthread-timers.c \
471 bionic/ptrace.c
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800472
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700473libc_static_common_src_files += \
474 bionic/pthread.c \
475
Dima Zavinca122b02009-05-27 10:52:37 -0700476# this is needed for static versions of libc
477libc_arch_static_src_files := \
478 arch-x86/bionic/dl_iterate_phdr_static.c
479
480libc_arch_dynamic_src_files :=
Shin-ichiro KAWASAKI10093272009-09-28 16:11:39 +0900481else # !x86
482
483ifeq ($(TARGET_ARCH),sh)
484libc_common_src_files += \
485 arch-sh/bionic/__get_pc.S \
486 arch-sh/bionic/__get_sp.S \
487 arch-sh/bionic/_exit_with_stack_teardown.S \
488 arch-sh/bionic/_setjmp.S \
489 arch-sh/bionic/atomics_sh.c \
490 arch-sh/bionic/atomic_cmpxchg.S \
491 arch-sh/bionic/clone.S \
492 arch-sh/bionic/pipe.S \
493 arch-sh/bionic/memcpy.S \
494 arch-sh/bionic/memset.S \
495 arch-sh/bionic/bzero.S \
496 arch-sh/bionic/setjmp.S \
497 arch-sh/bionic/sigsetjmp.S \
498 arch-sh/bionic/syscall.S \
499 arch-sh/bionic/memmove.S \
500 arch-sh/bionic/__set_tls.c \
501 arch-sh/bionic/__get_tls.c \
502 arch-sh/bionic/ffs.S \
Bruce Beare8ff1a272010-03-04 11:03:37 -0800503 string/bcopy.c \
504 string/strcmp.c \
505 string/strncmp.c \
Shin-ichiro KAWASAKI10093272009-09-28 16:11:39 +0900506 string/memcmp.c \
507 string/strlen.c \
Jim Huang73c04b32010-08-10 17:23:39 +0800508 string/strcpy.c \
Matt Fischer4f086ae2010-06-25 14:36:39 -0500509 bionic/pthread-atfork.c \
David 'Digit' Turner8a1d2cf2010-05-11 16:39:22 -0700510 bionic/pthread-rwlocks.c \
Shin-ichiro KAWASAKI10093272009-09-28 16:11:39 +0900511 bionic/pthread-timers.c \
512 bionic/ptrace.c \
513 unistd/socketcalls.c
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700514
515libc_static_common_src_files += \
516 bionic/pthread.c \
517
Shin-ichiro KAWASAKI10093272009-09-28 16:11:39 +0900518endif # sh
519
520endif # !x86
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800521endif # !arm
522
Dima Zavinca122b02009-05-27 10:52:37 -0700523# Define some common cflags
524# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800525libc_common_cflags := \
526 -DWITH_ERRLIST \
527 -DANDROID_CHANGES \
528 -DUSE_LOCKS \
529 -DREALLOC_ZERO_BYTES_FREES \
530 -D_LIBC=1 \
531 -DSOFTFLOAT \
532 -DFLOATING_POINT \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800533 -DINET6 \
534 -I$(LOCAL_PATH)/private \
Colin Cross4fa7b102010-01-12 18:59:25 -0800535 -DUSE_DL_PREFIX \
David 'Digit' Turnerc51871d2011-07-06 19:02:15 +0200536 -DPOSIX_MISTAKE \
537 -DLOG_ON_HEAP_ERROR \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800538
Ajay Dudanid196aa82012-01-01 19:56:35 -0500539ifeq ($(BOARD_USES_QCOM_HARDWARE),true)
540libc_common_cflags += -DQCOM_HARDWARE
541endif
542
David 'Digit' Turnerd7ed1ae2010-03-05 14:17:35 -0800543# these macro definitions are required to implement the
544# 'timezone' and 'daylight' global variables, as well as
545# properly update the 'tm_gmtoff' field in 'struct tm'.
546#
547libc_common_cflags += \
548 -DTM_GMTOFF=tm_gmtoff \
549 -DUSG_COMPAT=1
550
Dave Bortd2c9dcc2009-04-23 15:50:03 -0700551ifeq ($(strip $(DEBUG_BIONIC_LIBC)),true)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800552 libc_common_cflags += -DDEBUG
553endif
554
555ifeq ($(TARGET_ARCH),arm)
556 libc_common_cflags += -fstrict-aliasing
Dima Zavinca122b02009-05-27 10:52:37 -0700557 libc_crt_target_cflags := -mthumb-interwork
David 'Digit' Turner4a05d122009-09-18 13:35:05 -0700558 #
559 # Define HAVE_ARM_TLS_REGISTER macro to indicate to the C library
560 # that it should access the hardware TLS register directly in
561 # private/bionic_tls.h
562 #
563 # The value must match your kernel configuration
564 #
565 ifeq ($(ARCH_ARM_HAVE_TLS_REGISTER),true)
566 libc_common_cflags += -DHAVE_ARM_TLS_REGISTER
567 endif
Harshad Bhutadac8221472011-05-05 18:27:02 +0530568
andrew.boren6e4341b2011-11-25 18:34:55 -0700569 ifeq ($(TARGET_HAVE_TEGRA_ERRATA_657451),true)
570 libc_common_cflags += -DHAVE_TEGRA_ERRATA_657451
571 endif
Harshad Bhutadac8221472011-05-05 18:27:02 +0530572
573 # Add in defines to activate SCORPION_NEON_OPTIMIZATION
574 ifeq ($(TARGET_USE_SCORPION_BIONIC_OPTIMIZATION),true)
575 libc_common_cflags += -DSCORPION_NEON_OPTIMIZATION
576 ifeq ($(TARGET_USE_SCORPION_PLD_SET),true)
577 libc_common_cflags += -DPLDOFFS=$(TARGET_SCORPION_BIONIC_PLDOFFS)
578 libc_common_cflags += -DPLDSIZE=$(TARGET_SCORPION_BIONIC_PLDSIZE)
579 endif
580 endif
xkonni0e3f18c2012-06-21 03:07:53 +0200581 # Add in defines to activate KRAIT_NEON_OPTIMIZATION
582 ifeq ($(TARGET_USE_KRAIT_BIONIC_OPTIMIZATION),true)
583 libc_common_cflags += -DKRAIT_NEON_OPTIMIZATION
584 ifeq ($(TARGET_USE_KRAIT_PLD_SET),true)
585 libc_common_cflags += -DPLDOFFS=$(TARGET_KRAIT_BIONIC_PLDOFFS)
586 libc_common_cflags += -DPLDTHRESH=$(TARGET_KRAIT_BIONIC_PLDTHRESH)
587 libc_common_cflags += -DPLDSIZE=$(TARGET_KRAIT_BIONIC_PLDSIZE)
588 libc_common_cflags += -DBBTHRESH=$(TARGET_KRAIT_BIONIC_BBTHRESH)
589 endif
590 endif
Chitti Babu Theegalaf554a192011-11-18 10:25:58 +0530591 ifeq ($(TARGET_CORTEX_CACHE_LINE_32),true)
592 libc_common_cflags += -DCORTEX_CACHE_LINE_32
593 endif
Dima Zavinca122b02009-05-27 10:52:37 -0700594else # !arm
595 ifeq ($(TARGET_ARCH),x86)
Bruce Beare019814d2011-12-09 13:52:19 -0800596 libc_crt_target_cflags :=
597 # TARGET_GLOBAL_CFLAGS from build/core/combo/TARGET_linux-x86.mk sets all required flags.
Dima Zavinca122b02009-05-27 10:52:37 -0700598 endif # x86
599endif # !arm
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800600
Andy McFaddenfcd00eb2010-05-28 13:31:45 -0700601# Define ANDROID_SMP appropriately.
602ifeq ($(TARGET_CPU_SMP),true)
603 libc_common_cflags += -DANDROID_SMP=1
604else
605 libc_common_cflags += -DANDROID_SMP=0
606endif
607
David 'Digit' Turner6a9b8882010-06-18 14:47:22 -0700608# Needed to access private/__dso_handle.S from
609# crtbegin_xxx.S and crtend_xxx.S
610#
611libc_crt_target_cflags += -I$(LOCAL_PATH)/private
Andy McFaddenfcd00eb2010-05-28 13:31:45 -0700612
Bruce Beare39640842011-06-20 10:29:50 -0700613ifeq ($(TARGET_ARCH),arm)
614libc_crt_target_cflags += -DCRT_LEGACY_WORKAROUND
615endif
616
Dima Zavinca122b02009-05-27 10:52:37 -0700617# Define some common includes
618# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800619libc_common_c_includes := \
620 $(LOCAL_PATH)/stdlib \
621 $(LOCAL_PATH)/string \
622 $(LOCAL_PATH)/stdio
623
David 'Digit' Turner3b43f872010-07-01 23:09:28 -0700624# Needed to access private/__dso_handle.S from
625# crtbegin_xxx.S and crtend_xxx.S
626#
627libc_crt_target_cflags += -I$(LOCAL_PATH)/private
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800628
Dima Zavinca122b02009-05-27 10:52:37 -0700629# Define the libc run-time (crt) support object files that must be built,
630# which are needed to build all other objects (shared/static libs and
631# executables)
632# ==========================================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800633
David 'Digit' Turner6a9b8882010-06-18 14:47:22 -0700634ifneq ($(filter arm x86,$(TARGET_ARCH)),)
635# ARM and x86 need crtbegin_so/crtend_so.
636#
637# For x86, the .init section must point to a function that calls all
638# entries in the .ctors section. (on ARM this is done through the
639# .init_array section instead).
640#
641# For both platforms, the .fini_array section must point to a function
642# that will call __cxa_finalize(&__dso_handle) in order to ensure that
643# static C++ destructors are properly called on dlclose().
644#
David 'Digit' Turner2d2dbd32011-06-25 17:26:38 +0200645
646libc_crt_target_so_cflags := $(libc_crt_target_cflags)
647ifeq ($(TARGET_ARCH),x86)
648 # This flag must be added for x86 targets, but not for ARM
649 libc_crt_target_so_cflags += -fPIC
650endif
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800651GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_so.o
652$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin_so.S
653 @mkdir -p $(dir $@)
David 'Digit' Turner2d2dbd32011-06-25 17:26:38 +0200654 $(TARGET_CC) $(libc_crt_target_so_cflags) -o $@ -c $<
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800655ALL_GENERATED_SOURCES += $(GEN)
656
657GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_so.o
658$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtend_so.S
659 @mkdir -p $(dir $@)
David 'Digit' Turner2d2dbd32011-06-25 17:26:38 +0200660 $(TARGET_CC) $(libc_crt_target_so_cflags) -o $@ -c $<
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800661ALL_GENERATED_SOURCES += $(GEN)
David 'Digit' Turner2d2dbd32011-06-25 17:26:38 +0200662endif # TARGET_ARCH == x86 || TARGET_ARCH == arm
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800663
Dima Zavinca122b02009-05-27 10:52:37 -0700664
665GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_static.o
666$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin_static.S
667 @mkdir -p $(dir $@)
668 $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $<
669ALL_GENERATED_SOURCES += $(GEN)
670
671GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_dynamic.o
672$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin_dynamic.S
673 @mkdir -p $(dir $@)
674 $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $<
675ALL_GENERATED_SOURCES += $(GEN)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800676
677
Dima Zavinca122b02009-05-27 10:52:37 -0700678# We rename crtend.o to crtend_android.o to avoid a
679# name clash between gcc and bionic.
680GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_android.o
681$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtend.S
682 @mkdir -p $(dir $@)
683 $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $<
684ALL_GENERATED_SOURCES += $(GEN)
685
686
687# To enable malloc leak check for statically linked programs, add
688# "WITH_MALLOC_CHECK_LIBC_A := true" to buildspec.mk
689WITH_MALLOC_CHECK_LIBC_A := $(strip $(WITH_MALLOC_CHECK_LIBC_A))
690
691# ========================================================
692# libc_common.a
693# ========================================================
694include $(CLEAR_VARS)
695
696LOCAL_SRC_FILES := $(libc_common_src_files)
697LOCAL_CFLAGS := $(libc_common_cflags)
Bruce Beare39640842011-06-20 10:29:50 -0700698ifeq ($(TARGET_ARCH),arm)
699LOCAL_CFLAGS += -DCRT_LEGACY_WORKAROUND
700endif
Dima Zavinca122b02009-05-27 10:52:37 -0700701LOCAL_C_INCLUDES := $(libc_common_c_includes)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800702LOCAL_MODULE := libc_common
703LOCAL_SYSTEM_SHARED_LIBRARIES :=
704
705include $(BUILD_STATIC_LIBRARY)
706
707
Dima Zavinca122b02009-05-27 10:52:37 -0700708# ========================================================
Dima Zavin49e55332009-05-27 10:52:37 -0700709# libc_nomalloc.a
710# ========================================================
711#
712# This is a version of the static C library that does not
713# include malloc. It's useful in situations when calling
714# the user wants to provide their own malloc implementation,
715# or wants to explicitly disallow the use of the use of malloc,
716# like the dynamic loader.
717
718include $(CLEAR_VARS)
719
720LOCAL_SRC_FILES := \
721 $(libc_arch_static_src_files) \
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700722 $(libc_static_common_src_files) \
Dima Zavin49e55332009-05-27 10:52:37 -0700723 bionic/libc_init_static.c
724
725LOCAL_C_INCLUDES := $(libc_common_c_includes)
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700726LOCAL_CFLAGS := $(libc_common_cflags) \
727 -DLIBC_STATIC
Dima Zavin49e55332009-05-27 10:52:37 -0700728
729LOCAL_MODULE := libc_nomalloc
730LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
731LOCAL_SYSTEM_SHARED_LIBRARIES :=
732
733include $(BUILD_STATIC_LIBRARY)
734
735
736# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800737# libc.a
738# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800739include $(CLEAR_VARS)
740
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800741LOCAL_SRC_FILES := \
Dima Zavinca122b02009-05-27 10:52:37 -0700742 $(libc_arch_static_src_files) \
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700743 $(libc_static_common_src_files) \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800744 bionic/dlmalloc.c \
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800745 bionic/malloc_debug_common.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800746 bionic/libc_init_static.c
747
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800748LOCAL_CFLAGS := $(libc_common_cflags) \
749 -DLIBC_STATIC
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800750LOCAL_C_INCLUDES := $(libc_common_c_includes)
Dima Zavinca122b02009-05-27 10:52:37 -0700751LOCAL_MODULE := libc
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800752LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800753LOCAL_SYSTEM_SHARED_LIBRARIES :=
754
755include $(BUILD_STATIC_LIBRARY)
756
757
Dima Zavinca122b02009-05-27 10:52:37 -0700758# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800759# libc.so
760# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800761include $(CLEAR_VARS)
762
763LOCAL_CFLAGS := $(libc_common_cflags)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800764LOCAL_C_INCLUDES := $(libc_common_c_includes)
765
766LOCAL_SRC_FILES := \
Dima Zavinca122b02009-05-27 10:52:37 -0700767 $(libc_arch_dynamic_src_files) \
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700768 $(libc_static_common_src_files) \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800769 bionic/dlmalloc.c \
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800770 bionic/malloc_debug_common.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800771 bionic/libc_init_dynamic.c
772
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800773LOCAL_MODULE:= libc
774
775# WARNING: The only library libc.so should depend on is libdl.so! If you add other libraries,
776# make sure to add -Wl,--exclude-libs=libgcc.a to the LOCAL_LDFLAGS for those libraries. This
777# ensures that symbols that are pulled into those new libraries from libgcc.a are not declared
778# external; if that were the case, then libc would not pull those symbols from libgcc.a as it
779# should, instead relying on the external symbols from the dependent libraries. That would
780# create an "cloaked" dependency on libgcc.a in libc though the libraries, which is not what
781# you wanted!
782
783LOCAL_SHARED_LIBRARIES := libdl
784LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
785LOCAL_SYSTEM_SHARED_LIBRARIES :=
786
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800787include $(BUILD_SHARED_LIBRARY)
788
789
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800790# For all builds, except for the -user build we will enable memory
791# allocation checking (including memory leaks, buffer overwrites, etc.)
792# Note that all these checks are also controlled by env. settings
793# that can enable, or disable specific checks. Note also that some of
794# the checks are available only in emulator and are implemeted in
795# libc_malloc_qemu_instrumented.so.
796ifneq ($(TARGET_BUILD_VARIANT),user)
797
Dima Zavinca122b02009-05-27 10:52:37 -0700798# ========================================================
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800799# libc_malloc_debug_leak.so
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800800# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800801include $(CLEAR_VARS)
802
Dima Zavinca122b02009-05-27 10:52:37 -0700803LOCAL_CFLAGS := \
804 $(libc_common_cflags) \
805 -DMALLOC_LEAK_CHECK
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800806
807LOCAL_C_INCLUDES := $(libc_common_c_includes)
808
809LOCAL_SRC_FILES := \
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800810 bionic/malloc_debug_leak.c
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800811
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800812LOCAL_MODULE:= libc_malloc_debug_leak
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800813
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800814LOCAL_SHARED_LIBRARIES := libc
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800815LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
816LOCAL_SYSTEM_SHARED_LIBRARIES :=
Bruce Beareaa46fa22010-07-08 14:47:50 -0700817LOCAL_ALLOW_UNDEFINED_SYMBOLS := true
Iliyan Malchev36807042011-03-14 14:02:05 -0700818
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800819# Don't install on release build
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800820LOCAL_MODULE_TAGS := eng debug
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800821
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800822include $(BUILD_SHARED_LIBRARY)
823
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800824
825# ========================================================
826# libc_malloc_debug_qemu.so
827# ========================================================
828include $(CLEAR_VARS)
829
830LOCAL_CFLAGS := \
831 $(libc_common_cflags) \
832 -DMALLOC_QEMU_INSTRUMENT
833
834LOCAL_C_INCLUDES := $(libc_common_c_includes)
835
836LOCAL_SRC_FILES := \
837 bionic/malloc_debug_qemu.c
838
839LOCAL_MODULE:= libc_malloc_debug_qemu
840
841LOCAL_SHARED_LIBRARIES := libc
842LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
843LOCAL_SYSTEM_SHARED_LIBRARIES :=
Iliyan Malchev36807042011-03-14 14:02:05 -0700844
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800845# Don't install on release build
846LOCAL_MODULE_TAGS := eng debug
847
848include $(BUILD_SHARED_LIBRARY)
849
850endif #!user
851
852
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800853# ========================================================
854include $(call all-makefiles-under,$(LOCAL_PATH))