blob: d9278072b2427141da6296c25daca9404a334720 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001# Makefile for uClibc
2#
3# Copyright (C) 2000-2008 Erik Andersen <andersen@uclibc.org>
4#
5# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
6#
7
8subdirs += libc/stdlib
9
10include $(top_srcdir)libc/stdlib/malloc/Makefile.in
11include $(top_srcdir)libc/stdlib/malloc-simple/Makefile.in
12include $(top_srcdir)libc/stdlib/malloc-standard/Makefile.in
13
14CSRC-y := \
15 abort.c getenv.c mkdtemp.c realpath.c canonicalize.c mkstemp.c \
16 rand.c random.c random_r.c setenv.c div.c ldiv.c lldiv.c \
17 getpt.c drand48-iter.c jrand48.c \
18 jrand48_r.c lrand48.c lrand48_r.c mrand48.c mrand48_r.c nrand48.c \
19 nrand48_r.c rand_r.c srand48.c srand48_r.c seed48.c seed48_r.c \
20 valloc.c a64l.c l64a.c __uc_malloc.c
21CSRC-$(UCLIBC_HAS_ADVANCED_REALTIME) += posix_memalign.c
22CSRC-$(UCLIBC_HAS_PTY) += grantpt.c unlockpt.c ptsname.c
23CSRC-$(UCLIBC_HAS_ARC4RANDOM) += arc4random.c
24CSRC-$(UCLIBC_HAS_LFS) += mkstemp64.c
25CSRC-$(UCLIBC_HAS_FLOATS) += drand48.c drand48_r.c erand48.c erand48_r.c
26CSRC-$(if $(findstring yy,$(UCLIBC_HAS_FLOATS)$(UCLIBC_SUSV3_LEGACY)),y) += \
27 gcvt.c
28CSRC-$(UCLIBC_SUSV3_LEGACY) += mktemp.c
29
30ifneq ($(UCLIBC_HAS_BACKTRACE),)
31CFLAGS-abort.c = -fasynchronous-unwind-tables
32endif
33
34# multi source stdlib.c
35CSRC-y += abs.c labs.c atoi.c atol.c strtol.c strtoul.c _stdlib_strto_l.c \
36 qsort.c qsort_r.c bsearch.c \
37 llabs.c atoll.c strtoll.c strtoull.c _stdlib_strto_ll.c
38# (aliases) strtoq.o strtouq.o
39CSRC-$(UCLIBC_HAS_FLOATS) += atof.c
40CSRC-$(UCLIBC_HAS_XLOCALE) += strtol_l.c strtoul_l.c _stdlib_strto_l_l.c \
41 strtoll_l.c strtoull_l.c _stdlib_strto_ll_l.c
42
43CSRC-$(UCLIBC_HAS_WCHAR) += mblen.c mbtowc.c wctomb.c mbstowcs.c wcstombs.c \
44 _stdlib_mb_cur_max.c _stdlib_wcsto_l.c _stdlib_wcsto_ll.c \
45 wcstol.c wcstoul.c wcstoll.c wcstoull.c
46CSRC-$(if $(findstring yy,$(UCLIBC_HAS_WCHAR)$(UCLIBC_HAS_XLOCALE)),y) += \
47 _stdlib_wcsto_l_l.c _stdlib_wcsto_ll_l.c \
48 wcstol_l.c wcstoul_l.c wcstoll_l.c wcstoull_l.c
49
50# multi source _strtod.c
51CSRC-$(UCLIBC_HAS_FLOATS) += strtod.c strtof.c strtold.c __strtofpmax.c __fp_range_check.c
52CSRC-$(if $(findstring yy,$(UCLIBC_HAS_FLOATS)$(UCLIBC_HAS_XLOCALE)),y) += \
53 strtod_l.c strtof_l.c strtold_l.c __strtofpmax_l.c
54CSRC-$(if $(findstring yy,$(UCLIBC_HAS_FLOATS)$(UCLIBC_HAS_WCHAR)),y) += \
55 wcstod.c wcstof.c wcstold.c __wcstofpmax.c
56CSRC-$(if $(findstring yyy,$(UCLIBC_HAS_FLOATS)$(UCLIBC_HAS_WCHAR)$(UCLIBC_HAS_XLOCALE)),y) += \
57 wcstod_l.c wcstof_l.c wcstold_l.c __wcstofpmax_l.c
58# (aliases) wcstoq.o wcstouq.o
59# wcstod wcstof wcstold
60
61# multi source _atexit.c
62CSRC-y += __cxa_atexit.c __cxa_finalize.c __exit_handler.c exit.c on_exit.c
63CSRC-$(COMPAT_ATEXIT) += old_atexit.c
64
65STDLIB_DIR := $(top_srcdir)libc/stdlib
66STDLIB_OUT := $(top_builddir)libc/stdlib
67
68STDLIB_SRC := $(patsubst %.c,$(STDLIB_DIR)/%.c,$(CSRC-y))
69STDLIB_OBJ := $(patsubst %.c,$(STDLIB_OUT)/%.o,$(CSRC-y))
70
71libc-y += $(STDLIB_OBJ)
72libc-static-y += $(STDLIB_OUT)/atexit.o $(STDLIB_OUT)/system.o
73libc-shared-y += $(STDLIB_OUT)/system.oS
74
75# this should always be the PIC version, because it could be used in shared libs
76libc-nonshared-y += $(STDLIB_OUT)/atexit.os
77
78libc-nomulti-y += $(STDLIB_OUT)/labs.o $(STDLIB_OUT)/atol.o $(STDLIB_OUT)/_stdlib_strto_l.o $(STDLIB_OUT)/_stdlib_strto_ll.o
79libc-nomulti-$(UCLIBC_HAS_XLOCALE) += $(STDLIB_OUT)/_stdlib_strto_l_l.o $(STDLIB_OUT)/_stdlib_strto_ll_l.o
80
81objclean-y += CLEAN_libc/stdlib
82
83CLEAN_libc/stdlib:
84 $(do_rm) $(addprefix $(STDLIB_OUT)/*., o os oS)