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 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244
|
# -*- coding: utf-8 -*-
import os
import commands
import string
EnsureSConsVersion(0, 96)
# ----------------------------------------------------------------------
# Function definitions
# ----------------------------------------------------------------------
def CheckPKGConfig(context):
context.Message('Checking for pkg-config... ')
ret = context.TryAction('pkg-config --version')[0]
context.Result(ret)
return ret
def CheckPKG(context, name):
context.Message('Checking for %s... ' % name)
ret = context.TryAction('pkg-config --exists \'%s\'' % name)[0]
context.Result(ret)
return ret
def CheckCXXVersion(context, name, major, minor):
context.Message('Checking for %s >= %d.%d...' % (name, major, minor))
ret = commands.getoutput('%s -dumpversion' % name)
retval = 0
try:
if ((string.atoi(ret[0]) == major and string.atoi(ret[2]) >= minor)
or (string.atoi(ret[0]) > major)):
retval = 1
except ValueError:
print "No C++ compiler found!"
context.Result(retval)
return retval
# ----------------------------------------------------------------------
# Command-line options
# ----------------------------------------------------------------------
# Parameters are only sticky from scons -> scons install, otherwise they're cleared.
if COMMAND_LINE_TARGETS.count('install') == 1:
opts = Options('build/sconf/scache.conf')
else:
opts = Options()
opts.AddOptions(
BoolOption('debug', 'Compile the program with debug information', 0),
BoolOption('release', 'Compile the program with optimizations', 0),
BoolOption('profile', 'Compile the program with profiling information', 0),
PathOption('PREFIX', 'Compile the program with PREFIX as the root for installation', '/usr/local'),
('FAKE_ROOT', 'Make scons install linuxdcpp under a fake root (for gentoo ebuilds)', '')
)
# ----------------------------------------------------------------------
# Initialization
# ----------------------------------------------------------------------
env = Environment(ENV = os.environ, options = opts)
conf = Configure(env,
custom_tests =
{
'CheckPKGConfig' : CheckPKGConfig,
'CheckPKG' : CheckPKG,
'CheckCXXVersion' : CheckCXXVersion
},
conf_dir = 'build/sconf',
log_file = 'build/sconf/config.log')
if os.environ.has_key('CXX'):
env['CXX'] = os.environ['CXX']
if os.environ.has_key('CXXFLAGS'):
env['CXXFLAGS'] = os.environ['CXXFLAGS'].split()
env.SConsignFile('build/sconf/.sconsign')
opts.Save('build/sconf/scache.conf', env)
Help(opts.GenerateHelpText(env))
# ----------------------------------------------------------------------
# Dependencies
# ----------------------------------------------------------------------
if not env['CXX']:
print 'CXX env variable is not set, attempting to use g++'
env['CXX'] = 'g++'
if not conf.CheckCXXVersion(env['CXX'], 3, 4):
print 'Compiler version check failed. g++ 3.4 or later is needed'
Exit(1)
# Add support for compiler caches to speed-up compilation.
if conf.TryAction(Action('distcc'))[0]:
env.Prepend(CXX = 'distcc ')
print 'Enabling distcc...'
if conf.TryAction(Action('ccache'))[0]:
env.Prepend(CXX = 'ccache ')
print 'Enabling ccache...'
if not conf.CheckPKGConfig():
print 'pkg-config not found.'
Exit(1)
if not conf.CheckPKG('gtk+-2.0 >= 2.6'):
print 'gtk+ >= 2.6 not found.'
Exit(1)
if not conf.CheckPKG('gthread-2.0 >= 2.4'):
print 'gthread >= 2.4 not found.'
Exit(1)
if not conf.CheckPKG('libglade-2.0 >= 2.4'):
print 'libglade >= 2.4 not found.'
Exit(1)
if not conf.CheckHeader('time.h'):
print 'Did not find the header time.h'
print 'Can\'t live without it, sorry'
Exit(1)
if not conf.CheckHeader('signal.h'):
print 'Did not find the header signal.h'
print 'Can\'t live without it, sorry'
Exit(1)
if not conf.CheckHeader('unistd.h'):
print 'Did not find the header unistd.h'
print 'Can\'t live without it, sorry'
Exit(1)
if not conf.CheckLibWithHeader('pthread', 'pthread.h', 'c'):
print 'Did not find the pthread library, exiting!'
print 'Note: You might have the lib but not the headers'
Exit(1)
if not conf.CheckLibWithHeader('z', 'zlib.h', 'c'):
print 'Did not find the z library (gzip/z compression)'
print 'Can\'t live without it, exiting'
print 'Note: You might have the lib but not the headers'
Exit(1)
if not conf.CheckLibWithHeader('bz2', 'bzlib.h', 'c'):
print 'Did not find the bz2 library (bz2 compression)'
print 'Can\'t live without it, exiting'
print 'Note: You might have the lib but not the headers'
Exit(1)
env = conf.Finish()
# ----------------------------------------------------------------------
# Compile and link flags
# ----------------------------------------------------------------------
env.Append(CXXFLAGS = Split('-I. -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64'))
if env['debug']:
env.Append(CXXFLAGS = Split('-g -ggdb -D_DEBUG -Wall'))
env.Append(LDFLAGS = Split('-g -ggdb'))
if env['release']:
env.Append(CXXFLAGS = '-O3')
if env['profile']:
env.Append(CXXFLAGS = '-pg')
env.Append(LDFLAGS= '-pg')
if env['PREFIX']:
env.Append(CXXFLAGS = '-D_DATADIR=\'\"' + env['PREFIX'] + '/share' + '\"\'')
env.ParseConfig('pkg-config --libs libglade-2.0')
env.ParseConfig('pkg-config --libs gthread-2.0')
# ----------------------------------------------------------------------
# Build
# ----------------------------------------------------------------------
build = env.Program(target = 'linuxdcpp', source = [
SConscript('client/SConstruct', exports='env', build_dir='build/client', duplicate=0),
SConscript('linux/SConstruct', exports='env', build_dir='build/gui', duplicate=0)])
Default(build)
# ----------------------------------------------------------------------
# Install
# ----------------------------------------------------------------------
glade_files = [
'glade/downloadqueue.glade',
'glade/favoritehubs.glade',
'glade/finishedtransfers.glade',
'glade/hash.glade',
'glade/hub.glade',
'glade/mainwindow.glade',
'glade/privatemessage.glade',
'glade/publichubs.glade',
'glade/search.glade',
'glade/settingsdialog.glade',
'glade/sharebrowser.glade']
pixmap_files = [
'pixmaps/connect.png',
'pixmaps/dc++.png',
'pixmaps/dc++-fw.png',
'pixmaps/dc++-fw-op.png',
'pixmaps/dc++-op.png',
'pixmaps/download.png',
'pixmaps/favhubs.png',
'pixmaps/FinishedDL.png',
'pixmaps/FinishedUL.png',
'pixmaps/hash.png',
'pixmaps/linuxdcpp.png',
'pixmaps/linuxdcpp-icon.png',
'pixmaps/normal.png',
'pixmaps/normal-fw.png',
'pixmaps/normal-fw-op.png',
'pixmaps/normal-op.png',
'pixmaps/publichubs.png',
'pixmaps/queue.png',
'pixmaps/quit.png',
'pixmaps/search.png',
'pixmaps/settings.png',
'pixmaps/upload.png']
text_files = [
'Changelog.txt',
'Credits.txt',
'License.txt',
'Readme.txt']
env.Alias('install', env.Install(dir = env['FAKE_ROOT'] + env['PREFIX'] + '/share/linuxdcpp/glade', source = glade_files))
env.Alias('install', env.Install(dir = env['FAKE_ROOT'] + env['PREFIX'] + '/share/linuxdcpp/pixmaps', source = pixmap_files))
env.Alias('install', env.Install(dir = env['FAKE_ROOT'] + env['PREFIX'] + '/share/doc/linuxdcpp', source = text_files))
env.Alias('install', env.Install(dir = env['FAKE_ROOT'] + env['PREFIX'] + '/bin', source = 'linuxdcpp'))
|