#
# (GNU) Makefile for vc
#
# MODIFICATION HISTORY
# Mnemonic  Date    Rel Who
# RDPMK	    020604  1.0 mpw
#   Created.
# RDPMK	    071107  1.4 mpw
#   Added publish target; clean of doc is delegated
# RDPMK	    030321	mpw
#   Processing doc made optional since toolchain is not common
#   Add install and deinstall targets
# RDPMK	    060623	mpw
#   Use git archive for release build
# VC	    120424		mpw
#   Remove rdp from build; using Pratt parser

NAME=vc
CFLAGS=-g -Wall --pedantic
INSTALL-DIR=/usr/local/bin

.PHONY: release clean doc doc-clean install deinstall test

OBJS=vc.o parse.o lexer.o symtab.o op.o var.o

vc:		${OBJS}

vc.o:		vc.h
parse.o:	parse.h
lexer.o:	lexer.h
symtab.o:	symtab.h
op.o:		op.h
var.o:		var.h

clean:
	rm -f ${OBJS} ${NAME}

release:
	@-if [ v${version} = v ]; then \
		echo Please specify version required \(version=x.x\); \
	else \
		git archive --format=tar --prefix=${NAME}-${version}/ \
			v${version} >${NAME}-${version}.tar; \
		if [ $$? = 0 ]; then \
			gzip ${NAME}-${version}.tar; \
			echo ${NAME}-${version}.tar.gz created; \
		else \
			rm -f ${NAME}-${version}.tar; \
		fi; \
	fi

doc:
	cd man; make

doc-clean:
	cd man; make clean

publish:
	cd man; make publish

install:
	cp ${NAME} ${INSTALL-DIR}
	cd man; make install

deinstall:
	rm -f ${INSTALL-DIR}/${NAME}
	cd man; make deinstall

# specify TEST=gold on the make command line to rebuild the gold
# results files.
test:
	cd test; sh test.sh ${TEST}
