source: rtems-tools/rtemstoolkit/wscript @ c9fa179

4.105
Last change on this file since c9fa179 was 0382b68, checked in by Chris Johns <chrisj@…>, on 10/18/15 at 08:19:08

Fix Windows build issues.

Fix biulding the mmap Windows code.
Fix installing the files for Windows.

  • Property mode set to 100644
File size: 10.8 KB
Line 
1#
2# RTEMS Tools Project (http://www.rtems.org/)
3# Copyright 2014, 2015 Chris Johns (chrisj@rtems.org)
4# All rights reserved.
5#
6# This file is part of the RTEMS Tools package in 'rtems-tools'.
7#
8# Redistribution and use in source and binary forms, with or without
9# modification, are permitted provided that the following conditions are met:
10#
11# 1. Redistributions of source code must retain the above copyright notice,
12# this list of conditions and the following disclaimer.
13#
14# 2. Redistributions in binary form must reproduce the above copyright notice,
15# this list of conditions and the following disclaimer in the documentation
16# and/or other materials provided with the distribution.
17#
18# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28# POSSIBILITY OF SUCH DAMAGE.
29#
30
31#
32# RTEMS Toolkit build script.
33#
34import sys
35
36version_major = 1
37version_minor = 0
38version_revision = 0
39
40#
41# Waf system setup. Allow more than one build in the same tree.
42#
43top = '.'
44out = 'build-' + sys.platform
45
46def options(opt):
47    opt.load('compiler_c')
48    opt.load('compiler_cxx')
49
50def configure(conf):
51    conf.load('compiler_c')
52    conf.load('compiler_cxx')
53    conf_libiberty(conf)
54    conf_libelf(conf)
55
56    conf.find_program('m4')
57
58    conf.check(header_name='sys/wait.h',  features = 'c', mandatory = False)
59    conf.check_cc(function_name='kill', header_name="signal.h",
60                  features = 'c', mandatory = False)
61    conf.write_config_header('config.h')
62
63def build(bld):
64    #
65    # The local configuration.
66    #
67    conf = {}
68
69    #
70    # The include paths.
71    #
72    conf['includes'] = ['elftoolchain/libelf', 'elftoolchain/common', 'libiberty']
73    if bld.env.DEST_OS == 'win32':
74        conf['includes'] += ['win32']
75
76    #
77    # Build flags.
78    #
79    conf['warningflags'] = ['-Wall', '-Wextra', '-pedantic']
80    conf['optflags'] = bld.env.C_OPTS
81    conf['cflags'] = ['-pipe', '-g'] + conf['optflags']
82    conf['cxxflags'] = ['-pipe', '-g'] + conf['optflags']
83    conf['linkflags'] = ['-g']
84
85    #
86    # Create each of the modules as object files each with their own
87    # configurations.
88    #
89    bld_libelf(bld, conf)
90    bld_libiberty(bld, conf)
91
92    #
93    # RLD source.
94    #
95    rld_source = ['ConvertUTF.c',
96                  'pkgconfig.cpp',
97                  'rld-config.cpp',
98                  'rld-elf.cpp',
99                  'rld-files.cpp',
100                  'rld-cc.cpp',
101                  'rld-compression.cpp',
102                  'rld-outputter.cpp',
103                  'rld-path.cpp',
104                  'rld-process.cpp',
105                  'rld-resolver.cpp',
106                  'rld-rtems.cpp',
107                  'rld-symbols.cpp',
108                  'rld-rap.cpp',
109                  'rld.cpp']
110
111    #
112    # RTEMS Utilities.
113    #
114    rtems_utils = ['rtems-utils.cpp']
115
116    #
117    # Compression.
118    #
119    compression = ['fastlz.c']
120
121    #
122    # RTL static library
123    #
124    bld.stlib(target = 'rld',
125              install_path = None,
126              source = rld_source + rtems_utils + compression,
127              defines = ['HAVE_CONFIG_H=1',
128                         'RTEMS_VERSION=' + bld.env.RTEMS_VERSION,
129                         'FASTLZ_LEVEL=1'],
130              includes = ['.'] + conf['includes'],
131              cflags = conf['cflags'] + conf['warningflags'],
132              cxxflags = conf['cxxflags'] + conf['warningflags'],
133              linkflags = conf['linkflags'])
134
135    #
136    # The Python toolkit.
137    #
138    bld(features = 'py',
139        source = ['__init__.py',
140                  'check.py',
141                  'config.py',
142                  'darwin.py',
143                  'error.py',
144                  'execute.py',
145                  'freebsd.py',
146                  'git.py',
147                  'linux.py',
148                  'log.py',
149                  'macros.py',
150                  'mailer.py',
151                  'options.py',
152                  'path.py',
153                  'stacktraces.py',
154                  'version.py',
155                  'windows.py'],
156        install_path = '${PREFIX}/share/rtems/rtemstoolkit')
157
158def rebuild(ctx):
159    import waflib.Options
160    waflib.Options.commands.extend(['clean', 'build'])
161
162def tags(ctx):
163    ctx.exec_command('etags $(find . -name \*.[sSch])', shell = True)
164
165#
166# Libelf module.
167#
168def conf_libelf(conf):
169    pass
170
171def bld_libelf(bld, conf):
172    libelf = 'elftoolchain/libelf/'
173    m4_rule = '${M4} -D SRCDIR=../rtemstoolkit/' + libelf[:-1] + ' ${SRC} > ${TGT}'
174    if bld.env.DEST_OS == 'win32':
175        includes = ['win32']
176    else:
177        includes = []
178
179    bld(target = 'libelf_convert.c', source = libelf + 'libelf_convert.m4', rule = m4_rule)
180    bld(target = 'libelf_fsize.c',   source = libelf + 'libelf_fsize.m4',   rule = m4_rule)
181    bld(target = 'libelf_msize.c',   source = libelf + 'libelf_msize.m4',   rule = m4_rule)
182
183    host_source = []
184
185    if bld.env.DEST_OS == 'linux':
186        common = 'elftoolchain/common/'
187        bld(target = common + 'native-elf-format.h',
188            source = common + 'native-elf-format',
189            name = 'native-elf-format',
190            rule   = './${SRC} > ${TGT}')
191        bld.add_group ()
192    elif bld.env.DEST_OS == 'win32':
193        host_source += [libelf + 'mmap_win32.c']
194
195    bld.stlib(target = 'elf',
196              features = 'c',
197              install_path = None,
198              uses = ['native-elf-format'],
199              includes = [bld.bldnode.abspath(),
200                          'elftoolchain/libelf', 'elftoolchain/common'] + includes,
201              cflags = conf['cflags'],
202              source =[libelf + 'elf.c',
203                       libelf + 'elf_begin.c',
204                       libelf + 'elf_cntl.c',
205                       libelf + 'elf_end.c',
206                       libelf + 'elf_errmsg.c',
207                       libelf + 'elf_errno.c',
208                       libelf + 'elf_data.c',
209                       libelf + 'elf_fill.c',
210                       libelf + 'elf_flag.c',
211                       libelf + 'elf_getarhdr.c',
212                       libelf + 'elf_getarsym.c',
213                       libelf + 'elf_getbase.c',
214                       libelf + 'elf_getident.c',
215                       libelf + 'elf_hash.c',
216                       libelf + 'elf_kind.c',
217                       libelf + 'elf_memory.c',
218                       libelf + 'elf_next.c',
219                       libelf + 'elf_rand.c',
220                       libelf + 'elf_rawfile.c',
221                       libelf + 'elf_phnum.c',
222                       libelf + 'elf_shnum.c',
223                       libelf + 'elf_shstrndx.c',
224                       libelf + 'elf_scn.c',
225                       libelf + 'elf_strptr.c',
226                       libelf + 'elf_update.c',
227                       libelf + 'elf_version.c',
228                       libelf + 'gelf_cap.c',
229                       libelf + 'gelf_checksum.c',
230                       libelf + 'gelf_dyn.c',
231                       libelf + 'gelf_ehdr.c',
232                       libelf + 'gelf_getclass.c',
233                       libelf + 'gelf_fsize.c',
234                       libelf + 'gelf_move.c',
235                       libelf + 'gelf_phdr.c',
236                       libelf + 'gelf_rel.c',
237                       libelf + 'gelf_rela.c',
238                       libelf + 'gelf_shdr.c',
239                       libelf + 'gelf_sym.c',
240                       libelf + 'gelf_syminfo.c',
241                       libelf + 'gelf_symshndx.c',
242                       libelf + 'gelf_xlate.c',
243                       libelf + 'libelf_align.c',
244                       libelf + 'libelf_allocate.c',
245                       libelf + 'libelf_ar.c',
246                       libelf + 'libelf_ar_util.c',
247                       libelf + 'libelf_checksum.c',
248                       libelf + 'libelf_data.c',
249                       libelf + 'libelf_ehdr.c',
250                       libelf + 'libelf_extended.c',
251                       libelf + 'libelf_phdr.c',
252                       libelf + 'libelf_shdr.c',
253                       libelf + 'libelf_xlate.c',
254                       'libelf_convert.c',
255                       'libelf_fsize.c',
256                       'libelf_msize.c'] + host_source)
257
258#
259# Libiberty module.
260#
261def conf_libiberty(conf):
262    conf.check(header_name='alloca.h',    features = 'c', mandatory = False)
263    conf.check(header_name='fcntl.h',     features = 'c', mandatory = False)
264    conf.check(header_name='process.h',   features = 'c', mandatory = False)
265    conf.check(header_name='stdlib.h',    features = 'c')
266    conf.check(header_name='string.h',    features = 'c')
267    conf.check(header_name='strings.h',   features = 'c', mandatory = False)
268    conf.check(header_name='sys/file.h',  features = 'c', mandatory = False)
269    conf.check(header_name='sys/stat.h',  features = 'c', mandatory = False)
270    conf.check(header_name='sys/time.h',  features = 'c', mandatory = False)
271    conf.check(header_name='sys/types.h', features = 'c', mandatory = False)
272    conf.check(header_name='sys/wait.h',  features = 'c', mandatory = False)
273    conf.check(header_name='unistd.h',    features = 'c', mandatory = False)
274    conf.check(header_name='vfork.h',     features = 'c', mandatory = False)
275
276    conf.check_cc(function_name='getrusage',
277                  header_name="sys/time.h sys/resource.h",
278                  features = 'c', mandatory = False)
279
280    conf.write_config_header('libiberty/config.h')
281
282def bld_libiberty(bld, conf):
283    if bld.env.DEST_OS == 'win32':
284        pex_host = 'libiberty/pex-win32.c'
285    else:
286        pex_host = 'libiberty/pex-unix.c'
287    bld.stlib(target = 'iberty',
288              features = 'c',
289              install_path = None,
290              includes = ['libiberty'],
291              cflags = conf['cflags'],
292              defines = ['HAVE_CONFIG_H=1'],
293              source =['libiberty/concat.c',
294                       'libiberty/cplus-dem.c',
295                       'libiberty/cp-demangle.c',
296                       'libiberty/make-temp-file.c',
297                       'libiberty/mkstemps.c',
298                       'libiberty/safe-ctype.c',
299                       'libiberty/stpcpy.c',
300                       'libiberty/pex-common.c',
301                       'libiberty/pex-one.c',
302                       pex_host])
303
304#
305# The doxy command.
306#
307from waflib import Build
308class doxy(Build.BuildContext):
309    fun = 'build'
310    cmd = 'doxy'
Note: See TracBrowser for help on using the repository browser.