# Makefile for uClibc
#
# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#

# Make a list of *.o from $(ARCH)/*.[Sc] and generic/*.[Sc],
# filter out generic ones which have arch-specific implementation
g := $(notdir $(wildcard $(obj)/generic/*.c $(obj)/generic/*.S))
g := $(patsubst %.c,%.o,$(g))
g := $(patsubst %.S,%.o,$(g))
a := $(notdir $(wildcard $(obj)/$(ARCH)/*.c $(obj)/$(ARCH)/*.S))
a := $(patsubst %.c,%.o,$(a))
a := $(patsubst %.S,%.o,$(a))
# Remove those words in G which exist in A
g := $(filter-out $(a),$(g))


# Make a list of .c for this directory (no subdirs).
# Exclude stuff which is not configured in.
excluded := _collate.c
ifneq ($(UCLIBC_HAS_WCHAR),y)
excluded += $(notdir $(wildcard $(obj)/w*.c))
excluded += $(notdir $(wildcard $(obj)/w*_l.c))
endif
ifneq ($(UCLIBC_HAS_XLOCALE),y)
excluded += $(notdir $(wildcard $(obj)/*_l.c))
endif
ifneq ($(UCLIBC_HAS_LOCALE),y)
excluded += $(notdir $(wildcard $(obj)/wcsxfrm_l.c))
excluded += $(notdir $(wildcard $(obj)/strxfrm_l.c))
excluded += $(notdir $(wildcard $(obj)/wcsxfrm.c))
excluded += $(notdir $(wildcard $(obj)/strxfrm.c))
endif

t := $(notdir $(wildcard $(obj)/*.c))
t := $(filter-out $(excluded),$(t))

t := $(patsubst %.c,%.o,$(t))
t := $(patsubst %.S,%.o,$(t))


# Combine this directory's list with generic/arch subdirs
ifeq ($(UCLIBC_HAS_STRING_ARCH_OPT),y)
ifneq ($(strip $(a)),)
t := $(filter-out $(a),$(t))
endif
endif

ifeq ($(UCLIBC_HAS_STRING_GENERIC_OPT),y)
ifneq ($(strip $(g)),)
t := $(filter-out $(g),$(t))
endif
endif

klib-y := $(sort $(t) $(addprefix generic/,$(g)) $(addprefix $(ARCH)/,$(a)))
