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
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))
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 \
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
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)
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)
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)
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)
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
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)
#
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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 \
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
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)
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)
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
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)
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)