blob: 32bf9322eb7d7af83e6fb518c95224a474c873b6 [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 \
67 unistd/sysconf.c \
68 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 \
190 string/strcpy.c \
191 string/strcspn.c \
192 string/strdup.c \
193 string/strerror.c \
194 string/strerror_r.c \
195 string/strlcat.c \
196 string/strlcpy.c \
197 string/strncat.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800198 string/strncpy.c \
199 string/strndup.c \
200 string/strnlen.c \
201 string/strpbrk.c \
202 string/strrchr.c \
203 string/strsep.c \
204 string/strspn.c \
205 string/strstr.c \
206 string/strtok.c \
207 string/strtotimeval.c \
208 string/strxfrm.c \
David 'Digit' Turner3527fd62010-06-14 17:18:35 -0700209 wchar/wcpcpy.c \
210 wchar/wcpncpy.c \
211 wchar/wcscasecmp.c \
212 wchar/wcscat.c \
213 wchar/wcschr.c \
214 wchar/wcscmp.c \
215 wchar/wcscoll.c \
216 wchar/wcscpy.c \
217 wchar/wcscspn.c \
218 wchar/wcsdup.c \
219 wchar/wcslcat.c \
220 wchar/wcslcpy.c \
221 wchar/wcslen.c \
222 wchar/wcsncasecmp.c \
223 wchar/wcsncat.c \
224 wchar/wcsncmp.c \
225 wchar/wcsncpy.c \
226 wchar/wcsnlen.c \
227 wchar/wcspbrk.c \
228 wchar/wcsrchr.c \
229 wchar/wcsspn.c \
230 wchar/wcsstr.c \
231 wchar/wcstok.c \
232 wchar/wcswidth.c \
233 wchar/wmemchr.c \
234 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 \
Szymon Jakubczak41e533a2010-06-09 15:53:28 -0400243 inet/ether_aton.c \
244 inet/ether_ntoa.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800245 tzcode/asctime.c \
246 tzcode/difftime.c \
247 tzcode/localtime.c \
248 tzcode/strftime.c \
249 tzcode/strptime.c \
250 bionic/__errno.c \
251 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
Dima Zavinca122b02009-05-27 10:52:37 -0700319# Architecture specific source files go here
320# =========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800321ifeq ($(TARGET_ARCH),arm)
322libc_common_src_files += \
David 'Digit' Turner97cf7f32010-01-22 18:59:05 -0800323 bionic/bionic_clone.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800324 arch-arm/bionic/__get_pc.S \
325 arch-arm/bionic/__get_sp.S \
326 arch-arm/bionic/_exit_with_stack_teardown.S \
327 arch-arm/bionic/_setjmp.S \
328 arch-arm/bionic/atomics_arm.S \
329 arch-arm/bionic/clone.S \
David 'Digit' Turner6a9b8882010-06-18 14:47:22 -0700330 arch-arm/bionic/eabi.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800331 arch-arm/bionic/ffs.S \
332 arch-arm/bionic/kill.S \
David 'Digit' Turner2a7ad972009-09-29 14:43:38 -0700333 arch-arm/bionic/libgcc_compat.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800334 arch-arm/bionic/tkill.S \
335 arch-arm/bionic/memcmp.S \
336 arch-arm/bionic/memcmp16.S \
337 arch-arm/bionic/memcpy.S \
338 arch-arm/bionic/memset.S \
339 arch-arm/bionic/setjmp.S \
340 arch-arm/bionic/sigsetjmp.S \
341 arch-arm/bionic/strlen.c.arm \
342 arch-arm/bionic/syscall.S \
Shin-ichiro KAWASAKI10093272009-09-28 16:11:39 +0900343 string/memmove.c.arm \
Bruce Beare8ff1a272010-03-04 11:03:37 -0800344 string/bcopy.c \
345 string/strcmp.c \
346 string/strncmp.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800347 unistd/socketcalls.c
348
349# These files need to be arm so that gdbserver
350# can set breakpoints in them without messing
351# up any thumb code.
352libc_common_src_files += \
353 bionic/pthread.c.arm \
Matt Fischer4f086ae2010-06-25 14:36:39 -0500354 bionic/pthread-atfork.c.arm \
David 'Digit' Turner8a1d2cf2010-05-11 16:39:22 -0700355 bionic/pthread-rwlocks.c.arm \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800356 bionic/pthread-timers.c.arm \
357 bionic/ptrace.c.arm
Dima Zavinca122b02009-05-27 10:52:37 -0700358
359# these are used by the static and dynamic versions of the libc
360# respectively
361libc_arch_static_src_files := \
362 arch-arm/bionic/exidx_static.c
363
364libc_arch_dynamic_src_files := \
365 arch-arm/bionic/exidx_dynamic.c
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800366else # !arm
367
368ifeq ($(TARGET_ARCH),x86)
369libc_common_src_files += \
370 arch-x86/bionic/__get_sp.S \
371 arch-x86/bionic/__get_tls.c \
372 arch-x86/bionic/__set_tls.c \
373 arch-x86/bionic/atomics_x86.S \
374 arch-x86/bionic/clone.S \
375 arch-x86/bionic/_exit_with_stack_teardown.S \
376 arch-x86/bionic/setjmp.S \
377 arch-x86/bionic/_setjmp.S \
378 arch-x86/bionic/vfork.S \
Bruce Beare3c543e12010-03-04 10:29:38 -0800379 arch-x86/bionic/syscall.S \
Bruce Beare8ff1a272010-03-04 11:03:37 -0800380 arch-x86/string/bcopy_wrapper.S \
381 arch-x86/string/memcpy_wrapper.S \
382 arch-x86/string/memmove_wrapper.S \
383 arch-x86/string/bzero_wrapper.S \
384 arch-x86/string/memcmp_wrapper.S \
385 arch-x86/string/memset_wrapper.S \
386 arch-x86/string/strcmp_wrapper.S \
387 arch-x86/string/strncmp_wrapper.S \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800388 arch-x86/string/strlen.S \
389 bionic/pthread.c \
Matt Fischer4f086ae2010-06-25 14:36:39 -0500390 bionic/pthread-atfork.c \
David 'Digit' Turner8a1d2cf2010-05-11 16:39:22 -0700391 bionic/pthread-rwlocks.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800392 bionic/pthread-timers.c \
393 bionic/ptrace.c
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800394
Dima Zavinca122b02009-05-27 10:52:37 -0700395# this is needed for static versions of libc
396libc_arch_static_src_files := \
397 arch-x86/bionic/dl_iterate_phdr_static.c
398
399libc_arch_dynamic_src_files :=
Shin-ichiro KAWASAKI10093272009-09-28 16:11:39 +0900400else # !x86
401
402ifeq ($(TARGET_ARCH),sh)
403libc_common_src_files += \
404 arch-sh/bionic/__get_pc.S \
405 arch-sh/bionic/__get_sp.S \
406 arch-sh/bionic/_exit_with_stack_teardown.S \
407 arch-sh/bionic/_setjmp.S \
408 arch-sh/bionic/atomics_sh.c \
409 arch-sh/bionic/atomic_cmpxchg.S \
410 arch-sh/bionic/clone.S \
411 arch-sh/bionic/pipe.S \
412 arch-sh/bionic/memcpy.S \
413 arch-sh/bionic/memset.S \
414 arch-sh/bionic/bzero.S \
415 arch-sh/bionic/setjmp.S \
416 arch-sh/bionic/sigsetjmp.S \
417 arch-sh/bionic/syscall.S \
418 arch-sh/bionic/memmove.S \
419 arch-sh/bionic/__set_tls.c \
420 arch-sh/bionic/__get_tls.c \
421 arch-sh/bionic/ffs.S \
Bruce Beare8ff1a272010-03-04 11:03:37 -0800422 string/bcopy.c \
423 string/strcmp.c \
424 string/strncmp.c \
Shin-ichiro KAWASAKI10093272009-09-28 16:11:39 +0900425 string/memcmp.c \
426 string/strlen.c \
Shin-ichiro KAWASAKI10093272009-09-28 16:11:39 +0900427 bionic/pthread.c \
Matt Fischer4f086ae2010-06-25 14:36:39 -0500428 bionic/pthread-atfork.c \
David 'Digit' Turner8a1d2cf2010-05-11 16:39:22 -0700429 bionic/pthread-rwlocks.c \
Shin-ichiro KAWASAKI10093272009-09-28 16:11:39 +0900430 bionic/pthread-timers.c \
431 bionic/ptrace.c \
432 unistd/socketcalls.c
433endif # sh
434
435endif # !x86
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800436endif # !arm
437
Dima Zavinca122b02009-05-27 10:52:37 -0700438# Define some common cflags
439# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800440libc_common_cflags := \
441 -DWITH_ERRLIST \
442 -DANDROID_CHANGES \
443 -DUSE_LOCKS \
444 -DREALLOC_ZERO_BYTES_FREES \
445 -D_LIBC=1 \
446 -DSOFTFLOAT \
447 -DFLOATING_POINT \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800448 -DINET6 \
449 -I$(LOCAL_PATH)/private \
Colin Cross4fa7b102010-01-12 18:59:25 -0800450 -DUSE_DL_PREFIX \
451 -DPOSIX_MISTAKE
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800452
David 'Digit' Turnerd7ed1ae2010-03-05 14:17:35 -0800453# these macro definitions are required to implement the
454# 'timezone' and 'daylight' global variables, as well as
455# properly update the 'tm_gmtoff' field in 'struct tm'.
456#
457libc_common_cflags += \
458 -DTM_GMTOFF=tm_gmtoff \
459 -DUSG_COMPAT=1
460
Dave Bortd2c9dcc2009-04-23 15:50:03 -0700461ifeq ($(strip $(DEBUG_BIONIC_LIBC)),true)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800462 libc_common_cflags += -DDEBUG
463endif
464
465ifeq ($(TARGET_ARCH),arm)
466 libc_common_cflags += -fstrict-aliasing
Dima Zavinca122b02009-05-27 10:52:37 -0700467 libc_crt_target_cflags := -mthumb-interwork
David 'Digit' Turner4a05d122009-09-18 13:35:05 -0700468 #
469 # Define HAVE_ARM_TLS_REGISTER macro to indicate to the C library
470 # that it should access the hardware TLS register directly in
471 # private/bionic_tls.h
472 #
473 # The value must match your kernel configuration
474 #
475 ifeq ($(ARCH_ARM_HAVE_TLS_REGISTER),true)
476 libc_common_cflags += -DHAVE_ARM_TLS_REGISTER
477 endif
Dima Zavinca122b02009-05-27 10:52:37 -0700478else # !arm
479 ifeq ($(TARGET_ARCH),x86)
480 libc_crt_target_cflags := -m32
Bruce Beare8ff1a272010-03-04 11:03:37 -0800481
482 # Enable recent IA friendly memory routines (such as for Atom)
483 # These will not work on the earlier x86 machines
484 libc_common_cflags += -mtune=i686 -DUSE_SSSE3 -DUSE_SSE2
Dima Zavinca122b02009-05-27 10:52:37 -0700485 endif # x86
486endif # !arm
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800487
Andy McFaddenfcd00eb2010-05-28 13:31:45 -0700488# Define ANDROID_SMP appropriately.
489ifeq ($(TARGET_CPU_SMP),true)
490 libc_common_cflags += -DANDROID_SMP=1
491else
492 libc_common_cflags += -DANDROID_SMP=0
493endif
494
David 'Digit' Turner6a9b8882010-06-18 14:47:22 -0700495# Needed to access private/__dso_handle.S from
496# crtbegin_xxx.S and crtend_xxx.S
497#
498libc_crt_target_cflags += -I$(LOCAL_PATH)/private
Andy McFaddenfcd00eb2010-05-28 13:31:45 -0700499
Dima Zavinca122b02009-05-27 10:52:37 -0700500# Define some common includes
501# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800502libc_common_c_includes := \
503 $(LOCAL_PATH)/stdlib \
504 $(LOCAL_PATH)/string \
505 $(LOCAL_PATH)/stdio
506
David 'Digit' Turner3b43f872010-07-01 23:09:28 -0700507# Needed to access private/__dso_handle.S from
508# crtbegin_xxx.S and crtend_xxx.S
509#
510libc_crt_target_cflags += -I$(LOCAL_PATH)/private
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800511
Dima Zavinca122b02009-05-27 10:52:37 -0700512# Define the libc run-time (crt) support object files that must be built,
513# which are needed to build all other objects (shared/static libs and
514# executables)
515# ==========================================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800516
David 'Digit' Turner6a9b8882010-06-18 14:47:22 -0700517ifneq ($(filter arm x86,$(TARGET_ARCH)),)
518# ARM and x86 need crtbegin_so/crtend_so.
519#
520# For x86, the .init section must point to a function that calls all
521# entries in the .ctors section. (on ARM this is done through the
522# .init_array section instead).
523#
524# For both platforms, the .fini_array section must point to a function
525# that will call __cxa_finalize(&__dso_handle) in order to ensure that
526# static C++ destructors are properly called on dlclose().
527#
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800528GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_so.o
529$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin_so.S
530 @mkdir -p $(dir $@)
Dima Zavinca122b02009-05-27 10:52:37 -0700531 $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $<
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800532ALL_GENERATED_SOURCES += $(GEN)
533
534GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_so.o
535$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtend_so.S
536 @mkdir -p $(dir $@)
Dima Zavinca122b02009-05-27 10:52:37 -0700537 $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $<
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800538ALL_GENERATED_SOURCES += $(GEN)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800539endif # TARGET_ARCH == x86
540
Dima Zavinca122b02009-05-27 10:52:37 -0700541
542GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_static.o
543$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin_static.S
544 @mkdir -p $(dir $@)
545 $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $<
546ALL_GENERATED_SOURCES += $(GEN)
547
548GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_dynamic.o
549$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin_dynamic.S
550 @mkdir -p $(dir $@)
551 $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $<
552ALL_GENERATED_SOURCES += $(GEN)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800553
554
Dima Zavinca122b02009-05-27 10:52:37 -0700555# We rename crtend.o to crtend_android.o to avoid a
556# name clash between gcc and bionic.
557GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_android.o
558$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtend.S
559 @mkdir -p $(dir $@)
560 $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $<
561ALL_GENERATED_SOURCES += $(GEN)
562
563
564# To enable malloc leak check for statically linked programs, add
565# "WITH_MALLOC_CHECK_LIBC_A := true" to buildspec.mk
566WITH_MALLOC_CHECK_LIBC_A := $(strip $(WITH_MALLOC_CHECK_LIBC_A))
567
568# ========================================================
569# libc_common.a
570# ========================================================
571include $(CLEAR_VARS)
572
573LOCAL_SRC_FILES := $(libc_common_src_files)
574LOCAL_CFLAGS := $(libc_common_cflags)
575LOCAL_C_INCLUDES := $(libc_common_c_includes)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800576LOCAL_MODULE := libc_common
577LOCAL_SYSTEM_SHARED_LIBRARIES :=
578
579include $(BUILD_STATIC_LIBRARY)
580
581
Dima Zavinca122b02009-05-27 10:52:37 -0700582# ========================================================
Dima Zavin49e55332009-05-27 10:52:37 -0700583# libc_nomalloc.a
584# ========================================================
585#
586# This is a version of the static C library that does not
587# include malloc. It's useful in situations when calling
588# the user wants to provide their own malloc implementation,
589# or wants to explicitly disallow the use of the use of malloc,
590# like the dynamic loader.
591
592include $(CLEAR_VARS)
593
594LOCAL_SRC_FILES := \
595 $(libc_arch_static_src_files) \
596 bionic/libc_init_static.c
597
598LOCAL_C_INCLUDES := $(libc_common_c_includes)
599LOCAL_CFLAGS := $(libc_common_cflags)
600
601LOCAL_MODULE := libc_nomalloc
602LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
603LOCAL_SYSTEM_SHARED_LIBRARIES :=
604
605include $(BUILD_STATIC_LIBRARY)
606
607
608# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800609# libc.a
610# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800611include $(CLEAR_VARS)
612
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800613LOCAL_SRC_FILES := \
Dima Zavinca122b02009-05-27 10:52:37 -0700614 $(libc_arch_static_src_files) \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800615 bionic/dlmalloc.c \
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800616 bionic/malloc_debug_common.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800617 bionic/libc_init_static.c
618
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800619LOCAL_CFLAGS := $(libc_common_cflags) \
620 -DLIBC_STATIC
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800621LOCAL_C_INCLUDES := $(libc_common_c_includes)
Dima Zavinca122b02009-05-27 10:52:37 -0700622LOCAL_MODULE := libc
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800623LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800624LOCAL_SYSTEM_SHARED_LIBRARIES :=
625
626include $(BUILD_STATIC_LIBRARY)
627
628
Dima Zavinca122b02009-05-27 10:52:37 -0700629# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800630# libc.so
631# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800632include $(CLEAR_VARS)
633
634LOCAL_CFLAGS := $(libc_common_cflags)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800635LOCAL_C_INCLUDES := $(libc_common_c_includes)
636
637LOCAL_SRC_FILES := \
Dima Zavinca122b02009-05-27 10:52:37 -0700638 $(libc_arch_dynamic_src_files) \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800639 bionic/dlmalloc.c \
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800640 bionic/malloc_debug_common.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800641 bionic/libc_init_dynamic.c
642
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800643LOCAL_MODULE:= libc
644
645# WARNING: The only library libc.so should depend on is libdl.so! If you add other libraries,
646# make sure to add -Wl,--exclude-libs=libgcc.a to the LOCAL_LDFLAGS for those libraries. This
647# ensures that symbols that are pulled into those new libraries from libgcc.a are not declared
648# external; if that were the case, then libc would not pull those symbols from libgcc.a as it
649# should, instead relying on the external symbols from the dependent libraries. That would
650# create an "cloaked" dependency on libgcc.a in libc though the libraries, which is not what
651# you wanted!
652
653LOCAL_SHARED_LIBRARIES := libdl
654LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
655LOCAL_SYSTEM_SHARED_LIBRARIES :=
656
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800657include $(BUILD_SHARED_LIBRARY)
658
659
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800660# For all builds, except for the -user build we will enable memory
661# allocation checking (including memory leaks, buffer overwrites, etc.)
662# Note that all these checks are also controlled by env. settings
663# that can enable, or disable specific checks. Note also that some of
664# the checks are available only in emulator and are implemeted in
665# libc_malloc_qemu_instrumented.so.
666ifneq ($(TARGET_BUILD_VARIANT),user)
667
Dima Zavinca122b02009-05-27 10:52:37 -0700668# ========================================================
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800669# libc_malloc_debug_leak.so
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800670# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800671include $(CLEAR_VARS)
672
Dima Zavinca122b02009-05-27 10:52:37 -0700673LOCAL_CFLAGS := \
674 $(libc_common_cflags) \
675 -DMALLOC_LEAK_CHECK
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800676
677LOCAL_C_INCLUDES := $(libc_common_c_includes)
678
679LOCAL_SRC_FILES := \
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800680 bionic/malloc_debug_leak.c
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800681
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800682LOCAL_MODULE:= libc_malloc_debug_leak
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800683
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800684LOCAL_SHARED_LIBRARIES := libc
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800685LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
686LOCAL_SYSTEM_SHARED_LIBRARIES :=
Bruce Beareaa46fa22010-07-08 14:47:50 -0700687LOCAL_ALLOW_UNDEFINED_SYMBOLS := true
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800688# Don't prelink
689LOCAL_PRELINK_MODULE := false
690# Don't install on release build
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800691LOCAL_MODULE_TAGS := eng debug
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800692
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800693include $(BUILD_SHARED_LIBRARY)
694
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800695
696# ========================================================
697# libc_malloc_debug_qemu.so
698# ========================================================
699include $(CLEAR_VARS)
700
701LOCAL_CFLAGS := \
702 $(libc_common_cflags) \
703 -DMALLOC_QEMU_INSTRUMENT
704
705LOCAL_C_INCLUDES := $(libc_common_c_includes)
706
707LOCAL_SRC_FILES := \
708 bionic/malloc_debug_qemu.c
709
710LOCAL_MODULE:= libc_malloc_debug_qemu
711
712LOCAL_SHARED_LIBRARIES := libc
713LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
714LOCAL_SYSTEM_SHARED_LIBRARIES :=
715# Don't prelink
716LOCAL_PRELINK_MODULE := false
717# Don't install on release build
718LOCAL_MODULE_TAGS := eng debug
719
720include $(BUILD_SHARED_LIBRARY)
721
722endif #!user
723
724
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800725# ========================================================
726include $(call all-makefiles-under,$(LOCAL_PATH))