From fcc62dcfb3a18ea208777b0afb7cd30ab15b865e Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Fri, 19 Dec 2014 09:05:33 +0100 Subject: [PATCH] wafsamba: flags from enviroment are put before our own internal versions Ensure user provided CPPFLAGS and LDFLAGS are put *behind* our internally computed compiler and linker flags. Bug: https://bugzilla.samba.org/show_bug.cgi?id=10877 Signed-off-by: Ralph Boehme --- buildtools/wafsamba/samba_optimisation.py | 28 +++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/buildtools/wafsamba/samba_optimisation.py b/buildtools/wafsamba/samba_optimisation.py index 583a6514d78..4e59d310268 100644 --- a/buildtools/wafsamba/samba_optimisation.py +++ b/buildtools/wafsamba/samba_optimisation.py @@ -59,6 +59,13 @@ def apply_incpaths(self): if node: self.env.append_value('INC_PATHS', node) +@feature('cc') +@before('apply_incpaths') +def samba_stash_cppflags(self): + """Fix broken waf ordering of CPPFLAGS""" + self.env['SAVED_CPPFLAGS'] = self.env['CPPFLAGS'] + self.env['CPPFLAGS'] = [] + @feature('cc') @after('apply_incpaths') def apply_obj_vars_cc(self): @@ -90,6 +97,10 @@ def apply_obj_vars_cc(self): for i in env['CPPPATH']: app('_CCINCFLAGS', cpppath_st % i) + # append stashed user CPPFLAGS after our internally computed flags + app('_CCINCFLAGS', env['SAVED_CPPFLAGS']) + env['SAVED_CPPFLAGS'] = [] + import Node, Environment def vari(self): @@ -331,3 +342,20 @@ def samba_before_apply_obj_vars(self): for i in v['LIBPATH']: if is_standard_libpath(v, i): v['LIBPATH'].remove(i) + +@feature('cprogram', 'cshlib', 'cstaticlib') +@before('apply_obj_vars', 'add_extra_flags') +def samba_stash_linkflags(self): + """stash away LINKFLAGS in order to fix waf's broken ordering wrt or + user LDFLAGS""" + + self.env.SAVE_LINKFLAGS = self.env['LINKFLAGS'] + self.env['LINKFLAGS'] = [] + +@feature('cprogram', 'cshlib', 'cstaticlib') +@after('apply_obj_vars', 'add_extra_flags') +def samba_pop_linkflags(self): + """after apply_obj_vars append saved LDFLAGS""" + + self.env.append_value('LINKFLAGS', self.env.SAVE_LINKFLAGS) + self.env.SAVE_LINKFLAGS = [] -- 2.34.1