All pastes #10060 Raw Edit

Miscellany

public text v1 · immutable
#10060 ·published 2005-04-22 03:45 UTC
rendered paste body
# -*- mode: python -*-

import os

OSARCH = os.uname()[0]
PROC = os.uname()[-1]

basic_env = Environment()

basic_env.Append(INSTALL_PREFIX = '')
basic_env.Append(DESTDIR        = '')
basic_env.Append(ASTETCDIR      = '${INSTALL_PREFIX}/etc/asterisk')
basic_env.Append(ASTLIBDIR      = '${INSTALL_PREFIX}/usr/lib/asterisk')
basic_env.Append(ASTVARLIBDIR   = '${INSTALL_PREFIX}/var/lib/asterisk')
basic_env.Append(ASTVARRUNDIR   = '${INSTALL_PREFIX}/var/run')
basic_env.Append(ASTSPOOLDIR    = '${INSTALL_PREFIX}/var/spool/asterisk')
basic_env.Append(ASTLOGDIR      = '${INSTALL_PREFIX}/var/log/asterisk')
basic_env.Append(ASTCONFPATH    = '${ASTETCDIR}/asterisk.conf')
basic_env.Append(ASTMODDIR      = '${ASTLIBDIR}/modules')
basic_env.Append(ASTAGIDIR      = '${ASTVARLIBDIR}/agi-bin')

basic_env.Append(CCFLAGS = '-pipe')
basic_env.Append(CCFLAGS = '-g')
basic_env.Append(CCFLAGS = '-Wall')
basic_env.Append(CCFLAGS = '-Wstrict-prototypes')
basic_env.Append(CCFLAGS = '-Wmissing-prototypes')
basic_env.Append(CCFLAGS = '-Wmissing-declarations')

basic_env.Append(CCFLAGS = '-D_REENTRANT')
basic_env.Append(CCFLAGS = '-D_GNU_SOURCE')
#basic_env.Append(CCFLAGS = '-DMAKE_VALGRIND_HAPPY')


basic_env.Append(CCFLAGS = '-DASTERISK_VERSION=\\"xXx\\"')
basic_env.Append(CCFLAGS = '-DASTERISK_VERSION_NUM=999999')
basic_env.Append(CCFLAGS = '-DINSTALL_PREFIX=\\"\\"')
basic_env.Append(CCFLAGS = '-DASTETCDIR=\\"${ASTETCDIR}\\"')
basic_env.Append(CCFLAGS = '-DASTLIBDIR=\\"${ASTLIBDIR}\\"')
basic_env.Append(CCFLAGS = '-DASTVARLIBDIR=\\"${ASTVARLIBDIR}\\"')
basic_env.Append(CCFLAGS = '-DASTVARRUNDIR=\\"${ASTVARRUNDIR}\\"')
basic_env.Append(CCFLAGS = '-DASTSPOOLDIR=\\"${ASTSPOOLDIR}\\"')
basic_env.Append(CCFLAGS = '-DASTLOGDIR=\\"${ASTLOGDIR}\\"')
basic_env.Append(CCFLAGS = '-DASTCONFPATH=\\"${ASTCONFPATH}\\"')
basic_env.Append(CCFLAGS = '-DASTMODDIR=\\"${ASTMODDIR}\\"')
basic_env.Append(CCFLAGS = '-DASTAGIDIR=\\"${ASTAGIDIR}\\"')

if PROC == 'ppc':
    basic_env.Append(CCFLAGS = '-fsigned-char')

if OSARCH == 'FreeBSD':
    OSVERSION = long(os.popen('make -V OSVERSION -f /usr/share/mk/bsd.port.subdir.mk').read())
    if OSVERSION < 500016:
        basic_env.Append(CCFLAGS = '-D_THREAD_SAFE')
    if OSVERSION < 502102:
        basic_env.Append(LIBS = 'c_r')
    else:
        basic_env.Append(CCFLAGS = '-pthread')
    basic_env.Append(CPPPATH = '/usr/local/include')

if OSARCH == 'NetBSD':
    basic_env.Append(CCFLAGS = '-pthread')
    basic_env.Append(CPPPATH = ['/usr/local/include', '/usr/pkg/include'])
    
if OSARCH == 'OpenBSD':
    basic_env.Append(CCFLAGS = '-pthread')

if OSARCH == 'SunOS':
    basic_env.Append(CCFLAGS = '-Wcast-align')
    basic_env.Append(CCFLAGS = '-DSOALRIS')

# If you are running a radio application, define RADIO_RELAX so that the DTMF
# will be received more reliably
#basic_env.Append(CCFLAGS = '-DRADIO_RELAX')

# If you don't have a lot of memory (e.g. embedded Asterisk), define LOW_MEMORY
# to reduce the size of certain static buffers
#basic_env.Append(CCFLAGS = '-DLOW_MEMORY')

# Optional debugging parameters
#basic_env.Append(CCFLAGS = '-DDEBUG_THREADS')
#basic_env.Append(CCFLAGS = '-DDO_CRASH')
#basic_env.Append(CCFLAGS = '-DDETECT_DEADLOCKS')


# Uncomment next one to enable ast_frame tracing (for debugging)
#basic_env.Append(CCFLAGS = '-DTRACE_FRAMES')

# Uncomment next one to enable malloc debugging
# You can view malloc debugging with:
#   *CLI> show memory allocations [filename]
#   *CLI> show memory summary [filename]
#
#basic_env.Append(CCFLAGS = '-include #/include/asterisk/astmm.h' % os.getcwd())

#Uncomment this to use the older DSP routines
#OLD_DSP_ROUTINES=#-DOLD_DSP_ROUTINES

######### More GSM codec optimization
######### Uncomment to enable MMXTM optimizations for x86 architecture CPU's
######### which support MMX instructions.  This should be newer pentiums,
######### ppro's, etc, as well as the AMD K6 and K7.
#K6OPT  = -DK6OPT

# Original busydetect routine
#BUSYDETECT = -DBUSYDETECT
# Improved busydetect routine, comment the previous one if you use this one
basic_env.Append(CCFLAGS = '-DBUSYDETECT_MARTIN')
# Detect the busy signal looking only at tone lengths
# For example if you have 3 beeps 100ms tone, 100ms silence separated by 500 ms of silence
#BUSYDETECT=-DBUSYDETECT_TONEONLY
# Inforce the detection of busy singal (get rid of false hangups)
# Don't use together with -DBUSYDETECT_TONEONLY
#BUSYDETECT=-DBUSYDETECT_COMPARE_TONE_AND_SILENCE


basic_env.Append(CCFLAGS = '-fomit-frame-pointer')

conf = Configure(basic_env)

if conf.CheckCHeader('linux/zaptel.h'):
    conf.env.Append(CCFLAGS = ['-DZAPTEL_OPTIMIZATIONS'])

if conf.CheckCHeader('osp/osp.h'):
    conf.env.Append(CCFLAGS = ['-DOSP_SUPPORT'])
    conf.env.Append(CPPPATH = ['/usr/include/osp'])
    
basic_env = conf.Finish()

    
basic_env.Append(CPPPATH = ['#/include'])


#
# Build environment for main asterisk binary
#

asterisk_env = basic_env.Copy()

asterisk_objects = []

conf = Configure(asterisk_env)

strcompat = []
# SunOS is missing strsep and strtoq
if not conf.CheckFunc('strsep') or not conf.CheckFunc('strtoq'):
    strcompat = asterisk_env.StaticObject('strcompat.c')
    asterisk_objects.append(strcompat)

if not conf.CheckFunc('poll'):
    asterisk_objects.append(asterisk_env.StaticObject('poll.c'))

if not conf.CheckLib(library = ['dl'], symbol = 'dlopen', autoadd = 1):
    asterisk_objects.append(asterisk_env.StaticObject('dlfcn.c'))

if not conf.CheckLib(library = ['resolv'], symbol = 'res_query', autoadd = 1):
    Exit(1)

if not conf.CheckLib(library = ['pthread'], symbol = 'pthread_create', autoadd = 1):
    Exit(1)

asterisk_env = conf.Finish()

asterisk_env.Append(LIBS = ['ncurses', 'm'])

if OSARCH == 'Linux':
    asterisk_env.Append(LIBS = ['resolv'])

if OSARCH == 'Darwin':
    asterisk_env.Append(LIBS = ['resolv'])
    asterisk_env.Append(CCFLAGS = ['-D__OSX__'])
    
if OSARCH == 'FreeBSD':
    asterisk_env.Append(LIBS = ['crypto'])

if OSARCH == 'NetBSD':
    asterisk_env.Append(LIBS = ['crypto'])
    asterisk_env.Append(LIBPATH = ['/usr/local/lib', '/usr/pkg/lib'])

if OSARCH == 'OpenBSD':
    asterisk_env.Append(LIBS = ['crypto', 'pthread'])

if OSARCH == 'SunOS':
    asterisk_env.Append(LIBS = ['nsl', 'socket', 'resolv'])
    asterisk_env.Append(LIBPATH = ['/usr/local/ssl/lib'])
    
asterisk_sources = ['acl.c',
                    'aescrypt.c',
                    'aeskey.c',
                    'aestab.c',
                    'alaw.c',
                    'app.c',
                    'asterisk.c',
                    'astmm.c',
                    'autoservice.c',
                    'callerid.c',
                    'cdr.c',
                    'channel.c',
                    'chanvars.c',
                    'cli.c',
                    'config.c',
                    'config_old.c',
                    'db.c',
                    'dns.c',
                    'dnsmgr.c',
                    'dsp.c',
                    'enum.c',
                    'file.c',
                    'frame.c',
                    'fskmodem.c',
                    'image.c',
                    'indications.c',
                    'io.c',
                    'jitterbuf.c',
                    'loader.c',
                    'logger.c',
                    'manager.c',
                    'pbx.c',
                    'plc.c',
                    'privacy.c',
                    'rtp.c',
                    'say.c',
                    'sched.c',
                    'srv.c',
                    'tdd.c',
                    'term.c',
                    'translate.c',
                    'ulaw.c',
                    'utils.c']

for asterisk_source in asterisk_sources:
    asterisk_objects.append(asterisk_env.StaticObject(asterisk_source))

md5 = asterisk_env.StaticObject('md5.c')
asterisk_objects.append(md5)

#asterisk_env.Depends('build.h', '.version')
asterisk_env.Command('build.h', 'make_build_h', './make_build_h')

asterisk_objects.append(asterisk_env.CFile('ast_expr.y', YACCFLAGS=['--name-prefix=ast_yy']))

asterisk_objects.append(SConscript('editline/SConscript', 'basic_env'))
asterisk_objects.append(SConscript('db1-ast/SConscript', 'basic_env'))
asterisk_objects.append(SConscript('stdtime/SConscript', 'basic_env'))

asterisk_env.Program('asterisk', asterisk_objects, LINKFLAGS=['-Wl,-E'])

#TODO: fix linkflags for alternate platforms
basic_module_env = basic_env.Copy(SHLIBPREFIX='', LINKFLAGS=['-Xlinker','-x'])

SConscript('apps/SConscript', ['basic_module_env', 'basic_env'])
SConscript('cdr/SConscript', ['basic_module_env', 'basic_env'])
SConscript('channels/SConscript', ['basic_module_env', 'basic_env'])
SConscript('codecs/SConscript', ['basic_module_env', 'basic_env'])
SConscript('formats/SConscript', ['basic_module_env', 'basic_env'])
SConscript('pbx/SConscript', ['basic_module_env', 'basic_env'])
SConscript('res/SConscript', ['basic_module_env', 'basic_env'])
SConscript('utils/SConscript', ['basic_module_env', 'basic_env', 'md5', 'strcompat'])