f09dd22812527cee53f1e184dcba75d07f8e27fc
[deb_shairplay.git] / src / SConscript
1 Import('env')
2
3 files = [Glob('lib/*.c'),Glob('lib/alac/*.c'),Glob('lib/crypto/*.c')]
4
5 env.Append(CPPPATH = ['include'])
6
7 # Set up the environment for compiling the libraries
8 libenv = env.Clone()
9 libenv.Append(CPPPATH = ['lib'])
10
11 # Make sure libraries are compiled with DLL_EXPORT on windows
12 if libenv['PLATFORM'] == 'win32' or GetOption('mingw32') or GetOption('mingw64'):
13 libenv.Append(CPPDEFINES = ['DLL_EXPORT'])
14
15 # Prepare the libobj and shlibobj object files
16 libobj = libenv.Object(files)
17 if libenv['STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME']:
18 shlibobj = libobj
19 else:
20 shlibobj = libenv.SharedObject(files)
21
22 # Compile the static library into lib directory and shared library
23 # for the bindings
24 if not libenv['STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME']:
25 libenv.Library('shairplay', libobj, install=False)
26 libenv.SharedLibrary('shairplay', shlibobj, install=False)
27
28 # If we want to create universal binaries of the dynamic library on Mac, do it here
29 if GetOption('universal'):
30 libenv["ENV"]["MACOSX_DEPLOYMENT_TARGET"] = "10.4"
31 libenv.Append(CFLAGS = ['-arch', 'i386', '-arch', 'x86_64'])
32 libenv32 = libenv.Clone()
33 libenv64 = libenv.Clone()
34
35 libenv32.Append(LINKFLAGS = ['-undefined', 'dynamic_lookup'])
36 libenv32.Append(LINKFLAGS = ['-arch', 'i386'])
37 libenv32.Append(LINKFLAGS = ['-install_name', 'libshairplay32.dylib'])
38 libenv32.SharedLibrary('shairplay32', shlibobj, install=False)
39
40 libenv64.Append(LINKFLAGS = ['-undefined', 'dynamic_lookup'])
41 libenv64.Append(LINKFLAGS = ['-arch', 'x86_64'])
42 libenv64.Append(LINKFLAGS = ['-install_name', 'libshairplay64.dylib'])
43 libenv64.SharedLibrary('shairplay64', shlibobj, install=False)
44
45 libenv.Append(LINKFLAGS = ['-undefined', 'dynamic_lookup'])
46 libenv.Append(LINKFLAGS = ['-arch', 'i386', '-arch', 'x86_64'])
47 libenv.Append(LINKFLAGS = ['-install_name', 'libshairplay.dylib'])
48
49 # Set up the environment for compiling the examples
50 appenv = env.Clone()
51 conf = Configure(appenv)
52 conf.CheckLib('pthread')
53 conf.CheckLib('dns_sd')
54 appenv = conf.Finish()
55 appenv.Append(LIBPATH = ['.'])
56 appenv.Prepend(LIBS = ['shairplay'])
57
58 exampleobj = appenv.Object(['test/example.c'])
59 appenv.Program('example', exampleobj, install=False)