include Makefile.inc

ALL_TARGETS =	starter options simple_project full_project xml_stream \
		oo_interfaces oo_airline containers $(PLUGINS) stream_io \
		altivec oo_sockets volatile_streams dimensioned_units \
		filesys_traversal knights_tour menace threadsafe_output

XML_FRAGMENTS=	full_project/full.xml \
		options/options.xml \
		other_languages/cpp_main/cpp_main.xml \
		other_languages/cpp_pragmas/cpp_pragmas.xml \
		other_languages/import_from_c/import_from_c.xml \
		plugins/plugins.xml \
		knights_tour/knights_tour.xml \
		filesys_traversal/filesys_traversal.xml \
		dimensioned_units/dimensioned_units.xml \
		menace/menace.xml \
		stream_io/stream_io.xml \
		threadsafe_output/threadsafe_output.xml \
		volatile_streams/volatile_streams.xml \
		simple_project/simple.xml \
		starter/starter.xml \
		xml_stream/xml_stream.xml \
		oo_sockets/oo_sockets.xml \
		containers/anagram/anagram.xml \
		containers/genealogy/genealogy.xml \
		containers/hash/hash.xml \
		containers/library/library.xml \
		containers/shapes/shapes.xml \
		containers/spellcheck/spellcheck.xml \
		containers/wordcount/wordcount.xml \
		containers/wordfreq/wordfreq.xml \
		oo_interfaces/oo_interfaces.xml \
		oo_airline/oo_airline.xml \
		altivec/altivec.xml

all: $(ALL_TARGETS) other_languages

$(ALL_TARGETS):
	make -C $@ $(PASS)

other_languages:
	make -C $@ -f Makefile

clean:
	$(foreach DIR,$(ALL_TARGETS), make -C $(DIR) clean $(PASS) &&) echo end
	make -C other_languages -f Makefile clean
	rm -f gnat-examples.xml

gnat-examples.xml: $(XML_FRAGMENTS) header.xml footer.xml
	cat header.xml         > gnat-examples.xml
	cat $(XML_FRAGMENTS)  >> gnat-examples.xml
	cat footer.xml        >> gnat-examples.xml
	sed "s:PREFIX:$(GNAT_ROOT):" gnat-examples.xml > gnat-examples.xml.tmp
	mv gnat-examples.xml.tmp gnat-examples.xml

install: gnat-examples.xml
	if [ ! -d $(GNAT_ROOT)/share/gps/plug-ins ]; then \
		mkdir -p $(GNAT_ROOT)/share/gps/plug-ins;    \
	fi
	cp gnat-examples.xml $(GNAT_ROOT)/share/gps/plug-ins

.PHONY: $(ALL_TARGETS) clean other_languages
