
PARTS = args.pl cmdline.pl cmds.pl color.pl curses.pl draw.pl env.pl exec.pl \
  getch.pl misc.pl prompt.pl read.pl search.pl screen.pl vitrc.pl

PREFIX=@prefix@
VERSION=@VERSION@
TASK=@TASK@
PERL=@PERL@
CLEAR=@CLEAR@

.PHONY : install

build: 
	@echo "adding vit.pl to vit"
	@cat vit.pl | grep -v ^require \
	  | sed "s:%prefix%:$(PREFIX):" \
	  | sed "s/%BUILD%/$(VERSION) built `LC_ALL=C date --utc --date="@$${SOURCE_DATE_EPOCH:-$$(date +%s)}"`/" \
	  | sed "s/%VERSION%/$(VERSION) (`date --utc --date="@$${SOURCE_DATE_EPOCH:-$$(date +%s)}" +%Y%m%d`)/" \
	  | sed "s:%TASK%:$(TASK):" \
	  | sed "s:%CLEAR%:$(CLEAR):" \
	  > vit
	@for f in $(PARTS); do \
	  echo "adding $$f to vit"; \
	  echo "########################################################" >> vit; \
	  echo "## $$f..." >> vit; \
	  grep -v ^return $$f >> vit; \
	done
	chmod 755 vit

install:
	sudo mkdir -p @prefix@/bin
	sudo cp vit @prefix@/bin/vit
	sudo mkdir -p @prefix@/man/man1
	sudo cp vit.1 @prefix@/man/man1/
	sudo mkdir -p @prefix@/man/man5
	sudo cp vitrc.5 @prefix@/man/man5/
	sudo mkdir -p @prefix@/etc/
	sudo cp commands @prefix@/etc/vit-commands

autoconf:
	@make -f .makefile autoconf

release:
	@make -f .makefile release

push:
	@make -f .makefile push

debug:
	@make -f .makefile debug

test:
	@make -f .makefile test

diffs:
	@make -f .makefile diffs

ci:
	@make -f .makefile ci

