
all:

include Makefile.conf

oldconfig: conf autoconf
	$(SCRIPTSDIR)/conf -o Kconfig

config: conf autoconf
	$(SCRIPTSDIR)/conf Kconfig

menuconfig: mconf autoconf
	$(SCRIPTSDIR)/mconf Kconfig

gconfig: gconf autoconf
	$(SCRIPTSDIR)/gconf Kconfig

qconfig: qconf autoconf
	$(SCRIPTSDIR)/qconf Kconfig

xconfig: gconfig autoconf

.PHONY: automake force autoclean
autoconf: ../vendors/Kconfig ../lib/Kconfig.auto ../user/Kconfig.auto   automake
automake: ../lib/Makefile.auto ../user/Makefile.auto  
force:

#
# build the auto config Kconfig.auto files and their Makefile.auto components
# also include any vendor Kconfig files if they exist.
#
../vendors/Kconfig ../lib/Kconfig.auto ../user/Kconfig.auto  : force

../vendors/Kconfig: Makefile
	@echo "# autogenerated, do not EDIT" > $@; \
	. ../.config; \
	for i in $$CONFIG_VENDOR/$$CONFIG_PRODUCT/. $$CONFIG_VENDOR/.; do \
		[ -f ../vendors/$$i/Kconfig ] || continue; \
		echo "source ../vendors/$$i/Kconfig" >> $@; \
		echo "autoconf: vendors/$$i/Kconfig"; \
	done

../lib/Kconfig.auto ../user/Kconfig.auto ../lib/Makefile.auto ../user/Makefile.auto  : Makefile
	@cd `dirname $@`; \
	P=`dirname $(@)`; \
	T=`basename $$P | tr '[a-z]' '[A-Z]'`; \
	echo "# autogenerated, do not EDIT" > Kconfig.auto; \
	echo "# autogenerated, do not EDIT" > Makefile.auto; \
	fgrep -l automake.inc */[mM]akefile 2> /dev/null | while read t; do \
		D=`dirname $$t`; \
		M=`echo $$D | tr '[a-z]' '[A-Z]' | sed 's/[-+]/_/g'`; \
		if [ -f $$D/Kconfig ]; then \
			echo "automake: $$D (custom Kconfig)"; \
			echo "source  $$P/$$D/Kconfig" >> Kconfig.auto; \
		else \
			echo "automake: $$D (default Kconfig)"; \
			( \
			echo "config $${T}_$${M}"; \
		    echo "bool \"$$D\""; \
			echo "help"; \
			echo "    Automake package for $$D."; \
			echo "    see $(ROOTDIR)/Documentation/automake.txt for details"; \
			echo "    on improving this help."; \
			) >> Kconfig.auto; \
		fi; \
		echo "dir_$$""(CONFIG_$${T}_$${M})	+= $$D" >> Makefile.auto; \
		if [ -f $$D/Makefile.auto ]; then \
			echo "include $$D/Makefile.auto" >> Makefile.auto; \
		fi; \
	done

autoclean:
	rm -f ../lib/Kconfig.auto ../user/Kconfig.auto
	rm -f ../lib/Makefile.auto ../user/Makefile.auto
	rm -f  
	rm -f ../vendors/Kconfig

clean: confclean autoclean
	rm -f autoconf.h auto.conf .config .config.old

.PHONY: all oldconfig config menuconfig gconfig qconfig xconfig clean
