TOPDIR=./
-include ./.config
-include $(CONFIG_CONFIG)

ifeq ($(subst s,,$(MAKEFLAGS)),$(MAKEFLAGS))
export MAKE_IS_SILENT=n
SECHO=@echo
SHELL_SET_X=set -x
else
export MAKE_IS_SILENT=y
SECHO=-@false
SHELL_SET_X=set +x
endif

ifeq ("$(CONFIG_MODEL)", "AP903")
CONFIG_LIB_NL_FORCE=y
endif

ifeq ("$(CONFIG_USER_GDB_DEBUG)", "y")
CONFIG_LIB_READLINE_FORCE=y
CONFIG_LIB_NCURSE_FORCE=y
endif

ifeq ("$(CONFIG_USER_SSH_SERVER)", "y")
CONFIG_LIB_UTIL_FORCE=y
endif

CONFIG_GLIBC_2_20=n

RUNTIME_PREFIX:=$(strip $(subst //,/, $(subst ,/, $(subst ",, $(strip $(RUNTIME_PREFIX))))))

DIRS=

ifeq ($(CONFIG_LIB_LIBGMP_FORCE),y)
    DIRS += libgmp
endif
ifeq ($(CONFIG_LIB_ZLIB_FORCE),y)
ifeq ($(CONFIG_GLIBC_2_20),y) 
    DIRS += zlib-1.2.8
else
    DIRS += zlib-1.2.3
endif
endif
ifeq ($(CONFIG_LIB_LIBNVRAM_FORCE),y)
    DIRS += libnvram
endif
ifeq ($(CONFIG_LIB_LIBNTFS3G_FORCE),y)
    DIRS += libntfs-3g
endif
ifeq ($(CONFIG_LIB_LIBBT_FORCE),y)
    DIRS += libbluetooth
endif
ifeq ($(CONFIG_LIB_READLINE_FORCE),y)
    DIRS += libreadline
endif
ifeq ($(CONFIG_LIB_NL_FORCE),y)
    DIRS += libnl
endif
ifeq ($(CONFIG_LIB_LIBSQLITE3_FORCE),y)
    DIRS += libsqlite3
endif
ifeq ($(CONFIG_LIB_LIBEXIF_FORCE),y)
    DIRS += libexif
endif
ifeq ($(CONFIG_LIB_LIBOGG_FORCE),y)
    DIRS += libogg
endif
ifeq ($(CONFIG_LIB_LIBVORBIS_FORCE),y)
    DIRS += libvorbis
endif
ifeq ($(CONFIG_LIB_LIBFLAC_FORCE),y)
    DIRS += libflac
endif
ifeq ($(CONFIG_LIB_LIBJPEG_FORCE),y)
    DIRS += libjpeg
endif
ifeq ($(CONFIG_LIB_LIBJPEG_TURBO_FORCE),y)
    DIRS += libjpeg-turbo-1.4.0
endif
ifeq ($(CONFIG_LIB_LIBPCAP_FORCE),y)
    DIRS += libpcap-1.0.0
endif
ifeq ($(CONFIG_LIB_LIBEVENT_FORCE),y)
     DIRS += libevent-2.0.2-alpha
endif
ifeq ($(CONFIG_LIB_NCURSE_FORCE),y)
    DIRS += libncurses-5.7
endif
ifeq ($(CONFIG_LIB_FLEX_FORCE),y)
    DIRS += libflex
endif
ifeq ($(CONFIG_LIB_LIBUPNP_FORCE),y)
    DIRS += libupnp
endif
ifeq ($(CONFIG_LIB_LIBUPNP166_DMS_FORCE),y)
    DIRS += libupnp-1.6.6-dms
endif
ifeq ($(CONFIG_LIB_LIBFFMPEG_FORCE),y)
    DIRS += libffmpeg-0.5
endif
ifeq ($(CONFIG_LIB_LIBDLNA_FORCE),y)
    DIRS += libdlna-0.2.3
endif
ifeq ($(CONFIG_LIB_LIBGDBM_FORCE),y)
    DIRS += libgdbm-1.8.3
endif
ifeq ($(CONFIG_LIB_LIBID3TAG_FORCE),y)
    DIRS += libid3tag-0.15.1b
endif
ifeq ($(CONFIG_LIB_LIBZEBRA_FORCE),y)
    DIRS += libzebra
endif
ifeq ($(CONFIG_LIB_USB0112_FORCE),y)
    DIRS += libusb-0.1.12
endif
ifeq ($(CONFIG_GLIBC_2_20),y) 
ifeq ($(CONFIG_LIB_USB100_FORCE),y)
    DIRS += libusb-1.0.9
endif
else
ifeq ($(CONFIG_LIB_USB100_FORCE),y)
    DIRS += libusb-1.0.0
endif
endif
ifeq ($(CONFIG_LIB_PCRE_FORCE),y)
    DIRS += pcre-8.01
endif
ifeq ($(CONFIG_LIB_VSTR_FORCE),y)
    DIRS += vstr-1.0.15
endif
ifeq ($(CONFIG_LIB_CYASSL_FORCE),y)
    DIRS += cyassl-3.3.0
endif

# mtd-utils-1.5.0

ifeq ($(CONFIG_LIB_LZO_FORCE),y)
    DIRS += lzo-2.03
endif
ifeq ($(CONFIG_LIB_UUID_FORCE),y)
    DIRS += libuuid-1.0.3
endif
# end

INSTALL    = install
LN         = ln
RM         = rm -f

ifndef CONFIG_OPENWRT
ifeq ($(CONFIG_GLIBC_2_20),y) 
all: shared_glibc 
else
all: headers pregen subdirs shared finished
endif
else
all:
endif

# In this section, we need .config
-include .config.cmd

ifeq ($(CONFIG_GLIBC_2_20),y) 
shared_glibc:
else
shared: subdirs
endif
ifeq ($(strip $(HAVE_SHARED)),y)
	$(SECHO)
	$(SECHO) Building shared libraries ...
	$(SECHO)
ifeq ($(CONFIG_LIB_LIBNVRAM_FORCE),y)
	@$(MAKE) -C libnvram shared
endif
ifeq ($(CONFIG_LIB_LIBNTFS3G_FORCE),y)
	@$(MAKE) -C libntfs-3g shared
endif
ifeq ($(CONFIG_LIB_LIBBT_FORCE),y)
	@$(MAKE) -C libbluetooth shared
endif
ifeq ($(CONFIG_LIB_READLINE_FORCE),y)
	@$(MAKE) -C libreadline shared
endif
ifeq ($(CONFIG_LIB_NL_FORCE),y)
	touch libnl/configure
	touch libnl/configure.ac
	@$(MAKE) -C libnl shared
endif
ifeq ($(CONFIG_LIB_LIBSQLITE3_FORCE),y)
	@$(MAKE) -C libsqlite3 shared
endif
ifeq ($(CONFIG_LIB_LIBEXIF_FORCE),y)
	@$(MAKE) -C libexif shared
endif
ifeq ($(CONFIG_LIB_LIBOGG_FORCE),y)
	@$(MAKE) -C libogg shared
endif
ifeq ($(CONFIG_LIB_LIBVORBIS_FORCE),y)
	@$(MAKE) -C libvorbis shared
endif
ifeq ($(CONFIG_LIB_LIBFLAC_FORCE),y)
	@$(MAKE) -C libflac shared
endif
ifeq ($(CONFIG_LIB_LIBJPEG_FORCE),y)
	@$(MAKE) -C libjpeg shared
endif
ifeq ($(CONFIG_LIB_LIBPCAP_FORCE),y)
	@$(MAKE) -C libpcap-1.0.0 shared
endif
ifeq ($(CONFIG_LIB_LIBJPEG_TURBO_FORCE),y)
	@$(MAKE) -C libjpeg-turbo-1.4.0 shared
endif
ifeq ($(CONFIG_LIB_LIBEVENT_FORCE),y)
	@$(MAKE) -C libevent-2.0.2-alpha shared
endif
ifeq ($(CONFIG_LIB_NCURSE_FORCE),y)
	@$(MAKE) -C libncurses-5.7 shared
endif
ifeq ($(CONFIG_LIB_FLEX_FORCE),y)
	@$(MAKE) -C libflex shared
endif
ifeq ($(CONFIG_LIB_LIBUPNP_FORCE),y)
	@$(MAKE) -C libupnp shared
endif
ifeq ($(CONFIG_LIB_LIBUPNP166_DMS_FORCE),y)
	@$(MAKE) -C libupnp-1.6.6-dms
endif
ifeq ($(CONFIG_LIB_LIBFFMPEG_FORCE),y)
	@$(MAKE) -C libffmpeg-0.5
endif
ifeq ($(CONFIG_LIB_LIBDLNA_FORCE),y)
	@$(MAKE) -C libdlna-0.2.3
endif
ifeq ($(CONFIG_LIB_LIBGDBM_FORCE),y)
	@$(MAKE) -C libgdbm-1.8.3 shared
endif
ifeq ($(CONFIG_LIB_LIBID3TAG_FORCE),y)
	@$(MAKE) -C libid3tag-0.15.1b shared
endif
ifeq ($(CONFIG_LIB_LIBGMP_FORCE),y)
	@$(MAKE) -C libgmp shared
endif
ifeq ($(CONFIG_LIB_ZLIB_FORCE),y)
ifeq ($(CONFIG_GLIBC_2_20),y) 
	@$(MAKE) -C zlib-1.2.8 shared
else
	@$(MAKE) -C zlib-1.2.3 shared
endif
endif
ifeq ($(CONFIG_LIB_UTIL_FORCE),y)
	@$(MAKE) -C libutil
endif
ifeq ($(CONFIG_LIB_LIBZEBRA_FORCE),y)
	@$(MAKE) -C libzebra shared
endif
ifeq ($(CONFIG_LIB_USB0112_FORCE),y)
	@$(MAKE) -C libusb-0.1.12 shared
endif
ifeq ($(CONFIG_GLIBC_2_20),y) 
ifeq ($(CONFIG_LIB_USB100_FORCE),y)
	@$(MAKE) -C libusb-1.0.9 shared
endif
else
ifeq ($(CONFIG_LIB_USB100_FORCE),y)
	@$(MAKE) -C libusb-1.0.0 shared
endif
endif
ifeq ($(CONFIG_LIB_PCRE_FORCE),y)
	@$(MAKE) -C pcre-8.01 shared
endif
ifeq ($(CONFIG_LIB_CYASSL_FORCE),y)
	@$(MAKE) -C cyassl-3.3.0 shared
endif
ifeq ($(CONFIG_LIB_VSTR_FORCE),y)
	@$(MAKE) -C vstr-1.0.15 shared
endif
ifeq ($(CONFIG_LIB_LZO_FORCE),y)
	@$(MAKE) -C lzo-2.03
endif
ifeq ($(CONFIG_LIB_UUID_FORCE),y)
	@$(MAKE) -C libuuid-1.0.3
endif
else
	$(SECHO)
	$(SECHO) Not building shared libraries ...
	$(SECHO)
endif

finished: shared
	$(SECHO)
	$(SECHO) Finally finished compiling ...
	$(SECHO)

include/bits/uClibc_config.h: .config
	@if [ ! -x ./extra/config/conf ] ; then \
	    $(MAKE) -C extra/config conf; \
	fi;
	$(RM) -r include/bits
	$(INSTALL) -d include/bits
	@./extra/config/conf -o extra/Configs/Config.in

ifeq ($(strip $(ARCH_HAS_MMU)),y)
export header_extra_args = 
else
export header_extra_args = -n
endif
headers: include/bits/uClibc_config.h
	@$(SHELL_SET_X); \
	./extra/scripts/fix_includes.sh \
		-k $(KERNEL_SOURCE) -t $(ARCH) \
		$(header_extra_args)
	@cd include/bits; \
	set -e; \
	for i in `ls ../../libc/sysdeps/linux/common/bits/*.h` ; do \
		$(LN) -fs $$i .; \
	done; \
	if [ -d ../../libc/sysdeps/linux/$(ARCH)/bits ] ; then \
		for i in `ls ../../libc/sysdeps/linux/$(ARCH)/bits/*.h` ; do \
			$(LN) -fs $$i .; \
		done; \
	fi
	@cd include/sys; \
	set -e; \
	for i in `ls ../../libc/sysdeps/linux/common/sys/*.h` ; do \
		$(LN) -fs $$i .; \
	done; \
	if [ -d ../../libc/sysdeps/linux/$(ARCH)/sys ] ; then \
		for i in `ls ../../libc/sysdeps/linux/$(ARCH)/sys/*.h` ; do \
			$(LN) -fs $$i .; \
		done; \
	fi
	@cd $(TOPDIR); \
	set -e; \
	$(SHELL_SET_X); \
	TOPDIR=. CC="$(CC)" /bin/sh extra/scripts/gen_bits_syscall_h.sh > include/bits/sysnum.h.new; \
	if cmp include/bits/sysnum.h include/bits/sysnum.h.new >/dev/null 2>&1; then \
		$(RM) include/bits/sysnum.h.new; \
	else \
		mv -f include/bits/sysnum.h.new include/bits/sysnum.h; \
	fi
	$(MAKE) -C libc/sysdeps/linux/common headers
	$(MAKE) -C libc/sysdeps/linux/$(ARCH) headers


pregen: headers

subdirs: $(patsubst %, _dir_%, $(DIRS))
$(patsubst %, _dir_%, $(DIRS)): headers
	$(MAKE) -C $(patsubst _dir_%, %, $@)

tags:
	ctags -R

install: install_runtime install_dev finished2

romfs: install_runtime

RUNTIME_PREFIX_LIB_FROM_DEVEL_PREFIX_LIB=$(shell extra/scripts/relative_path.sh $(DEVEL_PREFIX)lib $(RUNTIME_PREFIX)lib)

# Installs header files and development library links.
install_dev:
	$(INSTALL) -d $(PREFIX)$(DEVEL_PREFIX)lib
	$(INSTALL) -d $(PREFIX)$(DEVEL_PREFIX)include
	-$(INSTALL) -m 644 lib/*.[ao] $(PREFIX)$(DEVEL_PREFIX)lib/
	if [ "$(KERNEL_SOURCE)" == "$(DEVEL_PREFIX)" ] ; then \
		extra_exclude="--exclude include/linux --exclude include/asm'*'" ; \
	else \
		extra_exclude="" ; \
	fi ; \
	tar -chf - include --exclude .svn --exclude CVS $$extra_exclude \
		| tar -xf - -C $(PREFIX)$(DEVEL_PREFIX)
ifneq ($(strip $(UCLIBC_HAS_FLOATS)),y)
	# Remove floating point related headers since float support is disabled.
	$(RM) $(PREFIX)$(DEVEL_PREFIX)include/complex.h
	$(RM) $(PREFIX)$(DEVEL_PREFIX)include/fpu_control.h
	$(RM) $(PREFIX)$(DEVEL_PREFIX)include/ieee754.h
	$(RM) $(PREFIX)$(DEVEL_PREFIX)include/math.h
	$(RM) $(PREFIX)$(DEVEL_PREFIX)include/tgmath.h
endif
ifneq ($(strip $(UCLIBC_HAS_WCHAR)),y)
	# Remove wide char headers since wide char support is disabled.
	$(RM) $(PREFIX)$(DEVEL_PREFIX)include/wctype.h
	$(RM) $(PREFIX)$(DEVEL_PREFIX)include/wchar.h
endif
ifneq ($(strip $(UCLIBC_HAS_LOCALE)),y)
	# Remove iconv header since locale support is disabled.
	$(RM) $(PREFIX)$(DEVEL_PREFIX)include/iconv.h
endif
ifneq ($(strip $(UCLIBC_HAS_GLIBC_CUSTOM_PRINTF)),y)
	# Remove printf header since custom print specifier support is disabled.
	$(RM) $(PREFIX)$(DEVEL_PREFIX)include/printf.h
endif
ifneq ($(strip $(UCLIBC_HAS_XLOCALE)),y)
	# Remove xlocale header since extended locale support is disabled.
	$(RM) $(PREFIX)$(DEVEL_PREFIX)include/xlocale.h
endif
ifneq ($(strip $(UCLIBC_HAS_GETTEXT_AWARENESS)),y)
	# Remove libintl header since gettext support is disabled.
	$(RM) $(PREFIX)$(DEVEL_PREFIX)include/libintl.h
endif
ifneq ($(strip $(UCLIBC_HAS_REGEX)),y)
	# Remove regex headers since regex support is disabled.
	$(RM) $(PREFIX)$(DEVEL_PREFIX)include/regex.h
	$(RM) $(PREFIX)$(DEVEL_PREFIX)include/regexp.h
endif
ifneq ($(strip $(UCLIBC_HAS_WORDEXP)),y)
	# Remove wordexp header since wordexp support is disabled.
	$(RM) $(PREFIX)$(DEVEL_PREFIX)include/wordexp.h
endif
ifneq ($(strip $(UCLIBC_HAS_FTW)),y)
	# Remove ftw header since ftw support is disabled.
	$(RM) $(PREFIX)$(DEVEL_PREFIX)include/ftw.h
endif
ifneq ($(strip $(UCLIBC_HAS_GLOB)),y)
	# Remove glob header since glob support is disabled.
	$(RM) $(PREFIX)$(DEVEL_PREFIX)include/glob.h
endif
ifneq ($(strip $(UCLIBC_HAS_GNU_GETOPT)),y)
	# Remove getopt header since gnu getopt support is disabled.
	$(RM) $(PREFIX)$(DEVEL_PREFIX)include/getopt.h
endif
ifneq ($(strip $(HAS_SHADOW)),y)
	# Remove getopt header since shadow password support is disabled.
	$(RM) $(PREFIX)$(DEVEL_PREFIX)include/shadow.h
endif
	-@for i in `find  $(PREFIX)$(DEVEL_PREFIX) -type d` ; do \
	    chmod 755 $$i; chmod 644 $$i/*.h > /dev/null 2>&1; \
	done;
	-find $(PREFIX)$(DEVEL_PREFIX) -name .svn | xargs $(RM) -r;
	-chown -R `id | sed 's/^uid=\([0-9]*\).*gid=\([0-9]*\).*$$/\1:\2/'` $(PREFIX)$(DEVEL_PREFIX)
ifeq ($(strip $(HAVE_SHARED)),y)
	for i in `find lib/ -type l -name 'lib[a-zA-Z]*.so' | \
	sed -e 's/lib\///'` ; do \
		$(LN) -sf $(RUNTIME_PREFIX_LIB_FROM_DEVEL_PREFIX_LIB)$$i.0 \
		$(PREFIX)$(DEVEL_PREFIX)lib/$$i; \
	done;
ifeq ($(strip $(PTHREADS_DEBUG_SUPPORT)),y)
	$(LN) -sf $(RUNTIME_PREFIX_LIB_FROM_DEVEL_PREFIX_LIB)libthread_db.so.1 \
		$(PREFIX)$(DEVEL_PREFIX)lib/libthread_db.so
endif
#	# If we build shared libraries then the static libs are PIC...
#	# Make _pic.a symlinks to make mklibs.py and similar tools happy.
	for i in `find lib/  -type f -name '*.a' | sed -e 's/lib\///'` ; do \
		$(LN) -sf $$i $(PREFIX)$(DEVEL_PREFIX)lib/`echo $$i \
			| sed -e 's/\.a$$/_pic.a/'`; \
	done;
	# Ugh!!! Remember that libdl.a and libdl_pic.a are different.  Since
	# libdl is pretty small, and not likely to benefit from mklibs.py and
	# similar, lets just remove libdl_pic.a and avoid the issue
	rm -f $(PREFIX)$(DEVEL_PREFIX)lib/libdl_pic.a
endif


# Installs run-time libraries
install_runtime:
ifeq ($(strip $(HAVE_SHARED)),y)
	$(INSTALL) -d $(PREFIX)$(RUNTIME_PREFIX)lib
ifeq ($(CONFIG_GLIBC_2_20),) 
	$(INSTALL) -m 644 lib/lib*-0.9.28.so \
		$(PREFIX)$(RUNTIME_PREFIX)lib
endif
	for i in $(shell ls lib/*.so*); do \
		cp -dRf $$i $(PREFIX)$(RUNTIME_PREFIX)lib; \
	done
endif


finished2:
	$(SECHO)
	$(SECHO) Finished installing ...
	$(SECHO)


clean:
	- find . \( -name \*.o -o -name \*.a -o -name \*.so -o -name core -o -name .\#\* \) -exec $(RM) {} \;
	@$(RM) -r tmp lib include/bits libc/tmp _install lib_optim
	$(RM) libc/obj.* headers lib_diff
ifndef CONFIG_OPENWRT
	$(MAKE) -C libc/misc/internals clean
	$(MAKE) -C libc/misc/wchar clean
	$(MAKE) -C libc/unistd clean
	$(MAKE) -C libc/sysdeps/linux/common clean
	$(MAKE) -C extra/locale clean
	$(MAKE) -C extra clean
endif

ifeq ($(CONFIG_LIB_LIBGMP_FORCE),y)
	$(MAKE) -C libgmp clean
endif
ifeq ($(CONFIG_LIB_LIBUPNP_FORCE),y)
	$(MAKE) -C libupnp clean
endif
ifeq ($(CONFIG_LIB_LIBUPNP166_DMS_FORCE),y)
	@$(MAKE) -C libupnp-1.6.6-dms clean
endif
ifeq ($(CONFIG_LIB_LIBFFMPEG_FORCE),y)
	$(MAKE) -C libffmpeg-0.5 clean
endif
ifeq ($(CONFIG_LIB_LIBDLNA_FORCE),y)
	$(MAKE) -C libdlna-0.2.3 clean
endif
ifeq ($(CONFIG_LIB_LIBGDBM_FORCE),y)
	$(MAKE) -C libgdbm-1.8.3 clean
endif
ifeq ($(CONFIG_LIB_LIBID3TAG_FORCE),y)
	$(MAKE) -C libid3tag-0.15.1b clean
endif
ifeq ($(CONFIG_LIB_LIBBT_FORCE),y)
	$(MAKE) -C libbluetooth clean
endif
ifeq ($(CONFIG_LIB_READLINE_FORCE),y)
	$(MAKE) -C libreadline clean
endif
ifeq ($(CONFIG_LIB_NL_FORCE),y)
	touch libnl/configure
	touch libnl/configure.ac
	$(MAKE) -C libnl clean
endif
ifeq ($(CONFIG_LIB_LIBSQLITE3_FORCE),y)
	@$(MAKE) -C libsqlite3 clean
endif
ifeq ($(CONFIG_LIB_LIBEXIF_FORCE),y)
	@$(MAKE) -C libexif clean
endif
ifeq ($(CONFIG_LIB_LIBOGG_FORCE),y)
	@$(MAKE) -C libogg clean
endif
ifeq ($(CONFIG_LIB_LIBVORBIS_FORCE),y)
	@$(MAKE) -C libvorbis clean
endif
ifeq ($(CONFIG_LIB_LIBFLAC_FORCE),y)
	@$(MAKE) -C libflac clean
endif
ifeq ($(CONFIG_LIB_LIBJPEG_FORCE),y)
	@$(MAKE) -C libjpeg clean
endif
ifeq ($(CONFIG_LIB_LIBJPEG_TURBO_FORCE),y)
	@$(MAKE) -C libjpeg-turbo-1.4.0 clean
endif
ifeq ($(CONFIG_LIB_LIBPCAP_FORCE),y)
	$(MAKE) -C libpcap-1.0.0 clean
endif
ifeq ($(CONFIG_LIB_LIBEVENT_FORCE),y)
	$(MAKE) -C libevent-2.0.2-alpha clean
endif
ifeq ($(CONFIG_LIB_NCURSE_FORCE),y)
	$(MAKE) -C libncurses-5.7 clean
endif
ifeq ($(CONFIG_LIB_LIBNTFS3G_FORCE),y)
	$(MAKE) -C libntfs-3g clean
endif
ifeq ($(CONFIG_LIB_FLEX_FORCE),y)
	$(MAKE) -C libflex clean
endif
ifeq ($(CONFIG_LIB_USB0112_FORCE),y)
	$(MAKE) -C libusb-0.1.12 clean
endif
ifeq ($(CONFIG_GLIBC_2_20),y) 
ifeq ($(CONFIG_LIB_USB100_FORCE),y)
	$(MAKE) -C libusb-1.0.9 clean
endif
else
ifeq ($(CONFIG_LIB_USB100_FORCE),y)
	$(MAKE) -C libusb-1.0.0 clean
endif
endif
ifeq ($(CONFIG_LIB_PCRE_FORCE),y)
	$(MAKE) -C pcre-8.01 clean
endif
ifeq ($(CONFIG_LIB_CYASSL_FORCE),y)
	$(MAKE) -C cyassl-3.3.0 clean
endif
ifeq ($(CONFIG_LIB_VSTR_FORCE),y)
	$(MAKE) -C vstr-1.0.15 clean
endif
ifeq ($(CONFIG_LIB_LZO_FORCE),y)
	$(MAKE) -C lzo-2.03 clean
endif
ifeq ($(CONFIG_LIB_UUID_FORCE),y)
	$(MAKE) -C libuuid-1.0.3 clean
endif
ifeq ($(CONFIG_LIB_ZLIB_FORCE),y)
ifeq ($(CONFIG_GLIBC_2_20),y) 
	@$(MAKE) -C zlib-1.2.8 clean
else
	@$(MAKE) -C zlib-1.2.3 clean
endif
endif
ifeq ($(CONFIG_GLIBC_2_20),) 
	@set -e; \
	for i in `(cd $(TOPDIR)/libc/sysdeps/linux/common/sys; ls *.h)` ; do \
		$(RM) include/sys/$$i; \
	done; \
	if [ -d libc/sysdeps/linux/$(ARCH)/sys ] ; then \
		for i in `(cd libc/sysdeps/linux/$(ARCH)/sys; ls *.h)` ; do \
			$(RM) include/sys/$$i; \
		done; \
	fi;
	@$(RM) include/linux include/asm*
	@if [ -d libc/sysdeps/linux/$(ARCH) ]; then		\
	    $(MAKE) -C libc/sysdeps/linux/$(ARCH) clean;		\
	fi;
endif

distclean: clean
	$(RM) .config .config.old .config.cmd

release: distclean


export INSTALL LN RM
.PHONY: dummy subdirs release distclean clean 
