include ../config

NAME = lua-4.0

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) && rmdir lua-4.0
	cd $(SRCDIR) && tar xfz $(DEBSRCDIR)/lua-4.0.tar.gz
	cd $(SRCDIR) && mv lua lua-4.0
	touch stamp-untar

custom_patches = lua-config

custom-patch: stamp-custom-patch
stamp-custom-patch: stamp-untar
	set -e; \
	for f in $(custom_patches); do \
	  echo "custom patch $$f:"; \
	  patch -d $(LSRCDIR) -p1 <$(PWD)/$$f.patch; \
	done
	touch stamp-custom-patch

build: stamp-build
stamp-build: stamp-custom-patch
	cd $(LSRCDIR) && PATH=$(INSTALLDIR)/bin:$$PATH \
		make
	touch stamp-build

install: stamp-install
stamp-install: stamp-build
	cd $(LSRCDIR) && PATH=$(INSTALLDIR)/bin:$$PATH \
		make install INSTALL_ROOT=$(INSTALLDIR)
	touch stamp-upstream-install
