
# Makefile for  mstoical
#
# See src/config.h for build options.

VERS= @PACKAGE_VERSION@
META= Makefile
OBJS= kernel.o term.o mem.o hash.o dict.o debug.o string.o signal.o
SRCS= kernel.c term.c dict.c string.c hash.c debug.c mem.c signal.c
PREFIX= @prefix@
NAME = mstoical-$(VERS)
LIBROOT= $(PREFIX)/lib/mstoical
CFLAGS= -c -DVERSION=\"$(VERS)\" -DLIBROOT=\"$(LIBROOT)\" -Wall @CFLAGS@
LIBS= @LIBS@

all: src/.depend 
	cd src && $(MAKE)

src/.depend:
	@echo Generating dependencies
	@cd src && $(CC) -MM $(SRCS) > .depend

doc:
	@echo Generating documentation
	@./mstoical -l lib util/docex src/words.c lib/def doc/words.d
	@echo Generating Vim syntax
	@mkdir -p vim/syntax
	@./mstoical -l lib util/genvim doc/words.d >vim/syntax/mstoical.vim
	@cat doc/words.d/* >doc/words; rm -rf doc/words.d

test:
	cd $@ && $(MAKE)

install: all doc
	install -s mstoical $(PREFIX)/bin
	mkdir -p $(LIBROOT); cp -R lib/* $(LIBROOT)
	gzip -c doc/mstoical.1 > /usr/share/man/man1/mstoical.1.gz

clean:
	rm -f mstoical
	cd src && $(MAKE) $@

distclean: clean
	rm -f Makefile src/Makefile config.cache config.h config.log
	echo -e 'all:\n%:\n\t./configure && $(MAKE) $$@' > Makefile

.PHONY: doc test clean
.EXPORT_ALL_VARIABLES:

