
include ../builder/config

GCC_DIR=$(INSTALLDIR)
PROJ=snow2
export GCC_DIR
export PROJ

PWD := $(shell pwd)
libgcc = $(shell mipsel-linux-gcc -print-libgcc-file-name)
gcc_private = $(shell dirname $(libgcc))

all: build-romdisk

random-fixups: stamp-random-fixups
stamp-random-fixups:
	cd $(INSTALLDIR)/lib/snow && ln -fs ../../mipsel-linux/lib/soft-float/snow-model/libcrypt.a .
	cd $(INSTALLDIR)/lib/snow && ln -fs ../../mipsel-linux/lib/soft-float/snow-model/libdl.a .
	cd $(INSTALLDIR)/lib/snow && ln -fs ../../mipsel-linux/lib/soft-float/snow-model/libfl.a .
	cd $(INSTALLDIR)/lib/snow && ln -fs ../../mipsel-linux/lib/soft-float/snow-model/libutil.a .
	cd $(INSTALLDIR)/mipsel-linux/include && patch -p1 <$(PWD)/random-include-hacks.patch
	cd $(gcc_private)/include && patch -p1 <$(PWD)/random-include-hacks2.patch
	touch stamp-random-fixups

install-specs: stamp-install-specs
stamp-install-specs:
	cp $(PWD)/lib-specs/* $(INSTALLDIR)/lib/snow/lib-specs/
	touch stamp-install-specs

install-scripts: stamp-install-scripts
stamp-install-scripts:
	cp $(PWD)/scripts/* $(VRP_BUILD_TREE)/scripts/
	touch stamp-install-scripts

install-source-patches: stamp-install-source-packages
stamp-install-source-patches:
	cd $(PWD)/source && find . -print | cpio -pumd $(VRP_BUILD_TREE)/source/
	touch stamp-install-source-patches

tree-ready: stamp-tree-ready
stamp-tree-ready: stamp-install-specs stamp-install-scripts stamp-install-source-patches
	touch stamp-tree-ready

toolchain-ready: stamp-toolchain-ready
stamp-toolchain-ready: stamp-random-fixups
	touch stamp-toolchain-ready

build-libs: stamp-build-libs
stamp-build-libs: stamp-toolchain-ready stamp-tree-ready
	cd $(VRP_BUILD_TREE) && fakeroot scripts/build_libs-nop
	touch stamp-build-libs

build-bin: stamp-build-bin
stamp-build-bin: stamp-build-libs
	cd $(VRP_BUILD_TREE) && fakeroot scripts/build_bin-nop
	touch stamp-build-bin

build-romdisk: stamp-build-romdisk
stamp-build-romdisk: stamp-build-bin stamp-build-libs
	cd $(VRP_BUILD_TREE) && fakeroot scripts/build_mine
	touch stamp-build-romdisk
