Skip to content
Snippets Groups Projects
wscript 12.5 KiB
Newer Older
#! /usr/bin/env python
# encoding: utf-8

import Build
nedko's avatar
nedko committed
import re
import os

def configure(conf):
    conf.check_cc(header_name='samplerate.h', define_name="HAVE_SAMPLERATE")
   
    if conf.is_defined('HAVE_SAMPLERATE'):
        conf.env['LIB_SAMPLERATE'] = ['samplerate']

    conf.env['BUILD_NETLIB'] = conf.is_defined('HAVE_SAMPLERATE')
    conf.env['BUILD_ADAPTER'] = conf.is_defined('HAVE_SAMPLERATE')

sletz's avatar
sletz committed
def create_jack_process_obj(bld, target, sources, uselib = None):
    process = bld.new_task_gen('cxx', 'shlib')
sletz's avatar
sletz committed
    process.env['shlib_PATTERN'] = '%s.so'
    process.defines  = ['HAVE_CONFIG_H','SERVER_SIDE']
    if bld.env['IS_MACOSX']:
        env_includes = ['../macosx', '../posix', '../macosx/coreaudio']
    if bld.env['IS_LINUX']:
	env_includes = ['../linux', '../posix', '../linux/alsa']
    if bld.env['IS_SUN']:
        env_includes = ['../solaris', '../posix', '../solaris/oss']
    process.includes = ['.'] + env_includes + ['jack', '..']
sletz's avatar
sletz committed
    process.name     = target
    process.target   = target
    process.source   = sources
    if bld.env['IS_LINUX']:
        process.env.append_value("CPPFLAGS", "-fvisibility=hidden")
    if bld.env['IS_MACOSX']:
        process.env.append_value("CPPFLAGS", "-mmacosx-version-min=10.4 -arch i386 -arch ppc -arch x86_64")
        #process.env.append_value("LINKFLAGS", "-arch i386 -arch ppc -arch x86_64")
        process.env.append_value("CPPFLAGS", "-fvisibility=hidden")
    process.install_path = '${ADDON_DIR}/'
sletz's avatar
sletz committed
    process.uselib_local = uselib.name
sletz's avatar
sletz committed
    return process

nedko's avatar
nedko committed
    common_libsources = [
        'JackActivationCount.cpp',
        'JackAPI.cpp',
        'JackClient.cpp',
        'JackConnectionManager.cpp',
nedko's avatar
nedko committed
        'ringbuffer.c',
sletz's avatar
sletz committed
	'JackException.cpp',
        'JackFrameTimer.cpp',
        'JackGraphManager.cpp',
        'JackPort.cpp',
        'JackPortType.cpp',
        'JackAudioPort.cpp',
        'JackMidiPort.cpp',
        'JackMidiAPI.cpp',
nedko's avatar
nedko committed
        'JackEngineControl.cpp',
	'JackGenericClientChannel.cpp',
        'shm.c',
        'JackGlobals.cpp',
        'JackDebugClient.cpp',
        'JackTransportEngine.cpp',
        'timestamps.c',
        'JackTools.cpp',
        'JackMessageBuffer.cpp',
        'JackEngineProfiling.cpp',
sletz's avatar
sletz committed
    uselib = ["PTHREAD", "CELT"]
    if bld.env['IS_LINUX']:
            '../posix/JackPosixThread.cpp',
            '../posix/JackPosixSemaphore.cpp',
            '../posix/JackProcessSync.cpp',
sletz's avatar
sletz committed
	    '../posix/JackPosixMutex.cpp',
            '../posix/JackSocket.cpp',
            '../linux/JackLinuxTime.c',
        includes = ['../linux', '../posix'] + includes
        uselib.append('DL')
    if bld.env['IS_SUN']:
        common_libsources += [
           '../posix/JackPosixThread.cpp',
           '../posix/JackFifo.cpp',
           '../posix/JackProcessSync.cpp',
sletz's avatar
sletz committed
           '../posix/JackPosixMutex.cpp',
           '../posix/JackSocket.cpp',
           '../solaris/JackSolarisTime.c',
           ]
        includes = ['../solaris', '../posix'] + includes
        uselib.append('RT')

    if bld.env['IS_MACOSX']:
            '../posix/JackProcessSync.cpp',
            '../posix/JackPosixThread.cpp',
            '../macosx/JackMachThread.cpp',
            '../macosx/JackMachSemaphore.cpp',
sletz's avatar
sletz committed
            '../posix/JackSocket.cpp',
            '../macosx/JackMachTime.c',
        includes = ['../macosx', '../macosx/RPC', '../posix'] + includes
    serverlib = bld.new_task_gen('cxx', 'shlib')
nedko's avatar
nedko committed
    serverlib.features.append('cc')
    serverlib.defines = ['HAVE_CONFIG_H','SERVER_SIDE']
nedko's avatar
nedko committed
    serverlib.name         = 'serverlib'
    serverlib.target       = 'jackserver'
    serverlib.install_path = '${LIBDIR}'
nedko's avatar
nedko committed
    serverlib.source = [] + common_libsources
    serverlib.source += [
        'JackAudioDriver.cpp',
sletz's avatar
sletz committed
        'JackMidiDriver.cpp',
nedko's avatar
nedko committed
        'JackDriver.cpp',
        'JackEngine.cpp',
        'JackExternalClient.cpp',
        'JackFreewheelDriver.cpp',
        'JackInternalClient.cpp',
        'JackServer.cpp',
        'JackThreadedDriver.cpp',
        'JackRestartThreadedDriver.cpp',
        'JackWaitThreadedDriver.cpp',
nedko's avatar
nedko committed
        'JackServerAPI.cpp',
        'JackDriverLoader.cpp',
        'JackServerGlobals.cpp',
sletz's avatar
sletz committed
        'JackControlAPI.cpp',
moret's avatar
moret committed
        'JackNetInterface.cpp',
sletz's avatar
sletz committed
    	'JackRequestDecoder.cpp',
sletz's avatar
sletz committed
        'JackMidiAsyncQueue.cpp',
        'JackMidiAsyncWaitQueue.cpp',
        'JackMidiBufferReadQueue.cpp',
        'JackMidiBufferWriteQueue.cpp',
        'JackMidiRawInputWriteQueue.cpp',
        'JackMidiRawOutputWriteQueue.cpp',
        'JackMidiReadQueue.cpp',
        'JackMidiReceiveQueue.cpp',
        'JackMidiSendQueue.cpp',
        'JackMidiUtil.cpp',
        'JackMidiWriteQueue.cpp'
nedko's avatar
nedko committed
        ]
    if bld.env['IS_LINUX']:
            '../posix/JackSocketServerChannel.cpp',
            '../posix/JackSocketNotifyChannel.cpp',
            '../posix/JackSocketServerNotifyChannel.cpp',
            '../posix/JackNetUnixSocket.cpp',
    if bld.env['IS_SUN']:
        serverlib.source += [
            '../posix/JackSocketServerChannel.cpp',
            '../posix/JackSocketNotifyChannel.cpp',
            '../posix/JackSocketServerNotifyChannel.cpp',
            '../posix/JackNetUnixSocket.cpp',
            ]

    if bld.env['IS_MACOSX']:
sletz's avatar
sletz committed
            '../posix/JackSocketServerChannel.cpp',
            '../posix/JackSocketNotifyChannel.cpp',
            '../posix/JackSocketServerNotifyChannel.cpp',
            '../posix/JackNetUnixSocket.cpp',
    serverlib.vnum = bld.env['JACK_API_VERSION']

    if bld.env['IS_LINUX']:
        serverlib.env.append_value("CPPFLAGS", "-fvisibility=hidden")

    if bld.env['IS_MACOSX']:
        serverlib.env.append_value("CPPFLAGS", "-fvisibility=hidden")
        serverlib.env.append_value("CPPFLAGS", "-mmacosx-version-min=10.4 -arch i386 -arch ppc -arch x86_64")
        #serverlib.env.append_value("LINKFLAGS", "-framework CoreAudio -framework vecLib -single_module -arch i386 -arch ppc -arch x86_64")
sletz's avatar
sletz committed
        serverlib.env.append_value("LINKFLAGS", "-framework CoreAudio -framework CoreFoundation -framework vecLib -single_module")
        serverlib.env.append_value("LINKFLAGS", "-compatibility_version 1 -current_version 1")

    if bld.env['IS_SUN']:
        serverlib.env.append_value("LINKFLAGS", "-lnsl -lsocket")
    if bld.env['BUILD_NETLIB'] == True:
        netlib = bld.new_task_gen('cxx', 'shlib')
        netlib.features.append('cc')
        netlib.defines = ['HAVE_CONFIG_H','SERVER_SIDE']
        netlib.includes = includes
        netlib.name         = 'netlib'
        netlib.target       = 'jacknet'
        netlib.uselib = ['SAMPLERATE', 'CELT', 'PTHREAD' , 'RT']
        netlib.install_path = '${LIBDIR}'
        netlib.source = [
            'JackNetAPI.cpp',
            'JackNetInterface.cpp',
            'JackNetTool.cpp',
sletz's avatar
sletz committed
	    'JackException.cpp',
            'JackAudioAdapterInterface.cpp',
            'JackLibSampleRateResampler.cpp',
            'JackResampler.cpp',
            'JackGlobals.cpp',
            'ringbuffer.c']

        if bld.env['IS_LINUX']:
            netlib.source += ['../posix/JackNetUnixSocket.cpp','../posix/JackPosixThread.cpp', '../linux/JackLinuxTime.c']
            netlib.env.append_value("CPPFLAGS", "-fvisibility=hidden")

        if bld.env['IS_SUN']:
            netlib.source += ['../posix/JackNetUnixSocket.cpp','../posix/JackPosixThread.cpp', '../solaris/JackSolarisTime.c']
            netlib.env.append_value("CPPFLAGS", "-fvisibility=hidden")
        if bld.env['IS_MACOSX']:
            netlib.source += ['../posix/JackNetUnixSocket.cpp','../posix/JackPosixThread.cpp', '../macosx/JackMachThread.cpp', '../macosx/JackMachTime.c']
            netlib.env.append_value("LINKFLAGS", "-framework CoreAudio -single_module")
        netlib.vnum = bld.env['JACK_API_VERSION']
    clientlib = bld.new_task_gen('cxx', 'shlib')
nedko's avatar
nedko committed
    clientlib.features.append('cc')
    clientlib.defines = 'HAVE_CONFIG_H'
    clientlib.install_path = '${LIBDIR}'
sletz's avatar
sletz committed
    if bld.env['BUILD_JACKDBUS'] == True and bld.env['BUILD_JACKD'] == False:
nedko's avatar
nedko committed
        clientlib.uselib.append('DBUS-1')
nedko's avatar
nedko committed
    clientlib.name         = 'clientlib'
    clientlib.target       = 'jack'
    clientlib.source = [] + common_libsources
    clientlib.source += [
        'JackLibClient.cpp',
        'JackLibAPI.cpp',
        ]
    if bld.env['IS_LINUX']:
            '../posix/JackSocketClientChannel.cpp',
            '../posix/JackPosixServerLaunch.cpp',
    if bld.env['IS_SUN']:
        clientlib.source += [
            '../posix/JackSocketClientChannel.cpp',
            '../posix/JackPosixServerLaunch.cpp',
            ]

    if bld.env['IS_MACOSX']:
sletz's avatar
sletz committed
            '../posix/JackSocketClientChannel.cpp',
            '../posix/JackPosixServerLaunch.cpp',
    clientlib.vnum = bld.env['JACK_API_VERSION']

    if bld.env['IS_LINUX']:
        clientlib.env.append_value("CPPFLAGS", "-fvisibility=hidden")
    
    if bld.env['IS_MACOSX']:
        clientlib.env.append_value("CPPFLAGS", "-fvisibility=hidden")
        clientlib.env.append_value("CPPFLAGS", "-mmacosx-version-min=10.4 -arch i386 -arch ppc -arch x86_64")
        #clientlib.env.append_value("LINKFLAGS", "-framework CoreAudio -framework vecLib -single_module -arch i386 -arch ppc -arch x86_64"
        clientlib.env.append_value("LINKFLAGS", "-framework CoreAudio -framework vecLib -single_module")
sletz's avatar
sletz committed
        clientlib.env.append_value("LINKFLAGS", "-compatibility_version 1 -current_version 1")
    if bld.env['IS_SUN']:
        clientlib.env.append_value("LINKFLAGS", "-lnsl -lsocket")

sletz's avatar
sletz committed
    if bld.env['BUILD_WITH_32_64']:
        print "create 32bit lib..."
        clientlib32bit = clientlib.clone('lib32')
  
sletz's avatar
sletz committed
    create_jack_process_obj(bld, 'netmanager', 'JackNetManager.cpp', serverlib)

    create_jack_process_obj(bld, 'profiler', 'JackProfiler.cpp', serverlib)

    net_adapter_sources = [
sletz's avatar
sletz committed
        'JackResampler.cpp',
        'JackLibSampleRateResampler.cpp',
        'JackAudioAdapter.cpp',
        'JackAudioAdapterInterface.cpp',
        'JackNetAdapter.cpp',
        ]

    if bld.env['BUILD_ADAPTER'] == True:
        process = create_jack_process_obj(bld, 'netadapter', net_adapter_sources, serverlib)
        process.uselib = 'SAMPLERATE'

    audio_adapter_sources = [
        'JackResampler.cpp',
        'JackLibSampleRateResampler.cpp',
        'JackAudioAdapter.cpp',
sletz's avatar
sletz committed
        'JackAudioAdapterInterface.cpp',
        'JackAudioAdapterFactory.cpp',
sletz's avatar
sletz committed

    if bld.env['BUILD_ADAPTER'] and bld.env['IS_MACOSX']:
         audio_adapter_sources += ['../macosx/coreaudio/JackCoreAudioAdapter.cpp']
         process = create_jack_process_obj(bld, 'audioadapter', audio_adapter_sources, serverlib)
         process.env.append_value("LINKFLAGS", "-framework CoreAudio -framework AudioUnit -framework AudioToolbox -framework CoreServices")
         process.uselib = 'SAMPLERATE'
moret's avatar
moret committed

sletz's avatar
sletz committed
    if bld.env['BUILD_ADAPTER'] and bld.env['IS_LINUX'] and bld.env['BUILD_DRIVER_ALSA']:
         audio_adapter_sources += ['../linux/alsa/JackAlsaAdapter.cpp']
         process = create_jack_process_obj(bld, 'audioadapter', audio_adapter_sources, serverlib)
         process.uselib = ['ALSA', 'SAMPLERATE']
moret's avatar
moret committed

    if bld.env['BUILD_ADAPTER'] and bld.env['IS_SUN']:
         audio_adapter_sources += ['../solaris/oss/JackOSSAdapter.cpp', 'memops.c']
         process = create_jack_process_obj(bld, 'audioadapter', audio_adapter_sources, serverlib)
         process.uselib = 'SAMPLERATE'

    #audio_adapter_sources += ['../windows/JackPortAudioAdapter.cpp']
    #process = create_jack_process_obj(bld, 'audioadapter', audio_adapter_sources, serverlib)
moret's avatar
moret committed

    bld.install_files('${PREFIX}/include/jack', 'jack/*.h')
nedko's avatar
nedko committed

    # process jack.pc.in -> jack.pc
    import misc
    obj = bld.new_task_gen('subst')
nedko's avatar
nedko committed
    obj.source = '../jack.pc.in'
    obj.target = 'jack.pc'
    obj.dict = {'PREFIX': bld.env['PREFIX'],
                'LIBDIR': bld.env['LIBDIR'],
                'INCLUDEDIR': os.path.normpath(bld.env['PREFIX'] + '/include'),
nedko's avatar
nedko committed
                'SERVERLIB': serverlib.target,
                'JACK_VERSION': bld.env['JACK_VERSION'],
nedko's avatar
nedko committed
                }
    obj.install_path = '${LIBDIR}/pkgconfig/'
    obj.fun = misc.subst_func