blob: 9e6bdfbb493023d5793ed38dd1211debaa811bb9 [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 \
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 \
Kenny Rootcb99ab92010-09-10 12:20:58 -0700234 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 \
244 tzcode/asctime.c \
245 tzcode/difftime.c \
246 tzcode/localtime.c \
247 tzcode/strftime.c \
248 tzcode/strptime.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800249 bionic/__set_errno.c \
250 bionic/_rand48.c \
Mike Chan9f691562010-03-02 10:55:58 -0800251 bionic/cpuacct.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800252 bionic/arc4random.c \
253 bionic/basename.c \
254 bionic/basename_r.c \
Colin Crossfc10b242010-01-13 17:48:34 -0800255 bionic/clearenv.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800256 bionic/dirname.c \
257 bionic/dirname_r.c \
258 bionic/drand48.c \
259 bionic/erand48.c \
Colin Cross64ceac32010-01-13 21:19:52 -0800260 bionic/err.c \
Colin Crossfc10b242010-01-13 17:48:34 -0800261 bionic/fdprintf.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800262 bionic/fork.c \
Colin Cross64ceac32010-01-13 21:19:52 -0800263 bionic/fts.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800264 bionic/if_nametoindex.c \
265 bionic/if_indextoname.c \
266 bionic/ioctl.c \
267 bionic/ldexp.c \
268 bionic/libc_init_common.c \
269 bionic/logd_write.c \
270 bionic/md5.c \
271 bionic/pututline.c \
272 bionic/realpath.c \
273 bionic/semaphore.c \
274 bionic/sha1.c \
275 bionic/ssp.c \
276 bionic/stubs.c \
277 bionic/system_properties.c \
278 bionic/time64.c \
279 bionic/thread_atexit.c \
280 bionic/utime.c \
281 bionic/utmp.c \
282 netbsd/gethnamaddr.c \
283 netbsd/isc/ev_timers.c \
284 netbsd/isc/ev_streams.c \
285 netbsd/inet/nsap_addr.c \
286 netbsd/resolv/__dn_comp.c \
287 netbsd/resolv/__res_close.c \
288 netbsd/resolv/__res_send.c \
289 netbsd/resolv/herror.c \
290 netbsd/resolv/res_comp.c \
291 netbsd/resolv/res_data.c \
292 netbsd/resolv/res_debug.c \
293 netbsd/resolv/res_init.c \
294 netbsd/resolv/res_mkquery.c \
295 netbsd/resolv/res_query.c \
296 netbsd/resolv/res_send.c \
Shin-ichiro KAWASAKI10093272009-09-28 16:11:39 +0900297 netbsd/resolv/res_state.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800298 netbsd/resolv/res_cache.c \
299 netbsd/net/nsdispatch.c \
300 netbsd/net/getaddrinfo.c \
301 netbsd/net/getnameinfo.c \
302 netbsd/net/getservbyname.c \
303 netbsd/net/getservent.c \
304 netbsd/net/base64.c \
305 netbsd/net/getservbyport.c \
306 netbsd/nameser/ns_name.c \
307 netbsd/nameser/ns_parse.c \
308 netbsd/nameser/ns_ttl.c \
309 netbsd/nameser/ns_netint.c \
310 netbsd/nameser/ns_print.c \
Colin Cross4fa7b102010-01-12 18:59:25 -0800311 netbsd/nameser/ns_samedomain.c \
312 regex/regcomp.c \
313 regex/regerror.c \
314 regex/regexec.c \
315 regex/regfree.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800316
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700317# The following files are common, but must be compiled
318# with different C flags when building a static C library.
319#
320# The reason for this is the implementation of __get_tls()
321# that will differ between the shared and static versions
322# of the library.
323#
324# See comments in private/bionic_tls.h for more details.
325#
326# NOTE: bionic/pthread.c is added later to this list
327# because it needs special handling on ARM, see
328# below.
329#
330libc_static_common_src_files := \
331 unistd/sysconf.c \
332 bionic/__errno.c \
333
Dima Zavinca122b02009-05-27 10:52:37 -0700334# Architecture specific source files go here
335# =========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800336ifeq ($(TARGET_ARCH),arm)
337libc_common_src_files += \
David 'Digit' Turner97cf7f32010-01-22 18:59:05 -0800338 bionic/bionic_clone.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800339 arch-arm/bionic/__get_pc.S \
340 arch-arm/bionic/__get_sp.S \
341 arch-arm/bionic/_exit_with_stack_teardown.S \
342 arch-arm/bionic/_setjmp.S \
343 arch-arm/bionic/atomics_arm.S \
344 arch-arm/bionic/clone.S \
David 'Digit' Turner6a9b8882010-06-18 14:47:22 -0700345 arch-arm/bionic/eabi.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800346 arch-arm/bionic/ffs.S \
347 arch-arm/bionic/kill.S \
David 'Digit' Turner2a7ad972009-09-29 14:43:38 -0700348 arch-arm/bionic/libgcc_compat.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800349 arch-arm/bionic/tkill.S \
350 arch-arm/bionic/memcmp.S \
351 arch-arm/bionic/memcmp16.S \
352 arch-arm/bionic/memcpy.S \
353 arch-arm/bionic/memset.S \
354 arch-arm/bionic/setjmp.S \
355 arch-arm/bionic/sigsetjmp.S \
356 arch-arm/bionic/strlen.c.arm \
357 arch-arm/bionic/syscall.S \
Shin-ichiro KAWASAKI10093272009-09-28 16:11:39 +0900358 string/memmove.c.arm \
Bruce Beare8ff1a272010-03-04 11:03:37 -0800359 string/bcopy.c \
360 string/strcmp.c \
361 string/strncmp.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800362 unistd/socketcalls.c
363
364# These files need to be arm so that gdbserver
365# can set breakpoints in them without messing
366# up any thumb code.
367libc_common_src_files += \
David 'Digit' Turner8a1d2cf2010-05-11 16:39:22 -0700368 bionic/pthread-rwlocks.c.arm \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800369 bionic/pthread-timers.c.arm \
370 bionic/ptrace.c.arm
Dima Zavinca122b02009-05-27 10:52:37 -0700371
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700372libc_static_common_src_files += \
373 bionic/pthread.c.arm \
374
Dima Zavinca122b02009-05-27 10:52:37 -0700375# these are used by the static and dynamic versions of the libc
376# respectively
377libc_arch_static_src_files := \
378 arch-arm/bionic/exidx_static.c
379
380libc_arch_dynamic_src_files := \
381 arch-arm/bionic/exidx_dynamic.c
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800382else # !arm
383
384ifeq ($(TARGET_ARCH),x86)
385libc_common_src_files += \
386 arch-x86/bionic/__get_sp.S \
387 arch-x86/bionic/__get_tls.c \
388 arch-x86/bionic/__set_tls.c \
389 arch-x86/bionic/atomics_x86.S \
390 arch-x86/bionic/clone.S \
391 arch-x86/bionic/_exit_with_stack_teardown.S \
392 arch-x86/bionic/setjmp.S \
393 arch-x86/bionic/_setjmp.S \
394 arch-x86/bionic/vfork.S \
Bruce Beare3c543e12010-03-04 10:29:38 -0800395 arch-x86/bionic/syscall.S \
Bruce Beare8ff1a272010-03-04 11:03:37 -0800396 arch-x86/string/bcopy_wrapper.S \
397 arch-x86/string/memcpy_wrapper.S \
398 arch-x86/string/memmove_wrapper.S \
399 arch-x86/string/bzero_wrapper.S \
400 arch-x86/string/memcmp_wrapper.S \
401 arch-x86/string/memset_wrapper.S \
402 arch-x86/string/strcmp_wrapper.S \
403 arch-x86/string/strncmp_wrapper.S \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800404 arch-x86/string/strlen.S \
David 'Digit' Turner8a1d2cf2010-05-11 16:39:22 -0700405 bionic/pthread-rwlocks.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800406 bionic/pthread-timers.c \
407 bionic/ptrace.c
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800408
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700409libc_static_common_src_files += \
410 bionic/pthread.c \
411
Dima Zavinca122b02009-05-27 10:52:37 -0700412# this is needed for static versions of libc
413libc_arch_static_src_files := \
414 arch-x86/bionic/dl_iterate_phdr_static.c
415
416libc_arch_dynamic_src_files :=
Shin-ichiro KAWASAKI10093272009-09-28 16:11:39 +0900417else # !x86
418
419ifeq ($(TARGET_ARCH),sh)
420libc_common_src_files += \
421 arch-sh/bionic/__get_pc.S \
422 arch-sh/bionic/__get_sp.S \
423 arch-sh/bionic/_exit_with_stack_teardown.S \
424 arch-sh/bionic/_setjmp.S \
425 arch-sh/bionic/atomics_sh.c \
426 arch-sh/bionic/atomic_cmpxchg.S \
427 arch-sh/bionic/clone.S \
428 arch-sh/bionic/pipe.S \
429 arch-sh/bionic/memcpy.S \
430 arch-sh/bionic/memset.S \
431 arch-sh/bionic/bzero.S \
432 arch-sh/bionic/setjmp.S \
433 arch-sh/bionic/sigsetjmp.S \
434 arch-sh/bionic/syscall.S \
435 arch-sh/bionic/memmove.S \
436 arch-sh/bionic/__set_tls.c \
437 arch-sh/bionic/__get_tls.c \
438 arch-sh/bionic/ffs.S \
Bruce Beare8ff1a272010-03-04 11:03:37 -0800439 string/bcopy.c \
440 string/strcmp.c \
441 string/strncmp.c \
Shin-ichiro KAWASAKI10093272009-09-28 16:11:39 +0900442 string/memcmp.c \
443 string/strlen.c \
David 'Digit' Turner8a1d2cf2010-05-11 16:39:22 -0700444 bionic/pthread-rwlocks.c \
Shin-ichiro KAWASAKI10093272009-09-28 16:11:39 +0900445 bionic/pthread-timers.c \
446 bionic/ptrace.c \
447 unistd/socketcalls.c
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700448
449libc_static_common_src_files += \
450 bionic/pthread.c \
451
Shin-ichiro KAWASAKI10093272009-09-28 16:11:39 +0900452endif # sh
453
454endif # !x86
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800455endif # !arm
456
Dima Zavinca122b02009-05-27 10:52:37 -0700457# Define some common cflags
458# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800459libc_common_cflags := \
460 -DWITH_ERRLIST \
461 -DANDROID_CHANGES \
462 -DUSE_LOCKS \
463 -DREALLOC_ZERO_BYTES_FREES \
464 -D_LIBC=1 \
465 -DSOFTFLOAT \
466 -DFLOATING_POINT \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800467 -DINET6 \
468 -I$(LOCAL_PATH)/private \
Colin Cross4fa7b102010-01-12 18:59:25 -0800469 -DUSE_DL_PREFIX \
470 -DPOSIX_MISTAKE
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800471
David 'Digit' Turnerd7ed1ae2010-03-05 14:17:35 -0800472# these macro definitions are required to implement the
473# 'timezone' and 'daylight' global variables, as well as
474# properly update the 'tm_gmtoff' field in 'struct tm'.
475#
476libc_common_cflags += \
477 -DTM_GMTOFF=tm_gmtoff \
478 -DUSG_COMPAT=1
479
Dave Bortd2c9dcc2009-04-23 15:50:03 -0700480ifeq ($(strip $(DEBUG_BIONIC_LIBC)),true)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800481 libc_common_cflags += -DDEBUG
482endif
483
484ifeq ($(TARGET_ARCH),arm)
485 libc_common_cflags += -fstrict-aliasing
Dima Zavinca122b02009-05-27 10:52:37 -0700486 libc_crt_target_cflags := -mthumb-interwork
David 'Digit' Turner4a05d122009-09-18 13:35:05 -0700487 #
488 # Define HAVE_ARM_TLS_REGISTER macro to indicate to the C library
489 # that it should access the hardware TLS register directly in
490 # private/bionic_tls.h
491 #
492 # The value must match your kernel configuration
493 #
494 ifeq ($(ARCH_ARM_HAVE_TLS_REGISTER),true)
495 libc_common_cflags += -DHAVE_ARM_TLS_REGISTER
496 endif
Dima Zavinca122b02009-05-27 10:52:37 -0700497else # !arm
498 ifeq ($(TARGET_ARCH),x86)
499 libc_crt_target_cflags := -m32
Bruce Beare8ff1a272010-03-04 11:03:37 -0800500
501 # Enable recent IA friendly memory routines (such as for Atom)
502 # These will not work on the earlier x86 machines
503 libc_common_cflags += -mtune=i686 -DUSE_SSSE3 -DUSE_SSE2
Dima Zavinca122b02009-05-27 10:52:37 -0700504 endif # x86
505endif # !arm
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800506
Andy McFaddenfcd00eb2010-05-28 13:31:45 -0700507# Define ANDROID_SMP appropriately.
508ifeq ($(TARGET_CPU_SMP),true)
509 libc_common_cflags += -DANDROID_SMP=1
510else
511 libc_common_cflags += -DANDROID_SMP=0
512endif
513
David 'Digit' Turner6a9b8882010-06-18 14:47:22 -0700514# Needed to access private/__dso_handle.S from
515# crtbegin_xxx.S and crtend_xxx.S
516#
517libc_crt_target_cflags += -I$(LOCAL_PATH)/private
Andy McFaddenfcd00eb2010-05-28 13:31:45 -0700518
Dima Zavinca122b02009-05-27 10:52:37 -0700519# Define some common includes
520# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800521libc_common_c_includes := \
522 $(LOCAL_PATH)/stdlib \
523 $(LOCAL_PATH)/string \
524 $(LOCAL_PATH)/stdio
525
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800526
Dima Zavinca122b02009-05-27 10:52:37 -0700527# Define the libc run-time (crt) support object files that must be built,
528# which are needed to build all other objects (shared/static libs and
529# executables)
530# ==========================================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800531
David 'Digit' Turner6a9b8882010-06-18 14:47:22 -0700532ifneq ($(filter arm x86,$(TARGET_ARCH)),)
533# ARM and x86 need crtbegin_so/crtend_so.
534#
535# For x86, the .init section must point to a function that calls all
536# entries in the .ctors section. (on ARM this is done through the
537# .init_array section instead).
538#
539# For both platforms, the .fini_array section must point to a function
540# that will call __cxa_finalize(&__dso_handle) in order to ensure that
541# static C++ destructors are properly called on dlclose().
542#
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800543GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_so.o
544$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin_so.S
545 @mkdir -p $(dir $@)
Dima Zavinca122b02009-05-27 10:52:37 -0700546 $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $<
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800547ALL_GENERATED_SOURCES += $(GEN)
548
549GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_so.o
550$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtend_so.S
551 @mkdir -p $(dir $@)
Dima Zavinca122b02009-05-27 10:52:37 -0700552 $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $<
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800553ALL_GENERATED_SOURCES += $(GEN)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800554endif # TARGET_ARCH == x86
555
Dima Zavinca122b02009-05-27 10:52:37 -0700556
557GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_static.o
558$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin_static.S
559 @mkdir -p $(dir $@)
560 $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $<
561ALL_GENERATED_SOURCES += $(GEN)
562
563GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_dynamic.o
564$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin_dynamic.S
565 @mkdir -p $(dir $@)
566 $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $<
567ALL_GENERATED_SOURCES += $(GEN)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800568
569
Dima Zavinca122b02009-05-27 10:52:37 -0700570# We rename crtend.o to crtend_android.o to avoid a
571# name clash between gcc and bionic.
572GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_android.o
573$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtend.S
574 @mkdir -p $(dir $@)
575 $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $<
576ALL_GENERATED_SOURCES += $(GEN)
577
578
579# To enable malloc leak check for statically linked programs, add
580# "WITH_MALLOC_CHECK_LIBC_A := true" to buildspec.mk
581WITH_MALLOC_CHECK_LIBC_A := $(strip $(WITH_MALLOC_CHECK_LIBC_A))
582
583# ========================================================
584# libc_common.a
585# ========================================================
586include $(CLEAR_VARS)
587
588LOCAL_SRC_FILES := $(libc_common_src_files)
589LOCAL_CFLAGS := $(libc_common_cflags)
590LOCAL_C_INCLUDES := $(libc_common_c_includes)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800591LOCAL_MODULE := libc_common
592LOCAL_SYSTEM_SHARED_LIBRARIES :=
593
594include $(BUILD_STATIC_LIBRARY)
595
596
Dima Zavinca122b02009-05-27 10:52:37 -0700597# ========================================================
Dima Zavin49e55332009-05-27 10:52:37 -0700598# libc_nomalloc.a
599# ========================================================
600#
601# This is a version of the static C library that does not
602# include malloc. It's useful in situations when calling
603# the user wants to provide their own malloc implementation,
604# or wants to explicitly disallow the use of the use of malloc,
605# like the dynamic loader.
606
607include $(CLEAR_VARS)
608
609LOCAL_SRC_FILES := \
610 $(libc_arch_static_src_files) \
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700611 $(libc_static_common_src_files) \
Dima Zavin49e55332009-05-27 10:52:37 -0700612 bionic/libc_init_static.c
613
614LOCAL_C_INCLUDES := $(libc_common_c_includes)
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700615LOCAL_CFLAGS := $(libc_common_cflags) \
616 -DLIBC_STATIC
Dima Zavin49e55332009-05-27 10:52:37 -0700617
618LOCAL_MODULE := libc_nomalloc
619LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
620LOCAL_SYSTEM_SHARED_LIBRARIES :=
621
622include $(BUILD_STATIC_LIBRARY)
623
624
625# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800626# libc.a
627# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800628include $(CLEAR_VARS)
629
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800630LOCAL_SRC_FILES := \
Dima Zavinca122b02009-05-27 10:52:37 -0700631 $(libc_arch_static_src_files) \
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700632 $(libc_static_common_src_files) \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800633 bionic/dlmalloc.c \
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800634 bionic/malloc_debug_common.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800635 bionic/libc_init_static.c
636
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800637LOCAL_CFLAGS := $(libc_common_cflags) \
638 -DLIBC_STATIC
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800639LOCAL_C_INCLUDES := $(libc_common_c_includes)
Dima Zavinca122b02009-05-27 10:52:37 -0700640LOCAL_MODULE := libc
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800641LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800642LOCAL_SYSTEM_SHARED_LIBRARIES :=
643
644include $(BUILD_STATIC_LIBRARY)
645
646
Dima Zavinca122b02009-05-27 10:52:37 -0700647# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800648# libc.so
649# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800650include $(CLEAR_VARS)
651
652LOCAL_CFLAGS := $(libc_common_cflags)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800653LOCAL_C_INCLUDES := $(libc_common_c_includes)
654
655LOCAL_SRC_FILES := \
Dima Zavinca122b02009-05-27 10:52:37 -0700656 $(libc_arch_dynamic_src_files) \
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700657 $(libc_static_common_src_files) \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800658 bionic/dlmalloc.c \
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800659 bionic/malloc_debug_common.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800660 bionic/libc_init_dynamic.c
661
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800662LOCAL_MODULE:= libc
663
664# WARNING: The only library libc.so should depend on is libdl.so! If you add other libraries,
665# make sure to add -Wl,--exclude-libs=libgcc.a to the LOCAL_LDFLAGS for those libraries. This
666# ensures that symbols that are pulled into those new libraries from libgcc.a are not declared
667# external; if that were the case, then libc would not pull those symbols from libgcc.a as it
668# should, instead relying on the external symbols from the dependent libraries. That would
669# create an "cloaked" dependency on libgcc.a in libc though the libraries, which is not what
670# you wanted!
671
672LOCAL_SHARED_LIBRARIES := libdl
673LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
674LOCAL_SYSTEM_SHARED_LIBRARIES :=
675
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800676include $(BUILD_SHARED_LIBRARY)
677
678
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800679# For all builds, except for the -user build we will enable memory
680# allocation checking (including memory leaks, buffer overwrites, etc.)
681# Note that all these checks are also controlled by env. settings
682# that can enable, or disable specific checks. Note also that some of
683# the checks are available only in emulator and are implemeted in
684# libc_malloc_qemu_instrumented.so.
685ifneq ($(TARGET_BUILD_VARIANT),user)
686
Dima Zavinca122b02009-05-27 10:52:37 -0700687# ========================================================
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800688# libc_malloc_debug_leak.so
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800689# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800690include $(CLEAR_VARS)
691
Dima Zavinca122b02009-05-27 10:52:37 -0700692LOCAL_CFLAGS := \
693 $(libc_common_cflags) \
694 -DMALLOC_LEAK_CHECK
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800695
696LOCAL_C_INCLUDES := $(libc_common_c_includes)
697
698LOCAL_SRC_FILES := \
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800699 bionic/malloc_debug_leak.c
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800700
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800701LOCAL_MODULE:= libc_malloc_debug_leak
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800702
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800703LOCAL_SHARED_LIBRARIES := libc
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800704LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
705LOCAL_SYSTEM_SHARED_LIBRARIES :=
706# Don't prelink
707LOCAL_PRELINK_MODULE := false
708# Don't install on release build
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800709LOCAL_MODULE_TAGS := eng debug
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800710
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800711include $(BUILD_SHARED_LIBRARY)
712
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800713
714# ========================================================
715# libc_malloc_debug_qemu.so
716# ========================================================
717include $(CLEAR_VARS)
718
719LOCAL_CFLAGS := \
720 $(libc_common_cflags) \
721 -DMALLOC_QEMU_INSTRUMENT
722
723LOCAL_C_INCLUDES := $(libc_common_c_includes)
724
725LOCAL_SRC_FILES := \
726 bionic/malloc_debug_qemu.c
727
728LOCAL_MODULE:= libc_malloc_debug_qemu
729
730LOCAL_SHARED_LIBRARIES := libc
731LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
732LOCAL_SYSTEM_SHARED_LIBRARIES :=
733# Don't prelink
734LOCAL_PRELINK_MODULE := false
735# Don't install on release build
736LOCAL_MODULE_TAGS := eng debug
737
738include $(BUILD_SHARED_LIBRARY)
739
740endif #!user
741
742
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800743# ========================================================
744include $(call all-makefiles-under,$(LOCAL_PATH))