Пример #1
0
def SAMBA_CONFIG_H(conf, path=None):
    '''write out config.h in the right directory'''
    # we don't want to produce a config.h in places like lib/replace
    # when we are building projects that depend on lib/replace
    if not IN_LAUNCH_DIR(conf):
        return

    # we need to build real code that can't be optimized away to test
    if conf.check(fragment='''
        #include <stdio.h>

        int main(void)
        {
            char t[100000];
            while (fgets(t, sizeof(t), stdin));
            return 0;
        }
        ''',
                  execute=0,
                  ccflags='-fstack-protector',
                  ldflags='-fstack-protector',
                  mandatory=False,
                  msg='Checking if toolchain accepts -fstack-protector'):
        conf.ADD_CFLAGS('-fstack-protector')
        conf.ADD_LDFLAGS('-fstack-protector')

    if Options.options.debug:
        conf.ADD_CFLAGS('-g', testflags=True)

    if Options.options.developer:
        conf.env.DEVELOPER_MODE = True

        conf.ADD_CFLAGS('-g', testflags=True)
        conf.ADD_CFLAGS('-Wall', testflags=True)
        conf.ADD_CFLAGS('-Wshadow', testflags=True)
        conf.ADD_CFLAGS('-Wmissing-prototypes', testflags=True)
        conf.ADD_CFLAGS('-Wcast-align -Wcast-qual', testflags=True)
        conf.ADD_CFLAGS('-fno-common', testflags=True)

        conf.ADD_CFLAGS('-Werror=address', testflags=True)
        # we add these here to ensure that -Wstrict-prototypes is not set during configure
        conf.ADD_CFLAGS('-Werror=strict-prototypes -Wstrict-prototypes',
                        testflags=True)
        conf.ADD_CFLAGS('-Werror=write-strings -Wwrite-strings',
                        testflags=True)
        conf.ADD_CFLAGS('-Werror-implicit-function-declaration',
                        testflags=True)
        conf.ADD_CFLAGS('-Werror=pointer-arith -Wpointer-arith',
                        testflags=True)
        conf.ADD_CFLAGS(
            '-Werror=declaration-after-statement -Wdeclaration-after-statement',
            testflags=True)
        conf.ADD_CFLAGS('-Werror=return-type -Wreturn-type', testflags=True)
        conf.ADD_CFLAGS('-Werror=uninitialized -Wuninitialized',
                        testflags=True)

        conf.ADD_CFLAGS('-Wformat=2 -Wno-format-y2k', testflags=True)
        conf.ADD_CFLAGS('-Werror=format-security -Wformat-security',
                        testflags=True)
        # This check is because for ldb_search(), a NULL format string
        # is not an error, but some compilers complain about that.
        if CHECK_CFLAGS(
                conf, ["-Werror=format", "-Wformat=2"], '''
int testformat(char *format, ...) __attribute__ ((format (__printf__, 1, 2)));

int main(void) {
        testformat(0);
        return 0;
}

'''):
            if not 'EXTRA_CFLAGS' in conf.env:
                conf.env['EXTRA_CFLAGS'] = []
            conf.env['EXTRA_CFLAGS'].extend(TO_LIST("-Werror=format"))

    if Options.options.picky_developer:
        conf.ADD_NAMED_CFLAGS('PICKY_CFLAGS',
                              '-Werror -Wno-error=deprecated-declarations',
                              testflags=True)
        conf.ADD_NAMED_CFLAGS('PICKY_CFLAGS',
                              '-Wno-error=tautological-compare',
                              testflags=True)

    if Options.options.fatal_errors:
        conf.ADD_CFLAGS('-Wfatal-errors', testflags=True)

    if Options.options.pedantic:
        conf.ADD_CFLAGS('-W', testflags=True)

    if Options.options.address_sanitizer:
        conf.ADD_CFLAGS('-fno-omit-frame-pointer -O1 -fsanitize=address',
                        testflags=True)
        conf.ADD_LDFLAGS('-fsanitize=address', testflags=True)
        conf.env['ADDRESS_SANITIZER'] = True

    # Let people pass an additional ADDITIONAL_{CFLAGS,LDFLAGS}
    # environment variables which are only used the for final build.
    #
    # The CFLAGS and LDFLAGS environment variables are also
    # used for the configure checks which might impact their results.
    conf.add_os_flags('ADDITIONAL_CFLAGS')
    if conf.env.ADDITIONAL_CFLAGS and conf.CHECK_CFLAGS(
            conf.env['ADDITIONAL_CFLAGS']):
        conf.env['EXTRA_CFLAGS'].extend(conf.env['ADDITIONAL_CFLAGS'])
    conf.add_os_flags('ADDITIONAL_LDFLAGS')
    if conf.env.ADDITIONAL_LDFLAGS and conf.CHECK_LDFLAGS(
            conf.env['ADDITIONAL_LDFLAGS']):
        conf.env['EXTRA_LDFLAGS'].extend(conf.env['ADDITIONAL_LDFLAGS'])

    if path is None:
        conf.write_config_header('config.h', top=True)
    else:
        conf.write_config_header(path)
    conf.SAMBA_CROSS_CHECK_COMPLETE()
def SAMBA_CONFIG_H(conf, path=None):
    '''write out config.h in the right directory'''
    # we don't want to produce a config.h in places like lib/replace
    # when we are building projects that depend on lib/replace
    if not IN_LAUNCH_DIR(conf):
        return

    if conf.CHECK_CFLAGS(['-fstack-protector']) and conf.CHECK_LDFLAGS(
        ['-fstack-protector']):
        conf.ADD_CFLAGS('-fstack-protector')
        conf.ADD_LDFLAGS('-fstack-protector')

    if Options.options.debug:
        conf.ADD_CFLAGS('-g', testflags=True)

    if Options.options.developer:
        conf.env.DEVELOPER_MODE = True

        conf.ADD_CFLAGS('-g', testflags=True)
        conf.ADD_CFLAGS('-Wall', testflags=True)
        conf.ADD_CFLAGS('-Wshadow', testflags=True)
        conf.ADD_CFLAGS('-Wmissing-prototypes', testflags=True)
        conf.ADD_CFLAGS('-Wcast-align -Wcast-qual', testflags=True)
        conf.ADD_CFLAGS('-fno-common', testflags=True)

        conf.ADD_CFLAGS('-Werror=address', testflags=True)
        # we add these here to ensure that -Wstrict-prototypes is not set during configure
        conf.ADD_CFLAGS('-Werror=strict-prototypes -Wstrict-prototypes',
                        testflags=True)
        conf.ADD_CFLAGS('-Werror=write-strings -Wwrite-strings',
                        testflags=True)
        conf.ADD_CFLAGS('-Werror-implicit-function-declaration',
                        testflags=True)
        conf.ADD_CFLAGS('-Werror=pointer-arith -Wpointer-arith',
                        testflags=True)
        conf.ADD_CFLAGS(
            '-Werror=declaration-after-statement -Wdeclaration-after-statement',
            testflags=True)
        conf.ADD_CFLAGS('-Werror=return-type -Wreturn-type', testflags=True)

        conf.ADD_CFLAGS('-Wformat=2 -Wno-format-y2k', testflags=True)
        # This check is because for ldb_search(), a NULL format string
        # is not an error, but some compilers complain about that.
        if CHECK_CFLAGS(
                conf, ["-Werror=format", "-Wformat=2"], '''
int testformat(char *format, ...) __attribute__ ((format (__printf__, 1, 2)));

int main(void) {
        testformat(0);
        return 0;
}

'''):
            if not 'EXTRA_CFLAGS' in conf.env:
                conf.env['EXTRA_CFLAGS'] = []
            conf.env['EXTRA_CFLAGS'].extend(TO_LIST("-Werror=format"))

    if Options.options.picky_developer:
        conf.ADD_NAMED_CFLAGS('PICKY_CFLAGS', '-Werror', testflags=True)

    if Options.options.fatal_errors:
        conf.ADD_CFLAGS('-Wfatal-errors', testflags=True)

    if Options.options.pedantic:
        conf.ADD_CFLAGS('-W', testflags=True)

    # Let people pass an additional ADDITIONAL_{CFLAGS,LDFLAGS}
    # environment variables which are only used the for final build.
    #
    # The CFLAGS and LDFLAGS environment variables are also
    # used for the configure checks which might impact their results.
    conf.add_os_flags('ADDITIONAL_CFLAGS')
    if conf.env.ADDITIONAL_CFLAGS and conf.CHECK_CFLAGS(
            conf.env['ADDITIONAL_CFLAGS']):
        conf.env['EXTRA_CFLAGS'].extend(conf.env['ADDITIONAL_CFLAGS'])
    conf.add_os_flags('ADDITIONAL_LDFLAGS')
    if conf.env.ADDITIONAL_LDFLAGS and conf.CHECK_LDFLAGS(
            conf.env['ADDITIONAL_LDFLAGS']):
        conf.env['EXTRA_LDFLAGS'].extend(conf.env['ADDITIONAL_LDFLAGS'])

    if path is None:
        conf.write_config_header('config.h', top=True)
    else:
        conf.write_config_header(path)
    conf.SAMBA_CROSS_CHECK_COMPLETE()