
#---------------------------------------------------------------
# Project         : Mandrake Linux
# Module          : Borges
# File            : Makefile.entities
# Author          : Camille Bgnis
# Created On      : Mon May  1 16:25:21 2001
# Copyright       : Camille Bgnis camille@mandrakesoft.com,
#                    MandrakeSoft under the GPL license
#---------------------------------------------------------------
# This Makefile is responsible for cataloging all global entities 
# files so that they are easily accesible by all manuals

XMLTEST='<?xml version="1.0" standalone="yes"?> \
<!DOCTYPE test [<!ENTITY % entities SYSTEM "TEST">%entities;]> \
<test/>'

include /home/stew/RPM/BUILD/Borges-0.12.2/doc/Makefile.include

catalog: $(wildcard *.ent ../*.ent)
	@echo "****** Catalogging entities in $(PWD)..."; \
	rm -f $@
	touch $@
ifneq ($(wildcard *.ent ../*.ent),)
	for i in $(wildcard $(PWD)/*.ent $(PWD)/../*.ent); do \
		f=$$(echo $$i | sed -e "s,^/,,; s,[_./],-,g"); \
		echo "<!ENTITY % $$f SYSTEM \"$$i\">" >> $@; \
		echo "%$$f;" >> $@; \
	done
endif

%.validate: %.ent
	@echo $(XMLTEST) | sed -e "s,TEST,$<," > test_entity.xml
	xmllint --noout test_entity.xml > $@ 2>&1 
	@rm -f test_entity.xml
	@if [ -s $@ ]; then \
		echo "**********************************************************"; \
		echo "******* $< Not Valid: Consult $@ ********"; \
		echo "**********************************************************"; \
	else \
		echo "******* Validation OK ********"; \
		rm -f $@; \
	fi

%.commit: %.validate
	@if [ -s $< ]; then \
		echo "**********************************************************"; \
		echo "******* $*.ent Not Valid: Consult $@ ********"; \
		echo "**********************************************************"; \
	elif [ $(CVS) == 'yes' ]; then \
		$(call cvsadd,$*.ent) \
		cvs -z2 commit $*.ent; \
	fi

# Local variables:
# mode: makefile
# End: