Skip site navigation (1)Skip section navigation (2)
Date:      11 Aug 2002 06:05:27 -0700
From:      Max Okumoto <okumoto@ucsd.edu>
To:        The Anarcat <anarcat@anarcat.ath.cx>
Cc:        freebsd-libh@FreeBSD.ORG
Subject:   description of bm
Message-ID:  <hfwuqxczqg.fsf_-_@multivac.sdsc.edu>
In-Reply-To: Max Okumoto's message of "11 Aug 2002 06:01:51 -0700"
References:  <hfznwtquws.fsf@multivac.sdsc.edu> <20020810165454.GA34549@lenny.anarcat.ath.cx> <hfy9bdczwg.fsf@multivac.sdsc.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
Max Okumoto <okumoto@ucsd.edu> writes:

> > The Anarcat <anarcat@anarcat.ath.cx> writes:
> >
> > BTW, it would be nice if you could share with us how the heck this bm
> > thing works. :) I'm quite impressed at the compile time of the demo
> > you attached to this mail. Of course there's the whole TCL thing
> > that's skipped and taken care of by SWIG, but still, it's a great
> > improvement.
> 
> I really need to write a man page for it :-)   If you have a chance
> please read Peter Miller's paper,  it's the basis of my program.
> I will send a description to the list in a seperate email.

0. Intro
    The bm (Build Makefile) program is used to help create a project
    wide Makefile.  Using this project wide Makefile, only one
    instance of make is invoked, during the whole build process.
    The good thing about this is that all dependencies are seen by
    make, which means that file modification results in rebuilt of
    all dependent objects, and their intermediary files.

    In addition, since all the dependencies are contained in this
    file you can safely run make in parallel mode to maximal effect.
    (note: make -j4 seems to work best on my 2 processor machine)

    Please read the followin paper to understand the other advantages
    of a whole project makefile.
    http://www.canb.auug.org.au/~millerp/rmch/recu-make-cons-harm-old.html

1. Operation
    The Makefile at the top of the tree, libh/Makefile, drives the
    entire build process. It includes the makefile fragment generated
    by bm.

2. Inputs (module.m4 files)
    The input to bm is a set of module files which describe the
    contents of a directory, and the dependancies to other modules.
    Each module can ether be a library or a program.  (note: shared
    libraries have the same features as a program.)

	%cat libh/lib/HuiTv/module.m4
	library(HuiTv)				# type of module

	cflags(-I/usr/local/include)		# compiler flags used to comple
						# src files in this module

	ldflags(-L/usr/local/lib -ltvision)	# linker flags used if any
						# program uses this module.

	cfile(HuiTv.cc)				# list of src files.
	cfile(HuiTvApplication.cc)
	cfile(HuiTvButton.cc)
	...


	% cat libh/bin/HuiTvTest/module.m4
	program(HuiTvTest)			# type of module

	ldflags(-L/usr/local/lib -ltcl83)	# linker flags

	uselib(Hui)				# depends on library(Hui)
	uselib(HuiTv)

	cfile(main.cc)			# list of src files.

3. Output Makefile.hack
    After parsing all the modules files bm creates the file Makefile.hack.
    This file contains the rules to generate the object files, and
    depencencies computable from just the files and their respective
    types.

	#----------------------------------------
	# build rules for lib/HuiTv
	#----------------------------------------
	LIB_HuiTv_T = ${.OBJDIR}/lib/HuiTv/libHuiTv.a 
	LIB_HuiTv_O = ${.OBJDIR}/lib/HuiTv/HuiTv.o [line truncated]
	LIB_HuiTv_D = ${.OBJDIR}/lib/HuiTv/HuiTv.d [line truncated]
	LIB_HuiTv_CFLAGS = -I/usr/local/include 
	LIB_HuiTv_LDFLAGS = -L/usr/local/lib -ltvision 
	LIB_HuiTv_CLEAN = 

	${.OBJDIR}/lib/HuiTv/HuiTv.d: ${.CURDIR}/lib/HuiTv/HuiTv.cc 
		@echo build dependencies for lib/HuiTv/HuiTv.cc
		@${BUILD_DEP} ${.CURDIR}/ ${.OBJDIR}/ '${.OBJDIR}/lib/HuiTv/HuiTv.d ${.OBJDIR}/lib/HuiTv/HuiTv.o' ${.CURDIR}/lib/HuiTv/HuiTv.cc ${.OBJDIR}/lib/HuiTv/HuiTv.d ${CXX} ${CFLAGS} ${LIB_HuiTv_CFLAGS}

	${.OBJDIR}/lib/HuiTv/HuiTv.o: ${.CURDIR}/lib/HuiTv/HuiTv.cc 
		@echo compile lib/HuiTv/HuiTv.cc
		@${CXX} ${CFLAGS} ${LIB_HuiTv_CFLAGS} -o ${.OBJDIR}/lib/HuiTv/HuiTv.o -c ${.CURDIR}/lib/HuiTv/HuiTv.cc

	[lots of rules deleted]

	${LIB_HuiTv_T}: ${LIB_HuiTv_D} ${LIB_HuiTv_O} 

	${LIB_HuiTv_T}: 
		@echo archive $@
		@rm -f $@
		@${AR} cq $@ \
			`lorder ${LIB_HuiTv_O} | tsort -q`
		@${RANLIB} $@

	PROG_HuiTv_CLEAN: 
		rm -f ${LIB_HuiTv_T}
		rm -f ${LIB_HuiTv_O}
		rm -f ${LIB_HuiTv_CLEAN}

	PROG_HuiTv_CLEAN_DEP: 
		rm -f ${LIB_HuiTv_D}

	clean: PROG_HuiTv_CLEAN PROG_HuiTv_CLEAN_DEP 

	clean_dep: PROG_HuiTv_CLEAN_DEP 

	dep: ${LIB_HuiTv_D} 

	.for DFILE in ${LIB_HuiTv_D}
	.if exists(${DFILE})
	.include "${DFILE}"
	.endif
	.endfor

	#----------------------------------------
	# build rules for bin/HuiTvTest
	#----------------------------------------
	PROG_HuiTvTest_T = ${.OBJDIR}/bin/HuiTvTest/HuiTvTest 
	PROG_HuiTvTest_O = ${.OBJDIR}/bin/HuiTvTest/main.o 
	PROG_HuiTvTest_D = ${.OBJDIR}/bin/HuiTvTest/main.d 
	PROG_HuiTvTest_CFLAGS = 
	PROG_HuiTvTest_L = ${LIB_Hui_T} ${LIB_HuiTv_T} 
	PROG_HuiTvTest_CLEAN = 

	${.OBJDIR}/bin/HuiTvTest/main.d: ${.CURDIR}/bin/HuiTvTest/main.cc 
		@echo build dependencies for bin/HuiTvTest/main.cc
		@${BUILD_DEP} ${.CURDIR}/ ${.OBJDIR}/ '${.OBJDIR}/bin/HuiTvTest/main.d ${.OBJDIR}/bin/HuiTvTest/main.o' ${.CURDIR}/bin/HuiTvTest/main.cc ${.OBJDIR}/bin/HuiTvTest/main.d ${CXX} ${CFLAGS} ${PROG_HuiTvTest_CFLAGS}

	${.OBJDIR}/bin/HuiTvTest/main.o: ${.CURDIR}/bin/HuiTvTest/main.cc 
		@echo compile bin/HuiTvTest/main.cc
		@${CXX} ${CFLAGS} ${PROG_HuiTvTest_CFLAGS} -o ${.OBJDIR}/bin/HuiTvTest/main.o -c ${.CURDIR}/bin/HuiTvTest/main.cc

	${PROG_HuiTvTest_T}: ${PROG_HuiTvTest_D} ${PROG_HuiTvTest_O} ${PROG_HuiTvTest_L} 

	${PROG_HuiTvTest_T}: 
		@echo link $@
		@rm -f $@
		${CXX} ${CFLAGS} -o $@ \
			${PROG_HuiTvTest_O} \
			`lorder ${PROG_HuiTvTest_L} | tsort -q` \
			${LDFLAGS} -L/usr/local/lib -ltcl83 ${LIB_Hui_LDFLAGS} ${LIB_HuiTv_LDFLAGS} 

	PROG_HuiTvTest_CLEAN: 
		rm -f ${PROG_HuiTvTest_T}
		rm -f ${PROG_HuiTvTest_O}
		rm -f ${PROG_HuiTvTest_CLEAN}

	PROG_HuiTvTest_CLEAN_DEP: 
		rm -f ${PROG_HuiTvTest_D}

	clean: PROG_HuiTvTest_CLEAN PROG_HuiTvTest_CLEAN_DEP 

	clean_dep: PROG_HuiTvTest_CLEAN_DEP 

	dep: ${PROG_HuiTvTest_D} 

	targets: ${PROG_HuiTvTest_T} 

	.for DFILE in ${PROG_HuiTvTest_D}
	.if exists(${DFILE})
	.include "${DFILE}"
	.endif
	.endfor



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-libh" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?hfwuqxczqg.fsf_-_>