# (GNU) Makefile for maf

NAME=maf
DEBUG=-g
RELTMP=/tmp
INSTALL-DIR=/usr/local/bin

ifdef USE_BTREE
BTHOME=${HOME}/dev/btlib
INCLUDE=-I${BTHOME}/inc
BTLIB=${BTHOME}/lib/libbt.a
DEF_BTREE=-DUSE_BTREE
endif

CFLAGS=${DEBUG} ${INCLUDE} ${DEF_BTREE}

.PHONY: release doc publish install deinstall

OBJS= ${NAME}.o strutil.o stack.o dictint.o ds.o

all: ${NAME} doc

${NAME}:    ${OBJS} ${BTLIB}

strutil.o: 	strutil.h
stack.o: 	stack.h
dictint.o: 	dictint.h
ds.o:   	ds.h

clean:
	rm -rf ${OBJS} ${NAME}
	cd man; make clean

doc:
	cd man; make

publish:
	cd man; make publish

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

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

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