wscript 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #! /usr/bin/env python
  2. def options(opt):
  3. opt.load('compiler_c')
  4. def configure(conf):
  5. conf.load('compiler_c')
  6. conf.find_program('ldd')
  7. conf.where_is_shlib(lib='m')
  8. # --- support code below ---
  9. import re
  10. from waflib import Task, TaskGen, Configure
  11. class ldd_run(Task.Task):
  12. color = 'PINK'
  13. run_str = '${LDD} ${SRC} > ${TGT}'
  14. def post_run(self):
  15. ret = Task.Task.post_run(self)
  16. libname = self.generator.lib
  17. re_libpath = re.compile('lib%s.*\s+=>\s+(\S+%s\S+)\s+' % (libname, libname), re.M)
  18. m = re_libpath.search(self.outputs[0].read())
  19. if m:
  20. self.generator.tmp.append(m.group(1))
  21. else:
  22. return ret or 1
  23. return ret
  24. @TaskGen.feature('ldd_check')
  25. @TaskGen.after_method('apply_link')
  26. def do_ldd_check(self):
  27. self.create_task('ldd_run', self.link_task.outputs[0], self.path.find_or_declare('ldd.out'))
  28. @Configure.conf
  29. def where_is_shlib(self, lib):
  30. tmp = []
  31. def check_msg(self):
  32. return tmp[0]
  33. self.check(
  34. fragment = 'int main() { return 0; }\n',
  35. features = 'c cprogram ldd_check',
  36. lib = lib,
  37. linkflags = '-Wl,--no-as-needed',
  38. msg = 'Where is library %r' % lib,
  39. define = 'LIBFROM',
  40. tmp = tmp,
  41. okmsg = check_msg)
  42. return tmp[0]