Mapper

System Building

Makefile

# (Processed from) # $Header: /home/ben/Mapper/RCS/Makefile.in,v 6.51 2002/07/14 15:55:59 ben Exp $
#Template for Makefile, processed by configure,
#for Mapper.
#This is a gmake (GNU make) style Makefile
#    COPYRIGHT Benedict Adamson 1998, 1999, 2000, 2002.
#    This file is part of Mapper.

#    Mapper is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.

#    Mapper is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.

#    You should have received a copy of the GNU General Public License
#    along with Mapper; if not, write to the Free Software
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA


#Variables
AR:=ar
build:=@build@
CPPFLAGS:=-Iinclude @CPPFLAGS@
CXX:=@CXX@
CXXFLAGS:=@CXXFLAGS@
CXXFLAGSCHECK:=@CXXFLAGSCHECK@
CXXFLAGSDEBUG:=@CXXFLAGSDEBUG@
exec_prefix:=@exec_prefix@
host:=@host@
INSTALL:=@INSTALL@
INSTALL_DATA:=@INSTALL_DATA@
includedir:=@includedir@
libdir:=@libdir@
LDFLAGS:=@LDFLAGS@
prefix:=@prefix@
RANLIB:=@RANLIB@
BASELINE:=$(shell cat BASELINE)
RM:=rm -f
RMR:=rm -rf
srcdir:=@srcdir@
target:=@target@
TAR:=tar

#Default target
all:

#Virtual build targets.
all: Makefile

bin/test:

check: Makefile

clean::

debug:

depend: Makefile

dist:

doc:

test: Makefile

.SUFFIXES: .a .o .do .dep .chk

obj/%.o: c++/%.cpp
      $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@

check/c++/%.cpp.chk: c++/%.cpp obj/%.o
      $(CXX) $(CXXFLAGSCHECK) $(CPPFLAGS) -c $< -o obj/$*.tmp 2>&1 | tee $@
      $(RM) obj/$*.tmp

c++/%.bb: obj/%.do

c++/%.bbg: obj/%.do

obj/%.do: c++/%.cpp obj/%.o
      ${RM} c++/$*.bb  c++/$*.bbg
      $(CXX) $(CXXFLAGSDEBUG) $(CPPFLAGS) -c $< -o $@ && \
	(mv $(*F).bb c++/$*.bb; mv $(*F).bbg c++/$*.bbg)

test/coverage/%.cpp.gcov: test/result.tst
      ${RM} $@
      gcov -l $*.cpp && \
	(mv $(*F).cpp.$(*F).cpp.gcov $@; \
	for FILE in $(*F).cpp.*.gcov; do\
	if [ -f $$FILE ]; then\
	   mv $$FILE test/coverage/$(*D);\
	fi;\
	done)

depend/%.dep: c++/%.cpp
      $(CPP) -M $(CPPFLAGS) $< | sed -e 's|^.*\.o:|obj/$*.o:|' > $@ || $(RM) $@

check/%.html.provide: %.html bin/htmlanchors
      ${RM} $@
      bin/htmlanchors -P $< | sort -o $@

check/%.html.require: %.html bin/htmlanchors
      ${RM} $@
      bin/htmlanchors -R $< | sort -u -o $@
#... building rules


#sed commands for constructing file lists
SED_cxx:=-e '/^c++\//!d'
SED_include:=-e '/^include\//!d'

SED_cxx_chk:=-e 's:^c++\/:check/&:' -e 's:$$:&.chk:'
SED_dep:=-e 's:^c++\/:depend/:' -e 's:\.cpp$$:.dep:'

SED_html:=-e '/\.html$$/!d'
SED_provide:=-e 's:^:check/:' -e 's:\.html$$:&.provide:'
SED_require:=-e 's:^:check/:' -e 's:\.html$$:&.require:'

#Lists of files
MAPPER_H:=$(shell egrep '^include/[^/]+$$' Mapper.src)
TEST_H:=$(shell egrep '^include/test/[^/]+$$' Mapper.src)

TEST_DATA:=$(shell egrep '^lib/test/.*\.(xml|out)$$' Mapper.src)

MAPPER_CPP:=$(shell sed ${SED_cxx} -e '/^c++\/test/d' -e '/^c++\/mapper.cpp/d' Mapper.src)
MAPPER_O:=$(patsubst c++/%.cpp,obj/%.o,${MAPPER_CPP})
MAPPER_DO:=$(patsubst c++/%.cpp,obj/%.do,${MAPPER_CPP})
MAPPER_CHK:=$(patsubst c++/%.cpp,check/c++/%.cpp.chk,${MAPPER_CPP})
MAPPER_GCOV:=$(patsubst %.cpp,test/coverage/%.cpp.gcov,${MAPPER_CPP})

TEST_CPP:=$(shell sed ${SED_cxx} -e '/^c++\/test/!d' Mapper.src)
TEST_O:=$(patsubst c++/%.cpp,obj/%.o,${TEST_CPP})
TEST_DO:=$(patsubst c++/%.cpp,obj/%.do,${TEST_CPP})
TEST_CHK:=$(patsubst c++/%.cpp,check/c++/%.cpp.chk,${TEST_CPP})

DEPENDS:=$(shell sed ${SED_cxx} ${SED_dep} Mapper.src)
PROVIDES:=$(shell sed ${SED_html} ${SED_provide} Mapper.src Mapper.prd)
REQUIRES:=$(shell sed ${SED_html} ${SED_require} Mapper.src Mapper.prd)
DIST_FILES:=$(shell cat Mapper.prd Mapper.src)
SOURCE_FILES=$(shell cat Mapper.src)

configure: configure.in
      autoconf
Makefile: Makefile.in config.status
      ./config.status
config.status: configure
      ./config.status --recheck



#dependencies:

depend: depend/all.dep

depend/all.dep: ${DEPENDS}
      cat ${DEPENDS} > $@
include depend/all.dep



#Programs
#normal program
all: bin/mapper
bin/mapper: obj/mapper.o ${MAPPER_O}
      ${CXX} -o $@ obj/mapper.o ${MAPPER_O} -lxerces

#debugging program
debug: bin/mapper_d

bin/mapper_d: obj/mapper.do ${MAPPER_DO}
      ${CXX} -o $@ obj/mapper.do ${MAPPER_DO} -lxerces

#Compiler checks
check: ${MAPPER_CHK} ${TEST_CHK} check/c++/mapper.cpp.chk

#Check HTML anchors
check: check/tags.miss
check/tags.miss: check/all.require check/all.provide
      ${RM} $@
      comm -23 check/all.require check/all.provide 2>&1 | tee $@

check/all.provide: ${PROVIDES} \
   Mapper.src Mapper.prd external.provide check/doc/doxygen.provide
      ${RM} $@
      sort -o $@ ${PROVIDES} Mapper.src Mapper.prd external.provide check/doc/doxygen.provide

check/doc/doxygen.provide: doc/doxygen/html/index.html bin/htmlanchors
      bin/htmlanchors -P doc/doxygen/html/*.html | sort -o $@

check/all.require: ${REQUIRES} Mapper.src Mapper.prd
      ${RM} $@
      sort -u -o $@ ${REQUIRES}

#Tests

test: test/result.tst
test/result.tst: \
   bin/test/run \
   bin/test/modules \
   bin/test/modules_d \
   bin/mapper_d bin/mapper \
   lib/Map-Data.dtd \
   ${TEST_DATA}
      bin/test/run test/result.tst

bin/test: bin/test/modules_d
debug: bin/test/modules_d
bin/test/modules_d: ${TEST_DO} ${MAPPER_DO}
      $(CXX) $(CXXFLAGSDEBUG) $(LDFLAGS) -o $@ ${TEST_DO} ${MAPPER_DO} -lxerces

bin/test: bin/test/modules
bin/test/modules: ${TEST_O} ${MAPPER_O}
      $(CXX) $(LDFLAGS) -o $@ ${TEST_O} ${MAPPER_O} -lxerces

doc: doc/QA/coverage.html
test: doc/QA/coverage.html
doc/QA/coverage.html: bin/test/summarise_coverage \
   Mapper.src ${MAPPER_GCOV} test/coverage/c++/mapper.cpp.gcov
      bin/test/summarise_coverage Mapper.src > $@

#distribution
dist:dist/Mapper_${BASELINE}.tgz
dist/Mapper_${BASELINE}.tgz: Mapper.prd Mapper.src ${DIST_FILES}
      ${RM} $@
      sort -o Mapper.dst Mapper.prd Mapper.src
      ${TAR} -c -T Mapper.dst -f - | gzip -c > $@

#documentation
doc: doc/doxygen/html/index.html
doc/doxygen/html/index.html: Mapper.doxygen \
   ${MAPPER_H} ${MAPPER_CPP} ${TEST_CPP} \
   c++/mapper.cpp
      doxygen Mapper.doxygen

Mapper.doxygen: Mapper.doxygen.in BASELINE \
   ${MAPPER_H} ${TEST_H} ${MAPPER_CPP} ${TEST_CPP} \
   c++/mapper.cpp
      sed \
	   -e '1,$$s/^PROJECT_NUMBER *=.*$$/PROJECT_NUMBER = ${BASELINE}/' \
	   -e '1,$$s:^INPUT *=.*$$:INPUT = ${MAPPER_H} ${TEST_H} ${MAPPER_CPP} ${TEST_CPP} c++/mapper.cpp:' \
	   Mapper.doxygen.in > $@

doc: doc/build/Makefile.html
doc: doc/build/targets.html
doc/build/targets.html: doc/build/Makefile.html
doc/build/Makefile.html: Makefile.in bin/make2html
      bin/make2html Makefile.in doc/build

doc: doc/user/man.html
doc/user/man.html: doc/user/man/man1/mapper.1
      man2html doc/user/man/man1/mapper.1 | \
	sed -e '1,$$s|Content-type: text/html||' \
	-e '1,$$s|<A HREF="http://localhost/cgi-bin/man/man2html">man2html</A>|man2html|' \
	-e '1,$$s|<A HREF="http://localhost/cgi-bin/man/man2html">Return to Main Contents</A>||' > $@

doc: doc/downloading.html
doc/downloading.html: doc/downloading.html.in BASELINE
      sed \
	   -e '1,$$s/BASELINE/${BASELINE}/' \
	   doc/downloading.html.in > $@

Mapper.wc: Mapper.src ${SOURCE_FILES}
      wc ${SOURCE_FILES} > $@

#Cleanup
clean::
      rm -rf doc/doxygen/html/*;
      find check obj test -type f -exec ${RM} {} \;
      find . -type f -name 'core' -exec ${RM} {} \;
      find lib -type f -name 'lib*.a' -exec ${RM} {} \;
      find c++ -type f -name '*.da' -exec ${RM} {} \;
      find depend -type f -name '*.dep' -a ! -name 'all.dep' -exec ${RM} {} \};
      ${RM} Makefile config.cache config.log config.status
      ${RM} bin/test/modules bin/test/modules_d