blob: f339dd42c58b201ca9d676af08e3d748129ea74f [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 \
14 unistd/exec.c \
15 unistd/fcntl.c \
16 unistd/fnmatch.c \
David 'Digit' Turnerab8b5412010-07-08 16:52:27 -070017 unistd/fstatfs.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080018 unistd/ftime.c \
19 unistd/ftok.c \
20 unistd/getcwd.c \
21 unistd/getdtablesize.c \
22 unistd/gethostname.c \
23 unistd/getopt_long.c \
24 unistd/getpgrp.c \
25 unistd/getpriority.c \
26 unistd/getpt.c \
27 unistd/initgroups.c \
28 unistd/isatty.c \
29 unistd/issetugid.c \
Colin Cross8c59d962010-01-13 16:39:26 -080030 unistd/killpg.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080031 unistd/lseek64.c \
32 unistd/mmap.c \
33 unistd/nice.c \
34 unistd/open.c \
35 unistd/openat.c \
36 unistd/opendir.c \
37 unistd/pathconf.c \
38 unistd/perror.c \
39 unistd/popen.c \
40 unistd/pread.c \
41 unistd/pselect.c \
42 unistd/ptsname.c \
43 unistd/ptsname_r.c \
44 unistd/pwrite.c \
45 unistd/raise.c \
46 unistd/reboot.c \
47 unistd/recv.c \
48 unistd/sbrk.c \
49 unistd/send.c \
50 unistd/setegid.c \
Mike Chan9f691562010-03-02 10:55:58 -080051 unistd/setuid.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080052 unistd/seteuid.c \
Mike Chan9f691562010-03-02 10:55:58 -080053 unistd/setreuid.c \
54 unistd/setresuid.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080055 unistd/setpgrp.c \
56 unistd/sigblock.c \
57 unistd/siginterrupt.c \
58 unistd/siglist.c \
59 unistd/signal.c \
Thorsten Glaser92b10af2009-10-02 15:39:00 +020060 unistd/signame.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080061 unistd/sigsetmask.c \
62 unistd/sigsuspend.c \
63 unistd/sigwait.c \
64 unistd/sleep.c \
65 unistd/statfs.c \
66 unistd/strsignal.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080067 unistd/syslog.c \
68 unistd/system.c \
69 unistd/tcgetpgrp.c \
70 unistd/tcsetpgrp.c \
71 unistd/time.c \
72 unistd/umount.c \
73 unistd/unlockpt.c \
74 unistd/usleep.c \
75 unistd/wait.c \
76 stdio/asprintf.c \
77 stdio/clrerr.c \
78 stdio/fclose.c \
79 stdio/fdopen.c \
80 stdio/feof.c \
81 stdio/ferror.c \
82 stdio/fflush.c \
83 stdio/fgetc.c \
84 stdio/fgetln.c \
85 stdio/fgetpos.c \
86 stdio/fgets.c \
87 stdio/fileno.c \
88 stdio/findfp.c \
89 stdio/flags.c \
90 stdio/flockfile.c \
91 stdio/fopen.c \
92 stdio/fprintf.c \
93 stdio/fpurge.c \
94 stdio/fputc.c \
95 stdio/fputs.c \
96 stdio/fread.c \
97 stdio/freopen.c \
98 stdio/fscanf.c \
99 stdio/fseek.c \
100 stdio/fsetpos.c \
101 stdio/ftell.c \
102 stdio/funopen.c \
103 stdio/fvwrite.c \
104 stdio/fwalk.c \
105 stdio/fwrite.c \
106 stdio/getc.c \
107 stdio/getchar.c \
108 stdio/gets.c \
109 stdio/makebuf.c \
110 stdio/mktemp.c \
111 stdio/printf.c \
112 stdio/putc.c \
113 stdio/putchar.c \
114 stdio/puts.c \
115 stdio/putw.c \
116 stdio/refill.c \
117 stdio/remove.c \
118 stdio/rewind.c \
119 stdio/rget.c \
120 stdio/scanf.c \
121 stdio/setbuf.c \
122 stdio/setbuffer.c \
123 stdio/setvbuf.c \
124 stdio/snprintf.c\
125 stdio/sprintf.c \
126 stdio/sscanf.c \
127 stdio/stdio.c \
128 stdio/tempnam.c \
129 stdio/tmpfile.c \
130 stdio/tmpnam.c \
131 stdio/ungetc.c \
132 stdio/vasprintf.c \
133 stdio/vfprintf.c \
134 stdio/vfscanf.c \
135 stdio/vprintf.c \
136 stdio/vsnprintf.c \
137 stdio/vsprintf.c \
138 stdio/vscanf.c \
139 stdio/vsscanf.c \
140 stdio/wbuf.c \
141 stdio/wsetup.c \
142 stdlib/_rand48.c \
143 stdlib/assert.c \
144 stdlib/atexit.c \
145 stdlib/atoi.c \
146 stdlib/atol.c \
147 stdlib/atoll.c \
148 stdlib/bsearch.c \
149 stdlib/ctype_.c \
150 stdlib/div.c \
151 stdlib/exit.c \
152 stdlib/getenv.c \
153 stdlib/jrand48.c \
154 stdlib/ldiv.c \
155 stdlib/lldiv.c \
156 stdlib/locale.c \
157 stdlib/lrand48.c \
158 stdlib/mrand48.c \
159 stdlib/nrand48.c \
160 stdlib/putenv.c \
161 stdlib/qsort.c \
162 stdlib/seed48.c \
163 stdlib/setenv.c \
164 stdlib/setjmperr.c \
165 stdlib/srand48.c \
166 stdlib/strntoimax.c \
167 stdlib/strntoumax.c \
168 stdlib/strtod.c \
169 stdlib/strtoimax.c \
170 stdlib/strtol.c \
171 stdlib/strtoll.c \
172 stdlib/strtoul.c \
173 stdlib/strtoull.c \
174 stdlib/strtoumax.c \
175 stdlib/tolower_.c \
176 stdlib/toupper_.c \
177 stdlib/wchar.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800178 string/index.c \
179 string/memccpy.c \
180 string/memchr.c \
181 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 \
187 string/strchr.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800188 string/strcoll.c \
189 string/strcpy.c \
190 string/strcspn.c \
191 string/strdup.c \
192 string/strerror.c \
193 string/strerror_r.c \
194 string/strlcat.c \
195 string/strlcpy.c \
196 string/strncat.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800197 string/strncpy.c \
198 string/strndup.c \
199 string/strnlen.c \
200 string/strpbrk.c \
201 string/strrchr.c \
202 string/strsep.c \
203 string/strspn.c \
204 string/strstr.c \
205 string/strtok.c \
206 string/strtotimeval.c \
207 string/strxfrm.c \
David 'Digit' Turner3527fd62010-06-14 17:18:35 -0700208 wchar/wcpcpy.c \
209 wchar/wcpncpy.c \
210 wchar/wcscasecmp.c \
211 wchar/wcscat.c \
212 wchar/wcschr.c \
213 wchar/wcscmp.c \
214 wchar/wcscoll.c \
215 wchar/wcscpy.c \
216 wchar/wcscspn.c \
217 wchar/wcsdup.c \
218 wchar/wcslcat.c \
219 wchar/wcslcpy.c \
220 wchar/wcslen.c \
221 wchar/wcsncasecmp.c \
222 wchar/wcsncat.c \
223 wchar/wcsncmp.c \
224 wchar/wcsncpy.c \
225 wchar/wcsnlen.c \
226 wchar/wcspbrk.c \
227 wchar/wcsrchr.c \
228 wchar/wcsspn.c \
229 wchar/wcsstr.c \
230 wchar/wcstok.c \
231 wchar/wcswidth.c \
Kristian Monsen70465612010-06-16 14:51:52 +0100232 wchar/wcsxfrm.c \
David 'Digit' Turner3527fd62010-06-14 17:18:35 -0700233 wchar/wmemchr.c \
Kristian Monsen70465612010-06-16 14:51:52 +0100234 wchar/wmemcmp.c \
David 'Digit' Turner3527fd62010-06-14 17:18:35 -0700235 wchar/wmemcpy.c \
236 wchar/wmemmove.c \
237 wchar/wmemset.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800238 inet/bindresvport.c \
239 inet/inet_addr.c \
240 inet/inet_aton.c \
241 inet/inet_ntoa.c \
242 inet/inet_ntop.c \
243 inet/inet_pton.c \
Szymon Jakubczak41e533a2010-06-09 15:53:28 -0400244 inet/ether_aton.c \
245 inet/ether_ntoa.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800246 tzcode/asctime.c \
247 tzcode/difftime.c \
248 tzcode/localtime.c \
249 tzcode/strftime.c \
250 tzcode/strptime.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800251 bionic/__set_errno.c \
252 bionic/_rand48.c \
Mike Chan9f691562010-03-02 10:55:58 -0800253 bionic/cpuacct.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800254 bionic/arc4random.c \
255 bionic/basename.c \
256 bionic/basename_r.c \
Colin Crossfc10b242010-01-13 17:48:34 -0800257 bionic/clearenv.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800258 bionic/dirname.c \
259 bionic/dirname_r.c \
260 bionic/drand48.c \
261 bionic/erand48.c \
Colin Cross64ceac32010-01-13 21:19:52 -0800262 bionic/err.c \
Colin Crossfc10b242010-01-13 17:48:34 -0800263 bionic/fdprintf.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800264 bionic/fork.c \
Colin Cross64ceac32010-01-13 21:19:52 -0800265 bionic/fts.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800266 bionic/if_nametoindex.c \
267 bionic/if_indextoname.c \
268 bionic/ioctl.c \
269 bionic/ldexp.c \
270 bionic/libc_init_common.c \
271 bionic/logd_write.c \
272 bionic/md5.c \
273 bionic/pututline.c \
274 bionic/realpath.c \
275 bionic/semaphore.c \
276 bionic/sha1.c \
277 bionic/ssp.c \
278 bionic/stubs.c \
279 bionic/system_properties.c \
280 bionic/time64.c \
281 bionic/thread_atexit.c \
282 bionic/utime.c \
283 bionic/utmp.c \
284 netbsd/gethnamaddr.c \
285 netbsd/isc/ev_timers.c \
286 netbsd/isc/ev_streams.c \
287 netbsd/inet/nsap_addr.c \
288 netbsd/resolv/__dn_comp.c \
289 netbsd/resolv/__res_close.c \
290 netbsd/resolv/__res_send.c \
291 netbsd/resolv/herror.c \
292 netbsd/resolv/res_comp.c \
293 netbsd/resolv/res_data.c \
294 netbsd/resolv/res_debug.c \
295 netbsd/resolv/res_init.c \
296 netbsd/resolv/res_mkquery.c \
297 netbsd/resolv/res_query.c \
298 netbsd/resolv/res_send.c \
Shin-ichiro KAWASAKI10093272009-09-28 16:11:39 +0900299 netbsd/resolv/res_state.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800300 netbsd/resolv/res_cache.c \
301 netbsd/net/nsdispatch.c \
302 netbsd/net/getaddrinfo.c \
303 netbsd/net/getnameinfo.c \
304 netbsd/net/getservbyname.c \
305 netbsd/net/getservent.c \
306 netbsd/net/base64.c \
307 netbsd/net/getservbyport.c \
308 netbsd/nameser/ns_name.c \
309 netbsd/nameser/ns_parse.c \
310 netbsd/nameser/ns_ttl.c \
311 netbsd/nameser/ns_netint.c \
312 netbsd/nameser/ns_print.c \
Colin Cross4fa7b102010-01-12 18:59:25 -0800313 netbsd/nameser/ns_samedomain.c \
314 regex/regcomp.c \
315 regex/regerror.c \
316 regex/regexec.c \
317 regex/regfree.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800318
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700319# The following files are common, but must be compiled
320# with different C flags when building a static C library.
321#
322# The reason for this is the implementation of __get_tls()
323# that will differ between the shared and static versions
324# of the library.
325#
326# See comments in private/bionic_tls.h for more details.
327#
328# NOTE: bionic/pthread.c is added later to this list
329# because it needs special handling on ARM, see
330# below.
331#
332libc_static_common_src_files := \
333 unistd/sysconf.c \
334 bionic/__errno.c \
335
Dima Zavinca122b02009-05-27 10:52:37 -0700336# Architecture specific source files go here
337# =========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800338ifeq ($(TARGET_ARCH),arm)
339libc_common_src_files += \
David 'Digit' Turner97cf7f32010-01-22 18:59:05 -0800340 bionic/bionic_clone.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800341 arch-arm/bionic/__get_pc.S \
342 arch-arm/bionic/__get_sp.S \
343 arch-arm/bionic/_exit_with_stack_teardown.S \
344 arch-arm/bionic/_setjmp.S \
345 arch-arm/bionic/atomics_arm.S \
346 arch-arm/bionic/clone.S \
David 'Digit' Turner6a9b8882010-06-18 14:47:22 -0700347 arch-arm/bionic/eabi.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800348 arch-arm/bionic/ffs.S \
349 arch-arm/bionic/kill.S \
David 'Digit' Turner2a7ad972009-09-29 14:43:38 -0700350 arch-arm/bionic/libgcc_compat.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800351 arch-arm/bionic/tkill.S \
352 arch-arm/bionic/memcmp.S \
353 arch-arm/bionic/memcmp16.S \
354 arch-arm/bionic/memcpy.S \
355 arch-arm/bionic/memset.S \
356 arch-arm/bionic/setjmp.S \
357 arch-arm/bionic/sigsetjmp.S \
358 arch-arm/bionic/strlen.c.arm \
359 arch-arm/bionic/syscall.S \
Shin-ichiro KAWASAKI10093272009-09-28 16:11:39 +0900360 string/memmove.c.arm \
Bruce Beare8ff1a272010-03-04 11:03:37 -0800361 string/bcopy.c \
362 string/strcmp.c \
363 string/strncmp.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800364 unistd/socketcalls.c
365
366# These files need to be arm so that gdbserver
367# can set breakpoints in them without messing
368# up any thumb code.
369libc_common_src_files += \
Matt Fischer4f086ae2010-06-25 14:36:39 -0500370 bionic/pthread-atfork.c.arm \
David 'Digit' Turner8a1d2cf2010-05-11 16:39:22 -0700371 bionic/pthread-rwlocks.c.arm \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800372 bionic/pthread-timers.c.arm \
373 bionic/ptrace.c.arm
Dima Zavinca122b02009-05-27 10:52:37 -0700374
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700375libc_static_common_src_files += \
376 bionic/pthread.c.arm \
377
Dima Zavinca122b02009-05-27 10:52:37 -0700378# these are used by the static and dynamic versions of the libc
379# respectively
380libc_arch_static_src_files := \
381 arch-arm/bionic/exidx_static.c
382
383libc_arch_dynamic_src_files := \
384 arch-arm/bionic/exidx_dynamic.c
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800385else # !arm
386
387ifeq ($(TARGET_ARCH),x86)
388libc_common_src_files += \
389 arch-x86/bionic/__get_sp.S \
390 arch-x86/bionic/__get_tls.c \
391 arch-x86/bionic/__set_tls.c \
392 arch-x86/bionic/atomics_x86.S \
393 arch-x86/bionic/clone.S \
394 arch-x86/bionic/_exit_with_stack_teardown.S \
395 arch-x86/bionic/setjmp.S \
396 arch-x86/bionic/_setjmp.S \
397 arch-x86/bionic/vfork.S \
Bruce Beare3c543e12010-03-04 10:29:38 -0800398 arch-x86/bionic/syscall.S \
Bruce Beare8ff1a272010-03-04 11:03:37 -0800399 arch-x86/string/bcopy_wrapper.S \
400 arch-x86/string/memcpy_wrapper.S \
401 arch-x86/string/memmove_wrapper.S \
402 arch-x86/string/bzero_wrapper.S \
403 arch-x86/string/memcmp_wrapper.S \
404 arch-x86/string/memset_wrapper.S \
405 arch-x86/string/strcmp_wrapper.S \
406 arch-x86/string/strncmp_wrapper.S \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800407 arch-x86/string/strlen.S \
Matt Fischer4f086ae2010-06-25 14:36:39 -0500408 bionic/pthread-atfork.c \
David 'Digit' Turner8a1d2cf2010-05-11 16:39:22 -0700409 bionic/pthread-rwlocks.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800410 bionic/pthread-timers.c \
411 bionic/ptrace.c
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800412
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700413libc_static_common_src_files += \
414 bionic/pthread.c \
415
Dima Zavinca122b02009-05-27 10:52:37 -0700416# this is needed for static versions of libc
417libc_arch_static_src_files := \
418 arch-x86/bionic/dl_iterate_phdr_static.c
419
420libc_arch_dynamic_src_files :=
Shin-ichiro KAWASAKI10093272009-09-28 16:11:39 +0900421else # !x86
422
423ifeq ($(TARGET_ARCH),sh)
424libc_common_src_files += \
425 arch-sh/bionic/__get_pc.S \
426 arch-sh/bionic/__get_sp.S \
427 arch-sh/bionic/_exit_with_stack_teardown.S \
428 arch-sh/bionic/_setjmp.S \
429 arch-sh/bionic/atomics_sh.c \
430 arch-sh/bionic/atomic_cmpxchg.S \
431 arch-sh/bionic/clone.S \
432 arch-sh/bionic/pipe.S \
433 arch-sh/bionic/memcpy.S \
434 arch-sh/bionic/memset.S \
435 arch-sh/bionic/bzero.S \
436 arch-sh/bionic/setjmp.S \
437 arch-sh/bionic/sigsetjmp.S \
438 arch-sh/bionic/syscall.S \
439 arch-sh/bionic/memmove.S \
440 arch-sh/bionic/__set_tls.c \
441 arch-sh/bionic/__get_tls.c \
442 arch-sh/bionic/ffs.S \
Bruce Beare8ff1a272010-03-04 11:03:37 -0800443 string/bcopy.c \
444 string/strcmp.c \
445 string/strncmp.c \
Shin-ichiro KAWASAKI10093272009-09-28 16:11:39 +0900446 string/memcmp.c \
447 string/strlen.c \
Matt Fischer4f086ae2010-06-25 14:36:39 -0500448 bionic/pthread-atfork.c \
David 'Digit' Turner8a1d2cf2010-05-11 16:39:22 -0700449 bionic/pthread-rwlocks.c \
Shin-ichiro KAWASAKI10093272009-09-28 16:11:39 +0900450 bionic/pthread-timers.c \
451 bionic/ptrace.c \
452 unistd/socketcalls.c
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700453
454libc_static_common_src_files += \
455 bionic/pthread.c \
456
Shin-ichiro KAWASAKI10093272009-09-28 16:11:39 +0900457endif # sh
458
459endif # !x86
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800460endif # !arm
461
Dima Zavinca122b02009-05-27 10:52:37 -0700462# Define some common cflags
463# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800464libc_common_cflags := \
465 -DWITH_ERRLIST \
466 -DANDROID_CHANGES \
467 -DUSE_LOCKS \
468 -DREALLOC_ZERO_BYTES_FREES \
469 -D_LIBC=1 \
470 -DSOFTFLOAT \
471 -DFLOATING_POINT \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800472 -DINET6 \
473 -I$(LOCAL_PATH)/private \
Colin Cross4fa7b102010-01-12 18:59:25 -0800474 -DUSE_DL_PREFIX \
475 -DPOSIX_MISTAKE
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800476
David 'Digit' Turnerd7ed1ae2010-03-05 14:17:35 -0800477# these macro definitions are required to implement the
478# 'timezone' and 'daylight' global variables, as well as
479# properly update the 'tm_gmtoff' field in 'struct tm'.
480#
481libc_common_cflags += \
482 -DTM_GMTOFF=tm_gmtoff \
483 -DUSG_COMPAT=1
484
Dave Bortd2c9dcc2009-04-23 15:50:03 -0700485ifeq ($(strip $(DEBUG_BIONIC_LIBC)),true)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800486 libc_common_cflags += -DDEBUG
487endif
488
489ifeq ($(TARGET_ARCH),arm)
490 libc_common_cflags += -fstrict-aliasing
Dima Zavinca122b02009-05-27 10:52:37 -0700491 libc_crt_target_cflags := -mthumb-interwork
David 'Digit' Turner4a05d122009-09-18 13:35:05 -0700492 #
493 # Define HAVE_ARM_TLS_REGISTER macro to indicate to the C library
494 # that it should access the hardware TLS register directly in
495 # private/bionic_tls.h
496 #
497 # The value must match your kernel configuration
498 #
499 ifeq ($(ARCH_ARM_HAVE_TLS_REGISTER),true)
500 libc_common_cflags += -DHAVE_ARM_TLS_REGISTER
501 endif
Dima Zavinca122b02009-05-27 10:52:37 -0700502else # !arm
503 ifeq ($(TARGET_ARCH),x86)
504 libc_crt_target_cflags := -m32
Bruce Beare8ff1a272010-03-04 11:03:37 -0800505
506 # Enable recent IA friendly memory routines (such as for Atom)
507 # These will not work on the earlier x86 machines
508 libc_common_cflags += -mtune=i686 -DUSE_SSSE3 -DUSE_SSE2
Dima Zavinca122b02009-05-27 10:52:37 -0700509 endif # x86
510endif # !arm
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800511
Andy McFaddenfcd00eb2010-05-28 13:31:45 -0700512# Define ANDROID_SMP appropriately.
513ifeq ($(TARGET_CPU_SMP),true)
514 libc_common_cflags += -DANDROID_SMP=1
515else
516 libc_common_cflags += -DANDROID_SMP=0
517endif
518
David 'Digit' Turner6a9b8882010-06-18 14:47:22 -0700519# Needed to access private/__dso_handle.S from
520# crtbegin_xxx.S and crtend_xxx.S
521#
522libc_crt_target_cflags += -I$(LOCAL_PATH)/private
Andy McFaddenfcd00eb2010-05-28 13:31:45 -0700523
Dima Zavinca122b02009-05-27 10:52:37 -0700524# Define some common includes
525# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800526libc_common_c_includes := \
527 $(LOCAL_PATH)/stdlib \
528 $(LOCAL_PATH)/string \
529 $(LOCAL_PATH)/stdio
530
David 'Digit' Turner3b43f872010-07-01 23:09:28 -0700531# Needed to access private/__dso_handle.S from
532# crtbegin_xxx.S and crtend_xxx.S
533#
534libc_crt_target_cflags += -I$(LOCAL_PATH)/private
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800535
Dima Zavinca122b02009-05-27 10:52:37 -0700536# Define the libc run-time (crt) support object files that must be built,
537# which are needed to build all other objects (shared/static libs and
538# executables)
539# ==========================================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800540
David 'Digit' Turner6a9b8882010-06-18 14:47:22 -0700541ifneq ($(filter arm x86,$(TARGET_ARCH)),)
542# ARM and x86 need crtbegin_so/crtend_so.
543#
544# For x86, the .init section must point to a function that calls all
545# entries in the .ctors section. (on ARM this is done through the
546# .init_array section instead).
547#
548# For both platforms, the .fini_array section must point to a function
549# that will call __cxa_finalize(&__dso_handle) in order to ensure that
550# static C++ destructors are properly called on dlclose().
551#
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800552GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_so.o
553$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin_so.S
554 @mkdir -p $(dir $@)
Dima Zavinca122b02009-05-27 10:52:37 -0700555 $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $<
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800556ALL_GENERATED_SOURCES += $(GEN)
557
558GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_so.o
559$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtend_so.S
560 @mkdir -p $(dir $@)
Dima Zavinca122b02009-05-27 10:52:37 -0700561 $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $<
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800562ALL_GENERATED_SOURCES += $(GEN)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800563endif # TARGET_ARCH == x86
564
Dima Zavinca122b02009-05-27 10:52:37 -0700565
566GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_static.o
567$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin_static.S
568 @mkdir -p $(dir $@)
569 $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $<
570ALL_GENERATED_SOURCES += $(GEN)
571
572GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_dynamic.o
573$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin_dynamic.S
574 @mkdir -p $(dir $@)
575 $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $<
576ALL_GENERATED_SOURCES += $(GEN)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800577
578
Dima Zavinca122b02009-05-27 10:52:37 -0700579# We rename crtend.o to crtend_android.o to avoid a
580# name clash between gcc and bionic.
581GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_android.o
582$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtend.S
583 @mkdir -p $(dir $@)
584 $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $<
585ALL_GENERATED_SOURCES += $(GEN)
586
587
588# To enable malloc leak check for statically linked programs, add
589# "WITH_MALLOC_CHECK_LIBC_A := true" to buildspec.mk
590WITH_MALLOC_CHECK_LIBC_A := $(strip $(WITH_MALLOC_CHECK_LIBC_A))
591
592# ========================================================
593# libc_common.a
594# ========================================================
595include $(CLEAR_VARS)
596
597LOCAL_SRC_FILES := $(libc_common_src_files)
598LOCAL_CFLAGS := $(libc_common_cflags)
599LOCAL_C_INCLUDES := $(libc_common_c_includes)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800600LOCAL_MODULE := libc_common
601LOCAL_SYSTEM_SHARED_LIBRARIES :=
602
603include $(BUILD_STATIC_LIBRARY)
604
605
Dima Zavinca122b02009-05-27 10:52:37 -0700606# ========================================================
Dima Zavin49e55332009-05-27 10:52:37 -0700607# libc_nomalloc.a
608# ========================================================
609#
610# This is a version of the static C library that does not
611# include malloc. It's useful in situations when calling
612# the user wants to provide their own malloc implementation,
613# or wants to explicitly disallow the use of the use of malloc,
614# like the dynamic loader.
615
616include $(CLEAR_VARS)
617
618LOCAL_SRC_FILES := \
619 $(libc_arch_static_src_files) \
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700620 $(libc_static_common_src_files) \
Dima Zavin49e55332009-05-27 10:52:37 -0700621 bionic/libc_init_static.c
622
623LOCAL_C_INCLUDES := $(libc_common_c_includes)
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700624LOCAL_CFLAGS := $(libc_common_cflags) \
625 -DLIBC_STATIC
Dima Zavin49e55332009-05-27 10:52:37 -0700626
627LOCAL_MODULE := libc_nomalloc
628LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
629LOCAL_SYSTEM_SHARED_LIBRARIES :=
630
631include $(BUILD_STATIC_LIBRARY)
632
633
634# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800635# libc.a
636# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800637include $(CLEAR_VARS)
638
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800639LOCAL_SRC_FILES := \
Dima Zavinca122b02009-05-27 10:52:37 -0700640 $(libc_arch_static_src_files) \
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700641 $(libc_static_common_src_files) \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800642 bionic/dlmalloc.c \
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800643 bionic/malloc_debug_common.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800644 bionic/libc_init_static.c
645
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800646LOCAL_CFLAGS := $(libc_common_cflags) \
647 -DLIBC_STATIC
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800648LOCAL_C_INCLUDES := $(libc_common_c_includes)
Dima Zavinca122b02009-05-27 10:52:37 -0700649LOCAL_MODULE := libc
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800650LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800651LOCAL_SYSTEM_SHARED_LIBRARIES :=
652
653include $(BUILD_STATIC_LIBRARY)
654
655
Dima Zavinca122b02009-05-27 10:52:37 -0700656# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800657# libc.so
658# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800659include $(CLEAR_VARS)
660
661LOCAL_CFLAGS := $(libc_common_cflags)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800662LOCAL_C_INCLUDES := $(libc_common_c_includes)
663
664LOCAL_SRC_FILES := \
Dima Zavinca122b02009-05-27 10:52:37 -0700665 $(libc_arch_dynamic_src_files) \
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700666 $(libc_static_common_src_files) \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800667 bionic/dlmalloc.c \
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800668 bionic/malloc_debug_common.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800669 bionic/libc_init_dynamic.c
670
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800671LOCAL_MODULE:= libc
672
673# WARNING: The only library libc.so should depend on is libdl.so! If you add other libraries,
674# make sure to add -Wl,--exclude-libs=libgcc.a to the LOCAL_LDFLAGS for those libraries. This
675# ensures that symbols that are pulled into those new libraries from libgcc.a are not declared
676# external; if that were the case, then libc would not pull those symbols from libgcc.a as it
677# should, instead relying on the external symbols from the dependent libraries. That would
678# create an "cloaked" dependency on libgcc.a in libc though the libraries, which is not what
679# you wanted!
680
681LOCAL_SHARED_LIBRARIES := libdl
682LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
683LOCAL_SYSTEM_SHARED_LIBRARIES :=
684
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800685include $(BUILD_SHARED_LIBRARY)
686
687
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800688# For all builds, except for the -user build we will enable memory
689# allocation checking (including memory leaks, buffer overwrites, etc.)
690# Note that all these checks are also controlled by env. settings
691# that can enable, or disable specific checks. Note also that some of
692# the checks are available only in emulator and are implemeted in
693# libc_malloc_qemu_instrumented.so.
694ifneq ($(TARGET_BUILD_VARIANT),user)
695
Dima Zavinca122b02009-05-27 10:52:37 -0700696# ========================================================
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800697# libc_malloc_debug_leak.so
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800698# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800699include $(CLEAR_VARS)
700
Dima Zavinca122b02009-05-27 10:52:37 -0700701LOCAL_CFLAGS := \
702 $(libc_common_cflags) \
703 -DMALLOC_LEAK_CHECK
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800704
705LOCAL_C_INCLUDES := $(libc_common_c_includes)
706
707LOCAL_SRC_FILES := \
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800708 bionic/malloc_debug_leak.c
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800709
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800710LOCAL_MODULE:= libc_malloc_debug_leak
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800711
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800712LOCAL_SHARED_LIBRARIES := libc
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800713LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
714LOCAL_SYSTEM_SHARED_LIBRARIES :=
Bruce Beareaa46fa22010-07-08 14:47:50 -0700715LOCAL_ALLOW_UNDEFINED_SYMBOLS := true
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800716# Don't prelink
717LOCAL_PRELINK_MODULE := false
718# Don't install on release build
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800719LOCAL_MODULE_TAGS := eng debug
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800720
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800721include $(BUILD_SHARED_LIBRARY)
722
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800723
724# ========================================================
725# libc_malloc_debug_qemu.so
726# ========================================================
727include $(CLEAR_VARS)
728
729LOCAL_CFLAGS := \
730 $(libc_common_cflags) \
731 -DMALLOC_QEMU_INSTRUMENT
732
733LOCAL_C_INCLUDES := $(libc_common_c_includes)
734
735LOCAL_SRC_FILES := \
736 bionic/malloc_debug_qemu.c
737
738LOCAL_MODULE:= libc_malloc_debug_qemu
739
740LOCAL_SHARED_LIBRARIES := libc
741LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
742LOCAL_SYSTEM_SHARED_LIBRARIES :=
743# Don't prelink
744LOCAL_PRELINK_MODULE := false
745# Don't install on release build
746LOCAL_MODULE_TAGS := eng debug
747
748include $(BUILD_SHARED_LIBRARY)
749
750endif #!user
751
752
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800753# ========================================================
754include $(call all-makefiles-under,$(LOCAL_PATH))