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

COMMON_DIR:=$(top_srcdir)libc/sysdeps/linux/common
COMMON_OUT:=$(top_builddir)libc/sysdeps/linux/common

CSRC:=$(patsubst $(COMMON_DIR)/%.c,%.c,$(wildcard $(COMMON_DIR)/*.c))

ifeq ($(EXCLUDE_BRK),y)
CSRC:=$(filter-out sbrk.c,$(CSRC))
endif

COMMON_SSP:=ssp.c ssp-local.c

# full list
#COMMON_NO_MULTI:=getcwd.c getrlimit.c getrlimit64.c setrlimit.c setrlimit64.c getpriority.c getpriority64.c setpriority.c getrusage.c wait4.c getitimer.c setitimer.c open.c open64.c uname.c __syscall_fcntl.c __syscall_fcntl64.c
COMMON_NO_MULTI:=getrlimit.c getrlimit64.c setrlimit.c setrlimit64.c getpriority.c setpriority.c getrusage.c getitimer.c setitimer.c uname.c __syscall_rt_sigaction.c

ifneq ($(UCLIBC_HAS_SSP),y)
CSRC:=$(filter-out $(COMMON_SSP),$(CSRC))
endif

ifneq ($(DOMULTI),n)
CSRC:=$(filter-out $(COMMON_NO_MULTI),$(CSRC))
CSRC:=$(filter-out $(COMMON_SSP),$(CSRC))
endif

# fails for some reason
ifneq ($(strip $(ARCH_OBJS)),)
CSRC:=$(filter-out $(notdir $(ARCH_OBJS:.o=.c)),$(CSRC))
endif

CFLAGS-ssp.c=$(SSP_DISABLE_FLAGS)
CFLAGS-ssp-local.c=$(SSP_DISABLE_FLAGS)

COMMON_SRC:=$(patsubst %.c,$(COMMON_DIR)/%.c,$(CSRC))
COMMON_OBJ:=$(patsubst %.c,$(COMMON_OUT)/%.o,$(CSRC))

libc-a-y+=$(COMMON_OBJ)
libc-so-y+=$(COMMON_OBJ:.o=.os)
libc-nonshared-$(UCLIBC_HAS_SSP)+=$(COMMON_OUT)/ssp-local.os

libc-multi-y+=$(COMMON_SRC)
libc-nomulti-y+=$(patsubst %.c,$(COMMON_OUT)/%.o,$(COMMON_NO_MULTI))
libc-nomulti-$(UCLIBC_HAS_SSP)+=$(patsubst %.c,$(COMMON_OUT)/%.o,$(COMMON_SSP))

objclean-y+=common_objclean

common_objclean:
	$(RM) $(COMMON_OUT)/*.{o,os}