blob: 9d7dd3ddfdc2b76c8a5ee77e7e1caac0d79df28b [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 \
232 wchar/wmemchr.c \
Kenny Rootcb99ab92010-09-10 12:20:58 -0700233 wchar/wmemcmp.c \
David 'Digit' Turner3527fd62010-06-14 17:18:35 -0700234 wchar/wmemcpy.c \
235 wchar/wmemmove.c \
236 wchar/wmemset.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800237 inet/bindresvport.c \
238 inet/inet_addr.c \
239 inet/inet_aton.c \
240 inet/inet_ntoa.c \
241 inet/inet_ntop.c \
242 inet/inet_pton.c \
243 tzcode/asctime.c \
244 tzcode/difftime.c \
245 tzcode/localtime.c \
246 tzcode/strftime.c \
247 tzcode/strptime.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800248 bionic/__set_errno.c \
249 bionic/_rand48.c \
Mike Chan9f691562010-03-02 10:55:58 -0800250 bionic/cpuacct.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800251 bionic/arc4random.c \
252 bionic/basename.c \
253 bionic/basename_r.c \
Colin Crossfc10b242010-01-13 17:48:34 -0800254 bionic/clearenv.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800255 bionic/dirname.c \
256 bionic/dirname_r.c \
257 bionic/drand48.c \
258 bionic/erand48.c \
Colin Cross64ceac32010-01-13 21:19:52 -0800259 bionic/err.c \
Colin Crossfc10b242010-01-13 17:48:34 -0800260 bionic/fdprintf.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800261 bionic/fork.c \
Colin Cross64ceac32010-01-13 21:19:52 -0800262 bionic/fts.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800263 bionic/if_nametoindex.c \
264 bionic/if_indextoname.c \
265 bionic/ioctl.c \
266 bionic/ldexp.c \
267 bionic/libc_init_common.c \
268 bionic/logd_write.c \
269 bionic/md5.c \
270 bionic/pututline.c \
271 bionic/realpath.c \
272 bionic/semaphore.c \
273 bionic/sha1.c \
274 bionic/ssp.c \
275 bionic/stubs.c \
276 bionic/system_properties.c \
277 bionic/time64.c \
278 bionic/thread_atexit.c \
279 bionic/utime.c \
280 bionic/utmp.c \
281 netbsd/gethnamaddr.c \
282 netbsd/isc/ev_timers.c \
283 netbsd/isc/ev_streams.c \
284 netbsd/inet/nsap_addr.c \
285 netbsd/resolv/__dn_comp.c \
286 netbsd/resolv/__res_close.c \
287 netbsd/resolv/__res_send.c \
288 netbsd/resolv/herror.c \
289 netbsd/resolv/res_comp.c \
290 netbsd/resolv/res_data.c \
291 netbsd/resolv/res_debug.c \
292 netbsd/resolv/res_init.c \
293 netbsd/resolv/res_mkquery.c \
294 netbsd/resolv/res_query.c \
295 netbsd/resolv/res_send.c \
Shin-ichiro KAWASAKI10093272009-09-28 16:11:39 +0900296 netbsd/resolv/res_state.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800297 netbsd/resolv/res_cache.c \
298 netbsd/net/nsdispatch.c \
299 netbsd/net/getaddrinfo.c \
300 netbsd/net/getnameinfo.c \
301 netbsd/net/getservbyname.c \
302 netbsd/net/getservent.c \
303 netbsd/net/base64.c \
304 netbsd/net/getservbyport.c \
305 netbsd/nameser/ns_name.c \
306 netbsd/nameser/ns_parse.c \
307 netbsd/nameser/ns_ttl.c \
308 netbsd/nameser/ns_netint.c \
309 netbsd/nameser/ns_print.c \
Colin Cross4fa7b102010-01-12 18:59:25 -0800310 netbsd/nameser/ns_samedomain.c \
311 regex/regcomp.c \
312 regex/regerror.c \
313 regex/regexec.c \
314 regex/regfree.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800315
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700316# The following files are common, but must be compiled
317# with different C flags when building a static C library.
318#
319# The reason for this is the implementation of __get_tls()
320# that will differ between the shared and static versions
321# of the library.
322#
323# See comments in private/bionic_tls.h for more details.
324#
325# NOTE: bionic/pthread.c is added later to this list
326# because it needs special handling on ARM, see
327# below.
328#
329libc_static_common_src_files := \
330 unistd/sysconf.c \
331 bionic/__errno.c \
332
Dima Zavinca122b02009-05-27 10:52:37 -0700333# Architecture specific source files go here
334# =========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800335ifeq ($(TARGET_ARCH),arm)
336libc_common_src_files += \
David 'Digit' Turner97cf7f32010-01-22 18:59:05 -0800337 bionic/bionic_clone.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800338 arch-arm/bionic/__get_pc.S \
339 arch-arm/bionic/__get_sp.S \
340 arch-arm/bionic/_exit_with_stack_teardown.S \
341 arch-arm/bionic/_setjmp.S \
342 arch-arm/bionic/atomics_arm.S \
343 arch-arm/bionic/clone.S \
David 'Digit' Turner6a9b8882010-06-18 14:47:22 -0700344 arch-arm/bionic/eabi.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800345 arch-arm/bionic/ffs.S \
346 arch-arm/bionic/kill.S \
David 'Digit' Turner2a7ad972009-09-29 14:43:38 -0700347 arch-arm/bionic/libgcc_compat.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800348 arch-arm/bionic/tkill.S \
349 arch-arm/bionic/memcmp.S \
350 arch-arm/bionic/memcmp16.S \
351 arch-arm/bionic/memcpy.S \
352 arch-arm/bionic/memset.S \
353 arch-arm/bionic/setjmp.S \
354 arch-arm/bionic/sigsetjmp.S \
355 arch-arm/bionic/strlen.c.arm \
356 arch-arm/bionic/syscall.S \
Shin-ichiro KAWASAKI10093272009-09-28 16:11:39 +0900357 string/memmove.c.arm \
Bruce Beare8ff1a272010-03-04 11:03:37 -0800358 string/bcopy.c \
359 string/strcmp.c \
360 string/strncmp.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800361 unistd/socketcalls.c
362
363# These files need to be arm so that gdbserver
364# can set breakpoints in them without messing
365# up any thumb code.
366libc_common_src_files += \
David 'Digit' Turner8a1d2cf2010-05-11 16:39:22 -0700367 bionic/pthread-rwlocks.c.arm \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800368 bionic/pthread-timers.c.arm \
369 bionic/ptrace.c.arm
Dima Zavinca122b02009-05-27 10:52:37 -0700370
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700371libc_static_common_src_files += \
372 bionic/pthread.c.arm \
373
Dima Zavinca122b02009-05-27 10:52:37 -0700374# these are used by the static and dynamic versions of the libc
375# respectively
376libc_arch_static_src_files := \
377 arch-arm/bionic/exidx_static.c
378
379libc_arch_dynamic_src_files := \
380 arch-arm/bionic/exidx_dynamic.c
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800381else # !arm
382
383ifeq ($(TARGET_ARCH),x86)
384libc_common_src_files += \
385 arch-x86/bionic/__get_sp.S \
386 arch-x86/bionic/__get_tls.c \
387 arch-x86/bionic/__set_tls.c \
388 arch-x86/bionic/atomics_x86.S \
389 arch-x86/bionic/clone.S \
390 arch-x86/bionic/_exit_with_stack_teardown.S \
391 arch-x86/bionic/setjmp.S \
392 arch-x86/bionic/_setjmp.S \
393 arch-x86/bionic/vfork.S \
Bruce Beare3c543e12010-03-04 10:29:38 -0800394 arch-x86/bionic/syscall.S \
Bruce Beare8ff1a272010-03-04 11:03:37 -0800395 arch-x86/string/bcopy_wrapper.S \
396 arch-x86/string/memcpy_wrapper.S \
397 arch-x86/string/memmove_wrapper.S \
398 arch-x86/string/bzero_wrapper.S \
399 arch-x86/string/memcmp_wrapper.S \
400 arch-x86/string/memset_wrapper.S \
401 arch-x86/string/strcmp_wrapper.S \
402 arch-x86/string/strncmp_wrapper.S \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800403 arch-x86/string/strlen.S \
David 'Digit' Turner8a1d2cf2010-05-11 16:39:22 -0700404 bionic/pthread-rwlocks.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800405 bionic/pthread-timers.c \
406 bionic/ptrace.c
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800407
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700408libc_static_common_src_files += \
409 bionic/pthread.c \
410
Dima Zavinca122b02009-05-27 10:52:37 -0700411# this is needed for static versions of libc
412libc_arch_static_src_files := \
413 arch-x86/bionic/dl_iterate_phdr_static.c
414
415libc_arch_dynamic_src_files :=
Shin-ichiro KAWASAKI10093272009-09-28 16:11:39 +0900416else # !x86
417
418ifeq ($(TARGET_ARCH),sh)
419libc_common_src_files += \
420 arch-sh/bionic/__get_pc.S \
421 arch-sh/bionic/__get_sp.S \
422 arch-sh/bionic/_exit_with_stack_teardown.S \
423 arch-sh/bionic/_setjmp.S \
424 arch-sh/bionic/atomics_sh.c \
425 arch-sh/bionic/atomic_cmpxchg.S \
426 arch-sh/bionic/clone.S \
427 arch-sh/bionic/pipe.S \
428 arch-sh/bionic/memcpy.S \
429 arch-sh/bionic/memset.S \
430 arch-sh/bionic/bzero.S \
431 arch-sh/bionic/setjmp.S \
432 arch-sh/bionic/sigsetjmp.S \
433 arch-sh/bionic/syscall.S \
434 arch-sh/bionic/memmove.S \
435 arch-sh/bionic/__set_tls.c \
436 arch-sh/bionic/__get_tls.c \
437 arch-sh/bionic/ffs.S \
Bruce Beare8ff1a272010-03-04 11:03:37 -0800438 string/bcopy.c \
439 string/strcmp.c \
440 string/strncmp.c \
Shin-ichiro KAWASAKI10093272009-09-28 16:11:39 +0900441 string/memcmp.c \
442 string/strlen.c \
David 'Digit' Turner8a1d2cf2010-05-11 16:39:22 -0700443 bionic/pthread-rwlocks.c \
Shin-ichiro KAWASAKI10093272009-09-28 16:11:39 +0900444 bionic/pthread-timers.c \
445 bionic/ptrace.c \
446 unistd/socketcalls.c
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700447
448libc_static_common_src_files += \
449 bionic/pthread.c \
450
Shin-ichiro KAWASAKI10093272009-09-28 16:11:39 +0900451endif # sh
452
453endif # !x86
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800454endif # !arm
455
Dima Zavinca122b02009-05-27 10:52:37 -0700456# Define some common cflags
457# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800458libc_common_cflags := \
459 -DWITH_ERRLIST \
460 -DANDROID_CHANGES \
461 -DUSE_LOCKS \
462 -DREALLOC_ZERO_BYTES_FREES \
463 -D_LIBC=1 \
464 -DSOFTFLOAT \
465 -DFLOATING_POINT \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800466 -DINET6 \
467 -I$(LOCAL_PATH)/private \
Colin Cross4fa7b102010-01-12 18:59:25 -0800468 -DUSE_DL_PREFIX \
469 -DPOSIX_MISTAKE
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800470
David 'Digit' Turnerd7ed1ae2010-03-05 14:17:35 -0800471# these macro definitions are required to implement the
472# 'timezone' and 'daylight' global variables, as well as
473# properly update the 'tm_gmtoff' field in 'struct tm'.
474#
475libc_common_cflags += \
476 -DTM_GMTOFF=tm_gmtoff \
477 -DUSG_COMPAT=1
478
Dave Bortd2c9dcc2009-04-23 15:50:03 -0700479ifeq ($(strip $(DEBUG_BIONIC_LIBC)),true)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800480 libc_common_cflags += -DDEBUG
481endif
482
483ifeq ($(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
Dima Zavinca122b02009-05-27 10:52:37 -0700496else # !arm
497 ifeq ($(TARGET_ARCH),x86)
498 libc_crt_target_cflags := -m32
Bruce Beare8ff1a272010-03-04 11:03:37 -0800499
500 # Enable recent IA friendly memory routines (such as for Atom)
501 # These will not work on the earlier x86 machines
502 libc_common_cflags += -mtune=i686 -DUSE_SSSE3 -DUSE_SSE2
Dima Zavinca122b02009-05-27 10:52:37 -0700503 endif # x86
504endif # !arm
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800505
Andy McFaddenfcd00eb2010-05-28 13:31:45 -0700506# Define ANDROID_SMP appropriately.
507ifeq ($(TARGET_CPU_SMP),true)
508 libc_common_cflags += -DANDROID_SMP=1
509else
510 libc_common_cflags += -DANDROID_SMP=0
511endif
512
David 'Digit' Turner6a9b8882010-06-18 14:47:22 -0700513# Needed to access private/__dso_handle.S from
514# crtbegin_xxx.S and crtend_xxx.S
515#
516libc_crt_target_cflags += -I$(LOCAL_PATH)/private
Andy McFaddenfcd00eb2010-05-28 13:31:45 -0700517
Dima Zavinca122b02009-05-27 10:52:37 -0700518# Define some common includes
519# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800520libc_common_c_includes := \
521 $(LOCAL_PATH)/stdlib \
522 $(LOCAL_PATH)/string \
523 $(LOCAL_PATH)/stdio
524
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800525
Dima Zavinca122b02009-05-27 10:52:37 -0700526# Define the libc run-time (crt) support object files that must be built,
527# which are needed to build all other objects (shared/static libs and
528# executables)
529# ==========================================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800530
David 'Digit' Turner6a9b8882010-06-18 14:47:22 -0700531ifneq ($(filter arm x86,$(TARGET_ARCH)),)
532# ARM and x86 need crtbegin_so/crtend_so.
533#
534# For x86, the .init section must point to a function that calls all
535# entries in the .ctors section. (on ARM this is done through the
536# .init_array section instead).
537#
538# For both platforms, the .fini_array section must point to a function
539# that will call __cxa_finalize(&__dso_handle) in order to ensure that
540# static C++ destructors are properly called on dlclose().
541#
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800542GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_so.o
543$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin_so.S
544 @mkdir -p $(dir $@)
Dima Zavinca122b02009-05-27 10:52:37 -0700545 $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $<
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800546ALL_GENERATED_SOURCES += $(GEN)
547
548GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_so.o
549$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtend_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)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800553endif # TARGET_ARCH == x86
554
Dima Zavinca122b02009-05-27 10:52:37 -0700555
556GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_static.o
557$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin_static.S
558 @mkdir -p $(dir $@)
559 $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $<
560ALL_GENERATED_SOURCES += $(GEN)
561
562GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_dynamic.o
563$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin_dynamic.S
564 @mkdir -p $(dir $@)
565 $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $<
566ALL_GENERATED_SOURCES += $(GEN)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800567
568
Dima Zavinca122b02009-05-27 10:52:37 -0700569# We rename crtend.o to crtend_android.o to avoid a
570# name clash between gcc and bionic.
571GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_android.o
572$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtend.S
573 @mkdir -p $(dir $@)
574 $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $<
575ALL_GENERATED_SOURCES += $(GEN)
576
577
578# To enable malloc leak check for statically linked programs, add
579# "WITH_MALLOC_CHECK_LIBC_A := true" to buildspec.mk
580WITH_MALLOC_CHECK_LIBC_A := $(strip $(WITH_MALLOC_CHECK_LIBC_A))
581
582# ========================================================
583# libc_common.a
584# ========================================================
585include $(CLEAR_VARS)
586
587LOCAL_SRC_FILES := $(libc_common_src_files)
588LOCAL_CFLAGS := $(libc_common_cflags)
589LOCAL_C_INCLUDES := $(libc_common_c_includes)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800590LOCAL_MODULE := libc_common
591LOCAL_SYSTEM_SHARED_LIBRARIES :=
592
593include $(BUILD_STATIC_LIBRARY)
594
595
Dima Zavinca122b02009-05-27 10:52:37 -0700596# ========================================================
Dima Zavin49e55332009-05-27 10:52:37 -0700597# libc_nomalloc.a
598# ========================================================
599#
600# This is a version of the static C library that does not
601# include malloc. It's useful in situations when calling
602# the user wants to provide their own malloc implementation,
603# or wants to explicitly disallow the use of the use of malloc,
604# like the dynamic loader.
605
606include $(CLEAR_VARS)
607
608LOCAL_SRC_FILES := \
609 $(libc_arch_static_src_files) \
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700610 $(libc_static_common_src_files) \
Dima Zavin49e55332009-05-27 10:52:37 -0700611 bionic/libc_init_static.c
612
613LOCAL_C_INCLUDES := $(libc_common_c_includes)
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700614LOCAL_CFLAGS := $(libc_common_cflags) \
615 -DLIBC_STATIC
Dima Zavin49e55332009-05-27 10:52:37 -0700616
617LOCAL_MODULE := libc_nomalloc
618LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
619LOCAL_SYSTEM_SHARED_LIBRARIES :=
620
621include $(BUILD_STATIC_LIBRARY)
622
623
624# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800625# libc.a
626# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800627include $(CLEAR_VARS)
628
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800629LOCAL_SRC_FILES := \
Dima Zavinca122b02009-05-27 10:52:37 -0700630 $(libc_arch_static_src_files) \
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700631 $(libc_static_common_src_files) \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800632 bionic/dlmalloc.c \
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800633 bionic/malloc_debug_common.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800634 bionic/libc_init_static.c
635
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800636LOCAL_CFLAGS := $(libc_common_cflags) \
637 -DLIBC_STATIC
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800638LOCAL_C_INCLUDES := $(libc_common_c_includes)
Dima Zavinca122b02009-05-27 10:52:37 -0700639LOCAL_MODULE := libc
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800640LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800641LOCAL_SYSTEM_SHARED_LIBRARIES :=
642
643include $(BUILD_STATIC_LIBRARY)
644
645
Dima Zavinca122b02009-05-27 10:52:37 -0700646# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800647# libc.so
648# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800649include $(CLEAR_VARS)
650
651LOCAL_CFLAGS := $(libc_common_cflags)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800652LOCAL_C_INCLUDES := $(libc_common_c_includes)
653
654LOCAL_SRC_FILES := \
Dima Zavinca122b02009-05-27 10:52:37 -0700655 $(libc_arch_dynamic_src_files) \
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700656 $(libc_static_common_src_files) \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800657 bionic/dlmalloc.c \
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800658 bionic/malloc_debug_common.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800659 bionic/libc_init_dynamic.c
660
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800661LOCAL_MODULE:= libc
662
663# WARNING: The only library libc.so should depend on is libdl.so! If you add other libraries,
664# make sure to add -Wl,--exclude-libs=libgcc.a to the LOCAL_LDFLAGS for those libraries. This
665# ensures that symbols that are pulled into those new libraries from libgcc.a are not declared
666# external; if that were the case, then libc would not pull those symbols from libgcc.a as it
667# should, instead relying on the external symbols from the dependent libraries. That would
668# create an "cloaked" dependency on libgcc.a in libc though the libraries, which is not what
669# you wanted!
670
671LOCAL_SHARED_LIBRARIES := libdl
672LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
673LOCAL_SYSTEM_SHARED_LIBRARIES :=
674
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800675include $(BUILD_SHARED_LIBRARY)
676
677
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800678# For all builds, except for the -user build we will enable memory
679# allocation checking (including memory leaks, buffer overwrites, etc.)
680# Note that all these checks are also controlled by env. settings
681# that can enable, or disable specific checks. Note also that some of
682# the checks are available only in emulator and are implemeted in
683# libc_malloc_qemu_instrumented.so.
684ifneq ($(TARGET_BUILD_VARIANT),user)
685
Dima Zavinca122b02009-05-27 10:52:37 -0700686# ========================================================
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800687# libc_malloc_debug_leak.so
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800688# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800689include $(CLEAR_VARS)
690
Dima Zavinca122b02009-05-27 10:52:37 -0700691LOCAL_CFLAGS := \
692 $(libc_common_cflags) \
693 -DMALLOC_LEAK_CHECK
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800694
695LOCAL_C_INCLUDES := $(libc_common_c_includes)
696
697LOCAL_SRC_FILES := \
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800698 bionic/malloc_debug_leak.c
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800699
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800700LOCAL_MODULE:= libc_malloc_debug_leak
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800701
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800702LOCAL_SHARED_LIBRARIES := libc
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800703LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
704LOCAL_SYSTEM_SHARED_LIBRARIES :=
705# Don't prelink
706LOCAL_PRELINK_MODULE := false
707# Don't install on release build
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800708LOCAL_MODULE_TAGS := eng debug
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800709
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800710include $(BUILD_SHARED_LIBRARY)
711
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800712
713# ========================================================
714# libc_malloc_debug_qemu.so
715# ========================================================
716include $(CLEAR_VARS)
717
718LOCAL_CFLAGS := \
719 $(libc_common_cflags) \
720 -DMALLOC_QEMU_INSTRUMENT
721
722LOCAL_C_INCLUDES := $(libc_common_c_includes)
723
724LOCAL_SRC_FILES := \
725 bionic/malloc_debug_qemu.c
726
727LOCAL_MODULE:= libc_malloc_debug_qemu
728
729LOCAL_SHARED_LIBRARIES := libc
730LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
731LOCAL_SYSTEM_SHARED_LIBRARIES :=
732# Don't prelink
733LOCAL_PRELINK_MODULE := false
734# Don't install on release build
735LOCAL_MODULE_TAGS := eng debug
736
737include $(BUILD_SHARED_LIBRARY)
738
739endif #!user
740
741
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800742# ========================================================
743include $(call all-makefiles-under,$(LOCAL_PATH))