mkfile_path   := $(abspath $(lastword $(MAKEFILE_LIST)))
mkfile_dir    := $(dir $(mkfile_path))

.PHONY: all

all: $(mkfile_dir)/Makefile
	make -f $(mkfile_dir)/Makefile test

$(mkfile_dir)/Makefile: $(mkfile_dir)local/lib/perl5/Test/More.pm
	cd $(mkfile_dir)/ && perl Makefile.PL

$(mkfile_dir)local/lib/perl5/Test/More.pm: $(mkfile_dir)local/bin/carton
	perl -I$(mkfile_dir)local/lib/perl5 $(mkfile_dir)local/bin/carton \
	    install

$(mkfile_dir)local/bin/carton:
	curl -L https://cpanmin.us | perl - -l $(mkfile_dir)local Carton