From 16cedcb173da89a9d6f8894e6ff4a42158c5c3b2 Mon Sep 17 00:00:00 2001 From: Uri Simchoni Date: Thu, 23 Nov 2017 22:20:52 +0200 Subject: 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 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 Reviewed-by: Andrew Bartlett --- libcli/smbreadline/wscript_configure | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'libcli') diff --git a/libcli/smbreadline/wscript_configure b/libcli/smbreadline/wscript_configure index b4d1be2b434..912ff53a150 100644 --- a/libcli/smbreadline/wscript_configure +++ b/libcli/smbreadline/wscript_configure @@ -7,8 +7,38 @@ for termlib in ['ncurses', 'curses', 'termcap', 'terminfo', 'termlib', 'tinfo']: 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 + 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 with strict prototypes', + addmain=False): + conf.CHECK_CODE(''' + #define _FUNCTION_DEF + #include + int main() {return 0;} + ''', + cflags=conf.env['WERROR_CFLAGS'] + + ['-Wstrict-prototypes', + '-Werror=strict-prototypes'], + msg='for workaround to 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 # ifdef HAVE_READLINE_HISTORY_H # include @@ -28,6 +58,9 @@ msg='Checking for rl_completion_t') conf.CHECK_CODE(''' #ifdef HAVE_READLINE_READLINE_H +# ifdef HAVE_READLINE_READLINE_WORKAROUND +# define _FUNCTION_DEF +# endif # include # ifdef HAVE_READLINE_HISTORY_H # include -- cgit v1.2.1