summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2013-02-05 18:54:24 +0100
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2013-02-05 18:55:08 +0100
commit1b3025b7352f5e432ffa1c7adc57085ac9092b77 (patch)
treebb94261d0cf3f76b7bc206a8aa2e69b2419b3944
parentaeac3e1220a8afc856bd25e4d87441a26588aac0 (diff)
buildsys: switch libc to kbuild-style
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
-rw-r--r--libc/inet/Makefile.in15
-rw-r--r--libc/inet/rpc/Makefile.in28
-rw-r--r--libc/misc/assert/Makefile.in6
-rw-r--r--libc/misc/ctype/Makefile.in22
-rw-r--r--libc/misc/dirent/Makefile.in16
-rw-r--r--libc/misc/error/Makefile.in14
-rw-r--r--libc/misc/file/Makefile.in10
-rw-r--r--libc/misc/fnmatch/Makefile.in10
-rw-r--r--libc/misc/fts/Makefile.in6
-rw-r--r--libc/misc/ftw/Makefile.in10
-rw-r--r--libc/misc/glob/Makefile.in18
-rw-r--r--libc/misc/gnu/Makefile.in7
-rw-r--r--libc/misc/internals/Makefile.in6
-rw-r--r--libc/misc/locale/Makefile.in15
-rw-r--r--libc/misc/mntent/Makefile.in6
-rw-r--r--libc/misc/regex/Makefile.in11
-rw-r--r--libc/misc/search/Makefile.in14
-rw-r--r--libc/misc/statfs/Makefile.in15
-rw-r--r--libc/misc/syslog/Makefile.in6
-rw-r--r--libc/misc/sysvipc/Makefile.in12
-rw-r--r--libc/misc/time/Makefile.in29
-rw-r--r--libc/misc/ttyent/Makefile.in6
-rw-r--r--libc/misc/utmp/Makefile.in11
-rw-r--r--libc/misc/wchar/Makefile.in10
-rw-r--r--libc/misc/wctype/Makefile.in14
-rw-r--r--libc/misc/wordexp/Makefile.in6
-rw-r--r--libc/pwd_grp/Makefile.in17
-rw-r--r--libc/stdio/Makefile.in72
-rw-r--r--libc/stdlib/malloc-simple/Makefile.in8
-rw-r--r--libc/stdlib/malloc-standard/Makefile.in10
-rw-r--r--libc/stdlib/malloc/Makefile.in8
-rw-r--r--libc/unistd/Makefile.in50
32 files changed, 200 insertions, 288 deletions
diff --git a/libc/inet/Makefile.in b/libc/inet/Makefile.in
index a4d3c49e6..5a5593838 100644
--- a/libc/inet/Makefile.in
+++ b/libc/inet/Makefile.in
@@ -11,33 +11,34 @@ include $(top_srcdir)libc/inet/rpc/Makefile.in
INET_DIR := $(top_srcdir)libc/inet
INET_OUT := $(top_builddir)libc/inet
+V4_OR_V6 := $(findstring y,$(UCLIBC_HAS_IPV4)$(UCLIBC_HAS_IPV6))
CFLAGS-inet := -DRESOLVER="\"resolv.c\""
CSRC-y :=
# des uses ntohl
-CSRC-$(findstring y,$(UCLIBC_HAS_CRYPT_IMPL)$(UCLIBC_HAS_IPV4)$(UCLIBC_HAS_IPV6)) += ntohl.c
-CSRC-$(findstring y,$(UCLIBC_HAS_IPV4)$(UCLIBC_HAS_IPV6)) += \
+CSRC-$(findstring y,$(UCLIBC_HAS_CRYPT_IMPL)$(V4_OR_V6)) += ntohl.c
+CSRC-$(V4_OR_V6) += \
getservice.c getproto.c getnet.c hostid.c \
inet_net.c herror.c if_index.c gai_strerror.c getaddrinfo.c \
ifaddrs.c ntop.c
CSRC-$(UCLIBC_HAS_IPV6) += in6_addr.c
# multi source addr.c
-CSRC-$(findstring y,$(UCLIBC_HAS_IPV4)$(UCLIBC_HAS_IPV6)) += \
+CSRC-$(V4_OR_V6) += \
inet_aton.c inet_addr.c inet_ntoa.c inet_makeaddr.c \
inet_lnaof.c inet_netof.c
# multi source resolv.c
-CSRC-$(findstring y,$(UCLIBC_HAS_IPV4)$(UCLIBC_HAS_IPV6)) += \
+CSRC-$(V4_OR_V6) += \
encodeh.c decodeh.c encoded.c decoded.c \
encodeq.c encodea.c \
read_etc_hosts_r.c \
dnslookup.c opennameservers.c closenameservers.c \
getnameinfo.c \
gethostent.c gethostent_r.c
-CSRC-$(findstring y,$(UCLIBC_HAS_IPV4)$(UCLIBC_HAS_IPV6)) += \
+CSRC-$(V4_OR_V6) += \
get_hosts_byaddr_r.c get_hosts_byname_r.c \
gethostbyaddr_r.c gethostbyname_r.c gethostbyname2_r.c \
gethostbyaddr.c gethostbyname.c gethostbyname2.c
-CSRC-$(findstring y,$(UCLIBC_HAS_RESOLVER_SUPPORT)) += \
+CSRC-$(UCLIBC_HAS_RESOLVER_SUPPORT) += \
ns_netint.c ns_parse.c res_data.c \
res_init.c res_query.c res_comp.c ns_name.c \
_res_state.c
@@ -52,7 +53,7 @@ socketcalls_CSRC-y += \
socketcalls_CSRC-$(UCLIBC_LINUX_SPECIFIC) += accept4.c
CSRC-$(UCLIBC_HAS_SOCKET) += $(socketcalls_CSRC-y) opensock.c
-CSRC-$(findstring y,$(UCLIBC_HAS_SOCKET)$(UCLIBC_HAS_IPV4)$(UCLIBC_HAS_IPV6)) += ethers.c ether_addr.c
+CSRC-$(findstring y,$(UCLIBC_HAS_SOCKET)$(V4_OR_V6)) += ethers.c ether_addr.c
INET_SRC := $(patsubst %.c,$(INET_DIR)/%.c,$(CSRC-y))
INET_OBJ := $(patsubst %.c,$(INET_OUT)/%.o,$(CSRC-y))
diff --git a/libc/inet/rpc/Makefile.in b/libc/inet/rpc/Makefile.in
index 6ec674d10..481961d80 100644
--- a/libc/inet/rpc/Makefile.in
+++ b/libc/inet/rpc/Makefile.in
@@ -9,9 +9,8 @@ subdirs += libc/inet/rpc
CFLAGS-rpc := -fno-strict-aliasing
-ifneq ($(UCLIBC_HAS_FULL_RPC),y)
# For now, only compile the stuff needed to do an NFS mount....
-CSRC:= authunix_prot.c auth_none.c auth_unix.c bindresvport.c \
+CSRC_NFS = authunix_prot.c auth_none.c auth_unix.c bindresvport.c \
clnt_perror.c clnt_simple.c clnt_tcp.c clnt_udp.c \
create_xid.c getrpcent.c \
pmap_clnt.c pm_getmaps.c pm_getport.c pmap_prot.c pmap_prot2.c \
@@ -19,27 +18,22 @@ CSRC:= authunix_prot.c auth_none.c auth_unix.c bindresvport.c \
rpc_prot.c rpc_thread.c rtime.c ruserpass.c sa_len.c \
svc.c svc_auth.c svc_authux.c \
xdr.c xdr_array.c xdr_mem.c xdr_rec.c xdr_reference.c
-endif
+CSRC_ALL = $(notdir $(wildcard $(INET_RPC_DIR)/*.c))
+CSRC-y := $(if $(UCLIBC_HAS_FULL_RPC),$(CSRC_ALL),$(CSRC_NFS))
+# rpc_thread.oS is better, because the header adds unneeded references
+# to __pthread_internal_tsd*
+CSRC-y := $(filter-out rpc_thread.c,$(CSRC-y))
INET_RPC_DIR:=$(top_srcdir)libc/inet/rpc
INET_RPC_OUT:=$(top_builddir)libc/inet/rpc
-ifeq ($(UCLIBC_HAS_FULL_RPC),y)
-INET_RPC_SRC:=$(wildcard $(INET_RPC_DIR)/*.c)
-else
-INET_RPC_SRC:=$(patsubst %.c,$(INET_RPC_DIR)/%.c,$(CSRC))
-endif
-# rpc_thread.oS is better, because the header adds unneeded references to __pthread_internal_tsd*
-INET_RPC_SRC:=$(filter-out $(INET_RPC_DIR)/rpc_thread.c,$(INET_RPC_SRC))
-
-INET_RPC_OBJ:=$(patsubst $(INET_RPC_DIR)/%.c,$(INET_RPC_OUT)/%.o,$(INET_RPC_SRC))
-
-libc-static-$(UCLIBC_HAS_RPC)+=$(INET_RPC_OUT)/rpc_thread.o
-libc-shared-$(UCLIBC_HAS_RPC)+=$(INET_RPC_OUT)/rpc_thread.oS
+INET_RPC_SRC:=$(patsubst %.c,$(INET_RPC_DIR)/%.c,$(CSRC-y))
+INET_RPC_OBJ:=$(patsubst %.c,$(INET_RPC_OUT)/%.o,$(CSRC-y))
+libc-static-$(UCLIBC_HAS_RPC) += $(INET_RPC_OUT)/rpc_thread.o
+libc-shared-$(UCLIBC_HAS_RPC) += $(INET_RPC_OUT)/rpc_thread.oS
libc-nomulti-$(UCLIBC_HAS_RPC) += $(INET_RPC_OUT)/rpc_thread.o
-
-libc-$(UCLIBC_HAS_RPC)+=$(INET_RPC_OBJ)
+libc-$(UCLIBC_HAS_RPC) += $(INET_RPC_OBJ)
objclean-y+=CLEAN_libc/inet/rpc
diff --git a/libc/misc/assert/Makefile.in b/libc/misc/assert/Makefile.in
index a49e00d2e..aba8a3b8d 100644
--- a/libc/misc/assert/Makefile.in
+++ b/libc/misc/assert/Makefile.in
@@ -7,13 +7,13 @@
subdirs += libc/misc/assert
-CSRC := __assert.c
+CSRC-y := __assert.c
MISC_ASSERT_DIR := $(top_srcdir)libc/misc/assert
MISC_ASSERT_OUT := $(top_builddir)libc/misc/assert
-MISC_ASSERT_SRC := $(MISC_ASSERT_DIR)/__assert.c
-MISC_ASSERT_OBJ := $(MISC_ASSERT_OUT)/__assert.o
+MISC_ASSERT_SRC := $(patsubst %.c,$(MISC_ASSERT_DIR)/%.c,$(CSRC-y))
+MISC_ASSERT_OBJ := $(patsubst %.c,$(MISC_ASSERT_OUT)/%.o,$(CSRC-y))
libc-y += $(MISC_ASSERT_OBJ)
diff --git a/libc/misc/ctype/Makefile.in b/libc/misc/ctype/Makefile.in
index 125d91699..0ebaec285 100644
--- a/libc/misc/ctype/Makefile.in
+++ b/libc/misc/ctype/Makefile.in
@@ -8,31 +8,25 @@
subdirs += libc/misc/ctype
# multi source ctype.c
-COM_SRC := \
+COM_SRC-y := \
isalnum.c isalpha.c iscntrl.c isdigit.c \
isgraph.c islower.c isprint.c ispunct.c isspace.c \
isupper.c isxdigit.c tolower.c toupper.c \
isblank.c
-ifeq ($(UCLIBC_SUSV4_LEGACY),y)
-COM_SRC += isascii.c toascii.c
-endif
-CSRC := $(COM_SRC)
+COM_SRC-$(UCLIBC_SUSV4_LEGACY) += isascii.c toascii.c
+CSRC-y := $(COM_SRC-y)
-ifeq ($(UCLIBC_HAS_CTYPE_TABLES),y)
-CSRC += __C_ctype_b.c __C_ctype_tolower.c __C_ctype_toupper.c \
+CSRC-$(UCLIBC_HAS_CTYPE_TABLES) += \
+ __C_ctype_b.c __C_ctype_tolower.c __C_ctype_toupper.c \
__ctype_b_loc.c __ctype_tolower_loc.c __ctype_toupper_loc.c \
__ctype_assert.c isctype.c
-endif
-
-ifeq ($(UCLIBC_HAS_XLOCALE),y)
-CSRC += $(patsubst %.c,%_l.c,$(COM_SRC))
-endif
+CSRC-$(UCLIBC_HAS_XLOCALE) += $(patsubst %.c,%_l.c,$(COM_SRC-y))
MISC_CTYPE_DIR := $(top_srcdir)libc/misc/ctype
MISC_CTYPE_OUT := $(top_builddir)libc/misc/ctype
-MISC_CTYPE_SRC := $(patsubst %.c,$(MISC_CTYPE_DIR)/%.c,$(CSRC))
-MISC_CTYPE_OBJ := $(patsubst %.c,$(MISC_CTYPE_OUT)/%.o,$(CSRC))
+MISC_CTYPE_SRC := $(patsubst %.c,$(MISC_CTYPE_DIR)/%.c,$(CSRC-y))
+MISC_CTYPE_OBJ := $(patsubst %.c,$(MISC_CTYPE_OUT)/%.o,$(CSRC-y))
libc-y += $(MISC_CTYPE_OBJ)
diff --git a/libc/misc/dirent/Makefile.in b/libc/misc/dirent/Makefile.in
index d42dfeb1e..5cae8d44d 100644
--- a/libc/misc/dirent/Makefile.in
+++ b/libc/misc/dirent/Makefile.in
@@ -7,18 +7,18 @@
subdirs += libc/misc/dirent
-CSRC := alphasort.c closedir.c dirfd.c opendir.c readdir.c rewinddir.c \
- scandir.c seekdir.c telldir.c readdir_r.c versionsort.c
-
-ifeq ($(UCLIBC_HAS_LFS),y)
-CSRC += readdir64.c alphasort64.c scandir64.c readdir64_r.c versionsort64.c
-endif
+CSRC := alphasort.c readdir.c scandir.c versionsort.c
+CSRC_R := readdir_r.c
+CSRC-y := closedir.c dirfd.c opendir.c rewinddir.c seekdir.c telldir.c $(CSRC) \
+ $(CSRC_R)
+CSRC-$(UCLIBC_HAS_LFS) += $(patsubst %.c,%64.c,$(CSRC))
+CSRC-$(UCLIBC_HAS_LFS) += $(patsubst %_r.c,%64_r.c,$(CSRC_R))
MISC_DIRENT_DIR := $(top_srcdir)libc/misc/dirent
MISC_DIRENT_OUT := $(top_builddir)libc/misc/dirent
-MISC_DIRENT_SRC := $(patsubst %.c,$(MISC_DIRENT_DIR)/%.c,$(CSRC))
-MISC_DIRENT_OBJ := $(patsubst %.c,$(MISC_DIRENT_OUT)/%.o,$(CSRC))
+MISC_DIRENT_SRC := $(patsubst %.c,$(MISC_DIRENT_DIR)/%.c,$(CSRC-y))
+MISC_DIRENT_OBJ := $(patsubst %.c,$(MISC_DIRENT_OUT)/%.o,$(CSRC-y))
libc-y += $(MISC_DIRENT_OBJ)
diff --git a/libc/misc/error/Makefile.in b/libc/misc/error/Makefile.in
index b76a0dfff..fa959c131 100644
--- a/libc/misc/error/Makefile.in
+++ b/libc/misc/error/Makefile.in
@@ -7,19 +7,15 @@
subdirs += libc/misc/error
-CSRC :=
-ifeq ($(UCLIBC_HAS_BSD_ERR),y)
-CSRC += err.c
-endif
-ifeq ($(UCLIBC_HAS_GNU_ERROR),y)
-CSRC += error.c
-endif
+CSRC-y :=
+CSRC-$(UCLIBC_HAS_BSD_ERR) += err.c
+CSRC-$(UCLIBC_HAS_GNU_ERROR) += error.c
MISC_ERROR_DIR := $(top_srcdir)libc/misc/error
MISC_ERROR_OUT := $(top_builddir)libc/misc/error
-MISC_ERROR_SRC := $(patsubst %.c,$(MISC_ERROR_DIR)/%.c,$(CSRC))
-MISC_ERROR_OBJ := $(patsubst %.c,$(MISC_ERROR_OUT)/%.o,$(CSRC))
+MISC_ERROR_SRC := $(patsubst %.c,$(MISC_ERROR_DIR)/%.c,$(CSRC-y))
+MISC_ERROR_OBJ := $(patsubst %.c,$(MISC_ERROR_OUT)/%.o,$(CSRC-y))
libc-y += $(MISC_ERROR_OBJ)
diff --git a/libc/misc/file/Makefile.in b/libc/misc/file/Makefile.in
index ace9db060..b94efa67f 100644
--- a/libc/misc/file/Makefile.in
+++ b/libc/misc/file/Makefile.in
@@ -10,12 +10,12 @@ subdirs += libc/misc/file
MISC_FILE_DIR := $(top_srcdir)libc/misc/file
MISC_FILE_OUT := $(top_builddir)libc/misc/file
-MISC_FILE_SRC := $(wildcard $(MISC_FILE_DIR)/*.c)
-ifneq ($(UCLIBC_HAS_LFS),y)
-MISC_FILE_SRC := $(filter-out $(MISC_FILE_DIR)/lockf64.c,$(MISC_FILE_SRC))
-endif
-MISC_FILE_OBJ := $(patsubst $(MISC_FILE_DIR)/%.c,$(MISC_FILE_OUT)/%.o,$(MISC_FILE_SRC))
+CSRC-y := $(wildcard $(MISC_FILE_DIR)/*.c)
+CSRC_LFS := $(wildcard $(MISC_FILE_DIR)/*64.c)
+CSRC-y := $(filter-out $(CSRC_LFS),$(CSRC-y))
+CSRC-$(UCLIBC_HAS_LFS) += $(CSRC_LFS)
+MISC_FILE_OBJ := $(patsubst $(MISC_FILE_DIR)/%.c,$(MISC_FILE_OUT)/%.o,$(CSRC-y))
libc-y += $(MISC_FILE_OBJ)
libc-nomulti-$(UCLIBC_HAS_LFS) += $(MISC_FILE_OUT)/lockf64.o
diff --git a/libc/misc/fnmatch/Makefile.in b/libc/misc/fnmatch/Makefile.in
index 2557b5aa7..ab43e00f1 100644
--- a/libc/misc/fnmatch/Makefile.in
+++ b/libc/misc/fnmatch/Makefile.in
@@ -7,17 +7,13 @@
subdirs += libc/misc/fnmatch
-ifeq ($(UCLIBC_HAS_FNMATCH_OLD),y)
-CSRC := fnmatch_old.c
-else
-CSRC := fnmatch.c
-endif
+CSRC-y := $(if $(UCLIBC_HAS_FNMATCH_OLD),fnmatch_old.c,fnmatch.c)
MISC_FNMATCH_DIR := $(top_srcdir)libc/misc/fnmatch
MISC_FNMATCH_OUT := $(top_builddir)libc/misc/fnmatch
-MISC_FNMATCH_SRC := $(patsubst %.c,$(MISC_FNMATCH_DIR)/%.c,$(CSRC))
-MISC_FNMATCH_OBJ := $(patsubst %.c,$(MISC_FNMATCH_OUT)/%.o,$(CSRC))
+MISC_FNMATCH_SRC := $(patsubst %.c,$(MISC_FNMATCH_DIR)/%.c,$(CSRC-y))
+MISC_FNMATCH_OBJ := $(patsubst %.c,$(MISC_FNMATCH_OUT)/%.o,$(CSRC-y))
libc-$(UCLIBC_HAS_FNMATCH) += $(MISC_FNMATCH_OBJ)
diff --git a/libc/misc/fts/Makefile.in b/libc/misc/fts/Makefile.in
index a1d0efa32..aa87d993a 100644
--- a/libc/misc/fts/Makefile.in
+++ b/libc/misc/fts/Makefile.in
@@ -7,13 +7,13 @@
#
subdirs += libc/misc/fts
-CSRC := fts.c
+CSRC-y := fts.c
MISC_FTS_DIR := $(top_srcdir)libc/misc/fts
MISC_FTS_OUT := $(top_builddir)libc/misc/fts
-MISC_FTS_SRC := $(patsubst %.c,$(MISC_FTS_DIR)/%.c,$(CSRC))
-MISC_FTS_OBJ := $(patsubst %.c,$(MISC_FTS_OUT)/%.o,$(CSRC))
+MISC_FTS_SRC := $(patsubst %.c,$(MISC_FTS_DIR)/%.c,$(CSRC-y))
+MISC_FTS_OBJ := $(patsubst %.c,$(MISC_FTS_OUT)/%.o,$(CSRC-y))
libc-$(UCLIBC_HAS_FTS) += $(MISC_FTS_OBJ)
diff --git a/libc/misc/ftw/Makefile.in b/libc/misc/ftw/Makefile.in
index 2edd81959..084a73009 100644
--- a/libc/misc/ftw/Makefile.in
+++ b/libc/misc/ftw/Makefile.in
@@ -7,16 +7,14 @@
subdirs += libc/misc/ftw
-CSRC := ftw.c
-ifeq ($(UCLIBC_HAS_LFS),y)
-CSRC += ftw64.c
-endif
+CSRC-y := ftw.c
+CSRC-$(UCLIBC_HAS_LFS) += ftw64.c
MISC_FTW_DIR := $(top_srcdir)libc/misc/ftw
MISC_FTW_OUT := $(top_builddir)libc/misc/ftw
-MISC_FTW_SRC := $(patsubst %.c,$(MISC_FTW_DIR)/%.c,$(CSRC))
-MISC_FTW_OBJ := $(patsubst %.c,$(MISC_FTW_OUT)/%.o,$(CSRC))
+MISC_FTW_SRC := $(patsubst %.c,$(MISC_FTW_DIR)/%.c,$(CSRC-y))
+MISC_FTW_OBJ := $(patsubst %.c,$(MISC_FTW_OUT)/%.o,$(CSRC-y))
libc-$(findstring y,$(UCLIBC_HAS_FTW)$(UCLIBC_HAS_NFTW)) += $(MISC_FTW_OBJ)
diff --git a/libc/misc/glob/Makefile.in b/libc/misc/glob/Makefile.in
index 03bfcca36..c89d2b08d 100644
--- a/libc/misc/glob/Makefile.in
+++ b/libc/misc/glob/Makefile.in
@@ -7,23 +7,15 @@
subdirs += libc/misc/glob
-ifeq ($(UCLIBC_HAS_GNU_GLOB),y)
-CSRC := glob.c
-ifeq ($(UCLIBC_HAS_LFS),y)
-CSRC += glob64.c
-endif
-else
-CSRC := glob-susv3.c
-ifeq ($(UCLIBC_HAS_LFS),y)
-CSRC += glob64-susv3.c
-endif
-endif
+VARIANT := $(if $(UCLIBC_HAS_GNU_GLOB),,-susv3)
+CSRC-y := glob$(VARIANT).c
+CSRC-$(UCLIBC_HAS_LFS) += glob64$(VARIANT).c
MISC_GLOB_DIR := $(top_srcdir)libc/misc/glob
MISC_GLOB_OUT := $(top_builddir)libc/misc/glob
-MISC_GLOB_SRC := $(patsubst %.c,$(MISC_GLOB_DIR)/%.c,$(CSRC))
-MISC_GLOB_OBJ := $(patsubst %.c,$(MISC_GLOB_OUT)/%.o,$(CSRC))
+MISC_GLOB_SRC := $(patsubst %.c,$(MISC_GLOB_DIR)/%.c,$(CSRC-y))
+MISC_GLOB_OBJ := $(patsubst %.c,$(MISC_GLOB_OUT)/%.o,$(CSRC-y))
libc-$(UCLIBC_HAS_GLOB) += $(MISC_GLOB_OBJ)
diff --git a/libc/misc/gnu/Makefile.in b/libc/misc/gnu/Makefile.in
index 3990e4e8b..579cb01bc 100644
--- a/libc/misc/gnu/Makefile.in
+++ b/libc/misc/gnu/Makefile.in
@@ -7,13 +7,14 @@
subdirs += libc/misc/gnu
-CSRC := obstack.c
+$(warning XXX: add UCLIBC_HAS_OBSTACK)
+CSRC-y := obstack.c
MISC_GNU_DIR := $(top_srcdir)libc/misc/gnu
MISC_GNU_OUT := $(top_builddir)libc/misc/gnu
-MISC_GNU_SRC := $(MISC_GNU_DIR)/obstack.c
-MISC_GNU_OBJ := $(MISC_GNU_OUT)/obstack.o
+MISC_GNU_SRC := $(patsubst %.c,$(MISC_GNU_DIR)/%.c,$(CSRC-y))
+MISC_GNU_OBJ := $(patsubst %.c,$(MISC_GNU_OUT)/%.o,$(CSRC-y))
libc-y += $(MISC_GNU_OBJ)
diff --git a/libc/misc/internals/Makefile.in b/libc/misc/internals/Makefile.in
index 2123bbb76..ae094ee23 100644
--- a/libc/misc/internals/Makefile.in
+++ b/libc/misc/internals/Makefile.in
@@ -7,14 +7,14 @@
subdirs += libc/misc/internals
-CSRC := tempname.c errno.c h_errno.c __errno_location.c __h_errno_location.c \
+CSRC-y := tempname.c errno.c h_errno.c __errno_location.c __h_errno_location.c \
parse_config.c
MISC_INTERNALS_DIR := $(top_srcdir)libc/misc/internals
MISC_INTERNALS_OUT := $(top_builddir)libc/misc/internals
-MISC_INTERNALS_SRC := $(patsubst %.c,$(MISC_INTERNALS_DIR)/%.c,$(CSRC))
-MISC_INTERNALS_OBJ := $(patsubst %.c,$(MISC_INTERNALS_OUT)/%.o,$(CSRC))
+MISC_INTERNALS_SRC := $(patsubst %.c,$(MISC_INTERNALS_DIR)/%.c,$(CSRC-y))
+MISC_INTERNALS_OBJ := $(patsubst %.c,$(MISC_INTERNALS_OUT)/%.o,$(CSRC-y))
CFLAGS-__uClibc_main.c := $(SSP_DISABLE_FLAGS)
diff --git a/libc/misc/locale/Makefile.in b/libc/misc/locale/Makefile.in
index c12befd32..3db6d5c5c 100644
--- a/libc/misc/locale/Makefile.in
+++ b/libc/misc/locale/Makefile.in
@@ -8,19 +8,16 @@
subdirs += libc/misc/locale
# multi source locale.c
-CSRC := setlocale.c localeconv.c _locale_init.c nl_langinfo.c
-ifeq ($(UCLIBC_HAS_LOCALE),y)
-CSRC += newlocale.c __locale_mbrtowc_l.c
-endif
-ifeq ($(UCLIBC_HAS_XLOCALE),y)
-CSRC += nl_langinfo_l.c duplocale.c freelocale.c uselocale.c __curlocale.c
-endif
+CSRC-y := setlocale.c localeconv.c _locale_init.c nl_langinfo.c
+CSRC-$(UCLIBC_HAS_LOCALE) += newlocale.c __locale_mbrtowc_l.c
+CSRC-$(UCLIBC_HAS_XLOCALE) += nl_langinfo_l.c duplocale.c freelocale.c \
+ uselocale.c __curlocale.c
MISC_LOCALE_DIR := $(top_srcdir)libc/misc/locale
MISC_LOCALE_OUT := $(top_builddir)libc/misc/locale
-MISC_LOCALE_SRC := $(patsubst %.c,$(MISC_LOCALE_DIR)/%.c,$(CSRC))
-MISC_LOCALE_OBJ := $(patsubst %.c,$(MISC_LOCALE_OUT)/%.o,$(CSRC))
+MISC_LOCALE_SRC := $(patsubst %.c,$(MISC_LOCALE_DIR)/%.c,$(CSRC-y))
+MISC_LOCALE_OBJ := $(patsubst %.c,$(MISC_LOCALE_OUT)/%.o,$(CSRC-y))
libc-y += $(MISC_LOCALE_OBJ)
diff --git a/libc/misc/mntent/Makefile.in b/libc/misc/mntent/Makefile.in
index daa888da0..3ced9bbd1 100644
--- a/libc/misc/mntent/Makefile.in
+++ b/libc/misc/mntent/Makefile.in
@@ -7,13 +7,13 @@
subdirs += libc/misc/mntent
-CSRC := mntent.c
+CSRC-y := mntent.c
MISC_MNTENT_DIR := $(top_srcdir)libc/misc/mntent
MISC_MNTENT_OUT := $(top_builddir)libc/misc/mntent
-MISC_MNTENT_SRC := $(MISC_MNTENT_DIR)/mntent.c
-MISC_MNTENT_OBJ := $(MISC_MNTENT_OUT)/mntent.o
+MISC_MNTENT_SRC := $(patsubst %.c,$(MISC_MNTENT_DIR)/%.c,$(CSRC-y))
+MISC_MNTENT_OBJ := $(patsubst %.c,$(MISC_MNTENT_OUT)/%.o,$(CSRC-y))
libc-y += $(MISC_MNTENT_OBJ)
diff --git a/libc/misc/regex/Makefile.in b/libc/misc/regex/Makefile.in
index 94710238f..f95a9f7a3 100644
--- a/libc/misc/regex/Makefile.in
+++ b/libc/misc/regex/Makefile.in
@@ -7,17 +7,14 @@
subdirs += libc/misc/regex
-ifeq ($(UCLIBC_HAS_REGEX_OLD),y)
-CSRC := regex_old.c
-else
-CSRC := regex.c
-endif
+VARIANT := $(if $(UCLIBC_HAS_REGEX_OLD),_old)
+CSRC-y := regex$(VARIANT).c
MISC_REGEX_DIR := $(top_srcdir)libc/misc/regex
MISC_REGEX_OUT := $(top_builddir)libc/misc/regex
-MISC_REGEX_SRC := $(patsubst %.c,$(MISC_REGEX_DIR)/%.c,$(CSRC))
-MISC_REGEX_OBJ := $(patsubst %.c,$(MISC_REGEX_OUT)/%.o,$(CSRC))
+MISC_REGEX_SRC := $(patsubst %.c,$(MISC_REGEX_DIR)/%.c,$(CSRC-y))
+MISC_REGEX_OBJ := $(patsubst %.c,$(MISC_REGEX_OUT)/%.o,$(CSRC-y))
libc-$(UCLIBC_HAS_REGEX) += $(MISC_REGEX_OBJ)
diff --git a/libc/misc/search/Makefile.in b/libc/misc/search/Makefile.in
index 35dacb49b..d13766148 100644
--- a/libc/misc/search/Makefile.in
+++ b/libc/misc/search/Makefile.in
@@ -7,25 +7,25 @@
subdirs += libc/misc/search
-CSRC := hsearch.c
+CSRC-y := hsearch.c
# multi source _tsearch.c
-CSRC += tsearch.c tfind.c tdelete.c twalk.c tdestroy.c
+CSRC-y += tsearch.c tfind.c tdelete.c twalk.c tdestroy.c
# multi source _lsearch.c
-CSRC += lfind.c lsearch.c
+CSRC-y += lfind.c lsearch.c
# multi source insremque.c
-CSRC += insque.c remque.c
+CSRC-y += insque.c remque.c
# multi source _hsearch_r.c
-CSRC += hcreate_r.c hdestroy_r.c hsearch_r.c
+CSRC-y += hcreate_r.c hdestroy_r.c hsearch_r.c
MISC_SEARCH_DIR := $(top_srcdir)libc/misc/search
MISC_SEARCH_OUT := $(top_builddir)libc/misc/search
-MISC_SEARCH_SRC := $(patsubst %.c,$(MISC_SEARCH_DIR)/%.c,$(CSRC))
-MISC_SEARCH_OBJ := $(patsubst %.c,$(MISC_SEARCH_OUT)/%.o,$(CSRC))
+MISC_SEARCH_SRC := $(patsubst %.c,$(MISC_SEARCH_DIR)/%.c,$(CSRC-y))
+MISC_SEARCH_OBJ := $(patsubst %.c,$(MISC_SEARCH_OUT)/%.o,$(CSRC-y))
libc-y += $(MISC_SEARCH_OBJ)
diff --git a/libc/misc/statfs/Makefile.in b/libc/misc/statfs/Makefile.in
index aa92d1f70..d70ab8f6e 100644
--- a/libc/misc/statfs/Makefile.in
+++ b/libc/misc/statfs/Makefile.in
@@ -7,19 +7,16 @@
subdirs += libc/misc/statfs
-CSRC := statvfs.c fstatvfs.c
-ifeq ($(UCLIBC_HAS_LFS),y)
-ifeq ($(UCLIBC_LINUX_SPECIFIC),y)
-CSRC += fstatfs64.c statfs64.c
-endif
-CSRC += statvfs64.c fstatvfs64.c
-endif
+CSRC-y := statvfs.c fstatvfs.c
+CSRC-$(UCLIBC_HAS_LFS) += $(patsubst %.c,%64.c,$(CSRC-y))
+CSRC-$(if $(findstring yy,$(UCLIBC_HAS_LFS)$(UCLIBC_LINUX_SPECIFIC)),y) += \
+ fstatfs64.c statfs64.c
MISC_STATFS_DIR := $(top_srcdir)libc/misc/statfs
MISC_STATFS_OUT := $(top_builddir)libc/misc/statfs
-MISC_STATFS_SRC := $(patsubst %.c,$(MISC_STATFS_DIR)/%.c,$(CSRC))
-MISC_STATFS_OBJ := $(patsubst %.c,$(MISC_STATFS_OUT)/%.o,$(CSRC))
+MISC_STATFS_SRC := $(patsubst %.c,$(MISC_STATFS_DIR)/%.c,$(CSRC-y))
+MISC_STATFS_OBJ := $(patsubst %.c,$(MISC_STATFS_OUT)/%.o,$(CSRC-y))
libc-y += $(MISC_STATFS_OBJ)
diff --git a/libc/misc/syslog/Makefile.in b/libc/misc/syslog/Makefile.in
index 5cc4f5237..2d00a33fd 100644
--- a/libc/misc/syslog/Makefile.in
+++ b/libc/misc/syslog/Makefile.in
@@ -7,13 +7,13 @@
subdirs += libc/misc/syslog
-CSRC := syslog.c
+CSRC-y := syslog.c
MISC_SYSLOG_DIR := $(top_srcdir)libc/misc/syslog
MISC_SYSLOG_OUT := $(top_builddir)libc/misc/syslog
-MISC_SYSLOG_SRC := $(patsubst %.c,$(MISC_SYSLOG_DIR)/%.c,$(CSRC))
-MISC_SYSLOG_OBJ := $(patsubst %.c,$(MISC_SYSLOG_OUT)/%.o,$(CSRC))
+MISC_SYSLOG_SRC := $(patsubst %.c,$(MISC_SYSLOG_DIR)/%.c,$(CSRC-y))
+MISC_SYSLOG_OBJ := $(patsubst %.c,$(MISC_SYSLOG_OUT)/%.o,$(CSRC-y))
ifeq ($(UCLIBC_HAS_SYSLOG),y)
libc-y += $(MISC_SYSLOG_OBJ)
diff --git a/libc/misc/sysvipc/Makefile.in b/libc/misc/sysvipc/Makefile.in
index 115cfc67e..d1c124430 100644
--- a/libc/misc/sysvipc/Makefile.in
+++ b/libc/misc/sysvipc/Makefile.in
@@ -7,22 +7,22 @@
subdirs += libc/misc/sysvipc
-CSRC := ftok.c __syscall_ipc.c
+CSRC-y := ftok.c __syscall_ipc.c
# multi source sem.c
-CSRC += semget.c semctl.c semop.c semtimedop.c
+CSRC-y += semget.c semctl.c semop.c semtimedop.c
# multi source shm.c
-CSRC += shmat.c shmctl.c shmdt.c shmget.c
+CSRC-y += shmat.c shmctl.c shmdt.c shmget.c
# multi source msgq.c
-CSRC += msgctl.c msgget.c msgrcv.c msgsnd.c
+CSRC-y += msgctl.c msgget.c msgrcv.c msgsnd.c
MISC_SYSVIPC_DIR := $(top_srcdir)libc/misc/sysvipc
MISC_SYSVIPC_OUT := $(top_builddir)libc/misc/sysvipc
-MISC_SYSVIPC_SRC := $(patsubst %.c,$(MISC_SYSVIPC_DIR)/%.c,$(CSRC))
-MISC_SYSVIPC_OBJ := $(patsubst %.c,$(MISC_SYSVIPC_OUT)/%.o,$(CSRC))
+MISC_SYSVIPC_SRC := $(patsubst %.c,$(MISC_SYSVIPC_DIR)/%.c,$(CSRC-y))
+MISC_SYSVIPC_OBJ := $(patsubst %.c,$(MISC_SYSVIPC_OUT)/%.o,$(CSRC-y))
libc-y += $(MISC_SYSVIPC_OBJ)
diff --git a/libc/misc/time/Makefile.in b/libc/misc/time/Makefile.in
index 78f01ad85..906a1b28e 100644
--- a/libc/misc/time/Makefile.in
+++ b/libc/misc/time/Makefile.in
@@ -7,33 +7,24 @@
subdirs += libc/misc/time
-CSRC := adjtime.c
-ifeq ($(UCLIBC_SUSV3_LEGACY),y)
-CSRC += ftime.c
-endif
+CSRC-y := adjtime.c
+CSRC-$(UCLIBC_SUSV3_LEGACY) += ftime.c
# multi source time.c
-CSRC += asctime.c asctime_r.c clock.c ctime.c ctime_r.c gmtime.c gmtime_r.c \
+CSRC-y += asctime.c asctime_r.c clock.c ctime.c ctime_r.c gmtime.c gmtime_r.c \
localtime.c localtime_r.c mktime.c strftime.c strptime.c tzset.c \
_time_t2tm.c __time_tm.c _time_mktime.c dysize.c timegm.c \
_time_mktime_tzi.c _time_localtime_tzi.c
-ifeq ($(UCLIBC_HAS_FLOATS),y)
-CSRC += difftime.c
-endif
-ifeq ($(UCLIBC_HAS_XLOCALE),y)
-CSRC += strftime_l.c strptime_l.c
-endif
-ifeq ($(UCLIBC_HAS_WCHAR),y)
-CSRC += wcsftime.c
-ifeq ($(UCLIBC_HAS_XLOCALE),y)
-CSRC += wcsftime_l.c
-endif
-endif
+CSRC-$(UCLIBC_HAS_FLOATS) += difftime.c
+CSRC-$(UCLIBC_HAS_XLOCALE) += strftime_l.c strptime_l.c
+CSRC-$(UCLIBC_HAS_WCHAR) += wcsftime.c
+CSRC-$(if $(findstring yy,$(UCLIBC_HAS_WCHAR)$(UCLIBC_HAS_XLOCALE)),y) += \
+ wcsftime_l.c
MISC_TIME_DIR := $(top_srcdir)libc/misc/time
MISC_TIME_OUT := $(top_builddir)libc/misc/time
-MISC_TIME_SRC := $(patsubst %.c,$(MISC_TIME_DIR)/%.c,$(CSRC))
-MISC_TIME_OBJ := $(patsubst %.c,$(MISC_TIME_OUT)/%.o,$(CSRC))
+MISC_TIME_SRC := $(patsubst %.c,$(MISC_TIME_DIR)/%.c,$(CSRC-y))
+MISC_TIME_OBJ := $(patsubst %.c,$(MISC_TIME_OUT)/%.o,$(CSRC-y))
libc-y += $(MISC_TIME_OBJ)
diff --git a/libc/misc/ttyent/Makefile.in b/libc/misc/ttyent/Makefile.in
index bfa80bec1..02d7df8d1 100644
--- a/libc/misc/ttyent/Makefile.in
+++ b/libc/misc/ttyent/Makefile.in
@@ -7,13 +7,13 @@
subdirs += libc/misc/ttyent
-CSRC := getttyent.c
+CSRC-y := getttyent.c
MISC_TTYENT_DIR := $(top_srcdir)libc/misc/ttyent
MISC_TTYENT_OUT := $(top_builddir)libc/misc/ttyent
-MISC_TTYENT_SRC := $(patsubst %.c,$(MISC_TTYENT_DIR)/%.c,$(CSRC))
-MISC_TTYENT_OBJ := $(patsubst %.c,$(MISC_TTYENT_OUT)/%.o,$(CSRC))
+MISC_TTYENT_SRC := $(patsubst %.c,$(MISC_TTYENT_DIR)/%.c,$(CSRC-y))
+MISC_TTYENT_OBJ := $(patsubst %.c,$(MISC_TTYENT_OUT)/%.o,$(CSRC-y))
libc-y += $(MISC_TTYENT_OBJ)
diff --git a/libc/misc/utmp/Makefile.in b/libc/misc/utmp/Makefile.in
index 49ae5a503..535efb150 100644
--- a/libc/misc/utmp/Makefile.in
+++ b/libc/misc/utmp/Makefile.in
@@ -7,17 +7,14 @@
subdirs += libc/misc/utmp
-CSRC := utent.c wtent.c
-
-ifeq ($(UCLIBC_HAS_UTMPX),y)
-CSRC += utxent.c
-endif
+CSRC-y := utent.c wtent.c
+CSRC-$(UCLIBC_HAS_UTMPX) += utxent.c
MISC_UTMP_DIR := $(top_srcdir)libc/misc/utmp
MISC_UTMP_OUT := $(top_builddir)libc/misc/utmp
-MISC_UTMP_SRC := $(patsubst %.c,$(MISC_UTMP_DIR)/%.c,$(CSRC))
-MISC_UTMP_OBJ := $(patsubst %.c,$(MISC_UTMP_OUT)/%.o,$(CSRC))
+MISC_UTMP_SRC := $(patsubst %.c,$(MISC_UTMP_DIR)/%.c,$(CSRC-y))
+MISC_UTMP_OBJ := $(patsubst %.c,$(MISC_UTMP_OUT)/%.o,$(CSRC-y))
libc-y += $(MISC_UTMP_OBJ)
diff --git a/libc/misc/wchar/Makefile.in b/libc/misc/wchar/Makefile.in
index be95a186a..32a8dbc62 100644
--- a/libc/misc/wchar/Makefile.in
+++ b/libc/misc/wchar/Makefile.in
@@ -19,19 +19,17 @@
subdirs += libc/misc/wchar
# multi source wchar.c
-CSRC := btowc.c wctob.c mbsinit.c mbrlen.c mbrtowc.c wcrtomb.c mbsrtowcs.c \
+CSRC-y := btowc.c wctob.c mbsinit.c mbrlen.c mbrtowc.c wcrtomb.c mbsrtowcs.c \
wcsrtombs.c _wchar_utf8sntowcs.c _wchar_wcsntoutf8s.c \
mbsnrtowcs.c wcsnrtombs.c wcwidth.c wcswidth.c
-ifeq ($(UCLIBC_HAS_LOCALE),y)
-CSRC += iconv.c
-endif
+CSRC-$(UCLIBC_HAS_LOCALE) += iconv.c
MISC_WCHAR_DIR := $(top_srcdir)libc/misc/wchar
MISC_WCHAR_OUT := $(top_builddir)libc/misc/wchar
-MISC_WCHAR_SRC := $(patsubst %.c,$(MISC_WCHAR_DIR)/%.c,$(CSRC))
-MISC_WCHAR_OBJ := $(patsubst %.c,$(MISC_WCHAR_OUT)/%.o,$(CSRC))
+MISC_WCHAR_SRC := $(patsubst %.c,$(MISC_WCHAR_DIR)/%.c,$(CSRC-y))
+MISC_WCHAR_OBJ := $(patsubst %.c,$(MISC_WCHAR_OUT)/%.o,$(CSRC-y))
libc-$(UCLIBC_HAS_WCHAR) += $(MISC_WCHAR_OBJ)
diff --git a/libc/misc/wctype/Makefile.in b/libc/misc/wctype/Makefile.in
index 4eacc118e..d40c2d321 100644
--- a/libc/misc/wctype/Makefile.in
+++ b/libc/misc/wctype/Makefile.in
@@ -14,19 +14,15 @@ COM_SRC := \
iswxdigit.c iswblank.c wctrans.c towctrans.c \
wctype.c iswctype.c towlower.c towupper.c
-CSRC :=
-ifeq ($(UCLIBC_HAS_WCHAR),y)
-CSRC += $(COM_SRC)
-endif
-ifeq ($(UCLIBC_HAS_XLOCALE),y)
-CSRC += $(patsubst %.c,%_l.c,$(COM_SRC))
-endif
+CSRC-y :=
+CSRC-$(UCLIBC_HAS_WCHAR) += $(COM_SRC)
+CSRC-$(UCLIBC_HAS_XLOCALE) += $(patsubst %.c,%_l.c,$(COM_SRC))
MISC_WCTYPE_DIR := $(top_srcdir)libc/misc/wctype
MISC_WCTYPE_OUT := $(top_builddir)libc/misc/wctype
-MISC_WCTYPE_SRC := $(patsubst %.c,$(MISC_WCTYPE_DIR)/%.c,$(CSRC))
-MISC_WCTYPE_OBJ := $(patsubst %.c,$(MISC_WCTYPE_OUT)/%.o,$(CSRC))
+MISC_WCTYPE_SRC := $(patsubst %.c,$(MISC_WCTYPE_DIR)/%.c,$(CSRC-y))
+MISC_WCTYPE_OBJ := $(patsubst %.c,$(MISC_WCTYPE_OUT)/%.o,$(CSRC-y))
libc-y += $(MISC_WCTYPE_OBJ)
diff --git a/libc/misc/wordexp/Makefile.in b/libc/misc/wordexp/Makefile.in
index 981db643e..3d642488b 100644
--- a/libc/misc/wordexp/Makefile.in
+++ b/libc/misc/wordexp/Makefile.in
@@ -7,13 +7,13 @@
subdirs += libc/misc/wordexp
-CSRC := wordexp.c
+CSRC-y := wordexp.c
MISC_WORDEXP_DIR := $(top_srcdir)libc/misc/wordexp
MISC_WORDEXP_OUT := $(top_builddir)libc/misc/wordexp
-MISC_WORDEXP_SRC := $(patsubst %.c,$(MISC_WORDEXP_DIR)/%.c,$(CSRC))
-MISC_WORDEXP_OBJ := $(patsubst %.c,$(MISC_WORDEXP_OUT)/%.o,$(CSRC))
+MISC_WORDEXP_SRC := $(patsubst %.c,$(MISC_WORDEXP_DIR)/%.c,$(CSRC-y))
+MISC_WORDEXP_OBJ := $(patsubst %.c,$(MISC_WORDEXP_OUT)/%.o,$(CSRC-y))
libc-$(UCLIBC_HAS_WORDEXP) += $(MISC_WORDEXP_OBJ)
diff --git a/libc/pwd_grp/Makefile.in b/libc/pwd_grp/Makefile.in
index 757adc85c..4a2e77385 100644
--- a/libc/pwd_grp/Makefile.in
+++ b/libc/pwd_grp/Makefile.in
@@ -10,20 +10,17 @@ subdirs += libc/pwd_grp
PWDGRP_DIR := $(top_srcdir)libc/pwd_grp
PWDGRP_OUT := $(top_builddir)libc/pwd_grp
-CSRC := $(notdir $(wildcard $(PWDGRP_DIR)/*.c))
-CSRC := $(filter-out pwd_grp.c pwd_grp_internal.c,$(CSRC))
-
-ifneq ($(UCLIBC_HAS_SHADOW),y)
-SHADOW_CSRC := \
- fgetspent_r.c fgetspent.c getspent_r.c getspent.c \
+CSRC-y := $(notdir $(wildcard $(PWDGRP_DIR)/*.c))
+CSRC- := pwd_grp.c pwd_grp_internal.c # multi-source and helper
+CSRC-$(UCLIBC_HAS_SHADOW) += fgetspent_r.c fgetspent.c getspent_r.c getspent.c \
getspnam_r.c getspnam.c lckpwdf.c putspent.c \
sgetspent_r.c sgetspent.c __parsespent.c
# getspuid_r.c getspuid.c
-CSRC := $(filter-out $(SHADOW_CSRC),$(CSRC))
-endif
-PWDGRP_SRC := $(patsubst %.c,$(PWDGRP_DIR)/%.c,$(CSRC))
-PWDGRP_OBJ := $(patsubst %.c,$(PWDGRP_OUT)/%.o,$(CSRC))
+CSRC-y := $(filter-out $(CSRC-),$(CSRC-y))
+
+PWDGRP_SRC := $(patsubst %.c,$(PWDGRP_DIR)/%.c,$(CSRC-y))
+PWDGRP_OBJ := $(patsubst %.c,$(PWDGRP_OUT)/%.o,$(CSRC-y))
libc-y += $(PWDGRP_OBJ)
diff --git a/libc/stdio/Makefile.in b/libc/stdio/Makefile.in
index ff77bcb6a..7d697bf82 100644
--- a/libc/stdio/Makefile.in
+++ b/libc/stdio/Makefile.in
@@ -11,7 +11,7 @@
subdirs += libc/stdio
# SUSv3 functions
-CSRC := \
+CSRC-y := \
fclose.c fcloseall.c fdopen.c fgetpos.c fopen.c freopen.c \
fseeko.c fsetpos.c ftello.c getdelim.c getline.c gets.c getw.c \
perror.c puts.c putw.c remove.c rewind.c setbuf.c setbuffer.c \
@@ -19,92 +19,80 @@ CSRC := \
printf.c vprintf.c vsprintf.c fprintf.c snprintf.c dprintf.c \
asprintf.c sprintf.c vasprintf.c vdprintf.c vsnprintf.c \
tmpfile.c popen.c ctermid.c
+CSRC-$(UCLIBC_HAS_LFS) += fgetpos64.c fopen64.c freopen64.c \
+ fseeko64.c fsetpos64.c ftello64.c
+CSRC-$(UCLIBC_SUSV4_LEGACY) += tmpnam.c tmpnam_r.c tempnam.c
-ifeq ($(UCLIBC_HAS_LFS),y)
-CSRC += fgetpos64.c fopen64.c freopen64.c fseeko64.c fsetpos64.c ftello64.c
-endif
-ifeq ($(UCLIBC_SUSV4_LEGACY),y)
-CSRC += tmpnam.c tmpnam_r.c tempnam.c
-endif
-
-# getc -> alias for fgetc
-# putc -> alias for fputc
-# rename is a syscall
-
-# Implementation support functions
-CSRC += \
+# internal support functions
+CSRC-y += \
_READ.c _WRITE.c _adjust_pos.c _fopen.c _fwrite.c \
_rfill.c _stdio.c _trans2r.c _trans2w.c _wcommit.c \
_cs_funcs.c _load_inttype.c _store_inttype.c _uintmaxtostr.c
-ifeq ($(UCLIBC_HAS_FLOATS),y)
-CSRC += _fpmaxtostr.c
-endif
+CSRC-$(UCLIBC_HAS_FLOATS) += _fpmaxtostr.c
# stdio_ext.h functions
-CSRC += \
+CSRC-y += \
__fbufsize.c __flbf.c __fpending.c __fpurge.c __freadable.c \
__freading.c __fsetlocking.c __fwritable.c __fwriting.c _flushlbf.c
# Other glibc extensions
-ifeq ($(UCLIBC_HAS_GLIBC_CUSTOM_STREAMS),y)
-CSRC += fopencookie.c fmemopen.c open_memstream.c
-endif
+CSRC-$(UCLIBC_HAS_GLIBC_CUSTOM_STREAMS) += fopencookie.c fmemopen.c \
+ open_memstream.c
# pthread functions
-CSRC += flockfile.c ftrylockfile.c funlockfile.c
+CSRC-y += flockfile.c ftrylockfile.c funlockfile.c
# Functions with unlocked versions
-CUSRC := \
+CUSRC-y := \
clearerr.c feof.c ferror.c fflush.c fgetc.c fgets.c fileno.c \
fputc.c fputs.c fread.c fwrite.c getchar.c putchar.c
# getc_unlocked -> alias for fgetc_unlocked
# putc_unlocked -> alias for fputc_unlocked
# vfprintf and support functions
-ifneq ($(USE_OLD_VFPRINTF),y)
+ifeq ($(USE_OLD_VFPRINTF),y)
+VF_CSRC := old_vfprintf.c
+else
+# multi source _vfprintf.c
VF_CSRC := \
vfprintf.c \
_vfprintf_internal.c \
_ppfs_init.c _ppfs_prepargs.c _ppfs_setargs.c _ppfs_parsespec.c \
register_printf_function.c parse_printf_format.c
-CSRC += $(VF_CSRC)
-else
-CSRC += old_vfprintf.c
endif
+CSRC-y += $(VF_CSRC)
# vfscanf and support functions plus other *scanf funcs
-CSRC += \
+CSRC-y += \
vfscanf.c __scan_cookie.c __psfs_parse_spec.c __psfs_do_numeric.c \
scanf.c sscanf.c fscanf.c vscanf.c vsscanf.c
-ifeq ($(UCLIBC_HAS_WCHAR),y)
-CSRC += _wfwrite.c fwprintf.c swprintf.c vswprintf.c vwprintf.c wprintf.c \
+CSRC-$(UCLIBC_HAS_WCHAR) += \
+ _wfwrite.c fwprintf.c swprintf.c vswprintf.c vwprintf.c wprintf.c \
fwide.c ungetwc.c
-CUSRC += fgetwc.c getwchar.c fgetws.c fputwc.c putwchar.c fputws.c
+CUSRC-$(UCLIBC_HAS_WCHAR) += \
+ fgetwc.c getwchar.c fgetws.c fputwc.c putwchar.c fputws.c
# getwc (fgetwc alias) getwc_unlocked (fgetwc_unlocked alias)
# putwc (fputwc alias) putwc_unlocked (fputwc_unlocked alias)
-CSRC += vfwprintf.c _vfwprintf_internal.c
-CSRC += wscanf.c swscanf.c fwscanf.c vwscanf.c vswscanf.c vfwscanf.c
-endif
-
-CUSRC_UNLOCKED := $(patsubst %.c,%_unlocked.c,$(CUSRC))
+CSRC-$(UCLIBC_HAS_WCHAR) += vfwprintf.c _vfwprintf_internal.c \
+ wscanf.c swscanf.c fwscanf.c vwscanf.c vswscanf.c vfwscanf.c
-CSRC += $(CUSRC) $(CUSRC_UNLOCKED)
+CUSRC_UNLOCKED := $(patsubst %.c,%_unlocked.c,$(CUSRC-y))
+CSRC-y += $(CUSRC-y) $(CUSRC_UNLOCKED)
STDIO_DIR := $(top_srcdir)libc/stdio
STDIO_OUT := $(top_builddir)libc/stdio
-STDIO_SRC := $(patsubst %.c,$(STDIO_DIR)/%.c,$(CSRC))
-STDIO_OBJ := $(patsubst %.c,$(STDIO_OUT)/%.o,$(CSRC))
+STDIO_SRC := $(patsubst %.c,$(STDIO_DIR)/%.c,$(CSRC-y))
+STDIO_OBJ := $(patsubst %.c,$(STDIO_OUT)/%.o,$(CSRC-y))
libc-y += $(STDIO_OBJ)
ifneq ($(USE_OLD_VFPRINTF),y)
libc-nomulti-y += $(patsubst %.c,$(STDIO_OUT)/%.o,$(VF_CSRC))
endif
-ifeq ($(UCLIBC_HAS_WCHAR),y)
-libc-nomulti-y += $(STDIO_OUT)/vfwprintf.o $(STDIO_OUT)/vfwscanf.o
-endif
+libc-nomulti-$(UCLIBC_HAS_WCHAR) += $(STDIO_OUT)/vfwprintf.o \
+ $(STDIO_OUT)/vfwscanf.o
objclean-y += CLEAN_libc/stdio
diff --git a/libc/stdlib/malloc-simple/Makefile.in b/libc/stdlib/malloc-simple/Makefile.in
index 351504bda..05a2ebeee 100644
--- a/libc/stdlib/malloc-simple/Makefile.in
+++ b/libc/stdlib/malloc-simple/Makefile.in
@@ -10,11 +10,11 @@ subdirs += libc/stdlib/malloc-simple
STDLIB_MALLOC_SIMPLE_DIR := $(top_srcdir)libc/stdlib/malloc-simple
STDLIB_MALLOC_SIMPLE_OUT := $(top_builddir)libc/stdlib/malloc-simple
-CSRC := $(notdir $(wildcard $(STDLIB_MALLOC_SIMPLE_DIR)/*.c))
-CSRC := $(filter-out alloc.c,$(CSRC))
+CSRC-y := $(notdir $(wildcard $(STDLIB_MALLOC_SIMPLE_DIR)/*.c))
+CSRC-y := $(filter-out alloc.c,$(CSRC-y))
-STDLIB_MALLOC_SIMPLE_SRC := $(patsubst %.c,$(STDLIB_MALLOC_SIMPLE_DIR)/%.c,$(CSRC))
-STDLIB_MALLOC_SIMPLE_OBJ := $(patsubst %.c,$(STDLIB_MALLOC_SIMPLE_OUT)/%.o,$(CSRC))
+STDLIB_MALLOC_SIMPLE_SRC := $(patsubst %.c,$(STDLIB_MALLOC_SIMPLE_DIR)/%.c,$(CSRC-y))
+STDLIB_MALLOC_SIMPLE_OBJ := $(patsubst %.c,$(STDLIB_MALLOC_SIMPLE_OUT)/%.o,$(CSRC-y))
libc-$(MALLOC_SIMPLE) += $(STDLIB_MALLOC_SIMPLE_OBJ)
diff --git a/libc/stdlib/malloc-standard/Makefile.in b/libc/stdlib/malloc-standard/Makefile.in
index 7da7fe1df..04a46b681 100644
--- a/libc/stdlib/malloc-standard/Makefile.in
+++ b/libc/stdlib/malloc-standard/Makefile.in
@@ -7,15 +7,13 @@
subdirs += libc/stdlib/malloc-standard
-# calloc.c can be found at uClibc/libc/stdlib/calloc.c
-# valloc.c can be found at uClibc/libc/stdlib/valloc.c
-CSRC := malloc.c calloc.c realloc.c free.c memalign.c mallopt.c mallinfo.c
-
STDLIB_MALLOC_STANDARD_DIR := $(top_srcdir)libc/stdlib/malloc-standard
STDLIB_MALLOC_STANDARD_OUT := $(top_builddir)libc/stdlib/malloc-standard
-STDLIB_MALLOC_STANDARD_SRC := $(patsubst %.c,$(STDLIB_MALLOC_STANDARD_DIR)/%.c,$(CSRC))
-STDLIB_MALLOC_STANDARD_OBJ := $(patsubst %.c,$(STDLIB_MALLOC_STANDARD_OUT)/%.o,$(CSRC))
+CSRC-y := $(notdir $(wildcard $(STDLIB_MALLOC_STANDARD_DIR)/*.c))
+
+STDLIB_MALLOC_STANDARD_SRC := $(patsubst %.c,$(STDLIB_MALLOC_STANDARD_DIR)/%.c,$(CSRC-y))
+STDLIB_MALLOC_STANDARD_OBJ := $(patsubst %.c,$(STDLIB_MALLOC_STANDARD_OUT)/%.o,$(CSRC-y))
libc-$(MALLOC_STANDARD) += $(STDLIB_MALLOC_STANDARD_OBJ)
diff --git a/libc/stdlib/malloc/Makefile.in b/libc/stdlib/malloc/Makefile.in
index 642570c95..9efd34e8b 100644
--- a/libc/stdlib/malloc/Makefile.in
+++ b/libc/stdlib/malloc/Makefile.in
@@ -9,12 +9,12 @@
subdirs += libc/stdlib/malloc
-CSRC := malloc.c calloc.c free.c realloc.c memalign.c \
+CSRC-y := malloc.c calloc.c free.c realloc.c memalign.c \
heap_alloc.c heap_alloc_at.c heap_free.c
# Turn on malloc debugging if requested
+CSRC-$(UCLIBC_MALLOC_DEBUGGING) += malloc_debug.c heap_debug.c
ifeq ($(UCLIBC_MALLOC_DEBUGGING),y)
-CSRC += malloc_debug.c heap_debug.c
CFLAGS += -DMALLOC_DEBUGGING -DHEAP_DEBUGGING
ifeq ($(UCLIBC_UCLINUX_BROKEN_MUNMAP),y)
CFLAGS += -DMALLOC_MMB_DEBUGGING
@@ -24,8 +24,8 @@ endif
STDLIB_MALLOC_DIR := $(top_srcdir)libc/stdlib/malloc
STDLIB_MALLOC_OUT := $(top_builddir)libc/stdlib/malloc
-STDLIB_MALLOC_SRC := $(patsubst %.c,$(STDLIB_MALLOC_DIR)/%.c,$(CSRC))
-STDLIB_MALLOC_OBJ := $(patsubst %.c,$(STDLIB_MALLOC_OUT)/%.o,$(CSRC))
+STDLIB_MALLOC_SRC := $(patsubst %.c,$(STDLIB_MALLOC_DIR)/%.c,$(CSRC-y))
+STDLIB_MALLOC_OBJ := $(patsubst %.c,$(STDLIB_MALLOC_OUT)/%.o,$(CSRC-y))
libc-$(MALLOC) += $(STDLIB_MALLOC_OBJ)
diff --git a/libc/unistd/Makefile.in b/libc/unistd/Makefile.in
index 98edc6a25..5eedf1732 100644
--- a/libc/unistd/Makefile.in
+++ b/libc/unistd/Makefile.in
@@ -10,39 +10,23 @@ subdirs += libc/unistd
UNISTD_DIR := $(top_srcdir)libc/unistd
UNISTD_OUT := $(top_builddir)libc/unistd
-CSRC := $(notdir $(wildcard $(UNISTD_DIR)/*.c))
-# multi source
-CSRC := $(filter-out exec.c,$(CSRC))
-
-ifeq ($(ARCH_USE_MMU),y)
-CSRC := $(filter-out __exec_alloc.c,$(CSRC))
-endif
-
-ifeq ($(UCLIBC_HAS_GNU_GETOPT),y)
-CSRC := $(filter-out getopt-susv3.c getopt_long-simple.c,$(CSRC))
-else
-CSRC := $(filter-out getopt.c,$(CSRC))
-ifneq ($(UCLIBC_HAS_GETOPT_LONG),y)
-CSRC := $(filter-out getopt_long-simple.c,$(CSRC))
-endif
-endif
-
-ifeq ($(UCLIBC_HAS_GNU_GETSUBOPT),y)
-CSRC := $(filter-out getsubopt-susv3.c,$(CSRC))
-else
-CSRC := $(filter-out getsubopt.c,$(CSRC))
-endif
-
-ifneq ($(UCLIBC_SUSV3_LEGACY),y)
-CSRC := $(filter-out ualarm.c usleep.c,$(CSRC))
-endif
-
-#ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y)
-#CSRC := $(filter-out sleep.c,$(CSRC))
-#endif
-
-UNISTD_SRC := $(patsubst %.c,$(UNISTD_DIR)/%.c,$(CSRC))
-UNISTD_OBJ := $(patsubst %.c,$(UNISTD_OUT)/%.o,$(CSRC))
+CSRC-y := $(notdir $(wildcard $(UNISTD_DIR)/*.c))
+OMIT-y := exec.c # multi source
+OMIT-$(ARCH_USE_MMU) += __exec_alloc.c
+OMIT-$(if $(UCLIBC_SUSV3_LEGACY),,y) += ualarm.c usleep.c
+#OMIT-$(UCLIBC_HAS_THREADS_NATIVE) += sleep.c
+
+# the VARIANT we OMIT
+# GNU_GETOPT comes with getopt_long unconditionally (?), OMIT the other
+VARIANT := $(if $(UCLIBC_HAS_GNU_GETOPT),-susv3)
+GO_LONG := $(if $(UCLIBC_HAS_GNU_GETOPT),getopt_long-simple.c)
+OMIT-$(UCLIBC_HAS_GNU_GETOPT) += getopt$(VARIANT).c $(GO_LONG)
+OMIT-$(UCLIBC_HAS_GNU_GETSUBOPT) += getsubopt$(VARIANT).c
+
+CSRC-y := $(filter-out $(OMIT-y),$(CSRC-y))
+
+UNISTD_SRC := $(patsubst %.c,$(UNISTD_DIR)/%.c,$(CSRC-y))
+UNISTD_OBJ := $(patsubst %.c,$(UNISTD_OUT)/%.o,$(CSRC-y))
libc-y += $(UNISTD_OBJ)