blob: f700ca074b49982d15ca57cfc255c4d57681aabb [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 \
233 wchar/wmemcpy.c \
234 wchar/wmemmove.c \
235 wchar/wmemset.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800236 inet/bindresvport.c \
237 inet/inet_addr.c \
238 inet/inet_aton.c \
239 inet/inet_ntoa.c \
240 inet/inet_ntop.c \
241 inet/inet_pton.c \
242 tzcode/asctime.c \
243 tzcode/difftime.c \
244 tzcode/localtime.c \
245 tzcode/strftime.c \
246 tzcode/strptime.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800247 bionic/__set_errno.c \
248 bionic/_rand48.c \
Mike Chan9f691562010-03-02 10:55:58 -0800249 bionic/cpuacct.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800250 bionic/arc4random.c \
251 bionic/basename.c \
252 bionic/basename_r.c \
Colin Crossfc10b242010-01-13 17:48:34 -0800253 bionic/clearenv.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800254 bionic/dirname.c \
255 bionic/dirname_r.c \
256 bionic/drand48.c \
257 bionic/erand48.c \
Colin Cross64ceac32010-01-13 21:19:52 -0800258 bionic/err.c \
Colin Crossfc10b242010-01-13 17:48:34 -0800259 bionic/fdprintf.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800260 bionic/fork.c \
Colin Cross64ceac32010-01-13 21:19:52 -0800261 bionic/fts.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800262 bionic/if_nametoindex.c \
263 bionic/if_indextoname.c \
264 bionic/ioctl.c \
265 bionic/ldexp.c \
266 bionic/libc_init_common.c \
267 bionic/logd_write.c \
268 bionic/md5.c \
269 bionic/pututline.c \
270 bionic/realpath.c \
271 bionic/semaphore.c \
272 bionic/sha1.c \
273 bionic/ssp.c \
274 bionic/stubs.c \
275 bionic/system_properties.c \
276 bionic/time64.c \
277 bionic/thread_atexit.c \
278 bionic/utime.c \
279 bionic/utmp.c \
280 netbsd/gethnamaddr.c \
281 netbsd/isc/ev_timers.c \
282 netbsd/isc/ev_streams.c \
283 netbsd/inet/nsap_addr.c \
284 netbsd/resolv/__dn_comp.c \
285 netbsd/resolv/__res_close.c \
286 netbsd/resolv/__res_send.c \
287 netbsd/resolv/herror.c \
288 netbsd/resolv/res_comp.c \
289 netbsd/resolv/res_data.c \
290 netbsd/resolv/res_debug.c \
291 netbsd/resolv/res_init.c \
292 netbsd/resolv/res_mkquery.c \
293 netbsd/resolv/res_query.c \
294 netbsd/resolv/res_send.c \
Shin-ichiro KAWASAKI10093272009-09-28 16:11:39 +0900295 netbsd/resolv/res_state.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800296 netbsd/resolv/res_cache.c \
297 netbsd/net/nsdispatch.c \
298 netbsd/net/getaddrinfo.c \
299 netbsd/net/getnameinfo.c \
300 netbsd/net/getservbyname.c \
301 netbsd/net/getservent.c \
302 netbsd/net/base64.c \
303 netbsd/net/getservbyport.c \
304 netbsd/nameser/ns_name.c \
305 netbsd/nameser/ns_parse.c \
306 netbsd/nameser/ns_ttl.c \
307 netbsd/nameser/ns_netint.c \
308 netbsd/nameser/ns_print.c \
Colin Cross4fa7b102010-01-12 18:59:25 -0800309 netbsd/nameser/ns_samedomain.c \
310 regex/regcomp.c \
311 regex/regerror.c \
312 regex/regexec.c \
313 regex/regfree.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800314
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700315# The following files are common, but must be compiled
316# with different C flags when building a static C library.
317#
318# The reason for this is the implementation of __get_tls()
319# that will differ between the shared and static versions
320# of the library.
321#
322# See comments in private/bionic_tls.h for more details.
323#
324# NOTE: bionic/pthread.c is added later to this list
325# because it needs special handling on ARM, see
326# below.
327#
328libc_static_common_src_files := \
329 unistd/sysconf.c \
330 bionic/__errno.c \
331
Dima Zavinca122b02009-05-27 10:52:37 -0700332# Architecture specific source files go here
333# =========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800334ifeq ($(TARGET_ARCH),arm)
335libc_common_src_files += \
David 'Digit' Turner97cf7f32010-01-22 18:59:05 -0800336 bionic/bionic_clone.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800337 arch-arm/bionic/__get_pc.S \
338 arch-arm/bionic/__get_sp.S \
339 arch-arm/bionic/_exit_with_stack_teardown.S \
340 arch-arm/bionic/_setjmp.S \
341 arch-arm/bionic/atomics_arm.S \
342 arch-arm/bionic/clone.S \
David 'Digit' Turner6a9b8882010-06-18 14:47:22 -0700343 arch-arm/bionic/eabi.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800344 arch-arm/bionic/ffs.S \
345 arch-arm/bionic/kill.S \
David 'Digit' Turner2a7ad972009-09-29 14:43:38 -0700346 arch-arm/bionic/libgcc_compat.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800347 arch-arm/bionic/tkill.S \
348 arch-arm/bionic/memcmp.S \
349 arch-arm/bionic/memcmp16.S \
350 arch-arm/bionic/memcpy.S \
351 arch-arm/bionic/memset.S \
352 arch-arm/bionic/setjmp.S \
353 arch-arm/bionic/sigsetjmp.S \
354 arch-arm/bionic/strlen.c.arm \
355 arch-arm/bionic/syscall.S \
Shin-ichiro KAWASAKI10093272009-09-28 16:11:39 +0900356 string/memmove.c.arm \
Bruce Beare8ff1a272010-03-04 11:03:37 -0800357 string/bcopy.c \
358 string/strcmp.c \
359 string/strncmp.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800360 unistd/socketcalls.c
361
362# These files need to be arm so that gdbserver
363# can set breakpoints in them without messing
364# up any thumb code.
365libc_common_src_files += \
David 'Digit' Turner8a1d2cf2010-05-11 16:39:22 -0700366 bionic/pthread-rwlocks.c.arm \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800367 bionic/pthread-timers.c.arm \
368 bionic/ptrace.c.arm
Dima Zavinca122b02009-05-27 10:52:37 -0700369
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700370libc_static_common_src_files += \
371 bionic/pthread.c.arm \
372
Dima Zavinca122b02009-05-27 10:52:37 -0700373# these are used by the static and dynamic versions of the libc
374# respectively
375libc_arch_static_src_files := \
376 arch-arm/bionic/exidx_static.c
377
378libc_arch_dynamic_src_files := \
379 arch-arm/bionic/exidx_dynamic.c
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800380else # !arm
381
382ifeq ($(TARGET_ARCH),x86)
383libc_common_src_files += \
384 arch-x86/bionic/__get_sp.S \
385 arch-x86/bionic/__get_tls.c \
386 arch-x86/bionic/__set_tls.c \
387 arch-x86/bionic/atomics_x86.S \
388 arch-x86/bionic/clone.S \
389 arch-x86/bionic/_exit_with_stack_teardown.S \
390 arch-x86/bionic/setjmp.S \
391 arch-x86/bionic/_setjmp.S \
392 arch-x86/bionic/vfork.S \
Bruce Beare3c543e12010-03-04 10:29:38 -0800393 arch-x86/bionic/syscall.S \
Bruce Beare8ff1a272010-03-04 11:03:37 -0800394 arch-x86/string/bcopy_wrapper.S \
395 arch-x86/string/memcpy_wrapper.S \
396 arch-x86/string/memmove_wrapper.S \
397 arch-x86/string/bzero_wrapper.S \
398 arch-x86/string/memcmp_wrapper.S \
399 arch-x86/string/memset_wrapper.S \
400 arch-x86/string/strcmp_wrapper.S \
401 arch-x86/string/strncmp_wrapper.S \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800402 arch-x86/string/strlen.S \
David 'Digit' Turner8a1d2cf2010-05-11 16:39:22 -0700403 bionic/pthread-rwlocks.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800404 bionic/pthread-timers.c \
405 bionic/ptrace.c
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800406
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700407libc_static_common_src_files += \
408 bionic/pthread.c \
409
Dima Zavinca122b02009-05-27 10:52:37 -0700410# this is needed for static versions of libc
411libc_arch_static_src_files := \
412 arch-x86/bionic/dl_iterate_phdr_static.c
413
414libc_arch_dynamic_src_files :=
Shin-ichiro KAWASAKI10093272009-09-28 16:11:39 +0900415else # !x86
416
417ifeq ($(TARGET_ARCH),sh)
418libc_common_src_files += \
419 arch-sh/bionic/__get_pc.S \
420 arch-sh/bionic/__get_sp.S \
421 arch-sh/bionic/_exit_with_stack_teardown.S \
422 arch-sh/bionic/_setjmp.S \
423 arch-sh/bionic/atomics_sh.c \
424 arch-sh/bionic/atomic_cmpxchg.S \
425 arch-sh/bionic/clone.S \
426 arch-sh/bionic/pipe.S \
427 arch-sh/bionic/memcpy.S \
428 arch-sh/bionic/memset.S \
429 arch-sh/bionic/bzero.S \
430 arch-sh/bionic/setjmp.S \
431 arch-sh/bionic/sigsetjmp.S \
432 arch-sh/bionic/syscall.S \
433 arch-sh/bionic/memmove.S \
434 arch-sh/bionic/__set_tls.c \
435 arch-sh/bionic/__get_tls.c \
436 arch-sh/bionic/ffs.S \
Bruce Beare8ff1a272010-03-04 11:03:37 -0800437 string/bcopy.c \
438 string/strcmp.c \
439 string/strncmp.c \
Shin-ichiro KAWASAKI10093272009-09-28 16:11:39 +0900440 string/memcmp.c \
441 string/strlen.c \
David 'Digit' Turner8a1d2cf2010-05-11 16:39:22 -0700442 bionic/pthread-rwlocks.c \
Shin-ichiro KAWASAKI10093272009-09-28 16:11:39 +0900443 bionic/pthread-timers.c \
444 bionic/ptrace.c \
445 unistd/socketcalls.c
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700446
447libc_static_common_src_files += \
448 bionic/pthread.c \
449
Shin-ichiro KAWASAKI10093272009-09-28 16:11:39 +0900450endif # sh
451
452endif # !x86
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800453endif # !arm
454
Dima Zavinca122b02009-05-27 10:52:37 -0700455# Define some common cflags
456# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800457libc_common_cflags := \
458 -DWITH_ERRLIST \
459 -DANDROID_CHANGES \
460 -DUSE_LOCKS \
461 -DREALLOC_ZERO_BYTES_FREES \
462 -D_LIBC=1 \
463 -DSOFTFLOAT \
464 -DFLOATING_POINT \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800465 -DINET6 \
466 -I$(LOCAL_PATH)/private \
Colin Cross4fa7b102010-01-12 18:59:25 -0800467 -DUSE_DL_PREFIX \
468 -DPOSIX_MISTAKE
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800469
David 'Digit' Turnerd7ed1ae2010-03-05 14:17:35 -0800470# these macro definitions are required to implement the
471# 'timezone' and 'daylight' global variables, as well as
472# properly update the 'tm_gmtoff' field in 'struct tm'.
473#
474libc_common_cflags += \
475 -DTM_GMTOFF=tm_gmtoff \
476 -DUSG_COMPAT=1
477
Dave Bortd2c9dcc2009-04-23 15:50:03 -0700478ifeq ($(strip $(DEBUG_BIONIC_LIBC)),true)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800479 libc_common_cflags += -DDEBUG
480endif
481
482ifeq ($(TARGET_ARCH),arm)
483 libc_common_cflags += -fstrict-aliasing
Dima Zavinca122b02009-05-27 10:52:37 -0700484 libc_crt_target_cflags := -mthumb-interwork
David 'Digit' Turner4a05d122009-09-18 13:35:05 -0700485 #
486 # Define HAVE_ARM_TLS_REGISTER macro to indicate to the C library
487 # that it should access the hardware TLS register directly in
488 # private/bionic_tls.h
489 #
490 # The value must match your kernel configuration
491 #
492 ifeq ($(ARCH_ARM_HAVE_TLS_REGISTER),true)
493 libc_common_cflags += -DHAVE_ARM_TLS_REGISTER
494 endif
Dima Zavinca122b02009-05-27 10:52:37 -0700495else # !arm
496 ifeq ($(TARGET_ARCH),x86)
497 libc_crt_target_cflags := -m32
Bruce Beare8ff1a272010-03-04 11:03:37 -0800498
499 # Enable recent IA friendly memory routines (such as for Atom)
500 # These will not work on the earlier x86 machines
501 libc_common_cflags += -mtune=i686 -DUSE_SSSE3 -DUSE_SSE2
Dima Zavinca122b02009-05-27 10:52:37 -0700502 endif # x86
503endif # !arm
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800504
Andy McFaddenfcd00eb2010-05-28 13:31:45 -0700505# Define ANDROID_SMP appropriately.
506ifeq ($(TARGET_CPU_SMP),true)
507 libc_common_cflags += -DANDROID_SMP=1
508else
509 libc_common_cflags += -DANDROID_SMP=0
510endif
511
David 'Digit' Turner6a9b8882010-06-18 14:47:22 -0700512# Needed to access private/__dso_handle.S from
513# crtbegin_xxx.S and crtend_xxx.S
514#
515libc_crt_target_cflags += -I$(LOCAL_PATH)/private
Andy McFaddenfcd00eb2010-05-28 13:31:45 -0700516
Dima Zavinca122b02009-05-27 10:52:37 -0700517# Define some common includes
518# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800519libc_common_c_includes := \
520 $(LOCAL_PATH)/stdlib \
521 $(LOCAL_PATH)/string \
522 $(LOCAL_PATH)/stdio
523
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800524
Dima Zavinca122b02009-05-27 10:52:37 -0700525# Define the libc run-time (crt) support object files that must be built,
526# which are needed to build all other objects (shared/static libs and
527# executables)
528# ==========================================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800529
David 'Digit' Turner6a9b8882010-06-18 14:47:22 -0700530ifneq ($(filter arm x86,$(TARGET_ARCH)),)
531# ARM and x86 need crtbegin_so/crtend_so.
532#
533# For x86, the .init section must point to a function that calls all
534# entries in the .ctors section. (on ARM this is done through the
535# .init_array section instead).
536#
537# For both platforms, the .fini_array section must point to a function
538# that will call __cxa_finalize(&__dso_handle) in order to ensure that
539# static C++ destructors are properly called on dlclose().
540#
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800541GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_so.o
542$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin_so.S
543 @mkdir -p $(dir $@)
Dima Zavinca122b02009-05-27 10:52:37 -0700544 $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $<
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800545ALL_GENERATED_SOURCES += $(GEN)
546
547GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_so.o
548$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtend_so.S
549 @mkdir -p $(dir $@)
Dima Zavinca122b02009-05-27 10:52:37 -0700550 $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $<
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800551ALL_GENERATED_SOURCES += $(GEN)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800552endif # TARGET_ARCH == x86
553
Dima Zavinca122b02009-05-27 10:52:37 -0700554
555GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_static.o
556$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin_static.S
557 @mkdir -p $(dir $@)
558 $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $<
559ALL_GENERATED_SOURCES += $(GEN)
560
561GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_dynamic.o
562$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin_dynamic.S
563 @mkdir -p $(dir $@)
564 $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $<
565ALL_GENERATED_SOURCES += $(GEN)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800566
567
Dima Zavinca122b02009-05-27 10:52:37 -0700568# We rename crtend.o to crtend_android.o to avoid a
569# name clash between gcc and bionic.
570GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_android.o
571$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtend.S
572 @mkdir -p $(dir $@)
573 $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $<
574ALL_GENERATED_SOURCES += $(GEN)
575
576
577# To enable malloc leak check for statically linked programs, add
578# "WITH_MALLOC_CHECK_LIBC_A := true" to buildspec.mk
579WITH_MALLOC_CHECK_LIBC_A := $(strip $(WITH_MALLOC_CHECK_LIBC_A))
580
581# ========================================================
582# libc_common.a
583# ========================================================
584include $(CLEAR_VARS)
585
586LOCAL_SRC_FILES := $(libc_common_src_files)
587LOCAL_CFLAGS := $(libc_common_cflags)
588LOCAL_C_INCLUDES := $(libc_common_c_includes)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800589LOCAL_MODULE := libc_common
590LOCAL_SYSTEM_SHARED_LIBRARIES :=
591
592include $(BUILD_STATIC_LIBRARY)
593
594
Dima Zavinca122b02009-05-27 10:52:37 -0700595# ========================================================
Dima Zavin49e55332009-05-27 10:52:37 -0700596# libc_nomalloc.a
597# ========================================================
598#
599# This is a version of the static C library that does not
600# include malloc. It's useful in situations when calling
601# the user wants to provide their own malloc implementation,
602# or wants to explicitly disallow the use of the use of malloc,
603# like the dynamic loader.
604
605include $(CLEAR_VARS)
606
607LOCAL_SRC_FILES := \
608 $(libc_arch_static_src_files) \
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700609 $(libc_static_common_src_files) \
Dima Zavin49e55332009-05-27 10:52:37 -0700610 bionic/libc_init_static.c
611
612LOCAL_C_INCLUDES := $(libc_common_c_includes)
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700613LOCAL_CFLAGS := $(libc_common_cflags) \
614 -DLIBC_STATIC
Dima Zavin49e55332009-05-27 10:52:37 -0700615
616LOCAL_MODULE := libc_nomalloc
617LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
618LOCAL_SYSTEM_SHARED_LIBRARIES :=
619
620include $(BUILD_STATIC_LIBRARY)
621
622
623# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800624# libc.a
625# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800626include $(CLEAR_VARS)
627
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800628LOCAL_SRC_FILES := \
Dima Zavinca122b02009-05-27 10:52:37 -0700629 $(libc_arch_static_src_files) \
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700630 $(libc_static_common_src_files) \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800631 bionic/dlmalloc.c \
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800632 bionic/malloc_debug_common.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800633 bionic/libc_init_static.c
634
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800635LOCAL_CFLAGS := $(libc_common_cflags) \
636 -DLIBC_STATIC
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800637LOCAL_C_INCLUDES := $(libc_common_c_includes)
Dima Zavinca122b02009-05-27 10:52:37 -0700638LOCAL_MODULE := libc
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800639LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800640LOCAL_SYSTEM_SHARED_LIBRARIES :=
641
642include $(BUILD_STATIC_LIBRARY)
643
644
Dima Zavinca122b02009-05-27 10:52:37 -0700645# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800646# libc.so
647# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800648include $(CLEAR_VARS)
649
650LOCAL_CFLAGS := $(libc_common_cflags)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800651LOCAL_C_INCLUDES := $(libc_common_c_includes)
652
653LOCAL_SRC_FILES := \
Dima Zavinca122b02009-05-27 10:52:37 -0700654 $(libc_arch_dynamic_src_files) \
David 'Digit' Turner6a51def2010-08-27 08:19:19 -0700655 $(libc_static_common_src_files) \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800656 bionic/dlmalloc.c \
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800657 bionic/malloc_debug_common.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800658 bionic/libc_init_dynamic.c
659
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800660LOCAL_MODULE:= libc
661
662# WARNING: The only library libc.so should depend on is libdl.so! If you add other libraries,
663# make sure to add -Wl,--exclude-libs=libgcc.a to the LOCAL_LDFLAGS for those libraries. This
664# ensures that symbols that are pulled into those new libraries from libgcc.a are not declared
665# external; if that were the case, then libc would not pull those symbols from libgcc.a as it
666# should, instead relying on the external symbols from the dependent libraries. That would
667# create an "cloaked" dependency on libgcc.a in libc though the libraries, which is not what
668# you wanted!
669
670LOCAL_SHARED_LIBRARIES := libdl
671LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
672LOCAL_SYSTEM_SHARED_LIBRARIES :=
673
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800674include $(BUILD_SHARED_LIBRARY)
675
676
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800677# For all builds, except for the -user build we will enable memory
678# allocation checking (including memory leaks, buffer overwrites, etc.)
679# Note that all these checks are also controlled by env. settings
680# that can enable, or disable specific checks. Note also that some of
681# the checks are available only in emulator and are implemeted in
682# libc_malloc_qemu_instrumented.so.
683ifneq ($(TARGET_BUILD_VARIANT),user)
684
Dima Zavinca122b02009-05-27 10:52:37 -0700685# ========================================================
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800686# libc_malloc_debug_leak.so
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800687# ========================================================
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800688include $(CLEAR_VARS)
689
Dima Zavinca122b02009-05-27 10:52:37 -0700690LOCAL_CFLAGS := \
691 $(libc_common_cflags) \
692 -DMALLOC_LEAK_CHECK
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800693
694LOCAL_C_INCLUDES := $(libc_common_c_includes)
695
696LOCAL_SRC_FILES := \
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800697 bionic/malloc_debug_leak.c
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800698
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800699LOCAL_MODULE:= libc_malloc_debug_leak
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800700
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800701LOCAL_SHARED_LIBRARIES := libc
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800702LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
703LOCAL_SYSTEM_SHARED_LIBRARIES :=
704# Don't prelink
705LOCAL_PRELINK_MODULE := false
706# Don't install on release build
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800707LOCAL_MODULE_TAGS := eng debug
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800708
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800709include $(BUILD_SHARED_LIBRARY)
710
Vladimir Chtchetkineb74ceb22009-11-17 14:13:38 -0800711
712# ========================================================
713# libc_malloc_debug_qemu.so
714# ========================================================
715include $(CLEAR_VARS)
716
717LOCAL_CFLAGS := \
718 $(libc_common_cflags) \
719 -DMALLOC_QEMU_INSTRUMENT
720
721LOCAL_C_INCLUDES := $(libc_common_c_includes)
722
723LOCAL_SRC_FILES := \
724 bionic/malloc_debug_qemu.c
725
726LOCAL_MODULE:= libc_malloc_debug_qemu
727
728LOCAL_SHARED_LIBRARIES := libc
729LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
730LOCAL_SYSTEM_SHARED_LIBRARIES :=
731# Don't prelink
732LOCAL_PRELINK_MODULE := false
733# Don't install on release build
734LOCAL_MODULE_TAGS := eng debug
735
736include $(BUILD_SHARED_LIBRARY)
737
738endif #!user
739
740
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800741# ========================================================
742include $(call all-makefiles-under,$(LOCAL_PATH))