[bionic] Replace inline strcpy() with ARM assembly
[0xdroid:bionic.git] / libc / Android.mk
1 LOCAL_PATH:= $(call my-dir)
2
3 include $(LOCAL_PATH)/arch-$(TARGET_ARCH)/syscalls.mk
4
5 # Define the common source files for all the libc instances
6 # =========================================================
7 libc_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 \
17         unistd/ftime.c \
18         unistd/ftok.c \
19         unistd/getcwd.c \
20         unistd/getdtablesize.c \
21         unistd/gethostname.c \
22         unistd/getopt_long.c \
23         unistd/getpgrp.c \
24         unistd/getpriority.c \
25         unistd/getpt.c \
26         unistd/initgroups.c \
27         unistd/isatty.c \
28         unistd/issetugid.c \
29         unistd/lseek64.c \
30         unistd/mmap.c \
31         unistd/nice.c \
32         unistd/open.c \
33         unistd/openat.c \
34         unistd/opendir.c \
35         unistd/pathconf.c \
36         unistd/perror.c \
37         unistd/popen.c \
38         unistd/pread.c \
39         unistd/pselect.c \
40         unistd/ptsname.c \
41         unistd/ptsname_r.c \
42         unistd/pwrite.c \
43         unistd/raise.c \
44         unistd/reboot.c \
45         unistd/recv.c \
46         unistd/sbrk.c \
47         unistd/send.c \
48         unistd/setegid.c \
49         unistd/seteuid.c \
50         unistd/setpgrp.c \
51         unistd/sigblock.c \
52         unistd/siginterrupt.c \
53         unistd/siglist.c \
54         unistd/signal.c \
55         unistd/signame.c \
56         unistd/sigsetmask.c \
57         unistd/sigsuspend.c \
58         unistd/sigwait.c \
59         unistd/sleep.c \
60         unistd/statfs.c \
61         unistd/strsignal.c \
62         unistd/sysconf.c \
63         unistd/syslog.c \
64         unistd/system.c \
65         unistd/tcgetpgrp.c \
66         unistd/tcsetpgrp.c \
67         unistd/time.c \
68         unistd/umount.c \
69         unistd/unlockpt.c \
70         unistd/usleep.c \
71         unistd/wait.c \
72         stdio/asprintf.c \
73         stdio/clrerr.c \
74         stdio/fclose.c \
75         stdio/fdopen.c \
76         stdio/feof.c \
77         stdio/ferror.c \
78         stdio/fflush.c \
79         stdio/fgetc.c \
80         stdio/fgetln.c \
81         stdio/fgetpos.c \
82         stdio/fgets.c \
83         stdio/fileno.c \
84         stdio/findfp.c \
85         stdio/flags.c \
86         stdio/flockfile.c \
87         stdio/fopen.c \
88         stdio/fprintf.c \
89         stdio/fpurge.c \
90         stdio/fputc.c \
91         stdio/fputs.c \
92         stdio/fread.c \
93         stdio/freopen.c \
94         stdio/fscanf.c \
95         stdio/fseek.c \
96         stdio/fsetpos.c \
97         stdio/ftell.c \
98         stdio/funopen.c \
99         stdio/fvwrite.c \
100         stdio/fwalk.c \
101         stdio/fwrite.c \
102         stdio/getc.c \
103         stdio/getchar.c \
104         stdio/gets.c \
105         stdio/makebuf.c \
106         stdio/mktemp.c \
107         stdio/printf.c \
108         stdio/putc.c \
109         stdio/putchar.c \
110         stdio/puts.c \
111         stdio/putw.c \
112         stdio/refill.c \
113         stdio/remove.c \
114         stdio/rewind.c \
115         stdio/rget.c \
116         stdio/scanf.c \
117         stdio/setbuf.c \
118         stdio/setbuffer.c \
119         stdio/setvbuf.c \
120         stdio/snprintf.c\
121         stdio/sprintf.c \
122         stdio/sscanf.c \
123         stdio/stdio.c \
124         stdio/tempnam.c \
125         stdio/tmpfile.c \
126         stdio/tmpnam.c \
127         stdio/ungetc.c \
128         stdio/vasprintf.c \
129         stdio/vfprintf.c \
130         stdio/vfscanf.c \
131         stdio/vprintf.c \
132         stdio/vsnprintf.c \
133         stdio/vsprintf.c \
134         stdio/vscanf.c \
135         stdio/vsscanf.c \
136         stdio/wbuf.c \
137         stdio/wsetup.c \
138         stdlib/_rand48.c \
139         stdlib/assert.c \
140         stdlib/atexit.c \
141         stdlib/atoi.c \
142         stdlib/atol.c \
143         stdlib/atoll.c \
144         stdlib/bsearch.c \
145         stdlib/ctype_.c \
146         stdlib/div.c \
147         stdlib/exit.c \
148         stdlib/getenv.c \
149         stdlib/jrand48.c \
150         stdlib/ldiv.c \
151         stdlib/lldiv.c \
152         stdlib/locale.c \
153         stdlib/lrand48.c \
154         stdlib/mrand48.c \
155         stdlib/nrand48.c \
156         stdlib/putenv.c \
157         stdlib/qsort.c \
158         stdlib/seed48.c \
159         stdlib/setenv.c \
160         stdlib/setjmperr.c \
161         stdlib/srand48.c \
162         stdlib/strntoimax.c \
163         stdlib/strntoumax.c \
164         stdlib/strtod.c \
165         stdlib/strtoimax.c \
166         stdlib/strtol.c \
167         stdlib/strtoll.c \
168         stdlib/strtoul.c \
169         stdlib/strtoull.c \
170         stdlib/strtoumax.c \
171         stdlib/tolower_.c \
172         stdlib/toupper_.c \
173         stdlib/wchar.c \
174         string/bcopy.c \
175         string/index.c \
176         string/memccpy.c \
177         string/memchr.c \
178         string/memmem.c \
179         string/memrchr.c \
180         string/memswap.c \
181         string/strcasecmp.c \
182         string/strcasestr.c \
183         string/strcat.c \
184         string/strchr.c \
185         string/strcoll.c \
186         string/strcspn.c \
187         string/strdup.c \
188         string/strerror.c \
189         string/strerror_r.c \
190         string/strlcat.c \
191         string/strlcpy.c \
192         string/strncat.c \
193         string/strncmp.c \
194         string/strncpy.c \
195         string/strndup.c \
196         string/strnlen.c \
197         string/strpbrk.c \
198         string/strrchr.c \
199         string/strsep.c \
200         string/strspn.c \
201         string/strstr.c \
202         string/strtok.c \
203         string/strtotimeval.c \
204         string/strxfrm.c \
205         inet/bindresvport.c \
206         inet/inet_addr.c \
207         inet/inet_aton.c \
208         inet/inet_ntoa.c \
209         inet/inet_ntop.c \
210         inet/inet_pton.c \
211         tzcode/asctime.c \
212         tzcode/difftime.c \
213         tzcode/localtime.c \
214         tzcode/strftime.c \
215         tzcode/strptime.c \
216         bionic/__errno.c \
217         bionic/__set_errno.c \
218         bionic/_rand48.c \
219         bionic/arc4random.c \
220         bionic/basename.c \
221         bionic/basename_r.c \
222         bionic/dirname.c \
223         bionic/dirname_r.c \
224         bionic/drand48.c \
225         bionic/erand48.c \
226         bionic/fork.c \
227         bionic/if_nametoindex.c \
228         bionic/if_indextoname.c \
229         bionic/ioctl.c \
230         bionic/ldexp.c \
231         bionic/libc_init_common.c \
232         bionic/logd_write.c \
233         bionic/md5.c \
234         bionic/pututline.c \
235         bionic/realpath.c \
236         bionic/semaphore.c \
237         bionic/sha1.c \
238         bionic/ssp.c \
239         bionic/stubs.c \
240         bionic/system_properties.c \
241         bionic/time64.c \
242         bionic/thread_atexit.c \
243         bionic/utime.c \
244         bionic/utmp.c \
245         netbsd/gethnamaddr.c \
246         netbsd/isc/ev_timers.c \
247         netbsd/isc/ev_streams.c \
248         netbsd/inet/nsap_addr.c \
249         netbsd/resolv/__dn_comp.c \
250         netbsd/resolv/__res_close.c \
251         netbsd/resolv/__res_send.c \
252         netbsd/resolv/herror.c \
253         netbsd/resolv/res_comp.c \
254         netbsd/resolv/res_data.c \
255         netbsd/resolv/res_debug.c \
256         netbsd/resolv/res_init.c \
257         netbsd/resolv/res_mkquery.c \
258         netbsd/resolv/res_query.c \
259         netbsd/resolv/res_send.c \
260         netbsd/resolv/res_state.c \
261         netbsd/resolv/res_cache.c \
262         netbsd/net/nsdispatch.c \
263         netbsd/net/getaddrinfo.c \
264         netbsd/net/getnameinfo.c \
265         netbsd/net/getservbyname.c \
266         netbsd/net/getservent.c \
267         netbsd/net/base64.c \
268         netbsd/net/getservbyport.c \
269         netbsd/nameser/ns_name.c \
270         netbsd/nameser/ns_parse.c \
271         netbsd/nameser/ns_ttl.c \
272         netbsd/nameser/ns_netint.c \
273         netbsd/nameser/ns_print.c \
274         netbsd/nameser/ns_samedomain.c
275
276 # Architecture specific source files go here
277 # =========================================================
278 ifeq ($(TARGET_ARCH),arm)
279 libc_common_src_files += \
280         bionic/eabi.c \
281         arch-arm/bionic/__get_pc.S \
282         arch-arm/bionic/__get_sp.S \
283         arch-arm/bionic/_exit_with_stack_teardown.S \
284         arch-arm/bionic/_setjmp.S \
285         arch-arm/bionic/atomics_arm.S \
286         arch-arm/bionic/clone.S \
287         arch-arm/bionic/ffs.S \
288         arch-arm/bionic/kill.S \
289         arch-arm/bionic/libgcc_compat.c \
290         arch-arm/bionic/tkill.S \
291         arch-arm/bionic/memcmp.S \
292         arch-arm/bionic/memcmp16.S \
293         arch-arm/bionic/memset.S \
294         arch-arm/bionic/setjmp.S \
295         arch-arm/bionic/sigsetjmp.S \
296         arch-arm/bionic/strlen.S \
297         arch-arm/bionic/strcpy.S \
298         arch-arm/bionic/strcmp.S \
299         arch-arm/bionic/syscall.S \
300         string/memmove.c.arm \
301         unistd/socketcalls.c
302
303 ifeq ($(ALLOW_LGPL),true)
304 libc_common_src_files += \
305         arch-arm/bionic/memcpy-neon.S
306 else # !allow_lgpl
307 libc_common_src_files += \
308         arch-arm/bionic/memcpy.S
309 endif
310
311 # These files need to be arm so that gdbserver
312 # can set breakpoints in them without messing
313 # up any thumb code.
314 libc_common_src_files += \
315         bionic/pthread.c.arm \
316         bionic/pthread-timers.c.arm \
317         bionic/ptrace.c.arm
318
319 # these are used by the static and dynamic versions of the libc
320 # respectively
321 libc_arch_static_src_files := \
322         arch-arm/bionic/exidx_static.c
323
324 libc_arch_dynamic_src_files := \
325         arch-arm/bionic/exidx_dynamic.c
326 else # !arm
327
328 ifeq ($(TARGET_ARCH),x86)
329 libc_common_src_files += \
330         arch-x86/bionic/__get_sp.S \
331         arch-x86/bionic/__get_tls.c \
332         arch-x86/bionic/__set_tls.c \
333         arch-x86/bionic/atomics_x86.S \
334         arch-x86/bionic/clone.S \
335         arch-x86/bionic/_exit_with_stack_teardown.S \
336         arch-x86/bionic/setjmp.S \
337         arch-x86/bionic/_setjmp.S \
338         arch-x86/bionic/vfork.S \
339         arch-x86/string/bzero.S \
340         arch-x86/string/memset.S \
341         arch-x86/string/memcmp.S \
342         arch-x86/string/memcpy.S \
343         arch-x86/string/strlen.S \
344         arch-x86/string/strcpy.S \
345         arch-x86/string/strcmp.S \
346         string/memmove.c \
347         bionic/pthread.c \
348         bionic/pthread-timers.c \
349         bionic/ptrace.c
350
351 # this is needed for static versions of libc
352 libc_arch_static_src_files := \
353         arch-x86/bionic/dl_iterate_phdr_static.c
354
355 libc_arch_dynamic_src_files :=
356 else # !x86
357
358 ifeq ($(TARGET_ARCH),sh)
359 libc_common_src_files += \
360         arch-sh/bionic/__get_pc.S \
361         arch-sh/bionic/__get_sp.S \
362         arch-sh/bionic/_exit_with_stack_teardown.S \
363         arch-sh/bionic/_setjmp.S \
364         arch-sh/bionic/atomics_sh.c \
365         arch-sh/bionic/atomic_cmpxchg.S \
366         arch-sh/bionic/clone.S \
367         arch-sh/bionic/pipe.S \
368         arch-sh/bionic/memcpy.S \
369         arch-sh/bionic/memset.S \
370         arch-sh/bionic/bzero.S \
371         arch-sh/bionic/setjmp.S \
372         arch-sh/bionic/sigsetjmp.S \
373         arch-sh/bionic/syscall.S \
374         arch-sh/bionic/memmove.S \
375         arch-sh/bionic/__set_tls.c \
376         arch-sh/bionic/__get_tls.c \
377         arch-sh/bionic/ffs.S \
378         string/memcmp.c \
379         string/strlen.c \
380         bionic/eabi.c \
381         bionic/pthread.c \
382         bionic/pthread-timers.c \
383         bionic/ptrace.c \
384         unistd/socketcalls.c
385 endif # sh
386
387 endif # !x86
388 endif # !arm
389
390 # Define some common cflags
391 # ========================================================
392 libc_common_cflags := \
393                 -DWITH_ERRLIST                  \
394                 -DANDROID_CHANGES               \
395                 -DUSE_LOCKS                     \
396                 -DREALLOC_ZERO_BYTES_FREES      \
397                 -D_LIBC=1                       \
398                 -DSOFTFLOAT                     \
399                 -DFLOATING_POINT                \
400                 -DNEED_PSELECT=1                \
401                 -DINET6 \
402                 -I$(LOCAL_PATH)/private \
403                 -DUSE_DL_PREFIX
404
405 ifeq ($(strip $(DEBUG_BIONIC_LIBC)),true)
406   libc_common_cflags += -DDEBUG
407 endif
408
409 ifeq ($(TARGET_ARCH),arm)
410   libc_common_cflags += -fstrict-aliasing
411   libc_crt_target_cflags := -mthumb-interwork
412   #
413   # Define HAVE_ARM_TLS_REGISTER macro to indicate to the C library
414   # that it should access the hardware TLS register directly in
415   # private/bionic_tls.h
416   #
417   # The value must match your kernel configuration
418   #
419   ifeq ($(ARCH_ARM_HAVE_TLS_REGISTER),true)
420     libc_common_cflags += -DHAVE_ARM_TLS_REGISTER
421   endif
422 else # !arm
423   ifeq ($(TARGET_ARCH),x86)
424     libc_crt_target_cflags := -m32
425   endif # x86
426 endif # !arm
427
428 # Define some common includes
429 # ========================================================
430 libc_common_c_includes := \
431                 $(LOCAL_PATH)/stdlib  \
432                 $(LOCAL_PATH)/string  \
433                 $(LOCAL_PATH)/stdio
434
435
436 # Define the libc run-time (crt) support object files that must be built,
437 # which are needed to build all other objects (shared/static libs and
438 # executables)
439 # ==========================================================================
440
441 ifeq ($(TARGET_ARCH),x86)
442 # we only need begin_so/end_so for x86, since it needs an appropriate .init
443 # section in the shared library with a function to call all the entries in
444 # .ctors section. ARM uses init_array, and does not need the function.
445 GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_so.o
446 $(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin_so.S
447         @mkdir -p $(dir $@)
448         $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $<
449 ALL_GENERATED_SOURCES += $(GEN)
450
451 GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_so.o
452 $(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtend_so.S
453         @mkdir -p $(dir $@)
454         $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $<
455 ALL_GENERATED_SOURCES += $(GEN)
456 endif # TARGET_ARCH == x86
457
458
459 GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_static.o
460 $(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin_static.S
461         @mkdir -p $(dir $@)
462         $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $<
463 ALL_GENERATED_SOURCES += $(GEN)
464
465 GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_dynamic.o
466 $(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin_dynamic.S
467         @mkdir -p $(dir $@)
468         $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $<
469 ALL_GENERATED_SOURCES += $(GEN)
470
471
472 # We rename crtend.o to crtend_android.o to avoid a
473 # name clash between gcc and bionic.
474 GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_android.o
475 $(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtend.S
476         @mkdir -p $(dir $@)
477         $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $<
478 ALL_GENERATED_SOURCES += $(GEN)
479
480
481 # To enable malloc leak check for statically linked programs, add
482 # "WITH_MALLOC_CHECK_LIBC_A := true" to buildspec.mk
483 WITH_MALLOC_CHECK_LIBC_A := $(strip $(WITH_MALLOC_CHECK_LIBC_A))
484
485 # ========================================================
486 # libc_common.a
487 # ========================================================
488 include $(CLEAR_VARS)
489
490 LOCAL_SRC_FILES := $(libc_common_src_files)
491 LOCAL_CFLAGS := $(libc_common_cflags)
492 LOCAL_C_INCLUDES := $(libc_common_c_includes)
493 LOCAL_MODULE := libc_common
494 LOCAL_SYSTEM_SHARED_LIBRARIES :=
495
496 include $(BUILD_STATIC_LIBRARY)
497
498
499 # ========================================================
500 # libc_nomalloc.a
501 # ========================================================
502 #
503 # This is a version of the static C library that does not
504 # include malloc. It's useful in situations when calling
505 # the user wants to provide their own malloc implementation,
506 # or wants to explicitly disallow the use of the use of malloc,
507 # like the dynamic loader.
508
509 include $(CLEAR_VARS)
510
511 LOCAL_SRC_FILES := \
512         $(libc_arch_static_src_files) \
513         bionic/libc_init_static.c
514
515 LOCAL_C_INCLUDES := $(libc_common_c_includes)
516 LOCAL_CFLAGS := $(libc_common_cflags)
517
518 LOCAL_MODULE := libc_nomalloc
519 LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
520 LOCAL_SYSTEM_SHARED_LIBRARIES :=
521
522 include $(BUILD_STATIC_LIBRARY)
523
524
525 # ========================================================
526 # libc.a
527 # ========================================================
528 include $(CLEAR_VARS)
529
530 LOCAL_SRC_FILES := \
531         $(libc_arch_static_src_files) \
532         bionic/dlmalloc.c \
533         bionic/libc_init_static.c
534
535 LOCAL_CFLAGS := $(libc_common_cflags)
536
537 ifeq ($(WITH_MALLOC_CHECK_LIBC_A),true)
538   LOCAL_CFLAGS += -DMALLOC_LEAK_CHECK
539   LOCAL_SRC_FILES += bionic/malloc_leak.c.arm
540 endif
541
542 LOCAL_C_INCLUDES := $(libc_common_c_includes)
543
544 LOCAL_MODULE := libc
545 LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
546 LOCAL_SYSTEM_SHARED_LIBRARIES :=
547
548 include $(BUILD_STATIC_LIBRARY)
549
550
551 # ========================================================
552 # libc.so
553 # ========================================================
554 include $(CLEAR_VARS)
555
556 LOCAL_CFLAGS := $(libc_common_cflags)
557 LOCAL_C_INCLUDES := $(libc_common_c_includes)
558
559 LOCAL_SRC_FILES := \
560         $(libc_arch_dynamic_src_files) \
561         bionic/dlmalloc.c \
562         bionic/malloc_leak.c.arm \
563         bionic/libc_init_dynamic.c
564
565 LOCAL_MODULE:= libc
566
567 # WARNING: The only library libc.so should depend on is libdl.so!  If you add other libraries,
568 # make sure to add -Wl,--exclude-libs=libgcc.a to the LOCAL_LDFLAGS for those libraries.  This
569 # ensures that symbols that are pulled into those new libraries from libgcc.a are not declared
570 # external; if that were the case, then libc would not pull those symbols from libgcc.a as it
571 # should, instead relying on the external symbols from the dependent libraries.  That would
572 # create an "cloaked" dependency on libgcc.a in libc though the libraries, which is not what
573 # you wanted!
574
575 LOCAL_SHARED_LIBRARIES := libdl
576 LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
577 LOCAL_SYSTEM_SHARED_LIBRARIES :=
578
579 include $(BUILD_SHARED_LIBRARY)
580
581
582 # ========================================================
583 # libc_debug.so
584 # ========================================================
585 include $(CLEAR_VARS)
586
587 LOCAL_CFLAGS := \
588         $(libc_common_cflags) \
589         -DMALLOC_LEAK_CHECK
590
591 LOCAL_C_INCLUDES := $(libc_common_c_includes)
592
593 LOCAL_SRC_FILES := \
594         $(libc_arch_dynamic_src_files) \
595         bionic/dlmalloc.c \
596         bionic/malloc_leak.c.arm \
597         bionic/libc_init_dynamic.c
598
599 LOCAL_MODULE:= libc_debug
600
601 # WARNING: The only library libc.so should depend on is libdl.so!  If you add other libraries,
602 # make sure to add -Wl,--exclude-libs=libgcc.a to the LOCAL_LDFLAGS for those libraries.  This
603 # ensures that symbols that are pulled into those new libraries from libgcc.a are not declared
604 # external; if that were the case, then libc would not pull those symbols from libgcc.a as it
605 # should, instead relying on the external symbols from the dependent libraries.  That would
606 # create an "cloaked" dependency on libgcc.a in libc though the libraries, which is not what
607 # you wanted!
608
609 LOCAL_SHARED_LIBRARIES := libdl
610 LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
611 LOCAL_SYSTEM_SHARED_LIBRARIES :=
612 # Don't prelink
613 LOCAL_PRELINK_MODULE := false
614 # Don't install on release build
615 LOCAL_MODULE_TAGS := eng
616
617 include $(BUILD_SHARED_LIBRARY)
618
619 # ========================================================
620 include $(call all-makefiles-under,$(LOCAL_PATH))