1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00
samba-mirror/libcli/smbreadline/wscript_configure
Uri Simchoni 16cedcb173 lib/smbreadline: detect picky compile issue with readline.h
readline.h has build issues with clang if -Wstrict-prototypes
is enabled. Detect this and also detect whether the known
workaround works.

Fix suggested by Timur I. Bakeyev <timur@freebsd.org>

cf. https://lists.gnu.org/archive/html/bug-readline/2014-04/msg00018.html
cf. https://lists.samba.org/archive/samba-technical/2017-November/123923.html

Signed-off-by: Uri Simchoni <uri@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2017-11-24 01:13:15 +01:00

86 lines
2.7 KiB
Python

#!/usr/bin/env python
conf.CHECK_HEADERS('readline.h history.h readline/readline.h readline/history.h')
for termlib in ['ncurses', 'curses', 'termcap', 'terminfo', 'termlib', 'tinfo']:
if conf.CHECK_FUNCS_IN('tgetent', termlib):
conf.env['READLINE_TERMLIB'] = termlib
break
#
# Check if we need to work around readline/readline.h
# deprecated declarations
#
if conf.CONFIG_SET('HAVE_READLINE_READLINE_H'):
if not conf.CHECK_CODE('''
#include <readline/readline.h>
int main() {return 0;}
''',
define='HAVE_WORKING_READLINE_READLINE_WITH_STRICT_PROTO',
cflags=conf.env['WERROR_CFLAGS'] +
['-Wstrict-prototypes',
'-Werror=strict-prototypes'],
msg='for compiling <readline/readline.h> with strict prototypes',
addmain=False):
conf.CHECK_CODE('''
#define _FUNCTION_DEF
#include <readline/readline.h>
int main() {return 0;}
''',
cflags=conf.env['WERROR_CFLAGS'] +
['-Wstrict-prototypes',
'-Werror=strict-prototypes'],
msg='for workaround to <readline/readline.h> strict prototypes issue',
define='HAVE_READLINE_READLINE_WORKAROUND',
addmain=False)
conf.CHECK_CODE('''
#ifdef HAVE_READLINE_READLINE_H
# ifdef HAVE_READLINE_READLINE_WORKAROUND
# define _FUNCTION_DEF
# endif
# include <readline/readline.h>
# ifdef HAVE_READLINE_HISTORY_H
# include <readline/history.h>
# endif
#else
# ifdef HAVE_READLINE_H
# include <readline.h>
# ifdef HAVE_HISTORY_H
# include <history.h>
# endif
# endif
#endif
int main(void) {rl_completion_t f; return 0;}
''',
'HAVE_RL_COMPLETION_FUNC_T', execute=False, addmain=False,
msg='Checking for rl_completion_t')
conf.CHECK_CODE('''
#ifdef HAVE_READLINE_READLINE_H
# ifdef HAVE_READLINE_READLINE_WORKAROUND
# define _FUNCTION_DEF
# endif
# include <readline/readline.h>
# ifdef HAVE_READLINE_HISTORY_H
# include <readline/history.h>
# endif
#else
# ifdef HAVE_READLINE_H
# include <readline.h>
# ifdef HAVE_HISTORY_H
# include <history.h>
# endif
# endif
#endif
int main(void) {CPPFunction f; return 0;}
''',
'HAVE_CPPFUNCTION', execute=False, addmain=False,
msg='Checking for CPPFunction')
if conf.CHECK_FUNCS_IN('rl_completion_matches', 'readline'):
conf.DEFINE('HAVE_NEW_LIBREADLINE', 1)
if conf.CHECK_FUNCS_IN('history_list', 'readline'):
conf.DEFINE('HAVE_HISTORY_LIST', 1)