blob: 59e8e325d0558d8b553c560fe81335cc107d29d2 [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 \
Kenny Root72e64e02010-11-24 13:10:49 -080042 unistd/pread64.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080043 unistd/pselect.c \
44 unistd/ptsname.c \
45 unistd/ptsname_r.c \
46 unistd/pwrite.c \
Kenny Root72e64e02010-11-24 13:10:49 -080047 unistd/pwrite64.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080048 unistd/raise.c \
49 unistd/reboot.c \
50 unistd/recv.c \
51 unistd/sbrk.c \
52 unistd/send.c \
53 unistd/setegid.c \
Mike Chan9f691562010-03-02 10:55:58 -080054 unistd/setuid.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080055 unistd/seteuid.c \
Mike Chan9f691562010-03-02 10:55:58 -080056 unistd/setreuid.c \
57 unistd/setresuid.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080058 unistd/setpgrp.c \
59 unistd/sigblock.c \
60 unistd/siginterrupt.c \
61 unistd/siglist.c \
62 unistd/signal.c \
Thorsten Glaser92b10af2009-10-02 15:39:00 +020063 unistd/signame.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080064 unistd/sigsetmask.c \
65 unistd/sigsuspend.c \
66 unistd/sigwait.c \
67 unistd/sleep.c \
68 unistd/statfs.c \
69 unistd/strsignal.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080070 unistd/syslog.c \
71 unistd/system.c \
72 unistd/tcgetpgrp.c \
73 unistd/tcsetpgrp.c \
74 unistd/time.c \
75 unistd/umount.c \
76 unistd/unlockpt.c \
77 unistd/usleep.c \
78 unistd/wait.c \
79 stdio/asprintf.c \
80 stdio/clrerr.c \
81 stdio/fclose.c \
82 stdio/fdopen.c \
83 stdio/feof.c \
84 stdio/ferror.c \
85 stdio/fflush.c \
86 stdio/fgetc.c \
87 stdio/fgetln.c \
88 stdio/fgetpos.c \
89 stdio/fgets.c \
90 stdio/fileno.c \
91 stdio/findfp.c \
92 stdio/flags.c \
93 stdio/flockfile.c \
94 stdio/fopen.c \
95 stdio/fprintf.c \
96 stdio/fpurge.c \
97 stdio/fputc.c \
98 stdio/fputs.c \
99 stdio/fread.c \
100 stdio/freopen.c \
101 stdio/fscanf.c \
102 stdio/fseek.c \
103 stdio/fsetpos.c \
104 stdio/ftell.c \
105 stdio/funopen.c \
106 stdio/fvwrite.c \
107 stdio/fwalk.c \
108 stdio/fwrite.c \
109 stdio/getc.c \
110 stdio/getchar.c \
111 stdio/gets.c \
112 stdio/makebuf.c \
113 stdio/mktemp.c \
114 stdio/printf.c \
115 stdio/putc.c \
116 stdio/putchar.c \
117 stdio/puts.c \
118 stdio/putw.c \
119 stdio/refill.c \
120 stdio/remove.c \
121 stdio/rewind.c \
122 stdio/rget.c \
123 stdio/scanf.c \
124 stdio/setbuf.c \
125 stdio/setbuffer.c \
126 stdio/setvbuf.c \
127 stdio/snprintf.c\
128 stdio/sprintf.c \
129 stdio/sscanf.c \
130 stdio/stdio.c \
131 stdio/tempnam.c \
132 stdio/tmpfile.c \
133 stdio/tmpnam.c \
134 stdio/ungetc.c \
135 stdio/vasprintf.c \
136 stdio/vfprintf.c \
137 stdio/vfscanf.c \
138 stdio/vprintf.c \
139 stdio/vsnprintf.c \
140 stdio/vsprintf.c \
141 stdio/vscanf.c \
142 stdio/vsscanf.c \
143 stdio/wbuf.c \
144 stdio/wsetup.c \
145 stdlib/_rand48.c \
146 stdlib/assert.c \
147 stdlib/atexit.c \
148 stdlib/atoi.c \
149 stdlib/atol.c \
150 stdlib/atoll.c \
151 stdlib/bsearch.c \
152 stdlib/ctype_.c \
153 stdlib/div.c \
154 stdlib/exit.c \
155 stdlib/getenv.c \
156 stdlib/jrand48.c \
157 stdlib/ldiv.c \
158 stdlib/lldiv.c \
159 stdlib/locale.c \
160 stdlib/lrand48.c \
161 stdlib/mrand48.c \
162 stdlib/nrand48.c \
163 stdlib/putenv.c \
164 stdlib/qsort.c \
165 stdlib/seed48.c \
166 stdlib/setenv.c \
167 stdlib/setjmperr.c \
168 stdlib/srand48.c \
169 stdlib/strntoimax.c \
170 stdlib/strntoumax.c \
171 stdlib/strtod.c \
172 stdlib/strtoimax.c \
173 stdlib/strtol.c \
174 stdlib/strtoll.c \
175 stdlib/strtoul.c \
176 stdlib/strtoull.c \
177 stdlib/strtoumax.c \
178 stdlib/tolower_.c \
179 stdlib/toupper_.c \
180 stdlib/wchar.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800181 string/index.c \
182 string/memccpy.c \
183 string/memchr.c \
184 string/memmem.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800185 string/memrchr.c \
186 string/memswap.c \
187 string/strcasecmp.c \
188 string/strcasestr.c \
189 string/strcat.c \
190 string/strchr.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800191 string/strcoll.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800192 string/strcspn.c \
193 string/strdup.c \
194 string/strerror.c \
195 string/strerror_r.c \
196 string/strlcat.c \
197 string/strlcpy.c \
198 string/strncat.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800199 string/strncpy.c \
200 string/strndup.c \
201 string/strnlen.c \
202 string/strpbrk.c \
203 string/strrchr.c \
204 string/strsep.c \
205 string/strspn.c \
206 string/strstr.c \
207 string/strtok.c \
208 string/strtotimeval.c \
209 string/strxfrm.c \
David 'Digit' Turner3527fd62010-06-14 17:18:35 -0700210 wchar/wcpcpy.c \
211 wchar/wcpncpy.c \
212 wchar/wcscasecmp.c \
213 wchar/wcscat.c \
214 wchar/wcschr.c \
215 wchar/wcscmp.c \
216 wchar/wcscoll.c \
217 wchar/wcscpy.c \
218 wchar/wcscspn.c \
219 wchar/wcsdup.c \
220 wchar/wcslcat.c \
221 wchar/wcslcpy.c \
222 wchar/wcslen.c \
223 wchar/wcsncasecmp.c \
224 wchar/wcsncat.c \
225 wchar/wcsncmp.c \
226 wchar/wcsncpy.c \
227 wchar/wcsnlen.c \
228 wchar/wcspbrk.c \
229 wchar/wcsrchr.c \
230 wchar/wcsspn.c \
231 wchar/wcsstr.c \
232 wchar/wcstok.c \
233 wchar/wcswidth.c \
Kristian Monsen70465612010-06-16 14:51:52 +0100234 wchar/wcsxfrm.c \
David 'Digit' Turner3527fd62010-06-14 17:18:35 -0700235 wchar/wmemchr.c \
Kristian Monsen70465612010-06-16 14:51:52 +0100236 wchar/wmemcmp.c \
David 'Digit' Turner3527fd62010-06-14 17:18:35 -0700237 wchar/wmemcpy.c \
238 wchar/wmemmove.c \
239 wchar/wmemset.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800240 inet/bindresvport.c \
241 inet/inet_addr.c \
242 inet/inet_aton.c \
243 inet/inet_ntoa.c \
244 inet/inet_ntop.c \
245 inet/inet_pton.c \
Szymon Jakubczak41e533a2010-06-09 15:53:28 -0400246 inet/ether_aton.c \
247 inet/ether_ntoa.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800248 tzcode/asctime.c \
249 tzcode/difftime.c \
250 tzcode/localtime.c \
251 tzcode/strftime.c \
252 tzcode/strptime.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800253 bionic/__set_errno.c \
Mike Chan9f691562010-03-02 10:55:58 -0800254 bionic/cpuacct.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800255 bionic/arc4random.c \
256 bionic/basename.c \
257 bionic/basename_r.c \
Colin Crossfc10b242010-01-13 17:48:34 -0800258 bionic/clearenv.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800259 bionic/dirname.c \
260 bionic/dirname_r.c \
261 bionic/drand48.c \
262 bionic/erand48.c \
Colin Cross64ceac32010-01-13 21:19:52 -0800263 bionic/err.c \
Colin Crossfc10b242010-01-13 17:48:34 -0800264 bionic/fdprintf.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800265 bionic/fork.c \
Colin Cross64ceac32010-01-13 21:19:52 -0800266 bionic/fts.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800267 bionic/if_nametoindex.c \
268 bionic/if_indextoname.c \
269 bionic/ioctl.c \
270 bionic/ldexp.c \
271 bionic/libc_init_common.c \
272 bionic/logd_write.c \
273 bionic/md5.c \
274 bionic/pututline.c \
275 bionic/realpath.c \
276 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 \
346 arch-arm/bionic/atomics_arm.S \
347 arch-arm/bionic/clone.S \
David 'Digit' Turner6a9b8882010-06-18 14:47:22 -0700348 arch-arm/bionic/eabi.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800349 arch-arm/bionic/ffs.S \
350 arch-arm/bionic/kill.S \
David 'Digit' Turner2a7ad972009-09-29 14:43:38 -0700351 arch-arm/bionic/libgcc_compat.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800352 arch-arm/bionic/tkill.S \
353 arch-arm/bionic/memcmp.S \
354 arch-arm/bionic/memcmp16.S \
355 arch-arm/bionic/memcpy.S \
356 arch-arm/bionic/memset.S \
357 arch-arm/bionic/setjmp.S \
358 arch-arm/bionic/sigsetjmp.S \
359 arch-arm/bionic/strlen.c.arm \
Jim Huang73c04b32010-08-10 17:23:39 +0800360 arch-arm/bionic/strcpy.S \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800361 arch-arm/bionic/syscall.S \
Shin-ichiro KAWASAKI10093272009-09-28 16:11:39 +0900362 string/memmove.c.arm \
Bruce Beare8ff1a272010-03-04 11:03:37 -0800363 string/bcopy.c \
364 string/strcmp.c \
365 string/strncmp.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800366 unistd/socketcalls.c
367
368# These files need to be arm so that gdbserver
369# can set breakpoints in them without messing
370# up any thumb code.
371libc_common_src_files += \
Matt Fischer4f086ae2010-06-25 14:36:39 -0500372 bionic/pthread-atfork.c.arm \
David 'Digit' Turner8a1d2cf2010-05-11 16:39:22 -0700373 bionic/pthread-rwlocks.c.arm \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800374 bionic/pthread-timers.c.arm \
375 bionic/ptrace.c.arm
Dima Zavinca122b02009-05-27 10:52:37 -0700376
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700377libc_static_common_src_files += \
378 bionic/pthread.c.arm \
379
Dima Zavinca122b02009-05-27 10:52:37 -0700380# these are used by the static and dynamic versions of the libc
381# respectively
382libc_arch_static_src_files := \
383 arch-arm/bionic/exidx_static.c
384
385libc_arch_dynamic_src_files := \
386 arch-arm/bionic/exidx_dynamic.c
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800387else # !arm
388
389ifeq ($(TARGET_ARCH),x86)
390libc_common_src_files += \
391 arch-x86/bionic/__get_sp.S \
392 arch-x86/bionic/__get_tls.c \
393 arch-x86/bionic/__set_tls.c \
394 arch-x86/bionic/atomics_x86.S \
395 arch-x86/bionic/clone.S \
396 arch-x86/bionic/_exit_with_stack_teardown.S \
397 arch-x86/bionic/setjmp.S \
398 arch-x86/bionic/_setjmp.S \
399 arch-x86/bionic/vfork.S \
Bruce Beare3c543e12010-03-04 10:29:38 -0800400 arch-x86/bionic/syscall.S \
Bruce Beare8ff1a272010-03-04 11:03:37 -0800401 arch-x86/string/bcopy_wrapper.S \
402 arch-x86/string/memcpy_wrapper.S \
403 arch-x86/string/memmove_wrapper.S \
404 arch-x86/string/bzero_wrapper.S \
405 arch-x86/string/memcmp_wrapper.S \
406 arch-x86/string/memset_wrapper.S \
407 arch-x86/string/strcmp_wrapper.S \
408 arch-x86/string/strncmp_wrapper.S \
Bruce Beare124a5422010-10-11 12:24:41 -0700409 arch-x86/string/strlen_wrapper.S \
Jim Huang73c04b32010-08-10 17:23:39 +0800410 string/strcpy.c \
Matt Fischer4f086ae2010-06-25 14:36:39 -0500411 bionic/pthread-atfork.c \
David 'Digit' Turner8a1d2cf2010-05-11 16:39:22 -0700412 bionic/pthread-rwlocks.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800413 bionic/pthread-timers.c \
414 bionic/ptrace.c
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800415
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700416libc_static_common_src_files += \
417 bionic/pthread.c \
418
Dima Zavinca122b02009-05-27 10:52:37 -0700419# this is needed for static versions of libc
420libc_arch_static_src_files := \
421 arch-x86/bionic/dl_iterate_phdr_static.c
422
423libc_arch_dynamic_src_files :=
Shin-ichiro KAWASAKI10093272009-09-28 16:11:39 +0900424else # !x86
425
426ifeq ($(TARGET_ARCH),sh)
427libc_common_src_files += \
428 arch-sh/bionic/__get_pc.S \
429 arch-sh/bionic/__get_sp.S \
430 arch-sh/bionic/_exit_with_stack_teardown.S \
431 arch-sh/bionic/_setjmp.S \
432 arch-sh/bionic/atomics_sh.c \
433 arch-sh/bionic/atomic_cmpxchg.S \
434 arch-sh/bionic/clone.S \
435 arch-sh/bionic/pipe.S \
436 arch-sh/bionic/memcpy.S \
437 arch-sh/bionic/memset.S \
438 arch-sh/bionic/bzero.S \
439 arch-sh/bionic/setjmp.S \
440 arch-sh/bionic/sigsetjmp.S \
441 arch-sh/bionic/syscall.S \
442 arch-sh/bionic/memmove.S \
443 arch-sh/bionic/__set_tls.c \
444 arch-sh/bionic/__get_tls.c \
445 arch-sh/bionic/ffs.S \
Bruce Beare8ff1a272010-03-04 11:03:37 -0800446 string/bcopy.c \
447 string/strcmp.c \
448 string/strncmp.c \
Shin-ichiro KAWASAKI10093272009-09-28 16:11:39 +0900449 string/memcmp.c \
450 string/strlen.c \
Jim Huang73c04b32010-08-10 17:23:39 +0800451 string/strcpy.c \
Matt Fischer4f086ae2010-06-25 14:36:39 -0500452 bionic/pthread-atfork.c \
David 'Digit' Turner8a1d2cf2010-05-11 16:39:22 -0700453 bionic/pthread-rwlocks.c \
Shin-ichiro KAWASAKI10093272009-09-28 16:11:39 +0900454 bionic/pthread-timers.c \
455 bionic/ptrace.c \
456 unistd/socketcalls.c
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700457
458libc_static_common_src_files += \
459 bionic/pthread.c \
460
Shin-ichiro KAWASAKI10093272009-09-28 16:11:39 +0900461endif # sh
462
463endif # !x86
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800464endif # !arm
465
Dima Zavinca122b02009-05-27 10:52:37 -0700466# Define some common cflags
467# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800468libc_common_cflags := \
469 -DWITH_ERRLIST \
470 -DANDROID_CHANGES \
471 -DUSE_LOCKS \
472 -DREALLOC_ZERO_BYTES_FREES \
473 -D_LIBC=1 \
474 -DSOFTFLOAT \
475 -DFLOATING_POINT \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800476 -DINET6 \
477 -I$(LOCAL_PATH)/private \
Colin Cross4fa7b102010-01-12 18:59:25 -0800478 -DUSE_DL_PREFIX \
479 -DPOSIX_MISTAKE
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800480
David 'Digit' Turnerd7ed1ae2010-03-05 14:17:35 -0800481# these macro definitions are required to implement the
482# 'timezone' and 'daylight' global variables, as well as
483# properly update the 'tm_gmtoff' field in 'struct tm'.
484#
485libc_common_cflags += \
486 -DTM_GMTOFF=tm_gmtoff \
487 -DUSG_COMPAT=1
488
Dave Bortd2c9dcc2009-04-23 15:50:03 -0700489ifeq ($(strip $(DEBUG_BIONIC_LIBC)),true)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800490 libc_common_cflags += -DDEBUG
491endif
492
493ifeq ($(TARGET_ARCH),arm)
494 libc_common_cflags += -fstrict-aliasing
Dima Zavinca122b02009-05-27 10:52:37 -0700495 libc_crt_target_cflags := -mthumb-interwork
David 'Digit' Turner4a05d122009-09-18 13:35:05 -0700496 #
497 # Define HAVE_ARM_TLS_REGISTER macro to indicate to the C library
498 # that it should access the hardware TLS register directly in
499 # private/bionic_tls.h
500 #
501 # The value must match your kernel configuration
502 #
503 ifeq ($(ARCH_ARM_HAVE_TLS_REGISTER),true)
504 libc_common_cflags += -DHAVE_ARM_TLS_REGISTER
505 endif
Dima Zavinca122b02009-05-27 10:52:37 -0700506else # !arm
Chih-Wei Huang26c15a82010-07-26 11:29:08 +0800507 libc_crt_target_cflags :=
Dima Zavinca122b02009-05-27 10:52:37 -0700508endif # !arm
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800509
Andy McFaddenfcd00eb2010-05-28 13:31:45 -0700510# Define ANDROID_SMP appropriately.
511ifeq ($(TARGET_CPU_SMP),true)
512 libc_common_cflags += -DANDROID_SMP=1
513else
514 libc_common_cflags += -DANDROID_SMP=0
515endif
516
David 'Digit' Turner6a9b8882010-06-18 14:47:22 -0700517# Needed to access private/__dso_handle.S from
518# crtbegin_xxx.S and crtend_xxx.S
519#
520libc_crt_target_cflags += -I$(LOCAL_PATH)/private
Andy McFaddenfcd00eb2010-05-28 13:31:45 -0700521
Dima Zavinca122b02009-05-27 10:52:37 -0700522# Define some common includes
523# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800524libc_common_c_includes := \
525 $(LOCAL_PATH)/stdlib \
526 $(LOCAL_PATH)/string \
527 $(LOCAL_PATH)/stdio
528
David 'Digit' Turner3b43f872010-07-01 23:09:28 -0700529# Needed to access private/__dso_handle.S from
530# crtbegin_xxx.S and crtend_xxx.S
531#
532libc_crt_target_cflags += -I$(LOCAL_PATH)/private
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800533
Dima Zavinca122b02009-05-27 10:52:37 -0700534# Define the libc run-time (crt) support object files that must be built,
535# which are needed to build all other objects (shared/static libs and
536# executables)
537# ==========================================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800538
David 'Digit' Turner6a9b8882010-06-18 14:47:22 -0700539ifneq ($(filter arm x86,$(TARGET_ARCH)),)
540# ARM and x86 need crtbegin_so/crtend_so.
541#
542# For x86, the .init section must point to a function that calls all
543# entries in the .ctors section. (on ARM this is done through the
544# .init_array section instead).
545#
546# For both platforms, the .fini_array section must point to a function
547# that will call __cxa_finalize(&__dso_handle) in order to ensure that
548# static C++ destructors are properly called on dlclose().
549#
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800550GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_so.o
551$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin_so.S
552 @mkdir -p $(dir $@)
Dima Zavinca122b02009-05-27 10:52:37 -0700553 $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $<
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800554ALL_GENERATED_SOURCES += $(GEN)
555
556GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_so.o
557$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtend_so.S
558 @mkdir -p $(dir $@)
Dima Zavinca122b02009-05-27 10:52:37 -0700559 $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $<
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800560ALL_GENERATED_SOURCES += $(GEN)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800561endif # TARGET_ARCH == x86
562
Dima Zavinca122b02009-05-27 10:52:37 -0700563
564GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_static.o
565$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin_static.S
566 @mkdir -p $(dir $@)
567 $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $<
568ALL_GENERATED_SOURCES += $(GEN)
569
570GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_dynamic.o
571$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin_dynamic.S
572 @mkdir -p $(dir $@)
573 $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $<
574ALL_GENERATED_SOURCES += $(GEN)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800575
576
Dima Zavinca122b02009-05-27 10:52:37 -0700577# We rename crtend.o to crtend_android.o to avoid a
578# name clash between gcc and bionic.
579GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_android.o
580$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtend.S
581 @mkdir -p $(dir $@)
582 $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $<
583ALL_GENERATED_SOURCES += $(GEN)
584
585
586# To enable malloc leak check for statically linked programs, add
587# "WITH_MALLOC_CHECK_LIBC_A := true" to buildspec.mk
588WITH_MALLOC_CHECK_LIBC_A := $(strip $(WITH_MALLOC_CHECK_LIBC_A))
589
590# ========================================================
591# libc_common.a
592# ========================================================
593include $(CLEAR_VARS)
594
595LOCAL_SRC_FILES := $(libc_common_src_files)
596LOCAL_CFLAGS := $(libc_common_cflags)
597LOCAL_C_INCLUDES := $(libc_common_c_includes)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800598LOCAL_MODULE := libc_common
599LOCAL_SYSTEM_SHARED_LIBRARIES :=
600
601include $(BUILD_STATIC_LIBRARY)
602
603
Dima Zavinca122b02009-05-27 10:52:37 -0700604# ========================================================
Dima Zavin49e55332009-05-27 10:52:37 -0700605# libc_nomalloc.a
606# ========================================================
607#
608# This is a version of the static C library that does not
609# include malloc. It's useful in situations when calling
610# the user wants to provide their own malloc implementation,
611# or wants to explicitly disallow the use of the use of malloc,
612# like the dynamic loader.
613
614include $(CLEAR_VARS)
615
616LOCAL_SRC_FILES := \
617 $(libc_arch_static_src_files) \
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700618 $(libc_static_common_src_files) \
Dima Zavin49e55332009-05-27 10:52:37 -0700619 bionic/libc_init_static.c
620
621LOCAL_C_INCLUDES := $(libc_common_c_includes)
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700622LOCAL_CFLAGS := $(libc_common_cflags) \
623 -DLIBC_STATIC
Dima Zavin49e55332009-05-27 10:52:37 -0700624
625LOCAL_MODULE := libc_nomalloc
626LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
627LOCAL_SYSTEM_SHARED_LIBRARIES :=
628
629include $(BUILD_STATIC_LIBRARY)
630
631
632# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800633# libc.a
634# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800635include $(CLEAR_VARS)
636
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800637LOCAL_SRC_FILES := \
Dima Zavinca122b02009-05-27 10:52:37 -0700638 $(libc_arch_static_src_files) \
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700639 $(libc_static_common_src_files) \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800640 bionic/dlmalloc.c \
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800641 bionic/malloc_debug_common.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800642 bionic/libc_init_static.c
643
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800644LOCAL_CFLAGS := $(libc_common_cflags) \
645 -DLIBC_STATIC
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800646LOCAL_C_INCLUDES := $(libc_common_c_includes)
Dima Zavinca122b02009-05-27 10:52:37 -0700647LOCAL_MODULE := libc
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800648LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800649LOCAL_SYSTEM_SHARED_LIBRARIES :=
650
651include $(BUILD_STATIC_LIBRARY)
652
653
Dima Zavinca122b02009-05-27 10:52:37 -0700654# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800655# libc.so
656# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800657include $(CLEAR_VARS)
658
659LOCAL_CFLAGS := $(libc_common_cflags)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800660LOCAL_C_INCLUDES := $(libc_common_c_includes)
661
662LOCAL_SRC_FILES := \
Dima Zavinca122b02009-05-27 10:52:37 -0700663 $(libc_arch_dynamic_src_files) \
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700664 $(libc_static_common_src_files) \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800665 bionic/dlmalloc.c \
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800666 bionic/malloc_debug_common.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800667 bionic/libc_init_dynamic.c
668
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800669LOCAL_MODULE:= libc
670
671# WARNING: The only library libc.so should depend on is libdl.so! If you add other libraries,
672# make sure to add -Wl,--exclude-libs=libgcc.a to the LOCAL_LDFLAGS for those libraries. This
673# ensures that symbols that are pulled into those new libraries from libgcc.a are not declared
674# external; if that were the case, then libc would not pull those symbols from libgcc.a as it
675# should, instead relying on the external symbols from the dependent libraries. That would
676# create an "cloaked" dependency on libgcc.a in libc though the libraries, which is not what
677# you wanted!
678
679LOCAL_SHARED_LIBRARIES := libdl
680LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
681LOCAL_SYSTEM_SHARED_LIBRARIES :=
682
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800683include $(BUILD_SHARED_LIBRARY)
684
685
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800686# For all builds, except for the -user build we will enable memory
687# allocation checking (including memory leaks, buffer overwrites, etc.)
688# Note that all these checks are also controlled by env. settings
689# that can enable, or disable specific checks. Note also that some of
690# the checks are available only in emulator and are implemeted in
691# libc_malloc_qemu_instrumented.so.
692ifneq ($(TARGET_BUILD_VARIANT),user)
693
Dima Zavinca122b02009-05-27 10:52:37 -0700694# ========================================================
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800695# libc_malloc_debug_leak.so
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800696# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800697include $(CLEAR_VARS)
698
Dima Zavinca122b02009-05-27 10:52:37 -0700699LOCAL_CFLAGS := \
700 $(libc_common_cflags) \
701 -DMALLOC_LEAK_CHECK
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800702
703LOCAL_C_INCLUDES := $(libc_common_c_includes)
704
705LOCAL_SRC_FILES := \
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800706 bionic/malloc_debug_leak.c
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800707
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800708LOCAL_MODULE:= libc_malloc_debug_leak
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800709
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800710LOCAL_SHARED_LIBRARIES := libc
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800711LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
712LOCAL_SYSTEM_SHARED_LIBRARIES :=
Bruce Beareaa46fa22010-07-08 14:47:50 -0700713LOCAL_ALLOW_UNDEFINED_SYMBOLS := true
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800714# Don't prelink
715LOCAL_PRELINK_MODULE := false
716# Don't install on release build
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800717LOCAL_MODULE_TAGS := eng debug
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800718
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800719include $(BUILD_SHARED_LIBRARY)
720
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800721
722# ========================================================
723# libc_malloc_debug_qemu.so
724# ========================================================
725include $(CLEAR_VARS)
726
727LOCAL_CFLAGS := \
728 $(libc_common_cflags) \
729 -DMALLOC_QEMU_INSTRUMENT
730
731LOCAL_C_INCLUDES := $(libc_common_c_includes)
732
733LOCAL_SRC_FILES := \
734 bionic/malloc_debug_qemu.c
735
736LOCAL_MODULE:= libc_malloc_debug_qemu
737
738LOCAL_SHARED_LIBRARIES := libc
739LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
740LOCAL_SYSTEM_SHARED_LIBRARIES :=
741# Don't prelink
742LOCAL_PRELINK_MODULE := false
743# Don't install on release build
744LOCAL_MODULE_TAGS := eng debug
745
746include $(BUILD_SHARED_LIBRARY)
747
748endif #!user
749
750
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800751# ========================================================
752include $(call all-makefiles-under,$(LOCAL_PATH))