From: Stefan Metzmacher Date: Fri, 7 Sep 2018 14:27:58 +0000 (+0200) Subject: wafsamba: fix generic_cc.py to work with waf 2 X-Git-Tag: tdb-1.3.17~1664 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0cd9452ea6b6e402124bee970df5484c4a264368;p=thirdparty%2Fsamba.git wafsamba: fix generic_cc.py to work with waf 2 Signed-off-by: Stefan Metzmacher Reviewed-by: Andrew Bartlett --- diff --git a/buildtools/wafsamba/generic_cc.py b/buildtools/wafsamba/generic_cc.py index f6f8b180f45..1352c547acf 100644 --- a/buildtools/wafsamba/generic_cc.py +++ b/buildtools/wafsamba/generic_cc.py @@ -3,70 +3,68 @@ # based on suncc.py from waf import os, optparse -from waflib import Utils, Options, Configure +from waflib import Errors from waflib.Tools import ccroot, ar -from waflib.Configure import conftest +from waflib.Configure import conf +# +# Let waflib provide useful defaults, but +# provide generic_cc as last resort fallback on +# all platforms +# from waflib.Tools.compiler_c import c_compiler +for key in c_compiler.keys(): + c_compiler[key].append('generic_cc') -c_compiler['default'] = ['gcc', 'generic_cc', 'clang'] -c_compiler['freebsd'] = ['clang', 'generic_cc', 'gcc'] -c_compiler['hpux'] = ['gcc', 'generic_cc'] - -@conftest +@conf def find_generic_cc(conf): v = conf.env cc = None - if v['CC']: cc = v['CC'] - elif 'CC' in conf.environ: cc = conf.environ['CC'] - if not cc: cc = conf.find_program('cc', var='CC') - if not cc: conf.fatal('generic_cc was not found') - cc = conf.cmd_to_list(cc) - v['CC'] = cc - v['CC_NAME'] = 'generic' - -@conftest -def generic_cc_common_flags(conf): - v = conf.env + if v.CC: + cc = v.CC + elif 'CC' in conf.environ: + cc = conf.environ['CC'] + if not cc: + cc = conf.find_program('cc', var='CC') + if not cc: + conf.fatal('generic_cc was not found') - v['CC_SRC_F'] = '' - v['CC_TGT_F'] = ['-c', '-o', ''] - v['CPPPATH_ST'] = '-I%s' # template for adding include paths + try: + conf.cmd_and_log(cc + ['--version']) + except Errors.WafError: + conf.fatal('%r --version could not be executed' % cc) - # linker - if not v['LINK_CC']: v['LINK_CC'] = v['CC'] - v['CCLNK_SRC_F'] = '' - v['CCLNK_TGT_F'] = ['-o', ''] + v.CC = cc + v.CC_NAME = 'generic_cc' - v['LIB_ST'] = '-l%s' # template for adding libs - v['LIBPATH_ST'] = '-L%s' # template for adding libpaths - v['STATICLIB_ST'] = '-l%s' - v['STATICLIBPATH_ST'] = '-L%s' - v['CCDEFINES_ST'] = '-D%s' +@conf +def generic_cc_common_flags(conf): + v = conf.env -# v['SONAME_ST'] = '-Wl,-h -Wl,%s' -# v['SHLIB_MARKER'] = '-Bdynamic' -# v['STATICLIB_MARKER'] = '-Bstatic' + v.CC_SRC_F = '' + v.CC_TGT_F = ['-c', '-o'] + v.CPPPATH_ST = '-I%s' + v.DEFINES_ST = '-D%s' - # program - v['program_PATTERN'] = '%s' + if not v.LINK_CC: + v.LINK_CC = v.CC - # shared library -# v['shlib_CCFLAGS'] = ['-Kpic', '-DPIC'] -# v['shlib_LINKFLAGS'] = ['-G'] - v['shlib_PATTERN'] = 'lib%s.so' + v.CCLNK_SRC_F = '' + v.CCLNK_TGT_F = ['-o'] - # static lib -# v['staticlib_LINKFLAGS'] = ['-Bstatic'] -# v['staticlib_PATTERN'] = 'lib%s.a' + v.LIB_ST = '-l%s' # template for adding libs + v.LIBPATH_ST = '-L%s' # template for adding libpaths + v.STLIB_ST = '-l%s' + v.STLIBPATH_ST = '-L%s' -detect = ''' -find_generic_cc -find_cpp -find_ar -generic_cc_common_flags -cc_load_tools -cc_add_flags -link_add_flags -''' + v.cprogram_PATTERN = '%s' + v.cshlib_PATTERN = 'lib%s.so' + v.cstlib_PATTERN = 'lib%s.a' +def configure(conf): + conf.find_generic_cc() + conf.find_ar() + conf.generic_cc_common_flags() + conf.cc_load_tools() + conf.cc_add_flags() + conf.link_add_flags() diff --git a/buildtools/wafsamba/samba_autoconf.py b/buildtools/wafsamba/samba_autoconf.py index ced824d593d..5f203fc7d36 100644 --- a/buildtools/wafsamba/samba_autoconf.py +++ b/buildtools/wafsamba/samba_autoconf.py @@ -897,9 +897,6 @@ def CHECK_CC_ENV(conf): The build farm sometimes puts a space at the start""" if os.environ.get('CC'): conf.env.CC = TO_LIST(os.environ.get('CC')) - if len(conf.env.CC) == 1: - # make for nicer logs if just a single command - conf.env.CC = conf.env.CC[0] @conf