include ../config

NAME = zlib-1.1.3

PWD := $(shell pwd)

LSRCDIR= $(SRCDIR)/$(NAME)
#LBUILDDIR = $(BUILDDIR)/$(NAME)
LTMPDIR = $(BUILDDIR)/$(NAME)

all: install

dirs: stamp-dirs
stamp-dirs: 
	touch stamp-dirs

untar: stamp-untar
stamp-untar: stamp-dirs
	-cd $(SRCDIR) && rm -rf $(NAME)
	cd $(SRCDIR) && tar xfz $(DEBSRCDIR)/zlib-1.1.3.orig.tar.gz
	touch stamp-untar


configure: stamp-configure
stamp-configure: stamp-untar
	cd $(LSRCDIR) && PATH=$(INSTALLDIR)/bin:$$PATH \
		CC='mipsel-linux-snow-gcc' RANLIB='mipsel-linux-ranlib' CFLAGS='-O2' $(LSRCDIR)/configure 
	touch stamp-configure

install-spec: stamp-install-spec
stamp-install-spec:
	cp $(PWD)/libz.spec $(INSTALLDIR)/lib/snow/lib-specs/
	touch stamp-install-spec

build: stamp-build
stamp-build: stamp-configure stamp-install-spec
	cd $(LSRCDIR) && PATH=$(INSTALLDIR)/bin:$$PATH \
		make AR='mipsel-linux-ar rc' RANLIB='mipsel-linux-ranlib' libz.a
	cd $(LSRCDIR) && PATH=$(INSTALLDIR)/bin:$$PATH \
		mksnow libz
	touch stamp-build


install: stamp-install
stamp-install: stamp-build 
	cd $(LSRCDIR) && PATH=$(INSTALLDIR)/bin:$$PATH \
		cp libz.a $(INSTALLDIR)/mipsel-linux/lib/soft-float/snow-model/ && \
		cp libz.1.sso libz.sa $(INSTALLDIR)/lib/snow/
	cd $(INSTALLDIR)/lib/snow/ && ln -sf libz.sa libz.a
	cd $(LSRCDIR) && cp zlib.h zconf.h $(INSTALLDIR)/mipsel-linux/include/
	touch stamp-install
