|
|
Example Bakefile
#
# bakefile -- bake `pone' and `ptwo' projects
#
generated = []
Rule( Phony, 'default', 'all', '')
#
# Sample program targets
#
Var( 'CC', 'gcc')
Rule( Phony, 'all', 'pone ptwo', '')
r1 = Rule( File, 'pone', 'pone.o ffirst.o fsecond.o', '${CC} -o $@ $&')
r2 = Rule( File, 'ptwo', 'ptwo.o ffirst.o fthird.o', '${CC} -o $@ $&')
generated += [ r1.name, r2.name]
Suffix( File, '.o', '.c', '${CC} -o $@ -c $&')
Suffix( File, '.c', Cpp().findheaders)
#
# Installation targets
#
Suffix( File, '.gz', '', 'gzip -c -9 $& >$@')
Var( 'PREFIX', '/usr/local')
Var( 'EPREFIX', '${PREFIX}')
Var( 'BINDIR', '${EPREFIX}/bin')
Var( 'MANDIR', '${PREFIX}/man')
class ProgInst( Installer):
bins = [ 'pone', 'ptwo']
mans = [ 'pone.1.gz', 'ptwo.1.gz']
generated = bins + mans
def execfiles( self):
d = { '${BINDIR}' : ProgInst.bins}
for m in ProgInst.mans:
section = Ext.split( Ext.split( m)[ -2])[ -1]
mansect = '${MANDIR}/man%s' % section
d.setdefault( mansect, [])
d[ mansect] += [ m]
return d
def conffiles( self):
return {
'/etc': 'etc/ponetwo', # a directory
'/etc/ponetwo': 'ponetworc' # a file
}
pi = ProgInst()
# This instantiates the rules `check', `install',
# `remove', `purge' and `package'.
pi.stdrules()
generated += ProgInst.generated
#
# Cleanup targets
#
Rule( Phony, 'clear', '', [
'rm -f ' + ' '.join( generated)])
Rule( Phony, 'clean', '', [
'rm -f *~ \\#*#',
'rm -f *.o'])
Rule( Phony, 'wipe', 'clear clean', '')
#
# Archiving target
#
def tar( name, macros):
a = Archive( fakeroot = True)
a.targzall()
Rule( Phony, 'tar', 'wipe', tar)
# vim: syntax=python
# Local Variables:
# mode: Python
# End:
<previous next>
|