Skip to content

Commit a0f5531

Browse files
committed
Fix inclusion of Lua headers. See nmap#1355
We will need to do something similar for Ncat.
1 parent f836c16 commit a0f5531

19 files changed

+140
-234
lines changed

CHANGELOG

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#Nmap Changelog ($Id$); -*-text-*-
22

3+
o [GH#1355] When searching for Lua header files, actually use them where they
4+
are found instead of forcing /usr/include. [Fabrice Fontaine, Daniel Miller]
5+
36
o [NSE][GH#1331] Script traceroute-geolocation no longer crashes when
47
www.GeoPlugin.net returns null coordinates [Michal Kubenka, nnposter]
58

Makefile.in

+1-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ export NSOCKDIR=@NSOCKDIR@
2121
export LIBLUADIR = @LIBLUADIR@
2222
export LIBLINEARDIR = @LIBLINEARDIR@
2323
export NDIR=$(shell pwd)
24-
export LIBLUA_LIBS = @LIBLUA_LIBS@
2524
export LIBLINEAR_LIBS = @LIBLINEAR_LIBS@
2625
export NCATDIR=@NCATDIR@
2726
CC = @CC@
@@ -91,7 +90,7 @@ UNINSTALLZENMAP=@UNINSTALLZENMAP@
9190
UNINSTALLNDIFF=@UNINSTALLNDIFF@
9291
UNINSTALLNPING=@UNINSTALLNPING@
9392

94-
ifneq (@LIBLUA_LIBS@,)
93+
ifneq (@NOLUA@,yes)
9594
NSE_SRC=nse_main.cc nse_utility.cc nse_nsock.cc nse_dnet.cc nse_fs.cc nse_nmaplib.cc nse_debug.cc nse_pcrelib.cc nse_lpeg.cc
9695
NSE_HDRS=nse_main.h nse_utility.h nse_nsock.h nse_dnet.h nse_fs.h nse_nmaplib.h nse_debug.h nse_pcrelib.h nse_lpeg.h
9796
NSE_OBJS=nse_main.o nse_utility.o nse_nsock.o nse_dnet.o nse_fs.o nse_nmaplib.o nse_debug.o nse_pcrelib.o nse_lpeg.o

configure

+61-156
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,7 @@ LUA_CLEAN
653653
LUA_BUILD
654654
LIBLUADIR
655655
LIBLUA_LIBS
656+
NOLUA
656657
DNET_DIST_CLEAN
657658
DNET_CLEAN
658659
DNET_BUILD
@@ -2014,48 +2015,6 @@ $as_echo "$ac_res" >&6; }
20142015
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
20152016

20162017
} # ac_fn_c_check_func
2017-
2018-
# ac_fn_cxx_try_run LINENO
2019-
# ------------------------
2020-
# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes
2021-
# that executables *can* be run.
2022-
ac_fn_cxx_try_run ()
2023-
{
2024-
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
2025-
if { { ac_try="$ac_link"
2026-
case "(($ac_try" in
2027-
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
2028-
*) ac_try_echo=$ac_try;;
2029-
esac
2030-
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
2031-
$as_echo "$ac_try_echo"; } >&5
2032-
(eval "$ac_link") 2>&5
2033-
ac_status=$?
2034-
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
2035-
test $ac_status = 0; } && { ac_try='./conftest$ac_exeext'
2036-
{ { case "(($ac_try" in
2037-
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
2038-
*) ac_try_echo=$ac_try;;
2039-
esac
2040-
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
2041-
$as_echo "$ac_try_echo"; } >&5
2042-
(eval "$ac_try") 2>&5
2043-
ac_status=$?
2044-
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
2045-
test $ac_status = 0; }; }; then :
2046-
ac_retval=0
2047-
else
2048-
$as_echo "$as_me: program exited with status $ac_status" >&5
2049-
$as_echo "$as_me: failed program was:" >&5
2050-
sed 's/^/| /' conftest.$ac_ext >&5
2051-
2052-
ac_retval=$ac_status
2053-
fi
2054-
rm -rf conftest.dSYM conftest_ipa8_conftest.oo
2055-
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
2056-
as_fn_set_status $ac_retval
2057-
2058-
} # ac_fn_cxx_try_run
20592018
cat >config.log <<_ACEOF
20602019
This file contains any messages produced by compilers while
20612020
running configure, to aid debugging if configure makes a mistake.
@@ -7079,6 +7038,8 @@ if test "${with_liblua+set}" = set; then :
70797038
LUA_DIST_CLEAN="distclean-lua"
70807039
have_lua="yes"
70817040

7041+
$as_echo "#define LUA_INCLUDED 1" >>confdefs.h
7042+
70827043
;;
70837044
no)
70847045
no_lua="yes"
@@ -7154,7 +7115,7 @@ fi
71547115
if test "$no_lua" = "yes"; then
71557116
trace_no_use="$trace_no_use lua"
71567117
CPPFLAGS="-DNOLUA $CPPFLAGS"
7157-
LIBLUA_LIBS=""
7118+
NOLUA="yes"
71587119
LUA_BUILD=""
71597120
LUA_CLEAN=""
71607121
LUA_DIST_CLEAN=""
@@ -7173,53 +7134,17 @@ if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
71737134
cat >>confdefs.h <<_ACEOF
71747135
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
71757136
_ACEOF
7176-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for lua_isyieldable in -llua5.3" >&5
7177-
$as_echo_n "checking for lua_isyieldable in -llua5.3... " >&6; }
7178-
if ${ac_cv_lib_lua5_3_lua_isyieldable+:} false; then :
7179-
$as_echo_n "(cached) " >&6
7180-
else
7181-
ac_check_lib_save_LIBS=$LIBS
7182-
LIBS="-llua5.3 -lm $LIBS"
7183-
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
7184-
/* end confdefs.h. */
7185-
7186-
/* Override any GCC internal prototype to avoid an error.
7187-
Use char because int might match the return type of a GCC
7188-
builtin and then its argument prototype would still apply. */
7189-
#ifdef __cplusplus
7190-
extern "C"
7191-
#endif
7192-
char lua_isyieldable ();
7193-
int
7194-
main ()
7195-
{
7196-
return lua_isyieldable ();
7197-
;
7198-
return 0;
7199-
}
7200-
_ACEOF
7201-
if ac_fn_c_try_link "$LINENO"; then :
7202-
ac_cv_lib_lua5_3_lua_isyieldable=yes
7203-
else
7204-
ac_cv_lib_lua5_3_lua_isyieldable=no
7205-
fi
7206-
rm -f core conftest.err conftest.$ac_objext \
7207-
conftest$ac_exeext conftest.$ac_ext
7208-
LIBS=$ac_check_lib_save_LIBS
7209-
fi
7210-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_lua5_3_lua_isyieldable" >&5
7211-
$as_echo "$ac_cv_lib_lua5_3_lua_isyieldable" >&6; }
7212-
if test "x$ac_cv_lib_lua5_3_lua_isyieldable" = xyes; then :
7213-
have_lua=yes; LIBLUA_LIBS="-llua5.3"; CPPFLAGS="-I/usr/include/lua5.3 $CPPFLAGS"; break
7137+
break
72147138
fi
72157139

7216-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for lua_isyieldable in -llua53" >&5
7217-
$as_echo_n "checking for lua_isyieldable in -llua53... " >&6; }
7218-
if ${ac_cv_lib_lua53_lua_isyieldable+:} false; then :
7140+
done
7141+
7142+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing lua_isyieldable" >&5
7143+
$as_echo_n "checking for library containing lua_isyieldable... " >&6; }
7144+
if ${ac_cv_search_lua_isyieldable+:} false; then :
72197145
$as_echo_n "(cached) " >&6
72207146
else
7221-
ac_check_lib_save_LIBS=$LIBS
7222-
LIBS="-llua53 -lm $LIBS"
7147+
ac_func_search_save_LIBS=$LIBS
72237148
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
72247149
/* end confdefs.h. */
72257150
@@ -7238,101 +7163,79 @@ return lua_isyieldable ();
72387163
return 0;
72397164
}
72407165
_ACEOF
7241-
if ac_fn_c_try_link "$LINENO"; then :
7242-
ac_cv_lib_lua53_lua_isyieldable=yes
7243-
else
7244-
ac_cv_lib_lua53_lua_isyieldable=no
7166+
for ac_lib in '' lua5.3 lua53 lua; do
7167+
if test -z "$ac_lib"; then
7168+
ac_res="none required"
7169+
else
7170+
ac_res=-l$ac_lib
7171+
LIBS="-l$ac_lib -lm $ac_func_search_save_LIBS"
7172+
fi
7173+
if ac_fn_c_try_link "$LINENO"; then :
7174+
ac_cv_search_lua_isyieldable=$ac_res
72457175
fi
72467176
rm -f core conftest.err conftest.$ac_objext \
7247-
conftest$ac_exeext conftest.$ac_ext
7248-
LIBS=$ac_check_lib_save_LIBS
7249-
fi
7250-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_lua53_lua_isyieldable" >&5
7251-
$as_echo "$ac_cv_lib_lua53_lua_isyieldable" >&6; }
7252-
if test "x$ac_cv_lib_lua53_lua_isyieldable" = xyes; then :
7253-
have_lua=yes; LIBLUA_LIBS="-llua53"; CPPFLAGS="-I/usr/include/lua53 $CPPFLAGS"; break
7177+
conftest$ac_exeext
7178+
if ${ac_cv_search_lua_isyieldable+:} false; then :
7179+
break
72547180
fi
7181+
done
7182+
if ${ac_cv_search_lua_isyieldable+:} false; then :
72557183

7256-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for lua_isyieldable in -llua" >&5
7257-
$as_echo_n "checking for lua_isyieldable in -llua... " >&6; }
7258-
if ${ac_cv_lib_lua_lua_isyieldable+:} false; then :
7259-
$as_echo_n "(cached) " >&6
72607184
else
7261-
ac_check_lib_save_LIBS=$LIBS
7262-
LIBS="-llua -lm $LIBS"
7263-
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
7264-
/* end confdefs.h. */
7265-
7266-
/* Override any GCC internal prototype to avoid an error.
7267-
Use char because int might match the return type of a GCC
7268-
builtin and then its argument prototype would still apply. */
7269-
#ifdef __cplusplus
7270-
extern "C"
7271-
#endif
7272-
char lua_isyieldable ();
7273-
int
7274-
main ()
7275-
{
7276-
return lua_isyieldable ();
7277-
;
7278-
return 0;
7279-
}
7280-
_ACEOF
7281-
if ac_fn_c_try_link "$LINENO"; then :
7282-
ac_cv_lib_lua_lua_isyieldable=yes
7283-
else
7284-
ac_cv_lib_lua_lua_isyieldable=no
7285-
fi
7286-
rm -f core conftest.err conftest.$ac_objext \
7287-
conftest$ac_exeext conftest.$ac_ext
7288-
LIBS=$ac_check_lib_save_LIBS
7185+
ac_cv_search_lua_isyieldable=no
72897186
fi
7290-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_lua_lua_isyieldable" >&5
7291-
$as_echo "$ac_cv_lib_lua_lua_isyieldable" >&6; }
7292-
if test "x$ac_cv_lib_lua_lua_isyieldable" = xyes; then :
7293-
have_lua=yes; LIBLUA_LIBS="-llua"; CPPFLAGS="-I/usr/include/lua $CPPFLAGS"; break
7187+
rm conftest.$ac_ext
7188+
LIBS=$ac_func_search_save_LIBS
72947189
fi
7295-
7296-
7190+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_lua_isyieldable" >&5
7191+
$as_echo "$ac_cv_search_lua_isyieldable" >&6; }
7192+
ac_res=$ac_cv_search_lua_isyieldable
7193+
if test "$ac_res" != no; then :
7194+
test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
7195+
have_lua=yes
72977196
fi
72987197

7299-
done
7300-
7301-
7302-
ac_ext=cpp
7303-
ac_cpp='$CXXCPP $CPPFLAGS'
7304-
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
7305-
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
7306-
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
7198+
ac_ext=c
7199+
ac_cpp='$CPP $CPPFLAGS'
7200+
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
7201+
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
7202+
ac_compiler_gnu=$ac_cv_c_compiler_gnu
73077203

7308-
# We need Lua 5.2 exactly
7204+
# We need Lua 5.3 exactly
73097205
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for lua version == 503" >&5
73107206
$as_echo_n "checking for lua version == 503... " >&6; }
7311-
7312-
if test "$cross_compiling" = yes; then :
7313-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: cross-compiling -- assuming yes" >&5
7314-
$as_echo "cross-compiling -- assuming yes" >&6; }; have_lua=yes
7315-
else
7316-
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
7207+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
73177208
/* end confdefs.h. */
7318-
#include <lua.h>
7209+
7210+
#ifdef HAVE_LUA5_3_LUA_H
7211+
#include <lua5.3/lua.h>
7212+
#elif defined HAVE_LUA_5_3_LUA_H
7213+
#include <lua/5.3/lua.h>
7214+
#elif defined HAVE_LUA_H || defined LUA_INCLUDED
7215+
#include <lua.h>
7216+
#elif defined HAVE_LUA_LUA_H
7217+
#include <lua/lua.h>
7218+
#endif
7219+
7220+
#if (LUA_VERSION_NUM != 503)
7221+
#error Incorrect Lua version
7222+
#endif
7223+
73197224
int
73207225
main ()
73217226
{
73227227
if(LUA_VERSION_NUM != 503) return 1;
73237228
;
73247229
return 0;
73257230
}
7231+
73267232
_ACEOF
7327-
if ac_fn_cxx_try_run "$LINENO"; then :
7233+
if ac_fn_c_try_cpp "$LINENO"; then :
73287234
have_lua=yes
73297235
else
73307236
have_lua=no
73317237
fi
7332-
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
7333-
conftest.$ac_objext conftest.beam conftest.$ac_ext
7334-
fi
7335-
7238+
rm -f conftest.err conftest.i conftest.$ac_ext
73367239
ac_ext=c
73377240
ac_cpp='$CPP $CPPFLAGS'
73387241
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -7377,6 +7280,7 @@ fi
73777280

73787281

73797282

7283+
73807284
LIBLINEARDIR=liblinear
73817285
have_liblinear=no
73827286

@@ -7896,6 +7800,7 @@ fi
78967800
done
78977801

78987802

7803+
78997804
ac_ext=cpp
79007805
ac_cpp='$CXXCPP $CPPFLAGS'
79017806
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'

configure.ac

+25-14
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,7 @@ AC_SEARCH_LIBS(dlopen, dl)
821821
if test "$no_lua" = "yes"; then
822822
trace_no_use="$trace_no_use lua"
823823
CPPFLAGS="-DNOLUA $CPPFLAGS"
824-
LIBLUA_LIBS=""
824+
NOLUA="yes"
825825
LUA_BUILD=""
826826
LUA_CLEAN=""
827827
LUA_DIST_CLEAN=""
@@ -832,20 +832,30 @@ else
832832

833833
# If they didn't specify it, we try to find it
834834
if test $have_lua != yes; then
835-
AC_CHECK_HEADERS([lua5.3/lua.h lua/5.3/lua.h lua.h lua/lua.h],
836-
AC_CHECK_LIB(lua5.3, lua_isyieldable, [have_lua=yes; LIBLUA_LIBS="-llua5.3"; CPPFLAGS="-I/usr/include/lua5.3 $CPPFLAGS"; break],, [-lm])
837-
AC_CHECK_LIB(lua53, lua_isyieldable, [have_lua=yes; LIBLUA_LIBS="-llua53"; CPPFLAGS="-I/usr/include/lua53 $CPPFLAGS"; break],, [-lm])
838-
AC_CHECK_LIB(lua, lua_isyieldable, [have_lua=yes; LIBLUA_LIBS="-llua"; CPPFLAGS="-I/usr/include/lua $CPPFLAGS"; break],, [-lm])
839-
)
840-
841-
AC_LANG_PUSH(C++)
842-
# We need Lua 5.2 exactly
835+
AC_CHECK_HEADERS([lua5.3/lua.h lua/5.3/lua.h lua.h lua/lua.h], [break])
836+
AC_SEARCH_LIBS(lua_isyieldable, [lua5.3 lua53 lua], [have_lua=yes],, [-lm])
837+
AC_LANG_PUSH(C)
838+
# We need Lua 5.3 exactly
843839
AC_MSG_CHECKING([for lua version == 503])
844-
AC_RUN_IFELSE([ AC_LANG_PROGRAM(
845-
[[#include <lua.h>]],
846-
[[if(LUA_VERSION_NUM != 503) return 1;]])],
847-
have_lua=yes, have_lua=no, AC_MSG_RESULT(cross-compiling -- assuming yes); have_lua=yes)
848-
AC_LANG_POP(C++)
840+
AC_PREPROC_IFELSE([ AC_LANG_PROGRAM( [[
841+
#ifdef HAVE_LUA5_3_LUA_H
842+
#include <lua5.3/lua.h>
843+
#elif defined HAVE_LUA_5_3_LUA_H
844+
#include <lua/5.3/lua.h>
845+
#elif defined HAVE_LUA_H || defined LUA_INCLUDED
846+
#include <lua.h>
847+
#elif defined HAVE_LUA_LUA_H
848+
#include <lua/lua.h>
849+
#endif
850+
851+
#if (LUA_VERSION_NUM != 503)
852+
#error Incorrect Lua version
853+
#endif
854+
]],
855+
[[if(LUA_VERSION_NUM != 503) return 1;]])
856+
],
857+
[have_lua=yes], [have_lua=no])
858+
AC_LANG_POP(C)
849859

850860
LUA_BUILD=""
851861
LUA_CLEAN=""
@@ -869,6 +879,7 @@ else
869879
NSE_CHECK="check-nse"
870880
fi
871881

882+
AC_SUBST(NOLUA)
872883
AC_SUBST(LIBLUA_LIBS)
873884
AC_SUBST(LIBLUADIR)
874885
AC_SUBST(LUA_BUILD)

0 commit comments

Comments
 (0)