Skip to content

Commit

Permalink
lib/smbreadline: detect picky compile issue with readline.h
Browse files Browse the repository at this point in the history
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 <[email protected]>

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 <[email protected]>
Reviewed-by: Andrew Bartlett <[email protected]>
  • Loading branch information
urisimchoni authored and abartlet committed Nov 24, 2017
1 parent 4fc4e41 commit 16cedcb
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions libcli/smbreadline/wscript_configure
Original file line number Diff line number Diff line change
Expand Up @@ -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 <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>
Expand All @@ -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 <readline/readline.h>
# ifdef HAVE_READLINE_HISTORY_H
# include <readline/history.h>
Expand Down

0 comments on commit 16cedcb

Please sign in to comment.