blob: f919e316c352a2b63345db3ddafb9b1a321185c8 [file] [log] [blame]
The Android Open Source Project1dc9e472009-03-03 19:28:35 -08001LOCAL_PATH:= $(call my-dir)
2
3include $(LOCAL_PATH)/arch-$(TARGET_ARCH)/syscalls.mk
Dima Zavinca122b02009-05-27 10:52:37 -07004
5# Define the common source files for all the libc instances
6# =========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -08007libc_common_src_files := \
8 $(syscall_src) \
9 unistd/abort.c \
10 unistd/alarm.c \
11 unistd/brk.c \
12 unistd/creat.c \
13 unistd/daemon.c \
David 'Digit' Turnerdefd1622010-09-26 22:29:14 +020014 unistd/eventfd.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080015 unistd/exec.c \
16 unistd/fcntl.c \
17 unistd/fnmatch.c \
David 'Digit' Turnerab8b5412010-07-08 16:52:27 -070018 unistd/fstatfs.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080019 unistd/ftime.c \
20 unistd/ftok.c \
21 unistd/getcwd.c \
22 unistd/getdtablesize.c \
23 unistd/gethostname.c \
24 unistd/getopt_long.c \
25 unistd/getpgrp.c \
26 unistd/getpriority.c \
27 unistd/getpt.c \
28 unistd/initgroups.c \
29 unistd/isatty.c \
30 unistd/issetugid.c \
Colin Cross8c59d962010-01-13 16:39:26 -080031 unistd/killpg.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080032 unistd/lseek64.c \
33 unistd/mmap.c \
34 unistd/nice.c \
35 unistd/open.c \
36 unistd/openat.c \
37 unistd/opendir.c \
38 unistd/pathconf.c \
39 unistd/perror.c \
40 unistd/popen.c \
41 unistd/pread.c \
42 unistd/pselect.c \
43 unistd/ptsname.c \
44 unistd/ptsname_r.c \
45 unistd/pwrite.c \
46 unistd/raise.c \
47 unistd/reboot.c \
48 unistd/recv.c \
49 unistd/sbrk.c \
50 unistd/send.c \
51 unistd/setegid.c \
Mike Chan9f691562010-03-02 10:55:58 -080052 unistd/setuid.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080053 unistd/seteuid.c \
Mike Chan9f691562010-03-02 10:55:58 -080054 unistd/setreuid.c \
55 unistd/setresuid.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080056 unistd/setpgrp.c \
57 unistd/sigblock.c \
58 unistd/siginterrupt.c \
59 unistd/siglist.c \
60 unistd/signal.c \
Thorsten Glaser92b10af2009-10-02 15:39:00 +020061 unistd/signame.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080062 unistd/sigsetmask.c \
63 unistd/sigsuspend.c \
64 unistd/sigwait.c \
65 unistd/sleep.c \
66 unistd/statfs.c \
67 unistd/strsignal.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080068 unistd/syslog.c \
69 unistd/system.c \
70 unistd/tcgetpgrp.c \
71 unistd/tcsetpgrp.c \
72 unistd/time.c \
73 unistd/umount.c \
74 unistd/unlockpt.c \
75 unistd/usleep.c \
76 unistd/wait.c \
77 stdio/asprintf.c \
78 stdio/clrerr.c \
79 stdio/fclose.c \
80 stdio/fdopen.c \
81 stdio/feof.c \
82 stdio/ferror.c \
83 stdio/fflush.c \
84 stdio/fgetc.c \
85 stdio/fgetln.c \
86 stdio/fgetpos.c \
87 stdio/fgets.c \
88 stdio/fileno.c \
89 stdio/findfp.c \
90 stdio/flags.c \
91 stdio/flockfile.c \
92 stdio/fopen.c \
93 stdio/fprintf.c \
94 stdio/fpurge.c \
95 stdio/fputc.c \
96 stdio/fputs.c \
97 stdio/fread.c \
98 stdio/freopen.c \
99 stdio/fscanf.c \
100 stdio/fseek.c \
101 stdio/fsetpos.c \
102 stdio/ftell.c \
103 stdio/funopen.c \
104 stdio/fvwrite.c \
105 stdio/fwalk.c \
106 stdio/fwrite.c \
107 stdio/getc.c \
108 stdio/getchar.c \
109 stdio/gets.c \
110 stdio/makebuf.c \
111 stdio/mktemp.c \
112 stdio/printf.c \
113 stdio/putc.c \
114 stdio/putchar.c \
115 stdio/puts.c \
116 stdio/putw.c \
117 stdio/refill.c \
118 stdio/remove.c \
119 stdio/rewind.c \
120 stdio/rget.c \
121 stdio/scanf.c \
122 stdio/setbuf.c \
123 stdio/setbuffer.c \
124 stdio/setvbuf.c \
125 stdio/snprintf.c\
126 stdio/sprintf.c \
127 stdio/sscanf.c \
128 stdio/stdio.c \
129 stdio/tempnam.c \
130 stdio/tmpfile.c \
131 stdio/tmpnam.c \
132 stdio/ungetc.c \
133 stdio/vasprintf.c \
134 stdio/vfprintf.c \
135 stdio/vfscanf.c \
136 stdio/vprintf.c \
137 stdio/vsnprintf.c \
138 stdio/vsprintf.c \
139 stdio/vscanf.c \
140 stdio/vsscanf.c \
141 stdio/wbuf.c \
142 stdio/wsetup.c \
143 stdlib/_rand48.c \
144 stdlib/assert.c \
145 stdlib/atexit.c \
146 stdlib/atoi.c \
147 stdlib/atol.c \
148 stdlib/atoll.c \
149 stdlib/bsearch.c \
150 stdlib/ctype_.c \
151 stdlib/div.c \
152 stdlib/exit.c \
153 stdlib/getenv.c \
154 stdlib/jrand48.c \
155 stdlib/ldiv.c \
156 stdlib/lldiv.c \
157 stdlib/locale.c \
158 stdlib/lrand48.c \
159 stdlib/mrand48.c \
160 stdlib/nrand48.c \
161 stdlib/putenv.c \
162 stdlib/qsort.c \
163 stdlib/seed48.c \
164 stdlib/setenv.c \
165 stdlib/setjmperr.c \
166 stdlib/srand48.c \
167 stdlib/strntoimax.c \
168 stdlib/strntoumax.c \
169 stdlib/strtod.c \
170 stdlib/strtoimax.c \
171 stdlib/strtol.c \
172 stdlib/strtoll.c \
173 stdlib/strtoul.c \
174 stdlib/strtoull.c \
175 stdlib/strtoumax.c \
176 stdlib/tolower_.c \
177 stdlib/toupper_.c \
178 stdlib/wchar.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800179 string/index.c \
180 string/memccpy.c \
181 string/memchr.c \
182 string/memmem.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800183 string/memrchr.c \
184 string/memswap.c \
185 string/strcasecmp.c \
186 string/strcasestr.c \
187 string/strcat.c \
188 string/strchr.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800189 string/strcoll.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800190 string/strcspn.c \
191 string/strdup.c \
192 string/strerror.c \
193 string/strerror_r.c \
194 string/strlcat.c \
195 string/strlcpy.c \
196 string/strncat.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800197 string/strncpy.c \
198 string/strndup.c \
199 string/strnlen.c \
200 string/strpbrk.c \
201 string/strrchr.c \
202 string/strsep.c \
203 string/strspn.c \
204 string/strstr.c \
205 string/strtok.c \
206 string/strtotimeval.c \
207 string/strxfrm.c \
David 'Digit' Turner3527fd62010-06-14 17:18:35 -0700208 wchar/wcpcpy.c \
209 wchar/wcpncpy.c \
210 wchar/wcscasecmp.c \
211 wchar/wcscat.c \
212 wchar/wcschr.c \
213 wchar/wcscmp.c \
214 wchar/wcscoll.c \
215 wchar/wcscpy.c \
216 wchar/wcscspn.c \
217 wchar/wcsdup.c \
218 wchar/wcslcat.c \
219 wchar/wcslcpy.c \
220 wchar/wcslen.c \
221 wchar/wcsncasecmp.c \
222 wchar/wcsncat.c \
223 wchar/wcsncmp.c \
224 wchar/wcsncpy.c \
225 wchar/wcsnlen.c \
226 wchar/wcspbrk.c \
227 wchar/wcsrchr.c \
228 wchar/wcsspn.c \
229 wchar/wcsstr.c \
230 wchar/wcstok.c \
231 wchar/wcswidth.c \
Kristian Monsen70465612010-06-16 14:51:52 +0100232 wchar/wcsxfrm.c \
David 'Digit' Turner3527fd62010-06-14 17:18:35 -0700233 wchar/wmemchr.c \
Kristian Monsen70465612010-06-16 14:51:52 +0100234 wchar/wmemcmp.c \
David 'Digit' Turner3527fd62010-06-14 17:18:35 -0700235 wchar/wmemcpy.c \
236 wchar/wmemmove.c \
237 wchar/wmemset.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800238 inet/bindresvport.c \
239 inet/inet_addr.c \
240 inet/inet_aton.c \
241 inet/inet_ntoa.c \
242 inet/inet_ntop.c \
243 inet/inet_pton.c \
Szymon Jakubczak41e533a2010-06-09 15:53:28 -0400244 inet/ether_aton.c \
245 inet/ether_ntoa.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800246 tzcode/asctime.c \
247 tzcode/difftime.c \
248 tzcode/localtime.c \
249 tzcode/strftime.c \
250 tzcode/strptime.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800251 bionic/__set_errno.c \
Mike Chan9f691562010-03-02 10:55:58 -0800252 bionic/cpuacct.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800253 bionic/arc4random.c \
254 bionic/basename.c \
255 bionic/basename_r.c \
Colin Crossfc10b242010-01-13 17:48:34 -0800256 bionic/clearenv.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800257 bionic/dirname.c \
258 bionic/dirname_r.c \
259 bionic/drand48.c \
260 bionic/erand48.c \
Colin Cross64ceac32010-01-13 21:19:52 -0800261 bionic/err.c \
Colin Crossfc10b242010-01-13 17:48:34 -0800262 bionic/fdprintf.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800263 bionic/fork.c \
Colin Cross64ceac32010-01-13 21:19:52 -0800264 bionic/fts.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800265 bionic/if_nametoindex.c \
266 bionic/if_indextoname.c \
267 bionic/ioctl.c \
268 bionic/ldexp.c \
269 bionic/libc_init_common.c \
270 bionic/logd_write.c \
271 bionic/md5.c \
272 bionic/pututline.c \
273 bionic/realpath.c \
274 bionic/semaphore.c \
275 bionic/sha1.c \
276 bionic/ssp.c \
277 bionic/stubs.c \
278 bionic/system_properties.c \
279 bionic/time64.c \
280 bionic/thread_atexit.c \
281 bionic/utime.c \
282 bionic/utmp.c \
283 netbsd/gethnamaddr.c \
284 netbsd/isc/ev_timers.c \
285 netbsd/isc/ev_streams.c \
286 netbsd/inet/nsap_addr.c \
287 netbsd/resolv/__dn_comp.c \
288 netbsd/resolv/__res_close.c \
289 netbsd/resolv/__res_send.c \
290 netbsd/resolv/herror.c \
291 netbsd/resolv/res_comp.c \
292 netbsd/resolv/res_data.c \
293 netbsd/resolv/res_debug.c \
294 netbsd/resolv/res_init.c \
295 netbsd/resolv/res_mkquery.c \
296 netbsd/resolv/res_query.c \
297 netbsd/resolv/res_send.c \
Shin-ichiro KAWASAKI10093272009-09-28 16:11:39 +0900298 netbsd/resolv/res_state.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800299 netbsd/resolv/res_cache.c \
300 netbsd/net/nsdispatch.c \
301 netbsd/net/getaddrinfo.c \
302 netbsd/net/getnameinfo.c \
303 netbsd/net/getservbyname.c \
304 netbsd/net/getservent.c \
305 netbsd/net/base64.c \
306 netbsd/net/getservbyport.c \
307 netbsd/nameser/ns_name.c \
308 netbsd/nameser/ns_parse.c \
309 netbsd/nameser/ns_ttl.c \
310 netbsd/nameser/ns_netint.c \
311 netbsd/nameser/ns_print.c \
Colin Cross4fa7b102010-01-12 18:59:25 -0800312 netbsd/nameser/ns_samedomain.c \
313 regex/regcomp.c \
314 regex/regerror.c \
315 regex/regexec.c \
316 regex/regfree.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800317
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700318# The following files are common, but must be compiled
319# with different C flags when building a static C library.
320#
321# The reason for this is the implementation of __get_tls()
322# that will differ between the shared and static versions
323# of the library.
324#
325# See comments in private/bionic_tls.h for more details.
326#
327# NOTE: bionic/pthread.c is added later to this list
328# because it needs special handling on ARM, see
329# below.
330#
331libc_static_common_src_files := \
332 unistd/sysconf.c \
333 bionic/__errno.c \
334
Dima Zavinca122b02009-05-27 10:52:37 -0700335# Architecture specific source files go here
336# =========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800337ifeq ($(TARGET_ARCH),arm)
338libc_common_src_files += \
David 'Digit' Turner97cf7f32010-01-22 18:59:05 -0800339 bionic/bionic_clone.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800340 arch-arm/bionic/__get_pc.S \
341 arch-arm/bionic/__get_sp.S \
342 arch-arm/bionic/_exit_with_stack_teardown.S \
343 arch-arm/bionic/_setjmp.S \
344 arch-arm/bionic/atomics_arm.S \
345 arch-arm/bionic/clone.S \
David 'Digit' Turner6a9b8882010-06-18 14:47:22 -0700346 arch-arm/bionic/eabi.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800347 arch-arm/bionic/ffs.S \
348 arch-arm/bionic/kill.S \
David 'Digit' Turner2a7ad972009-09-29 14:43:38 -0700349 arch-arm/bionic/libgcc_compat.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800350 arch-arm/bionic/tkill.S \
351 arch-arm/bionic/memcmp.S \
352 arch-arm/bionic/memcmp16.S \
353 arch-arm/bionic/memcpy.S \
354 arch-arm/bionic/memset.S \
355 arch-arm/bionic/setjmp.S \
356 arch-arm/bionic/sigsetjmp.S \
357 arch-arm/bionic/strlen.c.arm \
Jim Huang73c04b32010-08-10 17:23:39 +0800358 arch-arm/bionic/strcpy.S \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800359 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 \
Bruce Beare124a5422010-10-11 12:24:41 -0700407 arch-x86/string/strlen_wrapper.S \
Jim Huang73c04b32010-08-10 17:23:39 +0800408 string/strcpy.c \
Matt Fischer4f086ae2010-06-25 14:36:39 -0500409 bionic/pthread-atfork.c \
David 'Digit' Turner8a1d2cf2010-05-11 16:39:22 -0700410 bionic/pthread-rwlocks.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800411 bionic/pthread-timers.c \
412 bionic/ptrace.c
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800413
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700414libc_static_common_src_files += \
415 bionic/pthread.c \
416
Dima Zavinca122b02009-05-27 10:52:37 -0700417# this is needed for static versions of libc
418libc_arch_static_src_files := \
419 arch-x86/bionic/dl_iterate_phdr_static.c
420
421libc_arch_dynamic_src_files :=
Shin-ichiro KAWASAKI10093272009-09-28 16:11:39 +0900422else # !x86
423
424ifeq ($(TARGET_ARCH),sh)
425libc_common_src_files += \
426 arch-sh/bionic/__get_pc.S \
427 arch-sh/bionic/__get_sp.S \
428 arch-sh/bionic/_exit_with_stack_teardown.S \
429 arch-sh/bionic/_setjmp.S \
430 arch-sh/bionic/atomics_sh.c \
431 arch-sh/bionic/atomic_cmpxchg.S \
432 arch-sh/bionic/clone.S \
433 arch-sh/bionic/pipe.S \
434 arch-sh/bionic/memcpy.S \
435 arch-sh/bionic/memset.S \
436 arch-sh/bionic/bzero.S \
437 arch-sh/bionic/setjmp.S \
438 arch-sh/bionic/sigsetjmp.S \
439 arch-sh/bionic/syscall.S \
440 arch-sh/bionic/memmove.S \
441 arch-sh/bionic/__set_tls.c \
442 arch-sh/bionic/__get_tls.c \
443 arch-sh/bionic/ffs.S \
Bruce Beare8ff1a272010-03-04 11:03:37 -0800444 string/bcopy.c \
445 string/strcmp.c \
446 string/strncmp.c \
Shin-ichiro KAWASAKI10093272009-09-28 16:11:39 +0900447 string/memcmp.c \
448 string/strlen.c \
Jim Huang73c04b32010-08-10 17:23:39 +0800449 string/strcpy.c \
Matt Fischer4f086ae2010-06-25 14:36:39 -0500450 bionic/pthread-atfork.c \
David 'Digit' Turner8a1d2cf2010-05-11 16:39:22 -0700451 bionic/pthread-rwlocks.c \
Shin-ichiro KAWASAKI10093272009-09-28 16:11:39 +0900452 bionic/pthread-timers.c \
453 bionic/ptrace.c \
454 unistd/socketcalls.c
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700455
456libc_static_common_src_files += \
457 bionic/pthread.c \
458
Shin-ichiro KAWASAKI10093272009-09-28 16:11:39 +0900459endif # sh
460
461endif # !x86
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800462endif # !arm
463
Dima Zavinca122b02009-05-27 10:52:37 -0700464# Define some common cflags
465# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800466libc_common_cflags := \
467 -DWITH_ERRLIST \
468 -DANDROID_CHANGES \
469 -DUSE_LOCKS \
470 -DREALLOC_ZERO_BYTES_FREES \
471 -D_LIBC=1 \
472 -DSOFTFLOAT \
473 -DFLOATING_POINT \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800474 -DINET6 \
475 -I$(LOCAL_PATH)/private \
Colin Cross4fa7b102010-01-12 18:59:25 -0800476 -DUSE_DL_PREFIX \
477 -DPOSIX_MISTAKE
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800478
David 'Digit' Turnerd7ed1ae2010-03-05 14:17:35 -0800479# these macro definitions are required to implement the
480# 'timezone' and 'daylight' global variables, as well as
481# properly update the 'tm_gmtoff' field in 'struct tm'.
482#
483libc_common_cflags += \
484 -DTM_GMTOFF=tm_gmtoff \
485 -DUSG_COMPAT=1
486
Dave Bortd2c9dcc2009-04-23 15:50:03 -0700487ifeq ($(strip $(DEBUG_BIONIC_LIBC)),true)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800488 libc_common_cflags += -DDEBUG
489endif
490
491ifeq ($(TARGET_ARCH),arm)
492 libc_common_cflags += -fstrict-aliasing
Dima Zavinca122b02009-05-27 10:52:37 -0700493 libc_crt_target_cflags := -mthumb-interwork
David 'Digit' Turner4a05d122009-09-18 13:35:05 -0700494 #
495 # Define HAVE_ARM_TLS_REGISTER macro to indicate to the C library
496 # that it should access the hardware TLS register directly in
497 # private/bionic_tls.h
498 #
499 # The value must match your kernel configuration
500 #
501 ifeq ($(ARCH_ARM_HAVE_TLS_REGISTER),true)
502 libc_common_cflags += -DHAVE_ARM_TLS_REGISTER
503 endif
Dima Zavinca122b02009-05-27 10:52:37 -0700504else # !arm
Chih-Wei Huang26c15a82010-07-26 11:29:08 +0800505 libc_crt_target_cflags :=
Dima Zavinca122b02009-05-27 10:52:37 -0700506endif # !arm
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800507
Andy McFaddenfcd00eb2010-05-28 13:31:45 -0700508# Define ANDROID_SMP appropriately.
509ifeq ($(TARGET_CPU_SMP),true)
510 libc_common_cflags += -DANDROID_SMP=1
511else
512 libc_common_cflags += -DANDROID_SMP=0
513endif
514
David 'Digit' Turner6a9b8882010-06-18 14:47:22 -0700515# Needed to access private/__dso_handle.S from
516# crtbegin_xxx.S and crtend_xxx.S
517#
518libc_crt_target_cflags += -I$(LOCAL_PATH)/private
Andy McFaddenfcd00eb2010-05-28 13:31:45 -0700519
Dima Zavinca122b02009-05-27 10:52:37 -0700520# Define some common includes
521# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800522libc_common_c_includes := \
523 $(LOCAL_PATH)/stdlib \
524 $(LOCAL_PATH)/string \
525 $(LOCAL_PATH)/stdio
526
David 'Digit' Turner3b43f872010-07-01 23:09:28 -0700527# Needed to access private/__dso_handle.S from
528# crtbegin_xxx.S and crtend_xxx.S
529#
530libc_crt_target_cflags += -I$(LOCAL_PATH)/private
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800531
Dima Zavinca122b02009-05-27 10:52:37 -0700532# Define the libc run-time (crt) support object files that must be built,
533# which are needed to build all other objects (shared/static libs and
534# executables)
535# ==========================================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800536
David 'Digit' Turner6a9b8882010-06-18 14:47:22 -0700537ifneq ($(filter arm x86,$(TARGET_ARCH)),)
538# ARM and x86 need crtbegin_so/crtend_so.
539#
540# For x86, the .init section must point to a function that calls all
541# entries in the .ctors section. (on ARM this is done through the
542# .init_array section instead).
543#
544# For both platforms, the .fini_array section must point to a function
545# that will call __cxa_finalize(&__dso_handle) in order to ensure that
546# static C++ destructors are properly called on dlclose().
547#
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800548GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_so.o
549$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin_so.S
550 @mkdir -p $(dir $@)
Dima Zavinca122b02009-05-27 10:52:37 -0700551 $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $<
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800552ALL_GENERATED_SOURCES += $(GEN)
553
554GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_so.o
555$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtend_so.S
556 @mkdir -p $(dir $@)
Dima Zavinca122b02009-05-27 10:52:37 -0700557 $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $<
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800558ALL_GENERATED_SOURCES += $(GEN)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800559endif # TARGET_ARCH == x86
560
Dima Zavinca122b02009-05-27 10:52:37 -0700561
562GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_static.o
563$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin_static.S
564 @mkdir -p $(dir $@)
565 $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $<
566ALL_GENERATED_SOURCES += $(GEN)
567
568GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_dynamic.o
569$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin_dynamic.S
570 @mkdir -p $(dir $@)
571 $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $<
572ALL_GENERATED_SOURCES += $(GEN)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800573
574
Dima Zavinca122b02009-05-27 10:52:37 -0700575# We rename crtend.o to crtend_android.o to avoid a
576# name clash between gcc and bionic.
577GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_android.o
578$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtend.S
579 @mkdir -p $(dir $@)
580 $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $<
581ALL_GENERATED_SOURCES += $(GEN)
582
583
584# To enable malloc leak check for statically linked programs, add
585# "WITH_MALLOC_CHECK_LIBC_A := true" to buildspec.mk
586WITH_MALLOC_CHECK_LIBC_A := $(strip $(WITH_MALLOC_CHECK_LIBC_A))
587
588# ========================================================
589# libc_common.a
590# ========================================================
591include $(CLEAR_VARS)
592
593LOCAL_SRC_FILES := $(libc_common_src_files)
594LOCAL_CFLAGS := $(libc_common_cflags)
595LOCAL_C_INCLUDES := $(libc_common_c_includes)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800596LOCAL_MODULE := libc_common
597LOCAL_SYSTEM_SHARED_LIBRARIES :=
598
599include $(BUILD_STATIC_LIBRARY)
600
601
Dima Zavinca122b02009-05-27 10:52:37 -0700602# ========================================================
Dima Zavin49e55332009-05-27 10:52:37 -0700603# libc_nomalloc.a
604# ========================================================
605#
606# This is a version of the static C library that does not
607# include malloc. It's useful in situations when calling
608# the user wants to provide their own malloc implementation,
609# or wants to explicitly disallow the use of the use of malloc,
610# like the dynamic loader.
611
612include $(CLEAR_VARS)
613
614LOCAL_SRC_FILES := \
615 $(libc_arch_static_src_files) \
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700616 $(libc_static_common_src_files) \
Dima Zavin49e55332009-05-27 10:52:37 -0700617 bionic/libc_init_static.c
618
619LOCAL_C_INCLUDES := $(libc_common_c_includes)
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700620LOCAL_CFLAGS := $(libc_common_cflags) \
621 -DLIBC_STATIC
Dima Zavin49e55332009-05-27 10:52:37 -0700622
623LOCAL_MODULE := libc_nomalloc
624LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
625LOCAL_SYSTEM_SHARED_LIBRARIES :=
626
627include $(BUILD_STATIC_LIBRARY)
628
629
630# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800631# libc.a
632# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800633include $(CLEAR_VARS)
634
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800635LOCAL_SRC_FILES := \
Dima Zavinca122b02009-05-27 10:52:37 -0700636 $(libc_arch_static_src_files) \
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700637 $(libc_static_common_src_files) \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800638 bionic/dlmalloc.c \
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800639 bionic/malloc_debug_common.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800640 bionic/libc_init_static.c
641
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800642LOCAL_CFLAGS := $(libc_common_cflags) \
643 -DLIBC_STATIC
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800644LOCAL_C_INCLUDES := $(libc_common_c_includes)
Dima Zavinca122b02009-05-27 10:52:37 -0700645LOCAL_MODULE := libc
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800646LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800647LOCAL_SYSTEM_SHARED_LIBRARIES :=
648
649include $(BUILD_STATIC_LIBRARY)
650
651
Dima Zavinca122b02009-05-27 10:52:37 -0700652# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800653# libc.so
654# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800655include $(CLEAR_VARS)
656
657LOCAL_CFLAGS := $(libc_common_cflags)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800658LOCAL_C_INCLUDES := $(libc_common_c_includes)
659
660LOCAL_SRC_FILES := \
Dima Zavinca122b02009-05-27 10:52:37 -0700661 $(libc_arch_dynamic_src_files) \
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700662 $(libc_static_common_src_files) \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800663 bionic/dlmalloc.c \
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800664 bionic/malloc_debug_common.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800665 bionic/libc_init_dynamic.c
666
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800667LOCAL_MODULE:= libc
668
669# WARNING: The only library libc.so should depend on is libdl.so! If you add other libraries,
670# make sure to add -Wl,--exclude-libs=libgcc.a to the LOCAL_LDFLAGS for those libraries. This
671# ensures that symbols that are pulled into those new libraries from libgcc.a are not declared
672# external; if that were the case, then libc would not pull those symbols from libgcc.a as it
673# should, instead relying on the external symbols from the dependent libraries. That would
674# create an "cloaked" dependency on libgcc.a in libc though the libraries, which is not what
675# you wanted!
676
677LOCAL_SHARED_LIBRARIES := libdl
678LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
679LOCAL_SYSTEM_SHARED_LIBRARIES :=
680
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800681include $(BUILD_SHARED_LIBRARY)
682
683
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800684# For all builds, except for the -user build we will enable memory
685# allocation checking (including memory leaks, buffer overwrites, etc.)
686# Note that all these checks are also controlled by env. settings
687# that can enable, or disable specific checks. Note also that some of
688# the checks are available only in emulator and are implemeted in
689# libc_malloc_qemu_instrumented.so.
690ifneq ($(TARGET_BUILD_VARIANT),user)
691
Dima Zavinca122b02009-05-27 10:52:37 -0700692# ========================================================
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800693# libc_malloc_debug_leak.so
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800694# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800695include $(CLEAR_VARS)
696
Dima Zavinca122b02009-05-27 10:52:37 -0700697LOCAL_CFLAGS := \
698 $(libc_common_cflags) \
699 -DMALLOC_LEAK_CHECK
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800700
701LOCAL_C_INCLUDES := $(libc_common_c_includes)
702
703LOCAL_SRC_FILES := \
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800704 bionic/malloc_debug_leak.c
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800705
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800706LOCAL_MODULE:= libc_malloc_debug_leak
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800707
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800708LOCAL_SHARED_LIBRARIES := libc
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800709LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
710LOCAL_SYSTEM_SHARED_LIBRARIES :=
Bruce Beareaa46fa22010-07-08 14:47:50 -0700711LOCAL_ALLOW_UNDEFINED_SYMBOLS := true
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800712# Don't prelink
713LOCAL_PRELINK_MODULE := false
714# Don't install on release build
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800715LOCAL_MODULE_TAGS := eng debug
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800716
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800717include $(BUILD_SHARED_LIBRARY)
718
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800719
720# ========================================================
721# libc_malloc_debug_qemu.so
722# ========================================================
723include $(CLEAR_VARS)
724
725LOCAL_CFLAGS := \
726 $(libc_common_cflags) \
727 -DMALLOC_QEMU_INSTRUMENT
728
729LOCAL_C_INCLUDES := $(libc_common_c_includes)
730
731LOCAL_SRC_FILES := \
732 bionic/malloc_debug_qemu.c
733
734LOCAL_MODULE:= libc_malloc_debug_qemu
735
736LOCAL_SHARED_LIBRARIES := libc
737LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
738LOCAL_SYSTEM_SHARED_LIBRARIES :=
739# Don't prelink
740LOCAL_PRELINK_MODULE := false
741# Don't install on release build
742LOCAL_MODULE_TAGS := eng debug
743
744include $(BUILD_SHARED_LIBRARY)
745
746endif #!user
747
748
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800749# ========================================================
750include $(call all-makefiles-under,$(LOCAL_PATH))