blob: 70a52439fb9f157c14654805566acbe6f444bf95 [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 \
Nick Kralevich0a230152012-06-04 15:20:25 -0700208 string/__memcpy_chk.c \
209 string/__memmove_chk.c \
Nick Kralevich71a18dd2012-06-07 14:01:26 -0700210 string/__memset_chk.c \
Nick Kralevich0a230152012-06-04 15:20:25 -0700211 string/__strcat_chk.c \
212 string/__strcpy_chk.c \
213 string/__strncat_chk.c \
214 string/__strncpy_chk.c \
David 'Digit' Turner3527fd62010-06-14 17:18:35 -0700215 wchar/wcpcpy.c \
216 wchar/wcpncpy.c \
217 wchar/wcscasecmp.c \
218 wchar/wcscat.c \
219 wchar/wcschr.c \
220 wchar/wcscmp.c \
221 wchar/wcscoll.c \
222 wchar/wcscpy.c \
223 wchar/wcscspn.c \
224 wchar/wcsdup.c \
225 wchar/wcslcat.c \
226 wchar/wcslcpy.c \
227 wchar/wcslen.c \
228 wchar/wcsncasecmp.c \
229 wchar/wcsncat.c \
230 wchar/wcsncmp.c \
231 wchar/wcsncpy.c \
232 wchar/wcsnlen.c \
233 wchar/wcspbrk.c \
234 wchar/wcsrchr.c \
235 wchar/wcsspn.c \
236 wchar/wcsstr.c \
237 wchar/wcstok.c \
238 wchar/wcswidth.c \
Kristian Monsen70465612010-06-16 14:51:52 +0100239 wchar/wcsxfrm.c \
David 'Digit' Turner3527fd62010-06-14 17:18:35 -0700240 wchar/wmemchr.c \
Kristian Monsen70465612010-06-16 14:51:52 +0100241 wchar/wmemcmp.c \
David 'Digit' Turner3527fd62010-06-14 17:18:35 -0700242 wchar/wmemcpy.c \
243 wchar/wmemmove.c \
244 wchar/wmemset.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800245 inet/bindresvport.c \
246 inet/inet_addr.c \
247 inet/inet_aton.c \
248 inet/inet_ntoa.c \
249 inet/inet_ntop.c \
250 inet/inet_pton.c \
Szymon Jakubczak41e533a2010-06-09 15:53:28 -0400251 inet/ether_aton.c \
252 inet/ether_ntoa.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800253 tzcode/asctime.c \
254 tzcode/difftime.c \
255 tzcode/localtime.c \
256 tzcode/strftime.c \
257 tzcode/strptime.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800258 bionic/__set_errno.c \
Mike Chan9f691562010-03-02 10:55:58 -0800259 bionic/cpuacct.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800260 bionic/arc4random.c \
261 bionic/basename.c \
262 bionic/basename_r.c \
Colin Crossfc10b242010-01-13 17:48:34 -0800263 bionic/clearenv.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800264 bionic/dirname.c \
265 bionic/dirname_r.c \
266 bionic/drand48.c \
267 bionic/erand48.c \
Colin Cross64ceac32010-01-13 21:19:52 -0800268 bionic/err.c \
Colin Crossfc10b242010-01-13 17:48:34 -0800269 bionic/fdprintf.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800270 bionic/fork.c \
Colin Cross64ceac32010-01-13 21:19:52 -0800271 bionic/fts.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800272 bionic/if_nametoindex.c \
273 bionic/if_indextoname.c \
274 bionic/ioctl.c \
275 bionic/ldexp.c \
276 bionic/libc_init_common.c \
277 bionic/logd_write.c \
278 bionic/md5.c \
Andy McFadden4ce737f2011-02-04 14:45:57 -0800279 bionic/memmove_words.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800280 bionic/pututline.c \
281 bionic/realpath.c \
David 'Digit' Turner72e6fd42010-12-03 18:04:01 +0100282 bionic/sched_getaffinity.c \
283 bionic/sched_getcpu.c \
284 bionic/sched_cpualloc.c \
285 bionic/sched_cpucount.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800286 bionic/semaphore.c \
287 bionic/sha1.c \
288 bionic/ssp.c \
289 bionic/stubs.c \
290 bionic/system_properties.c \
Ben Cheng21eab512012-03-13 23:04:57 -0700291 bionic/tdelete.c \
292 bionic/tdestroy.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800293 bionic/time64.c \
Ben Cheng21eab512012-03-13 23:04:57 -0700294 bionic/tfind.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800295 bionic/thread_atexit.c \
Ben Cheng21eab512012-03-13 23:04:57 -0700296 bionic/tsearch.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800297 bionic/utime.c \
298 bionic/utmp.c \
299 netbsd/gethnamaddr.c \
300 netbsd/isc/ev_timers.c \
301 netbsd/isc/ev_streams.c \
302 netbsd/inet/nsap_addr.c \
303 netbsd/resolv/__dn_comp.c \
304 netbsd/resolv/__res_close.c \
305 netbsd/resolv/__res_send.c \
306 netbsd/resolv/herror.c \
307 netbsd/resolv/res_comp.c \
308 netbsd/resolv/res_data.c \
309 netbsd/resolv/res_debug.c \
310 netbsd/resolv/res_init.c \
311 netbsd/resolv/res_mkquery.c \
312 netbsd/resolv/res_query.c \
313 netbsd/resolv/res_send.c \
Shin-ichiro KAWASAKI10093272009-09-28 16:11:39 +0900314 netbsd/resolv/res_state.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800315 netbsd/resolv/res_cache.c \
316 netbsd/net/nsdispatch.c \
317 netbsd/net/getaddrinfo.c \
318 netbsd/net/getnameinfo.c \
319 netbsd/net/getservbyname.c \
320 netbsd/net/getservent.c \
321 netbsd/net/base64.c \
322 netbsd/net/getservbyport.c \
323 netbsd/nameser/ns_name.c \
324 netbsd/nameser/ns_parse.c \
325 netbsd/nameser/ns_ttl.c \
326 netbsd/nameser/ns_netint.c \
327 netbsd/nameser/ns_print.c \
Colin Cross4fa7b102010-01-12 18:59:25 -0800328 netbsd/nameser/ns_samedomain.c \
329 regex/regcomp.c \
330 regex/regerror.c \
331 regex/regexec.c \
332 regex/regfree.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800333
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700334# The following files are common, but must be compiled
335# with different C flags when building a static C library.
336#
337# The reason for this is the implementation of __get_tls()
338# that will differ between the shared and static versions
339# of the library.
340#
341# See comments in private/bionic_tls.h for more details.
342#
343# NOTE: bionic/pthread.c is added later to this list
344# because it needs special handling on ARM, see
345# below.
346#
347libc_static_common_src_files := \
348 unistd/sysconf.c \
349 bionic/__errno.c \
350
Dima Zavinca122b02009-05-27 10:52:37 -0700351# Architecture specific source files go here
352# =========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800353ifeq ($(TARGET_ARCH),arm)
354libc_common_src_files += \
David 'Digit' Turner97cf7f32010-01-22 18:59:05 -0800355 bionic/bionic_clone.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800356 arch-arm/bionic/__get_pc.S \
357 arch-arm/bionic/__get_sp.S \
358 arch-arm/bionic/_exit_with_stack_teardown.S \
359 arch-arm/bionic/_setjmp.S \
Ben Cheng017f4382012-05-08 13:36:37 -0700360 arch-arm/bionic/abort_arm.S \
David 'Digit' Turner0fec6b92011-11-16 17:37:15 +0100361 arch-arm/bionic/atomics_arm.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800362 arch-arm/bionic/clone.S \
David 'Digit' Turner6a9b8882010-06-18 14:47:22 -0700363 arch-arm/bionic/eabi.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800364 arch-arm/bionic/ffs.S \
David 'Digit' Turner0fec6b92011-11-16 17:37:15 +0100365 arch-arm/bionic/futex_arm.S \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800366 arch-arm/bionic/kill.S \
David 'Digit' Turner2a7ad972009-09-29 14:43:38 -0700367 arch-arm/bionic/libgcc_compat.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800368 arch-arm/bionic/tkill.S \
Jeff Brown10c8ce52011-11-18 15:17:07 -0800369 arch-arm/bionic/tgkill.S \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800370 arch-arm/bionic/memcmp.S \
371 arch-arm/bionic/memcmp16.S \
372 arch-arm/bionic/memcpy.S \
373 arch-arm/bionic/memset.S \
374 arch-arm/bionic/setjmp.S \
375 arch-arm/bionic/sigsetjmp.S \
376 arch-arm/bionic/strlen.c.arm \
Jim Huang73c04b32010-08-10 17:23:39 +0800377 arch-arm/bionic/strcpy.S \
Jim Huangf50e9be2011-04-20 15:35:04 +0800378 arch-arm/bionic/strcmp.S \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800379 arch-arm/bionic/syscall.S \
Shin-ichiro KAWASAKI10093272009-09-28 16:11:39 +0900380 string/memmove.c.arm \
Bruce Beare8ff1a272010-03-04 11:03:37 -0800381 string/bcopy.c \
Bruce Beare8ff1a272010-03-04 11:03:37 -0800382 string/strncmp.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800383 unistd/socketcalls.c
384
385# 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 \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800411 arch-x86/bionic/clone.S \
412 arch-x86/bionic/_exit_with_stack_teardown.S \
David 'Digit' Turner0fec6b92011-11-16 17:37:15 +0100413 arch-x86/bionic/futex_x86.S \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800414 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
Shin-ichiro KAWASAKI10093272009-09-28 16:11:39 +0900444endif # !x86
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800445endif # !arm
446
Dima Zavinca122b02009-05-27 10:52:37 -0700447# Define some common cflags
448# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800449libc_common_cflags := \
Elliott Hughes470631e2012-06-06 10:32:56 -0700450 -DWITH_ERRLIST \
451 -DANDROID_CHANGES \
452 -DUSE_LOCKS \
453 -DREALLOC_ZERO_BYTES_FREES \
454 -D_LIBC=1 \
455 -DSOFTFLOAT \
456 -DFLOATING_POINT \
457 -DINET6 \
458 -I$(LOCAL_PATH)/private \
459 -DUSE_DL_PREFIX \
460 -DPOSIX_MISTAKE \
461 -DLOG_ON_HEAP_ERROR \
462 -std=gnu99
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800463
David 'Digit' Turnerd7ed1ae2010-03-05 14:17:35 -0800464# these macro definitions are required to implement the
465# 'timezone' and 'daylight' global variables, as well as
466# properly update the 'tm_gmtoff' field in 'struct tm'.
467#
468libc_common_cflags += \
469 -DTM_GMTOFF=tm_gmtoff \
470 -DUSG_COMPAT=1
471
Dave Bortd2c9dcc2009-04-23 15:50:03 -0700472ifeq ($(strip $(DEBUG_BIONIC_LIBC)),true)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800473 libc_common_cflags += -DDEBUG
474endif
475
Jack Ren2fd81ef2011-11-19 09:48:03 +0800476# To customize dlmalloc's alignment, set BOARD_MALLOC_ALIGNMENT in
477# the appropriate BoardConfig.mk file.
478#
479ifneq ($(BOARD_MALLOC_ALIGNMENT),)
480 libc_common_cflags += -DMALLOC_ALIGNMENT=$(BOARD_MALLOC_ALIGNMENT)
481endif
482
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800483ifeq ($(TARGET_ARCH),arm)
484 libc_common_cflags += -fstrict-aliasing
Dima Zavinca122b02009-05-27 10:52:37 -0700485 libc_crt_target_cflags := -mthumb-interwork
David 'Digit' Turner4a05d122009-09-18 13:35:05 -0700486 #
487 # Define HAVE_ARM_TLS_REGISTER macro to indicate to the C library
488 # that it should access the hardware TLS register directly in
489 # private/bionic_tls.h
490 #
491 # The value must match your kernel configuration
492 #
493 ifeq ($(ARCH_ARM_HAVE_TLS_REGISTER),true)
494 libc_common_cflags += -DHAVE_ARM_TLS_REGISTER
495 endif
Henrik Smidingfe6338d2010-09-15 16:08:03 +0200496 #
497 # Define HAVE_32_BYTE_CACHE_LINES to indicate to C
498 # library it should use to 32-byte version of memcpy, and not
499 # the 64-byte version.
500 #
501 ifeq ($(ARCH_ARM_HAVE_32_BYTE_CACHE_LINES),true)
502 libc_common_cflags += -DHAVE_32_BYTE_CACHE_LINE
503 endif
Prajakta Gudadhe08e72d02012-05-07 14:17:44 -0700504 ifeq ($(ARCH_ARM_USE_NON_NEON_MEMCPY),true)
505 libc_common_cflags += -DARCH_ARM_USE_NON_NEON_MEMCPY
506 endif
Dima Zavinca122b02009-05-27 10:52:37 -0700507else # !arm
508 ifeq ($(TARGET_ARCH),x86)
Bruce Beareaf96d4d2011-12-09 13:52:19 -0800509 libc_crt_target_cflags :=
David 'Digit' Turnera5cb76b2011-12-14 18:23:40 +0100510 ifeq ($(ARCH_X86_HAVE_SSE2),true)
511 libc_crt_target_cflags += -DUSE_SSE2=1
512 endif
513 ifeq ($(ARCH_X86_HAVE_SSSE3),true)
514 libc_crt_target_cflags += -DUSE_SSSE3=1
515 endif
Dima Zavinca122b02009-05-27 10:52:37 -0700516 endif # x86
517endif # !arm
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800518
Andy McFaddenfcd00eb2010-05-28 13:31:45 -0700519# Define ANDROID_SMP appropriately.
520ifeq ($(TARGET_CPU_SMP),true)
521 libc_common_cflags += -DANDROID_SMP=1
522else
523 libc_common_cflags += -DANDROID_SMP=0
524endif
525
Nick Kralevich9d403262012-05-31 11:40:10 -0700526# Needed to access private/__dso_handle.h from
527# crtbegin_xxx.c and crtend_xxx.c
David 'Digit' Turner6a9b8882010-06-18 14:47:22 -0700528#
529libc_crt_target_cflags += -I$(LOCAL_PATH)/private
Andy McFaddenfcd00eb2010-05-28 13:31:45 -0700530
Bruce Beare39640842011-06-20 10:29:50 -0700531ifeq ($(TARGET_ARCH),arm)
532libc_crt_target_cflags += -DCRT_LEGACY_WORKAROUND
533endif
534
Dima Zavinca122b02009-05-27 10:52:37 -0700535# Define some common includes
536# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800537libc_common_c_includes := \
538 $(LOCAL_PATH)/stdlib \
539 $(LOCAL_PATH)/string \
540 $(LOCAL_PATH)/stdio
541
Nick Kralevich9d403262012-05-31 11:40:10 -0700542# Needed to access private/__dso_handle.h from
David 'Digit' Turner3b43f872010-07-01 23:09:28 -0700543# crtbegin_xxx.S and crtend_xxx.S
544#
Kenny Root03273f82012-04-10 17:24:24 -0700545libc_crt_target_cflags += -I$(LOCAL_PATH)/private -I$(LOCAL_PATH)/arch-$(TARGET_ARCH)/include
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800546
Dima Zavinca122b02009-05-27 10:52:37 -0700547# Define the libc run-time (crt) support object files that must be built,
548# which are needed to build all other objects (shared/static libs and
549# executables)
550# ==========================================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800551
David 'Digit' Turner6a9b8882010-06-18 14:47:22 -0700552ifneq ($(filter arm x86,$(TARGET_ARCH)),)
553# ARM and x86 need crtbegin_so/crtend_so.
554#
555# For x86, the .init section must point to a function that calls all
556# entries in the .ctors section. (on ARM this is done through the
557# .init_array section instead).
558#
559# For both platforms, the .fini_array section must point to a function
560# that will call __cxa_finalize(&__dso_handle) in order to ensure that
561# static C++ destructors are properly called on dlclose().
562#
David 'Digit' Turner2d2dbd32011-06-25 17:26:38 +0200563
564libc_crt_target_so_cflags := $(libc_crt_target_cflags)
Nick Kralevich9d403262012-05-31 11:40:10 -0700565libc_crt_target_crtstart_file := $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin.c
566libc_crt_target_crtstart_so_file := $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin_so.c
David 'Digit' Turner2d2dbd32011-06-25 17:26:38 +0200567ifeq ($(TARGET_ARCH),x86)
568 # This flag must be added for x86 targets, but not for ARM
569 libc_crt_target_so_cflags += -fPIC
Nick Kralevich9d403262012-05-31 11:40:10 -0700570 libc_crt_target_crtstart_file := $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin.S
571 libc_crt_target_crtstart_so_file := $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin_so.S
David 'Digit' Turner2d2dbd32011-06-25 17:26:38 +0200572endif
Ying Wangfc9e5252012-05-15 15:15:11 -0700573GEN := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_so.o
Nick Kralevich9d403262012-05-31 11:40:10 -0700574$(GEN): $(libc_crt_target_crtstart_so_file)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800575 @mkdir -p $(dir $@)
David 'Digit' Turner2d2dbd32011-06-25 17:26:38 +0200576 $(TARGET_CC) $(libc_crt_target_so_cflags) -o $@ -c $<
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800577ALL_GENERATED_SOURCES += $(GEN)
578
Ying Wangfc9e5252012-05-15 15:15:11 -0700579GEN := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_so.o
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800580$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtend_so.S
581 @mkdir -p $(dir $@)
David 'Digit' Turner2d2dbd32011-06-25 17:26:38 +0200582 $(TARGET_CC) $(libc_crt_target_so_cflags) -o $@ -c $<
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800583ALL_GENERATED_SOURCES += $(GEN)
David 'Digit' Turner2d2dbd32011-06-25 17:26:38 +0200584endif # TARGET_ARCH == x86 || TARGET_ARCH == arm
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800585
Dima Zavinca122b02009-05-27 10:52:37 -0700586
Ying Wangfc9e5252012-05-15 15:15:11 -0700587GEN := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_static.o
Nick Kralevich9d403262012-05-31 11:40:10 -0700588$(GEN): $(libc_crt_target_crtstart_file)
Dima Zavinca122b02009-05-27 10:52:37 -0700589 @mkdir -p $(dir $@)
590 $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $<
591ALL_GENERATED_SOURCES += $(GEN)
592
Ying Wangfc9e5252012-05-15 15:15:11 -0700593GEN := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_dynamic.o
Nick Kralevich9d403262012-05-31 11:40:10 -0700594$(GEN): $(libc_crt_target_crtstart_file)
Dima Zavinca122b02009-05-27 10:52:37 -0700595 @mkdir -p $(dir $@)
596 $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $<
597ALL_GENERATED_SOURCES += $(GEN)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800598
599
Dima Zavinca122b02009-05-27 10:52:37 -0700600# We rename crtend.o to crtend_android.o to avoid a
601# name clash between gcc and bionic.
Ying Wangfc9e5252012-05-15 15:15:11 -0700602GEN := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_android.o
Dima Zavinca122b02009-05-27 10:52:37 -0700603$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtend.S
604 @mkdir -p $(dir $@)
605 $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $<
606ALL_GENERATED_SOURCES += $(GEN)
607
608
609# To enable malloc leak check for statically linked programs, add
610# "WITH_MALLOC_CHECK_LIBC_A := true" to buildspec.mk
611WITH_MALLOC_CHECK_LIBC_A := $(strip $(WITH_MALLOC_CHECK_LIBC_A))
612
613# ========================================================
614# libc_common.a
615# ========================================================
616include $(CLEAR_VARS)
617
618LOCAL_SRC_FILES := $(libc_common_src_files)
619LOCAL_CFLAGS := $(libc_common_cflags)
Bruce Beare39640842011-06-20 10:29:50 -0700620ifeq ($(TARGET_ARCH),arm)
621LOCAL_CFLAGS += -DCRT_LEGACY_WORKAROUND
622endif
Dima Zavinca122b02009-05-27 10:52:37 -0700623LOCAL_C_INCLUDES := $(libc_common_c_includes)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800624LOCAL_MODULE := libc_common
625LOCAL_SYSTEM_SHARED_LIBRARIES :=
626
627include $(BUILD_STATIC_LIBRARY)
628
629
Dima Zavinca122b02009-05-27 10:52:37 -0700630# ========================================================
Dima Zavin49e55332009-05-27 10:52:37 -0700631# libc_nomalloc.a
632# ========================================================
633#
634# This is a version of the static C library that does not
635# include malloc. It's useful in situations when calling
636# the user wants to provide their own malloc implementation,
637# or wants to explicitly disallow the use of the use of malloc,
638# like the dynamic loader.
639
640include $(CLEAR_VARS)
641
642LOCAL_SRC_FILES := \
643 $(libc_arch_static_src_files) \
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700644 $(libc_static_common_src_files) \
Dima Zavin49e55332009-05-27 10:52:37 -0700645 bionic/libc_init_static.c
646
647LOCAL_C_INCLUDES := $(libc_common_c_includes)
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700648LOCAL_CFLAGS := $(libc_common_cflags) \
649 -DLIBC_STATIC
Dima Zavin49e55332009-05-27 10:52:37 -0700650
651LOCAL_MODULE := libc_nomalloc
652LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
653LOCAL_SYSTEM_SHARED_LIBRARIES :=
654
655include $(BUILD_STATIC_LIBRARY)
656
657
658# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800659# libc.a
660# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800661include $(CLEAR_VARS)
662
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800663LOCAL_SRC_FILES := \
Dima Zavinca122b02009-05-27 10:52:37 -0700664 $(libc_arch_static_src_files) \
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700665 $(libc_static_common_src_files) \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800666 bionic/dlmalloc.c \
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800667 bionic/malloc_debug_common.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800668 bionic/libc_init_static.c
669
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800670LOCAL_CFLAGS := $(libc_common_cflags) \
671 -DLIBC_STATIC
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800672LOCAL_C_INCLUDES := $(libc_common_c_includes)
Dima Zavinca122b02009-05-27 10:52:37 -0700673LOCAL_MODULE := libc
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800674LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800675LOCAL_SYSTEM_SHARED_LIBRARIES :=
676
677include $(BUILD_STATIC_LIBRARY)
678
679
Dima Zavinca122b02009-05-27 10:52:37 -0700680# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800681# libc.so
682# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800683include $(CLEAR_VARS)
684
Mathias Agopian7c0c3792011-09-05 23:54:55 -0700685# pthread deadlock prediction:
686# set -DPTHREAD_DEBUG -DPTHREAD_DEBUG_ENABLED=1 to enable support for
687# pthread deadlock prediction.
688# Since this code is experimental it is disabled by default.
689# see libc/bionic/pthread_debug.c for details
690
691LOCAL_CFLAGS := $(libc_common_cflags) -DPTHREAD_DEBUG -DPTHREAD_DEBUG_ENABLED=0
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800692LOCAL_C_INCLUDES := $(libc_common_c_includes)
693
694LOCAL_SRC_FILES := \
Dima Zavinca122b02009-05-27 10:52:37 -0700695 $(libc_arch_dynamic_src_files) \
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700696 $(libc_static_common_src_files) \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800697 bionic/dlmalloc.c \
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800698 bionic/malloc_debug_common.c \
Mathias Agopian7c0c3792011-09-05 23:54:55 -0700699 bionic/pthread_debug.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800700 bionic/libc_init_dynamic.c
701
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800702LOCAL_MODULE:= libc
703
704# WARNING: The only library libc.so should depend on is libdl.so! If you add other libraries,
705# make sure to add -Wl,--exclude-libs=libgcc.a to the LOCAL_LDFLAGS for those libraries. This
706# ensures that symbols that are pulled into those new libraries from libgcc.a are not declared
707# external; if that were the case, then libc would not pull those symbols from libgcc.a as it
708# should, instead relying on the external symbols from the dependent libraries. That would
709# create an "cloaked" dependency on libgcc.a in libc though the libraries, which is not what
710# you wanted!
711
712LOCAL_SHARED_LIBRARIES := libdl
713LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
714LOCAL_SYSTEM_SHARED_LIBRARIES :=
715
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800716include $(BUILD_SHARED_LIBRARY)
717
718
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800719# For all builds, except for the -user build we will enable memory
720# allocation checking (including memory leaks, buffer overwrites, etc.)
721# Note that all these checks are also controlled by env. settings
722# that can enable, or disable specific checks. Note also that some of
723# the checks are available only in emulator and are implemeted in
724# libc_malloc_qemu_instrumented.so.
725ifneq ($(TARGET_BUILD_VARIANT),user)
726
Dima Zavinca122b02009-05-27 10:52:37 -0700727# ========================================================
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800728# libc_malloc_debug_leak.so
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800729# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800730include $(CLEAR_VARS)
731
Dima Zavinca122b02009-05-27 10:52:37 -0700732LOCAL_CFLAGS := \
733 $(libc_common_cflags) \
734 -DMALLOC_LEAK_CHECK
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800735
736LOCAL_C_INCLUDES := $(libc_common_c_includes)
737
738LOCAL_SRC_FILES := \
Iliyan Malcheve1dd3c22012-05-29 14:22:42 -0700739 bionic/malloc_debug_leak.c \
740 bionic/malloc_debug_check.c \
741 bionic/malloc_debug_check_mapinfo.c \
742 bionic/malloc_debug_stacktrace.c
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800743
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800744LOCAL_MODULE:= libc_malloc_debug_leak
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800745
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800746LOCAL_SHARED_LIBRARIES := libc
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800747LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
748LOCAL_SYSTEM_SHARED_LIBRARIES :=
Bruce Beareaa46fa22010-07-08 14:47:50 -0700749LOCAL_ALLOW_UNDEFINED_SYMBOLS := true
Iliyan Malchev36807042011-03-14 14:02:05 -0700750
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800751# Don't install on release build
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800752LOCAL_MODULE_TAGS := eng debug
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800753
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800754include $(BUILD_SHARED_LIBRARY)
755
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800756
757# ========================================================
758# libc_malloc_debug_qemu.so
759# ========================================================
760include $(CLEAR_VARS)
761
762LOCAL_CFLAGS := \
763 $(libc_common_cflags) \
764 -DMALLOC_QEMU_INSTRUMENT
765
766LOCAL_C_INCLUDES := $(libc_common_c_includes)
767
768LOCAL_SRC_FILES := \
769 bionic/malloc_debug_qemu.c
770
771LOCAL_MODULE:= libc_malloc_debug_qemu
772
Mathias Agopian7c0c3792011-09-05 23:54:55 -0700773LOCAL_SHARED_LIBRARIES := libc libdl
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800774LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
775LOCAL_SYSTEM_SHARED_LIBRARIES :=
Iliyan Malchev36807042011-03-14 14:02:05 -0700776
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800777# Don't install on release build
778LOCAL_MODULE_TAGS := eng debug
779
780include $(BUILD_SHARED_LIBRARY)
781
782endif #!user
783
784
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800785# ========================================================
786include $(call all-makefiles-under,$(LOCAL_PATH))