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

subdirs += libutil

CFLAGS-libutil := -DNOT_IN_libc -DIS_IN_libutil $(SSP_ALL_CFLAGS)

libutil_DIR := $(top_srcdir)libutil
libutil_OUT := $(top_builddir)libutil

libutil_SRC := $(wildcard $(libutil_DIR)/*.c)
ifneq ($(ARCH_USE_MMU),y)
libutil_SRC := $(filter-out $(libutil_DIR)/forkpty.c,$(libutil_SRC))
endif
ifneq ($(UCLIBC_HAS_PTY),y)
libutil_SRC := $(filter-out $(libutil_DIR)/openpty.c $(libutil_DIR)/forkpty.c \
		,$(libutil_SRC))
endif
ifeq ($(UCLIBC_HAS_UTMP)$(UCLIBC_HAS_UTMPX),)
libutil_SRC := $(filter-out \
	$(libutil_DIR)/logwtmp.c \
	$(libutil_DIR)/login.c \
	$(libutil_DIR)/logout.c \
		,$(libutil_SRC))
endif

libutil_OBJ := $(patsubst $(libutil_DIR)/%.c,$(libutil_OUT)/%.o,$(libutil_SRC))

ifeq ($(DOPIC),y)
libutil-a-y := $(libutil_OBJ:.o=.os)
else
libutil-a-y := $(libutil_OBJ)
endif
libutil-so-y := $(libutil_OBJ:.o=.os)

objclean-y += CLEAN_libutil

$(libutil_OUT)/libutil.oS: $(libutil_SRC)
	$(Q)$(RM) $@
	$(compile-m)

CLEAN_libutil:
	$(do_rm) $(addprefix $(libutil_OUT)/*., o os oS a)
