[IOT-1294] Fixed build failure for WITH_RA_IBB flags
[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 LIBSTROPHY_LIBS = ['strophe', 'ssl', 'crypto', 'resolv']
25
26 if with_ra_ibb:
27         # check 'libstrophe' library, if it doesn't exits, ask user to download it
28         if not os.path.exists(SRC_NAME):
29                 raxmpp_env = Environment(ENV = os.environ)
30                 c = raxmpp_env.Action(['git clone https://github.com/strophe/libstrophe.git ' + SRC_NAME,
31                         'cd ' + SRC_NAME + ' && git checkout 527bc0573a52f2af3ecad5b9ef39aeec7b669f77'
32                         ])
33
34                 print 'Downloading xmpp library ...'
35                 if raxmpp_env.Execute(c):
36                         print '''
37         *********************************** Error: ***********************************************
38         * Please download ra_xmpp as following:
39         *     $ git clone https://github.com/strophe/libstrophe.git extlibs/libstrophe/libstrophe
40         *     $ cd  extlibs/libstrophe/libstrophe
41         *     $ git checkout 527bc0573a52f2af3ecad5b9ef39aeec7b669f77
42         ******************************************************************************************
43         '''
44                         Exit(1)
45                 else:
46                         print 'Download xmpp library complete'
47
48         print 'Building with ' + SRC_NAME
49         #print 'base_dir', base_dir
50         #print 'target_os', target_os
51         #print 'target_arch', target_arch
52
53         foo=commands.getoutput('patch -N -p1 -d libstrophe < strophe-xmpp_conn_is_secured.patch')
54         print foo
55
56         os.chdir(SRC_NAME)
57         #sconsflags = ' RELEASE=true' if  env['RELEASE'] else ' RELEASE=false'
58         if not os.path.exists('configure') :
59                 foo=commands.getoutput('./bootstrap.sh')
60                 print foo
61         if not os.path.exists('config.status') :
62                 foo=commands.getoutput('./configure')
63                 print foo
64         if not os.path.exists('.libs/libstrophe.a') :
65                 foo=commands.getoutput('make libstrophe.la')
66                 print foo
67         if not os.path.exists('.libs/libstrophe.a') :
68                 print 'Building with ' + SRC_NAME + ' failed.'
69                 Exit(2)
70
71         print 'Building with ' + SRC_NAME + ' Completely.'
72         env.AppendUnique(CPPPATH = [INC_PATH], RALIBS = LIBSTROPHY_LIBS, RALIBPATH = [LIB_PATH], RARPATH = [LIB_PATH])
73         env.AppendUnique(LIBS= LIBSTROPHY_LIBS, LIBPATH = [LIB_PATH])
74 if env.GetOption('clean') :
75         act = env.Action(['cd ' + SRC_PATH, 'make clean'])
76         env.Execute(act)