- Timestamp:
- Sep 13, 2014, 2:09:16 AM (5 years ago)
- Branches:
- 4.10, 4.11, master
- Children:
- 73eb48a
- Parents:
- 749ddf1
- Location:
- linkers
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
linkers/README
r749ddf1 r87e0e76 1 RTEMS Dynamic Loader Project 2 ============================ 1 RTEMS Linkers. 2 ============== 3 3 4 Chris Johns <chrisj@rtems.org> 4 5 5 RTEMS Linker 6 ------------ 7 8 This package contains the RTEMS linker used to create dynamically loadable 9 applications. 10 11 To build download and install waf (http://code.google.com/p/waf/). Then: 12 13 $ waf configure build 14 15 You will have a linker. 6 This directory contains the RTEMS linkers and various tools to help managed 7 them. 16 8 17 9 License -
linkers/wscript
r749ddf1 r87e0e76 8 8 version_revision = 0 9 9 10 #11 # Waf system setup. Allow more than one build in the same tree.12 #13 top = '.'14 out = 'build-' + sys.platform15 16 10 def options(opt): 17 11 opt.load("g++") 18 12 opt.load("gcc") 19 opt.add_option('--rtems-version',20 default = '4.11',21 dest='rtems_version',22 help = 'Set the RTEMS version')23 opt.add_option('--c-opts',24 default = '-O2',25 dest='c_opts',26 help = 'Set build options, default: -O2.')27 opt.add_option('--show-commands',28 action = 'store_true',29 default = False,30 dest = 'show_commands',31 help = 'Print the commands as strings.')32 13 33 14 def configure(conf): 34 try:35 conf.load("doxygen", tooldir = 'waf-tools')36 except:37 pass38 15 conf.load("g++") 39 16 conf.load("gcc") 40 conf_libiberty(conf)41 conf_libelf(conf)42 43 conf.check(header_name='sys/wait.h', features = 'c', mandatory = False)44 conf.check_cc(function_name='kill', header_name="signal.h",45 features = 'c', mandatory = False)46 conf.write_config_header('config.h')47 17 48 18 conf.env.C_OPTS = conf.options.c_opts.split(',') 49 19 conf.env.RTEMS_VERSION = conf.options.rtems_version 50 51 if conf.options.show_commands: 52 show_commands = 'yes' 53 else: 54 show_commands = 'no' 55 conf.env.SHOW_COMMANDS = show_commands 20 conf.write_config_header('config.h') 56 21 57 22 def build(bld): … … 64 29 return 65 30 66 if bld.env.SHOW_COMMANDS == 'yes':67 output_command_line()68 69 31 # 70 # The include paths.32 # The local configuration. 71 33 # 72 bld.includes = ['elftoolchain/libelf', 'elftoolchain/common', 'libiberty'] 73 if sys.platform == 'win32': 74 bld.includes += ['win32'] 34 conf = {} 75 35 76 36 # 77 37 # Build flags. 78 38 # 79 bld.warningflags = ['-Wall', '-Wextra', '-pedantic'] 80 bld.optflags = bld.env.C_OPTS 81 bld.cflags = ['-pipe', '-g'] + bld.optflags 82 bld.cxxflags = ['-pipe', '-g'] + bld.optflags 83 bld.linkflags = ['-g'] 84 85 # 86 # Create each of the modules as object files each with their own 87 # configurations. 88 # 89 bld_fastlz(bld) 90 bld_libelf(bld) 91 bld_libiberty(bld) 92 93 # 94 # RLD source. 95 # 96 rld_source = ['ConvertUTF.c', 97 'pkgconfig.cpp', 98 'rld-config.cpp', 99 'rld-elf.cpp', 100 'rld-files.cpp', 101 'rld-cc.cpp', 102 'rld-compression.cpp', 103 'rld-outputter.cpp', 104 'rld-path.cpp', 105 'rld-process.cpp', 106 'rld-resolver.cpp', 107 'rld-rtems.cpp', 108 'rld-symbols.cpp', 109 'rld-rap.cpp', 110 'rld.cpp'] 111 112 # 113 # RTEMS Utilities. 114 # 115 rtems_utils = ['rtems-utils.cpp'] 116 117 # 118 # RTL static library 119 # 120 bld.stlib(target = 'rld', 121 source = rld_source + rtems_utils, 122 defines = ['HAVE_CONFIG_H=1', 'RTEMS_VERSION=' + bld.env.RTEMS_VERSION], 123 includes = ['.'] + bld.includes, 124 cflags = bld.cflags + bld.warningflags, 125 cxxflags = bld.cxxflags + bld.warningflags, 126 linkflags = bld.linkflags) 39 rtemstoolkit = '../rtemstoolkit' 40 conf['includes'] = [rtemstoolkit, 41 rtemstoolkit + '/elftoolchain/libelf', 42 rtemstoolkit + '/elftoolchain/common', 43 rtemstoolkit + '/libiberty'] 44 conf['warningflags'] = ['-Wall', '-Wextra', '-pedantic'] 45 conf['optflags'] = bld.env.C_OPTS 46 conf['cflags'] = ['-pipe', '-g'] + conf['optflags'] 47 conf['cxxflags'] = ['-pipe', '-g'] + conf['optflags'] 48 conf['linkflags'] = ['-g'] 127 49 128 50 # … … 137 59 source = ['rtems-ld.cpp'], 138 60 defines = ['HAVE_CONFIG_H=1', 'RTEMS_VERSION=' + bld.env.RTEMS_VERSION], 139 includes = ['.'] + bld.includes,140 cflags = bld.cflags + bld.warningflags,141 cxxflags = bld.cxxflags + bld.warningflags,142 linkflags = bld.linkflags,61 includes = ['.'] + conf['includes'], 62 cflags = conf['cflags'] + conf['warningflags'], 63 cxxflags = conf['cxxflags'] + conf['warningflags'], 64 linkflags = conf['linkflags'], 143 65 use = modules) 144 66 … … 149 71 source = ['rtems-ra.cpp'], 150 72 defines = ['HAVE_CONFIG_H=1', 'RTEMS_VERSION=' + bld.env.RTEMS_VERSION], 151 includes = ['.'] + bld.includes,152 cflags = bld.cflags + bld.warningflags,153 cxxflags = bld.cxxflags + bld.warningflags,154 linkflags = bld.linkflags,73 includes = ['.'] + conf['includes'], 74 cflags = conf['cflags'] + conf['warningflags'], 75 cxxflags = conf['cxxflags'] + conf['warningflags'], 76 linkflags = conf['linkflags'], 155 77 use = modules) 156 78 … … 161 83 source = ['rtems-tld.cpp'], 162 84 defines = ['HAVE_CONFIG_H=1', 'RTEMS_VERSION=' + bld.env.RTEMS_VERSION], 163 includes = ['.'] + bld.includes,164 cflags = bld.cflags + bld.warningflags,165 cxxflags = bld.cxxflags + bld.warningflags,166 linkflags = bld.linkflags,85 includes = ['.'] + conf['includes'], 86 cflags = conf['cflags'] + conf['warningflags'], 87 cxxflags = conf['cxxflags'] + conf['warningflags'], 88 linkflags = conf['linkflags'], 167 89 use = modules) 168 90 bld.install_files('${PREFIX}/share/rtems/trace-linker', … … 175 97 source = ['rtems-syms.cpp'], 176 98 defines = ['HAVE_CONFIG_H=1', 'RTEMS_VERSION=' + bld.env.RTEMS_VERSION], 177 includes = ['.'] + bld.includes,178 cflags = bld.cflags + bld.warningflags,179 cxxflags = bld.cxxflags + bld.warningflags,180 linkflags = bld.linkflags,99 includes = ['.'] + conf['includes'], 100 cflags = conf['cflags'] + conf['warningflags'], 101 cxxflags = conf['cxxflags'] + conf['warningflags'], 102 linkflags = conf['linkflags'], 181 103 use = modules) 182 104 … … 187 109 source = ['rtems-rapper.cpp'], 188 110 defines = ['HAVE_CONFIG_H=1', 'RTEMS_VERSION=' + bld.env.RTEMS_VERSION], 189 includes = ['.'] + bld.includes,190 cflags = bld.cflags + bld.warningflags,191 cxxflags = bld.cxxflags + bld.warningflags,192 linkflags = bld.linkflags,111 includes = ['.'] + conf['includes'], 112 cflags = conf['cflags'] + conf['warningflags'], 113 cxxflags = conf['cxxflags'] + conf['warningflags'], 114 linkflags = conf['linkflags'], 193 115 use = modules) 194 195 def rebuild(ctx):196 import waflib.Options197 waflib.Options.commands.extend(['clean', 'build'])198 116 199 117 def tags(ctx): 200 118 ctx.exec_command('etags $(find . -name \*.[sSch])', shell = True) 201 202 #203 # Libelf module.204 #205 def conf_libelf(conf):206 pass207 208 def bld_fastlz(bld):209 bld(target = 'fastlz',210 features = 'c',211 source = 'fastlz.c',212 cflags = bld.cflags,213 defines = ['FASTLZ_LEVEL=1'])214 215 def bld_libelf(bld):216 libelf = 'elftoolchain/libelf/'217 218 #219 # Work around the ${SRC} having Windows slashes which the MSYS m4 does not220 # understand.221 #222 if sys.platform == 'win32':223 m4_rule = 'type ${SRC} | m4 -D SRCDIR=../linkers/' + libelf[:-1] + '> ${TGT}"'224 includes = ['win32']225 else:226 m4_rule = 'm4 -D SRCDIR=../linkers/' + libelf[:-1] + ' ${SRC} > ${TGT}'227 includes = []228 229 bld(target = 'libelf_convert.c', source = libelf + 'libelf_convert.m4', rule = m4_rule)230 bld(target = 'libelf_fsize.c', source = libelf + 'libelf_fsize.m4', rule = m4_rule)231 bld(target = 'libelf_msize.c', source = libelf + 'libelf_msize.m4', rule = m4_rule)232 233 host_source = []234 235 if sys.platform == 'linux2':236 common = 'elftoolchain/common/'237 bld(target = common + 'native-elf-format.h',238 source = common + 'native-elf-format',239 name = 'native-elf-format',240 rule = './${SRC} > ${TGT}')241 bld.add_group ()242 elif sys.platform == 'win32':243 host_source += [libelf + 'mmap_win32.c']244 245 bld.stlib(target = 'elf',246 features = 'c',247 uses = ['native-elf-format'],248 includes = [bld.bldnode.abspath(), 'elftoolchain/libelf', 'elftoolchain/common'] + includes,249 cflags = bld.cflags,250 source =[libelf + 'elf.c',251 libelf + 'elf_begin.c',252 libelf + 'elf_cntl.c',253 libelf + 'elf_end.c',254 libelf + 'elf_errmsg.c',255 libelf + 'elf_errno.c',256 libelf + 'elf_data.c',257 libelf + 'elf_fill.c',258 libelf + 'elf_flag.c',259 libelf + 'elf_getarhdr.c',260 libelf + 'elf_getarsym.c',261 libelf + 'elf_getbase.c',262 libelf + 'elf_getident.c',263 libelf + 'elf_hash.c',264 libelf + 'elf_kind.c',265 libelf + 'elf_memory.c',266 libelf + 'elf_next.c',267 libelf + 'elf_rand.c',268 libelf + 'elf_rawfile.c',269 libelf + 'elf_phnum.c',270 libelf + 'elf_shnum.c',271 libelf + 'elf_shstrndx.c',272 libelf + 'elf_scn.c',273 libelf + 'elf_strptr.c',274 libelf + 'elf_update.c',275 libelf + 'elf_version.c',276 libelf + 'gelf_cap.c',277 libelf + 'gelf_checksum.c',278 libelf + 'gelf_dyn.c',279 libelf + 'gelf_ehdr.c',280 libelf + 'gelf_getclass.c',281 libelf + 'gelf_fsize.c',282 libelf + 'gelf_move.c',283 libelf + 'gelf_phdr.c',284 libelf + 'gelf_rel.c',285 libelf + 'gelf_rela.c',286 libelf + 'gelf_shdr.c',287 libelf + 'gelf_sym.c',288 libelf + 'gelf_syminfo.c',289 libelf + 'gelf_symshndx.c',290 libelf + 'gelf_xlate.c',291 libelf + 'libelf_align.c',292 libelf + 'libelf_allocate.c',293 libelf + 'libelf_ar.c',294 libelf + 'libelf_ar_util.c',295 libelf + 'libelf_checksum.c',296 libelf + 'libelf_data.c',297 libelf + 'libelf_ehdr.c',298 libelf + 'libelf_extended.c',299 libelf + 'libelf_phdr.c',300 libelf + 'libelf_shdr.c',301 libelf + 'libelf_xlate.c',302 'libelf_convert.c',303 'libelf_fsize.c',304 'libelf_msize.c'] + host_source)305 306 #307 # Libiberty module.308 #309 def conf_libiberty(conf):310 conf.check(header_name='alloca.h', features = 'c', mandatory = False)311 conf.check(header_name='fcntl.h', features = 'c', mandatory = False)312 conf.check(header_name='process.h', features = 'c', mandatory = False)313 conf.check(header_name='stdlib.h', features = 'c')314 conf.check(header_name='string.h', features = 'c')315 conf.check(header_name='strings.h', features = 'c', mandatory = False)316 conf.check(header_name='sys/file.h', features = 'c', mandatory = False)317 conf.check(header_name='sys/stat.h', features = 'c', mandatory = False)318 conf.check(header_name='sys/time.h', features = 'c', mandatory = False)319 conf.check(header_name='sys/types.h', features = 'c', mandatory = False)320 conf.check(header_name='sys/wait.h', features = 'c', mandatory = False)321 conf.check(header_name='unistd.h', features = 'c', mandatory = False)322 conf.check(header_name='vfork.h', features = 'c', mandatory = False)323 324 conf.check_cc(function_name='getrusage',325 header_name="sys/time.h sys/resource.h",326 features = 'c', mandatory = False)327 328 conf.write_config_header('libiberty/config.h')329 330 def bld_libiberty(bld):331 if sys.platform == 'win32':332 pex_host = 'libiberty/pex-win32.c'333 else:334 pex_host = 'libiberty/pex-unix.c'335 bld.stlib(target = 'iberty',336 features = 'c',337 includes = ['libiberty'],338 cflags = bld.cflags,339 defines = ['HAVE_CONFIG_H=1'],340 source =['libiberty/concat.c',341 'libiberty/cplus-dem.c',342 'libiberty/cp-demangle.c',343 'libiberty/make-temp-file.c',344 'libiberty/mkstemps.c',345 'libiberty/safe-ctype.c',346 'libiberty/stpcpy.c',347 'libiberty/pex-common.c',348 'libiberty/pex-one.c',349 pex_host])350 351 #352 # From the demos. Use this to get the command to cut+paste to play.353 #354 def output_command_line():355 # first, display strings, people like them356 from waflib import Utils, Logs357 from waflib.Context import Context358 def exec_command(self, cmd, **kw):359 subprocess = Utils.subprocess360 kw['shell'] = isinstance(cmd, str)361 if isinstance(cmd, str):362 Logs.info('%s' % cmd)363 else:364 Logs.info('%s' % ' '.join(cmd)) # here is the change365 Logs.debug('runner_env: kw=%s' % kw)366 try:367 if self.logger:368 self.logger.info(cmd)369 kw['stdout'] = kw['stderr'] = subprocess.PIPE370 p = subprocess.Popen(cmd, **kw)371 (out, err) = p.communicate()372 if out:373 self.logger.debug('out: %s' % out.decode(sys.stdout.encoding or 'iso8859-1'))374 if err:375 self.logger.error('err: %s' % err.decode(sys.stdout.encoding or 'iso8859-1'))376 return p.returncode377 else:378 p = subprocess.Popen(cmd, **kw)379 return p.wait()380 except OSError:381 return -1382 Context.exec_command = exec_command383 384 # Change the outputs for tasks too385 from waflib.Task import Task386 def display(self):387 return '' # no output on empty strings388 389 Task.__str__ = display390 391 #392 # The doxy command.393 #394 from waflib import Build395 class doxy(Build.BuildContext):396 fun = 'build'397 cmd = 'doxy'
Note: See TracChangeset
for help on using the changeset viewer.