# $Id: Makefile,v 1.5 2001/04/16 20:55:32 juphoff Exp $

export MIDORI_VERSION=$(shell cat VERSION)

ALL: all


cache/scripts/Makefile: .checkapps $(shell echo apps/mlbuild-*.mlz)
	@if ! id -nu | fgrep root > /dev/null ; then echo "You need to be root to build this system!"; exit 1 ; fi
	@if [ ! -f "`echo apps/mlbuild-*.mlz`" ] ; then echo "The build process needs exactly ONE apps/mlbuild*.mlz file" ; exit 1 ; fi
	mkdir -p cache/build
	rm -rf cache/build/mlbuild-*
	cd cache/build ; tar xzf ../../apps/mlbuild-*.mlz
	cache/build/mlbuild-*/build bootstrap

.checkapps:
	@for i in mlbuild configurator binutils findutils gcc ; do \
		if [ ! -f "`echo apps/$$i-*.mlz`" ] ; then \
			echo ; echo '****************************************************************' ; \
			echo "* Cannot find package '$$i'. Make sure that you move" ; \
			echo "* all *.mlz packages into the apps directory." ; \
			echo '****************************************************************' ; \
			exit 1 ; \
		fi ; \
	done
	@touch .checkapps

-include cache/scripts/Makefile
