
# Type "make" to see a list of available targets and their descriptions.

# All system-specific variables are in Makefile.options and should be
# edited there.  Nothing in this file should need editing.

# --------------------------- Variables -----------------------------------

-include Makefile.options

cs = $(CLASSPATH_SEP)

DOC_SAMPLE = $(DOCS_DIR)/index.html
DOC_OVERVIEW = overview.html

DOC_TITLE = 'BTools - Miscellaneous Java utility classes'
DOC_BOTTOM = 'Copyright &copy; 1998-2001, Ben Burton<br>This software is released under the GNU Public License.<br>For further information, or to submit a bug or other problem, please contact Ben Burton (<a href="mailto:benb@acm.org">benb@acm.org</a>).'

LICENSE = LICENSE.txt

# --------------------------- Rules ---------------------------------------

%.class : %.java
	$(JAVAC) -classpath '.$(cs)$(EXTRA_CLASSES)' $<

# --------------------------- Sources -------------------------------------

include Makefile.sources

raw_package_dirs = $(subst .,/,$(packages))
package_java_mask = $(patsubst %,%/*.java,$(raw_package_dirs))
package_class_mask = $(patsubst %,%/*.class,$(raw_package_dirs))

java_files = $(wildcard $(package_java_mask))
made_class_files = $(java_files:.java=.class)

package_overviews = $(patsubst %,%/package.html,$(raw_package_dirs))
aux_files = $(wildcard $(aux_mask))

doc_sources = $(package_overviews) $(DOC_OVERVIEW)
made_doc_mask = $(doc_mask:%=$(DOCS_DIR)/%)

# --------------------------- Targets -------------------------------------

help :
	@cat Makefile-help

.PHONY : classes jar docs all clean purge help

classes : $(made_class_files)

jar : $(RUNTIME_JAR)
$(RUNTIME_JAR) : $(made_class_files) $(aux_files) $(LICENSE)
	$(JAR) -cf $(RUNTIME_JAR) $(package_class_mask) $(aux_mask) $(LICENSE)

docs : $(DOC_SAMPLE)
$(DOC_SAMPLE) : $(java_files) $(doc_sources)
	$(JAVADOC) -classpath '.$(cs)$(EXTRA_CLASSES)' -d $(DOCS_DIR) \
		-overview $(DOC_OVERVIEW) -windowtitle $(DOC_TITLE) \
		-doctitle $(DOC_TITLE) -bottom $(DOC_BOTTOM) \
		-package -use $(packages)

all : classes jar docs

clean :
	-rm $(package_class_mask)
	-rm -rf $(made_doc_mask)

purge : clean
	-rm $(RUNTIME_JAR)

Makefile.options :
	@echo
	@echo "Makefile.options is missing."
	@echo "Try taking one of the sample files (Makefile.options.*) and"
	@echo "    modifying it to suit your system."
	@echo
	@false
