# Makefile for golem
SUBDIRS=	src plugins doc util



prefix=		
exec_prefix=	${prefix}

bindir=		${exec_prefix}/bin
datadir=	${prefix}/share
mandir=		${prefix}/man
libdir=		${exec_prefix}/lib

.PHONY:		all clean distclean full deinstall uninstall
.PHONY:		install install-bin install-data install-plugins install-man

# subdir recursion macro
RECUR=	@for dir in $(SUBDIRS) ; do \
		echo "===> $$dir"; \
		(cd $$dir ; $(MAKE) $@) \
	done

all:
	$(RECUR)

clean:
	-rm -rf build-plugin build-bin sample.golem/plugins
	$(RECUR)

distclean: clean
	-rm -f config.cache config.status config.log src/config.h
	-rm -f Makefile src/Makefile plugins/Makefile plugins/Makefile.plugin
	-rm -f doc/Makefile util/Makefile

full: clean all

install-bin: install-plugins
	/usr/bin/install -c -o root -g wheel -d $(bindir)
	/usr/bin/install -c -o root -g wheel build-bin/golem $(bindir)
	/usr/bin/install -c -o root -g wheel build-bin/golem.install $(bindir)

install-plugins:
	/usr/bin/install -c -o root -g wheel -d $(libdir)/golem/plugins
	for i in build-plugin/* ; do \
		/usr/bin/install -c -o root -g wheel $$i $(libdir)/golem/plugins/ ; \
	done

install-data:
	cd sample.golem ; \
	for i in `find . -type d | grep -v CVS` ; do \
		/usr/bin/install -c -o root -g wheel -d $(datadir)/golem/$$i ; \
	done ; \
	for i in `find . -type f | grep -v CVS` ; do \
		/usr/bin/install -c -o root -g wheel -m 444 $$i $(datadir)/golem/$$i ; \
	done

install-man:
	/usr/bin/install -c -o root -g wheel -d $(mandir)/man1
	/usr/bin/install -c -o root -g wheel -m 444 doc/golem.1.gz $(mandir)/man1/

install: all install-bin install-data install-man

# this will kill anything they put into those dirs also
deinstall:
	rm -f $(bindir)/golem
	rm -f $(bindir)/golem.install
	rm -f $(mandir)/man1/golem.1.gz
	rm -rf $(libdir)/golem
	rm -rf $(datadir)/golem

uninstall: deinstall


syntax highlighted by Code2HTML, v. 0.9.1