1import os.path
2
3Import("env", "buildDir")
4env.Append(CPPPATH="include")
5
6ApiVer = "0.0.12"
7Major, Minor, Micro = [int(c) for c in ApiVer.split(".")]
8
9sharedLibs = []
10staticLibs = []
11Import("Platform", "Posix")
12if Platform in Posix:
13    env["SHLIBSUFFIX"] = ".so.%d.%d.%d" % (Major, Minor, Micro)
14    soFile = "libportaudiocpp.so"
15    if Platform != 'darwin':
16        env.AppendUnique(SHLINKFLAGS="-Wl,-soname=%s.%d" % (soFile, Major))
17
18    # Create symlinks
19    def symlink(env, target, source):
20        trgt = str(target[0])
21        src = str(source[0])
22        if os.path.islink(trgt) or os.path.exists(trgt):
23            os.remove(trgt)
24        os.symlink(os.path.basename(src), trgt)
25    lnk0 = env.Command(soFile + ".%d" % (Major), soFile + ".%d.%d.%d" % (Major, Minor, Micro), symlink)
26    lnk1 = env.Command(soFile, soFile + ".%d" % (Major), symlink)
27    sharedLibs.append(lnk0)
28    sharedLibs.append(lnk1)
29
30src = [os.path.join("source", "portaudiocpp", "%s.cxx" % f) for f in ("BlockingStream", "CallbackInterface", \
31    "CallbackStream", "CFunCallbackStream","CppFunCallbackStream", "Device",
32    "DirectionSpecificStreamParameters", "Exception", "HostApi", "InterfaceCallbackStream",
33    "MemFunCallbackStream", "Stream", "StreamParameters", "System", "SystemDeviceIterator",
34    "SystemHostApiIterator")]
35env.Append(LIBS="portaudio", LIBPATH=buildDir)
36sharedLib = env.SharedLibrary("portaudiocpp", src, LIBS=["portaudio"])
37staticLib = env.Library("portaudiocpp", src, LIBS=["portaudio"])
38sharedLibs.append(sharedLib)
39staticLibs.append(staticLib)
40
41headers = Split("""AutoSystem.hxx
42                   BlockingStream.hxx
43                   CallbackInterface.hxx
44                   CallbackStream.hxx
45                   CFunCallbackStream.hxx
46                   CppFunCallbackStream.hxx
47                   Device.hxx
48                   DirectionSpecificStreamParameters.hxx
49                   Exception.hxx
50                   HostApi.hxx
51                   InterfaceCallbackStream.hxx
52                   MemFunCallbackStream.hxx
53                   PortAudioCpp.hxx
54                   SampleDataFormat.hxx
55                   Stream.hxx
56                   StreamParameters.hxx
57                   SystemDeviceIterator.hxx
58                   SystemHostApiIterator.hxx
59                   System.hxx
60                   """)
61if env["PLATFORM"] == "win32":
62    headers.append("AsioDeviceAdapter.hxx")
63headers = [File(os.path.join("include", "portaudiocpp", h)) for h in headers]
64
65Return("sharedLibs", "staticLibs", "headers")
66