From owner-freebsd-libh Sun Aug 11 6: 5:54 2002 Delivered-To: freebsd-libh@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id BCE4A37B400 for ; Sun, 11 Aug 2002 06:05:30 -0700 (PDT) Received: from postal.sdsc.edu (postal.sdsc.edu [132.249.20.114]) by mx1.FreeBSD.org (Postfix) with ESMTP id 561E943E42 for ; Sun, 11 Aug 2002 06:05:30 -0700 (PDT) (envelope-from okumoto@SDSC.EDU) Received: from multivac.sdsc.edu (IDENT:dIn8WaVvUuu/PuMtxuxlnmS7itaYtkPC@multivac.sdsc.edu [132.249.20.57]) by postal.sdsc.edu (8.11.6/8.11.6/server/44) with ESMTP id g7BD5T104635; Sun, 11 Aug 2002 06:05:29 -0700 (PDT) Received: by multivac (8.11.6+Sun/1.11-SolarisClient) id g7BD5R216109; Sun, 11 Aug 2002 06:05:27 -0700 (PDT) To: The Anarcat Cc: freebsd-libh@FreeBSD.ORG Subject: description of bm References: <20020810165454.GA34549@lenny.anarcat.ath.cx> From: Max Okumoto Date: 11 Aug 2002 06:05:27 -0700 In-Reply-To: Max Okumoto's message of "11 Aug 2002 06:01:51 -0700" Message-ID: Lines: 172 X-Mailer: Gnus v5.5/XEmacs 20.4 - "Emerald" Sender: owner-freebsd-libh@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Max Okumoto writes: > > The Anarcat 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