Imported Upstream version 1.1.0
[platform/upstream/iotivity.git] / extlibs / libstrophe / SConscript
1 ######################################################################
2 # ref. raxmpp library build script
3 #
4 ######################################################################
5 import os
6 import commands
7
8 Import('env')
9
10 base_dir = env.get('SRC_DIR')
11 target_os = env.get('TARGET_OS')
12 target_arch = env.get('TARGET_ARCH')
13 build_path = Dir('.').abspath
14
15 with_ra_ibb = env.get('WITH_RA_IBB')
16 PKG_NAME = 'strophe'
17 SRC_NAME = 'libstrophe'
18 EXT_NAME = 'libstrophe'
19 EXT_BASE = 'extlibs/' + EXT_NAME
20 EXT_PATH = EXT_BASE + '/' + SRC_NAME
21 SRC_PATH = base_dir + '/' + EXT_PATH
22 INC_PATH = SRC_PATH
23 LIB_PATH = SRC_PATH + '/' + '.libs'
24
25 if with_ra_ibb:
26         # check 'libstrophe' library, if it doesn't exits, ask user to download it
27         if not os.path.exists(SRC_NAME):
28                 raxmpp_env = Environment(ENV = os.environ)
29                 c = raxmpp_env.Action(['git clone https://github.com/strophe/libstrophe.git ' + SRC_NAME,
30                         'cd ' + SRC_NAME + ' && git checkout 527bc0573a52f2af3ecad5b9ef39aeec7b669f77'
31                         ])
32
33                 print 'Downloading xmpp library ...'
34                 if raxmpp_env.Execute(c):
35                         print '''
36         *********************************** Error: ***********************************************
37         * Please download ra_xmpp as following:
38         *     $ git clone https://github.com/strophe/libstrophe.git extlibs/libstrophe/libstrophe
39         *     $ cd  extlibs/libstrophe/libstrophe
40         *     $ git checkout 527bc0573a52f2af3ecad5b9ef39aeec7b669f77
41         ******************************************************************************************
42         '''
43                         Exit(1)
44                 else:
45                         print 'Download xmpp library complete'
46
47         print 'Building with ' + SRC_NAME
48         #print 'base_dir', base_dir
49         #print 'target_os', target_os
50         #print 'target_arch', target_arch
51
52         foo=commands.getoutput('patch -N -p1 -d libstrophe < strophe-xmpp_conn_is_secured.patch')
53         print foo
54
55         os.chdir(SRC_NAME)
56         #sconsflags = ' RELEASE=true' if  env['RELEASE'] else ' RELEASE=false'
57         if not os.path.exists('configure') :
58                 foo=commands.getoutput('./bootstrap.sh')
59                 print foo
60         if not os.path.exists('config.status') :
61                 foo=commands.getoutput('./configure')
62                 print foo
63         if not os.path.exists('.libs/libstrophe.a') :
64                 foo=commands.getoutput('make libstrophe.la')
65                 print foo
66         if not os.path.exists('.libs/libstrophe.a') :
67                 print 'Building with ' + SRC_NAME + ' failed.'
68                 Exit(2)
69
70         print 'Building with ' + SRC_NAME + ' Completely.'
71         env.AppendUnique(CPPPATH = [INC_PATH], RALIBS = ['strophe', 'ssl', 'crypto', 'resolv'], RALIBPATH = [LIB_PATH], RARPATH = [LIB_PATH])
72
73 if env.GetOption('clean') :
74         act = env.Action(['cd ' + SRC_PATH, 'make clean'])
75         env.Execute(act)