1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
|
import os
import sys
env = Environment( ENV = os.environ );
config = env.Configure();
# env.Append( CCFLAGS = flags, CPPPATH = [ "../src" ] );
print "Use 'scons -h' for help"
prefix = '/usr/local/games'
bin = '/usr/local/bin'
if sys.platform == 'win32':
try:
Execute(Mkdir('gen'))
except:
pass
prefix = 'gen'
bin = 'gen'
opts = Options( 'rafkill.conf' )
opts.Add( PathOption('prefix', 'Directory to install under', prefix ) )
opts.Add( PathOption('bin', 'Directory where symlinked executable should go', bin ) )
opts.Update( env )
opts.Save( 'rafkill.conf', env )
Help( opts.GenerateHelpText( env ) )
if False:
env.Append( CCFLAGS = [ '-Werror' ] )
if False:
env.Append( CCFLAGS = [ '-pg' ] )
env.Append( LINKFLAGS = [ '-pg' ] )
env.BuildDir( 'build/', 'src/' )
env.Append( LIBS = [ 'aldmb', 'dumb' ] );
if sys.platform == 'win32':
env.Append( CCFLAGS = [ '-DWINDOWS' ] )
env.Append( LIBS = [ 'alleg', 'pthreadGC2' ] )
else:
env.ParseConfig( 'allegro-config --libs' );
env.Append( LIBS = [ 'pthread' ] )
# print "Install directory = $prefix"
# print "Directory where symlinked binary will go = $bin"
flags = [ '-g3', '-Wall', '-fno-rtti', '-Woverloaded-virtual', '-O2', '-DINSTALL_DIR=\\\"$prefix\\\"' ];
env.Append( CCFLAGS = flags, CPPPATH = [ "build" ] )
# SConscript( 'src/SConscript', build_dir='build', exports = 'env' );
sources = SConscript( 'src/SConscript', exports = 'env' );
rafkill = env.Program( 'rafkill', map( lambda x: 'build/' + x, sources ) )
def installReminder( target, source, env ):
print
print "Run 'scons install' to install rafkill"
return 0
def ShutUp( target, source, env ):
pass
env.AddPostAction( rafkill, Action( installReminder, strfunction=ShutUp ) )
env.Default( rafkill )
# rafkill = env.Install( '.', 'build/rafkill' );
# env.Default( rafkill )
# package = env.Install( '.', 'source.tar' )
env.Alias( 'package', 'src/source.tar' )
def install( target, source, env ):
print "Installing!"
return 0
installDir = '$prefix/'
## Install binary
env.Install( installDir + 'rafkill', rafkill )
def addData( file ):
env.Install( installDir + 'rafkill/data', "data/%s" % file )
map( lambda x: addData( x ), Split( """
1.pck
2.pck
3.pck
beast.fnt
buy-menu.pcx
buy-scene.pcx
fonts.dat
intro.mod
level1.lev
level2.lev
level3.lev
level4.lev
level5.lev
level6.lev
level7.lev
level8.lev
logosmoot.pcx
raptor.dat
sound.dat
table.col
vulture.fnt
"""));
def addMusic( file ):
env.Install( installDir + 'rafkill/music', "music/%s" % file )
def songFile( song ):
import re
types = [ '.*\.s3m$', '.*\.mod$', '.*\.it$', '.*\.xm$' ]
for type in types:
if re.compile( type ).match( song.lower() ):
return True
return False
for i in os.listdir( 'music' ):
if songFile( i ):
addMusic( i )
installSymlink = '$bin/'
def makeSymLink( target, source, env ):
# srcFile = os.path.abspath( str(source[ 0 ]) )
srcFile = source[ 0 ]
env.Execute( Action( 'ln -s %s %s' % (srcFile,target[0]) ) )
# SymLink = Builder( action = "ln -s $SOURCES $TARGET" )
SymLink = Builder( action = Action( makeSymLink ) )
env.Append( BUILDERS = { 'SymLink' : SymLink } )
# link = env.SymLink( target = 'rafkill-link', source = '$prefix/rafkill/rafkill' )
# env.InstallAs( target = installSymlink + 'rafkill', source = link )
# env.Install( installSymlink + 'rafkill', link )
# print 'Absolute path = ' + os.path.abspath( '$prefix/rafkill/rafkill' )
# xpath = os.path.abspath( 'rafkill' )
xpath = '$prefix/rafkill/rafkill'
# print "XPath = " + xpath
# env.SymLink( '$bin/rafkill', os.path.abspath( '$prefix/rafkill/rafkill' ) )
if sys.platform != 'win32':
env.SymLink( '$bin/rafkill', xpath )
env.Alias( 'install', installDir )
env.Alias( 'install', installSymlink )
|