Android Protocol Plugin Manager API merge from android-api branch to master
[platform/upstream/iotivity.git] / extlibs / expat / SConscript
1 ##
2 # build script for expat library
3 #
4 # Note:
5 #   1) Only a part of source code are required to be built.
6 #   2) Download code from https://android.googlesource.com/platform/external/expat.git
7 # otherwise, after code is downloaded, it's required to execute './configure' to
8 # generate expat_config.h
9 #
10 ##
11
12 import os
13
14 Import('env')
15
16 expat_env = env.Clone()
17 SConscript(env.get('SRC_DIR') + '/build_common/tools/UnpackAll.py')
18 ######################################################################
19 # Build flags
20 ######################################################################
21 src_dir = 'expat-2.1.0/'
22
23 if not os.path.exists(src_dir):
24         # Prepare source code (download / unpack / run configure)
25         env.Download('expat.tar.gz', 'http://sourceforge.net/projects/expat/files/expat/2.1.0/expat-2.1.0.tar.gz/download')
26         expat_src = env.UnpackAll(src_dir + '/Makefile', 'expat.tar.gz')
27         env.Configure(src_dir, './configure')
28
29 expat_env.AppendUnique(CPPPATH = [src_dir, src_dir + 'lib', src_dir + 'vms'])
30
31 target_os = env.get('TARGET_OS')
32 if target_os not in ['windows', 'winrt']:
33         expat_env.AppendUnique(CCFLAGS = ['-g', '-O2', '-Wall',
34                         '-Wmissing-prototypes', '-Wstrict-prototypes',
35                         '-fexceptions', '-fno-common'])
36         expat_env.AppendUnique(CPPDEFINES = ['HAVE_EXPAT_CONFIG_H'])
37
38 ######################################################################
39 # Source files and Targets
40 ######################################################################
41 expat_src = [
42         src_dir + 'lib/xmlparse.c',
43         src_dir + 'lib/xmltok.c',
44         src_dir + 'lib/xmlrole.c',
45         ]
46
47 libexpat = expat_env.SharedLibrary('expat', expat_src)
48
49 ######################################################################
50 # Install header files and library binary
51 ######################################################################
52 h = expat_env.InstallHeadFile([src_dir + 'lib/expat.h', src_dir + 'lib/expat_external.h'])
53 lib = expat_env.InstallLib(libexpat)
54
55 expat_env.AppendTarget('libexpat', [h, lib])