Guava

The Guava Tools

Example Makefile


Home  Computer Software  Guava Main Page 

Example Makefile

This is an example makefile, similar to one that I have used for my own web pages.

This example has been updated for use with Guava 1.0.4 and later.

This makefile uses features of the GNU make program that may not be supported by make programs from other vendors. Please refer to the GNU web site for more information about GNU make.

This makefile uses a number of programs and scripts, in addition to the programs provided in the Guava tools:
man2html Earl Hood's man page to HTML conversion program.
depgenfilt.pl A script to add directory prefixes to dependency output from gcc or hss2html.
html2pre A simple filter to convert ampersands and angle brackets into HTML codes.
man, sed, cat, rm These programs should be installed on most systems.

 
#############################################################################
# Example Makefile for the Guava tools.
#
# Steve Morphet. 1999-2000.
# Designed for GNU make.
#
# You will need to modify this Makefile before using it in your own
# projects.  Most of the things you'll need to change are in the
# first section.
#
#############################################################################

# Where should we look for source files?
VPATH=src

# List of source files.
# Suffixes used for Guava source files are:
# .hss - hss2html source file.
# .htt - htt2html source file for multipage doc with contents.
# .htp - htt2html source file for multipage doc without contents.
SRC=src/src1.htp src/src2.htt src/src3.hss

# Extensions for generated files, and the directory where they should
# go if 'hss2html -M -MG' puts them in the current dir.
# Used by the depgenfilt.pl script.
INTER_EXT= "mhtml phtml"
INTER_DIR= "src   src"

# Dirs to search for include files.
INCLUDE=-Isrc/include -I../src/include

# Defines for the various modes.
LDEFINES= -DLOCAL
RDEFINES=

#############################################################################
# You shouldn't need to change much beyond this point.
#############################################################################

# Make dependency names by replacing source suffixes with .d
DEPS=$(addsuffix .d, $(basename $(SRC)))

# Make target names by stripping pathnames and replacing suffixes with html
TARGET=$(addsuffix .html, $(notdir $(basename $(SRC))))

# Programs to use to build.
HTTPROG=htt2html
HSSPROG=hss2html
MAN2HTML=man2html -topm 6 -botm 6 -pgsize 66 -compress -bare
HTML2PRE=html2pre

# Progs and filters for creating and postprocessing dependencies.
# DEPSED adds the .d file to the list of targets.
# DEPGENFILT adds directory prefixes to the dependency entries of
# generated files.
DEPSED=     sed 's\#: \# $@: \#g'
DEPGENFILT= depgenfilt.pl $(INTER_EXT) $(INTER_DIR)

# Include the options file, if it exists.
# This lets the makefile remember whether it was last called
# for the 'LOCAL' or 'REMOTE' target.
-include modeopt.dd

# If no mode option has been set use REMOTE, and write the mode file.
ifndef MODE_OPT
MODE_OPT=REMOTE
MODE_FILE=0
else
MODE_FILE=1
endif

ifeq ($(MODE_OPT), LOCAL)
	DEFINES=$(LDEFINES)
	FRFILE=/mnt/localweb/remotesite/fullref_local.dat
else
ifeq ($(MODE_OPT), REMOTE)
	DEFINES=$(RDEFINES)
	FRFILE=/mnt/localweb/remotesite/fullref_remote.dat
endif
endif

#############################################################################

# Default target - build the target files.
.PHONY: pages
pages : $(TARGET)

# Clean up.
.PHONY: clean
clean:
	-rm *.html
	-rm *.d
	-rm src/*.d

#############################################################################

# Rules to build html from various source types.
# htp is like htt, but is used with the -nocont option to htt2html.

# Rule to make an html page from an hss file.
%.html:%.hss
	$(HSSPROG) $(DEFINES) $(INCLUDE) \
	-rfile $(FRFILE) \
	-o $(basename $@) $<

# Rule to make an html document with contents from an htt file.
%.html:%.htt
	$(HTTPROG) $(DEFINES) $(INCLUDE) -hssprog $(HSSPROG) \
	-rfile $(FRFILE) \
	-o $(basename $@) -op $(basename $@) $<

# Rule to make html pages without contents from an htp file.
%.html:%.htp
	$(HTTPROG) $(DEFINES) $(INCLUDE) -nocont -hssprog $(HSSPROG) \
	-rfile $(FRFILE) \
	-op $(basename $@) $<

#############################################################################

# Rules for creating various intermediate files.

# Rule to make a .mhtml file from a .man page.
%.mhtml:%.man
	man ./$< | $(MAN2HTML) > $@

# Rule to make a .phtml file from a .pre page.
%.phtml:%.pre
	cat $< | $(HTML2PRE) > $@

#############################################################################

# Dependencies...

define guava-depend-pre
@echo "Making dependency file $*.d"
endef

define guava-depend-post
@cat $*.dXX | $(DEPSED) | $(DEPGENFILT) > $@
@rm $*.dXX
endef

# Rules to generate dependencies from source files.
%.d : %.hss
	$(guava-depend-pre)
	@$(HSSPROG) -M -MG \
		$(INCLUDE) $(addprefix -I, $(sort $(dir $(SRC)))) \
		$< > $*.dXX
	$(guava-depend-post)

%.d : %.htt
	$(guava-depend-pre)
	@$(HTTPROG) -M -MG \
		$(INCLUDE) $(addprefix -I, $(sort $(dir $(SRC)))) \
		-o index -op $(basename $@) \
		$< > $*.dXX
	$(guava-depend-post)

%.d : %.htp
	$(guava-depend-pre)
	@$(HTTPROG) -M -MG \
		-nocont \
		$(INCLUDE) $(addprefix -I, $(sort $(dir $(SRC)))) \
		-op $(basename $@) \
		$< > $*.dXX
	$(guava-depend-post)

# Include the generated dependency files.
# One for each target file.
include $(DEPS)

#############################################################################

# DEBUG mode targets.  Use one of these to set the debug mode for subseqent
# invocations of make.
.PHONY: remote local

# If there was no mode file, the mode will be REMOTE, but MODE_FILE will
# be zero.

remote:

ifeq ($(MODE_FILE), 0)
	@echo Creating mode file.
	@echo "MODE_OPT = REMOTE" > modeopt.dd
	make clean
	make
else
ifneq ($(MODE_OPT), REMOTE)
	@echo Setting makefile to remote mode.
	@echo "MODE_OPT = REMOTE" > modeopt.dd
	make clean
	make
else
	@echo Mode already remote.
	make
endif
endif

local:
ifneq ($(MODE_OPT), LOCAL)
	@echo Setting makefile to local mode.
	@echo "MODE_OPT = LOCAL" > modeopt.dd
	make clean
	make
else
	@echo Mode already local.
	make
endif

#############################################################################




Email: