blob: e7f2ccde10f9c6613280f8e19732208641bcaf9d [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/string/$(TARGET_ARCH) libc/string/generic
9
10#
11# Arch specific fun
12#
13# Collect the subarch specific implementation (asm files)
14ifneq ($(strip $(TARGET_SUBARCH)),)
15STRING_SUBARCH_DIR := $(top_srcdir)libc/string/$(TARGET_ARCH)/$(TARGET_SUBARCH)
16STRING_SUBARCH_OUT := $(top_builddir)libc/string/$(TARGET_ARCH)/$(TARGET_SUBARCH)
17
18STRING_SUBARCH_SSRC := $(wildcard $(STRING_SUBARCH_OUT)/*.S)
19STRING_SUBARCH_SOBJ := $(patsubst $(STRING_SUBARCH_DIR)/%.S,$(STRING_SUBARCH_OUT)/%.o,$(STRING_SUBARCH_SSRC))
20
21STRING_SUBARCH_CSRC := $(wildcard $(STRING_SUBARCH_OUT)/*.c)
22STRING_SUBARCH_COBJ := $(patsubst $(STRING_SUBARCH_DIR)/%.c,$(STRING_SUBARCH_OUT)/%.o,$(STRING_SUBARCH_CSRC))
23
24STRING_SUBARCH_OBJS := $(STRING_SUBARCH_SOBJ) $(STRING_SUBARCH_COBJ)
25endif
26
27# Collect the arch specific implementation (asm, c files)
28STRING_ARCH_DIR := $(top_srcdir)libc/string/$(TARGET_ARCH)
29STRING_ARCH_OUT := $(top_builddir)libc/string/$(TARGET_ARCH)
30
31STRING_ARCH_SRC := $(wildcard $(STRING_ARCH_DIR)/*.c)
32STRING_ARCH_OBJ := $(patsubst $(STRING_ARCH_DIR)/%.c,$(STRING_ARCH_OUT)/%.o,$(STRING_ARCH_SRC))
33
34STRING_ARCH_SSRC := $(wildcard $(STRING_ARCH_DIR)/*.S)
35
36# Exclude the subarch implementation from the arch ones
37ifneq ($(strip $(STRING_SUBARCH_OBJS)),)
38STRING_ARCH_SSRC := $(filter-out $(patsubst %.o,$(STRING_ARCH_DIR)/%.S,$(notdir $(STRING_SUBARCH_OBJS))),$(STRING_ARCH_SSRC))
39endif
40
41STRING_ARCH_SOBJ := $(patsubst $(STRING_ARCH_DIR)/%.S,$(STRING_ARCH_OUT)/%.o,$(STRING_ARCH_SSRC))
42
43STRING_ARCH_OBJS := $(STRING_ARCH_OBJ) $(STRING_ARCH_SOBJ)
44
45libc-$(UCLIBC_HAS_STRING_ARCH_OPT) += $(STRING_ARCH_OBJS) $(STRING_SUBARCH_OBJS)
46
47libc-nomulti-$(UCLIBC_HAS_STRING_ARCH_OPT) += $(STRING_ARCH_SOBJ) $(STRING_SUBARCH_OBJS)
48
49#
50# Generic stuff
51#
52STRING_GENERIC_DIR := $(top_srcdir)libc/string/generic
53STRING_GENERIC_OUT := $(top_builddir)libc/string/generic
54
55STRING_GENERIC_SRC := $(wildcard $(STRING_GENERIC_DIR)/*.c)
56STRING_GENERIC_SRC := $(filter-out $(STRING_GENERIC_DIR)/_memcpy_fwd.c, $(STRING_GENERIC_SRC))
57
58ifeq ($(UCLIBC_HAS_STRING_ARCH_OPT),y)
59ifneq ($(strip $(STRING_ARCH_OBJS)),)
60STRING_GENERIC_SRC := $(filter-out $(patsubst %.o,$(STRING_GENERIC_DIR)/%.c,$(notdir $(STRING_ARCH_OBJS))),$(STRING_GENERIC_SRC))
61endif
62ifneq ($(strip $(STRING_SUBARCH_OBJS)),)
63STRING_GENERIC_SRC := $(filter-out $(patsubst %.o,$(STRING_GENERIC_DIR)/%.c,$(notdir $(STRING_SUBARCH_OBJS))),$(STRING_GENERIC_SRC))
64endif
65endif
66
67STRING_GENERIC_OBJS := $(patsubst $(STRING_GENERIC_DIR)/%.c,$(STRING_GENERIC_OUT)/%.o,$(STRING_GENERIC_SRC))
68
69libc-$(UCLIBC_HAS_STRING_GENERIC_OPT) += $(STRING_GENERIC_OBJS)
70
71#
72# Top level string
73#
74STRING_DIR := $(top_srcdir)libc/string
75STRING_OUT := $(top_builddir)libc/string
76
77STRING_ALL_WXSRC := $(wildcard $(STRING_DIR)/w*_l.c)
78ifeq ($(UCLIBC_HAS_LOCALE),y)
79STRING_WXSRC := $(STRING_ALL_WXSRC)
80else
81# wcscoll_l
82STRING_WXSRC := $(filter-out $(STRING_DIR)/wcsxfrm_l.c,$(STRING_ALL_WXSRC))
83endif
84
85STRING_ALL_XLSRC := $(filter-out $(STRING_ALL_WXSRC),$(wildcard $(STRING_DIR)/*_l.c))
86ifeq ($(UCLIBC_HAS_LOCALE),y)
87STRING_XLSRC := $(STRING_ALL_XLSRC)
88else
89# strcoll_l
90STRING_XLSRC := $(filter-out $(STRING_DIR)/strxfrm_l.c,$(STRING_ALL_XLSRC))
91endif
92
93STRING_ALL_WSRC := $(filter-out $(STRING_ALL_WXSRC),$(wildcard $(STRING_DIR)/w*.c))
94ifeq ($(UCLIBC_HAS_LOCALE),y)
95STRING_WSRC := $(STRING_ALL_WSRC)
96else
97# wcscoll
98STRING_WSRC := $(filter-out $(STRING_DIR)/wcsxfrm.c,$(STRING_ALL_WSRC))
99endif
100
101STRING_ALL_CSRC := $(filter-out $(STRING_ALL_WXSRC) $(STRING_ALL_XLSRC) $(STRING_ALL_WSRC) $(STRING_DIR)/_collate.c,$(wildcard $(STRING_DIR)/*.c))
102ifeq ($(UCLIBC_HAS_LOCALE),y)
103STRING_CSRC := $(STRING_ALL_CSRC)
104else
105# strcoll
106STRING_CSRC := $(filter-out $(STRING_DIR)/strxfrm.c,$(STRING_ALL_CSRC))
107endif
108
109ifeq ($(UCLIBC_HAS_WCHAR),y)
110STRING_CSRC += $(STRING_WSRC)
111endif
112ifeq ($(UCLIBC_HAS_XLOCALE),y)
113STRING_CSRC += $(STRING_XLSRC)
114ifeq ($(UCLIBC_HAS_WCHAR),y)
115STRING_CSRC += $(STRING_WXSRC)
116endif
117endif
118
119ifeq ($(UCLIBC_HAS_STRING_ARCH_OPT),y)
120ifneq ($(strip $(STRING_ARCH_OBJS)),)
121STRING_CSRC := $(filter-out $(patsubst %.o,$(STRING_DIR)/%.c,$(notdir $(STRING_ARCH_OBJS))),$(STRING_CSRC))
122endif
123ifneq ($(strip $(STRING_SUBARCH_OBJS)),)
124STRING_CSRC := $(filter-out $(patsubst %.o,$(STRING_DIR)/%.c,$(notdir $(STRING_SUBARCH_OBJS))),$(STRING_CSRC))
125endif
126endif
127
128ifeq ($(UCLIBC_HAS_STRING_GENERIC_OPT),y)
129ifneq ($(strip $(STRING_GENERIC_OBJS)),)
130STRING_CSRC := $(filter-out $(patsubst %.o,$(STRING_DIR)/%.c,$(notdir $(STRING_GENERIC_OBJS))),$(STRING_CSRC))
131endif
132endif
133
134STRING_COBJ := $(patsubst $(STRING_DIR)/%.c,$(STRING_OUT)/%.o,$(STRING_CSRC))
135
136libc-y += $(STRING_COBJ)
137
138libc-nomulti-$(UCLIBC_HAS_XLOCALE) += $(STRING_OUT)/wcsxfrm_l.o
139libc-nomulti-y += $(STRING_OUT)/__xpg_strerror_r.o
140
141objclean-y += CLEAN_libc/string
142
143CLEAN_libc/string:
144 $(do_rm) $(addprefix $(STRING_OUT)/,$(addprefix *., o os oS) $(addprefix */*., o os oS) $(addprefix */*/*., o os oS))