File: configure.ac

package info (click to toggle)
nmap 7.40-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 50,080 kB
  • ctags: 26,777
  • sloc: ansic: 98,862; cpp: 64,063; python: 17,751; sh: 14,584; xml: 11,448; makefile: 2,635; perl: 2,585; yacc: 660; lex: 457; asm: 372; java: 45; objc: 43
file content (313 lines) | stat: -rw-r--r-- 8,548 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ(2.59)
AC_INIT(ncat_main.c)

AC_CONFIG_HEADER(config.h)

m4_include([../acinclude.m4])

AC_CANONICAL_HOST

use_openssl="yes"
specialssldir=""
AC_ARG_WITH(openssl,[  --with-openssl=DIR    Use optional openssl libs and includes from [DIR]/lib/ and [DIR]/include/openssl/],
[  case "$with_openssl" in
  yes)
  ;;
  no)
    use_openssl="no"
  ;;
  *)
    specialssldir="$with_openssl"
    LDFLAGS="$LDFLAGS -L$with_openssl/lib"
    CPPFLAGS="-I$with_openssl/include $CPPFLAGS"
  ;;
  esac]
)

# Checks for programs.
AC_PROG_CC
if test -n "$GCC"; then
  CFLAGS="$CFLAGS -Wall"
fi
AC_PROG_INSTALL

AC_PATH_TOOL([STRIP], [strip], [/bin/true])

# Checks for header files.
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS([fcntl.h limits.h netdb.h netinet/in.h stdlib.h string.h strings.h sys/param.h sys/socket.h sys/time.h sys/timeb.h unistd.h sys/un.h])

# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STAT
AC_C_CONST
AC_HEADER_TIME

# Checks for library functions.
AC_FUNC_FORK
AC_FUNC_SELECT_ARGTYPES
AC_TYPE_SIGNAL
AC_FUNC_VPRINTF
AC_CHECK_FUNCS([dup2 gettimeofday inet_ntoa memset mkstemp select socket strcasecmp strchr strdup strerror strncasecmp strtol])
AC_SEARCH_LIBS(setsockopt, socket)
# Ncat does not call gethostbyname directly, but some of the libraries
# it links to (such as libpcap) do. Instead it calls getaddrinfo. At
# one point we changed this test to use getaddrinfo rather than
# gethostbyname, but on a Solaris 9 SPARC box that function could be
# called without -lnsl, while gethostbyname sitll required -lnsl, so
# we changed the test back.
AC_SEARCH_LIBS(gethostbyname, nsl)
# OpenSSL requires dlopen on some platforms
AC_SEARCH_LIBS(dlopen, dl)

# If they didn't specify it, we try to find it
if test "$use_openssl" = "yes" -a -z "$specialssldir" ; then
	AC_CHECK_HEADER(openssl/ssl.h,,
			[ use_openssl="no"
        AC_MSG_WARN([Failed to find openssl/ssl.h so OpenSSL will not be used. 
	If it is installed you can try the --with-openssl=DIR argument]) ])

	if test "$use_openssl" = "yes"; then
	     AC_CHECK_HEADER(openssl/err.h,,
	         [ use_openssl="no"
		     AC_MSG_WARN([Failed to find openssl/err.h so OpenSSL will not be used.
		      If it is installed you can try the --with-openssl=DIR argument]) ])
	fi

	if test "$use_openssl" = "yes"; then
		   AC_CHECK_HEADER(openssl/rand.h,,
		       [ use_openssl="no"
		         AC_MSG_WARN([Failed to find openssl/rand.h so OpenSSL will not be used.
			  If it is installed you can try the --with-openssl=DIR argument]) ])
	fi

	if test "$use_openssl" = "yes"; then
	 AC_CHECK_LIB(crypto, BIO_int_ctrl,
	   [ use_openssl="yes"],
	   [ use_openssl="no"
	   AC_MSG_WARN([Failed to find libcrypto so OpenSSL will not be used.
	    If it is installed you can try the --with-openssl=DIR argument]) ])
	fi
										     
	if test "$use_openssl" = "yes"; then
	   AC_CHECK_LIB(ssl, SSL_new,
	   [ use_openssl="yes"],
	   [ use_openssl="no"
	   AC_MSG_WARN([Failed to find libssl so OpenSSL will not be used. 
If it is installed you can try the --with-openssl=DIR argument]) ],
     [ -lcrypto ])
	fi
fi

OPENSSL_LIBS=
if test "$use_openssl" = "yes"; then
  AC_DEFINE([HAVE_OPENSSL], [1], [Define to 1 if you have OpenSSL.])
  AC_DEFINE([HAVE_HTTP_DIGEST], [1], [Define to 1 to enable HTTP Digest authentication (requires OpenSSL).])
  OPENSSL_LIBS="-lssl -lcrypto"
  # Define in Makefile also.
  HAVE_OPENSSL=yes
  AC_SUBST(HAVE_OPENSSL)
fi

AC_SUBST(OPENSSL_LIBS)

libpcapdir=../libpcap
AC_SUBST(libpcapdir)

dnl Check whether libpcap is already available
have_libpcap=no

# By default, search for pcap library
test "${with_libpcap+set}" != "set" && with_libpcap=yes

AC_ARG_WITH(libpcap,
AC_HELP_STRING([--with-libpcap=DIR], [Look for pcap in DIR/include and DIR/libs.])
AC_HELP_STRING([--with-libpcap=included], [Always use version included with Nmap]),
[  case "$with_libpcap" in
  yes)
    AC_CHECK_HEADER(pcap.h,[
      AC_CHECK_LIB(pcap, pcap_datalink,
      [have_libpcap=yes ])])
    ;;
  included)
    have_libpcap=no
   ;;
  *)
    _cppflags=$CXXFLAGS
    _ldflags=$LDFLAGS

    CPPFLAGS="-I$with_libpcap/include $CPPFLAGS"
    LDFLAGS="-L$with_libpcap/lib $LDFLAGS"

    AC_CHECK_HEADER(pcap.h,[
      AC_CHECK_LIB(pcap, pcap_datalink,
	[have_libpcap=yes
	LIBPCAP_INC=$with_libpcap/include
	LIBPCAP_LIB=$with_libpcap/lib])])

    LDFLAGS=$_ldflags
    CXXFLAGS=$_cppflags
    ;;
  esac]
)

if test $have_libpcap = yes; then
  if test "${LIBPCAP_INC+set}" = "set"; then
    _cflags=$CXXFLAGS
    _ldflags=$LDFLAGS

    CPPFLAGS="-I$LIBPCAP_INC $CPPFLAGS"
    LDFLAGS="-L$LIBPCAP_LIB $LDFLAGS"
  fi

  # link with -lpcap for the purposes of this test
  LIBS_OLD="$LIBS"
  LIBS="$LIBS -lpcap"
  PCAP_IS_SUITABLE([have_libpcap=yes], [have_libpcap=no], [have_libpcap=yes])
  LIBS="$LIBS_OLD"
fi

PCAP_LIBS="-lpcap"
if test $have_libpcap = yes; then
  PCAP_DEPENDS=""
  PCAP_BUILD=""
  PCAP_CLEAN=""
  PCAP_DIST_CLEAN=""
  AC_DEFINE(HAVE_LIBPCAP)
else
  if test "${LIBPCAP_INC+set}" = "set"; then
    LDFLAGS="-L$libpcapdir $_ldflags"
    CPPFLAGS="$CPPFLAGS -I$LIBPCAP_INC"
  else
    LDFLAGS="-L$libpcapdir $LDFLAGS"
    CPPFLAGS="$CPPFLAGS -I$libpcapdir"
  fi
  PCAP_DEPENDS='$(LIBPCAPDIR)/libpcap.a'
  PCAP_BUILD="build-pcap"
  PCAP_CLEAN="clean-pcap"
  PCAP_DIST_CLEAN="distclean-pcap"
fi

AC_SUBST(PCAP_DEPENDS)
AC_SUBST(PCAP_BUILD)
AC_SUBST(PCAP_CLEAN)
AC_SUBST(PCAP_DIST_CLEAN)
AC_SUBST(PCAP_LIBS)

# Needed on AIX.
AC_CHECK_LIB(odm, odm_initialize)

# Needed on AIX.
AC_CHECK_LIB(odm, odm_initialize)
AC_CHECK_LIB(cfg, _system_configuration)



LIBLUADIR=../liblua

have_lua=no
requested_included_lua=no
no_lua=no

# First we test whether they specified liblua explicitly
AC_ARG_WITH(liblua, 
AC_HELP_STRING([--with-liblua=DIR], [Use an existing (compiled) lua lib from DIR/include and DIR/lib.])
AC_HELP_STRING([--with-liblua=included], [Use the liblua version included with Nmap])
AC_HELP_STRING([--without-liblua], [Compile without lua (this will exclude all of NSE from compilation)]),
[  case "$with_liblua" in
  yes)
  ;;
  included)
    CPPFLAGS="-I\$(top_srcdir)/$LIBLUADIR $CPPFLAGS"
    LIBLUA_LIBS="\$(top_srcdir)/$LIBLUADIR/liblua.a"
    LUA_DEPENDS="\$(top_srcdir)/$LIBLUADIR/liblua.a"
    LUA_BUILD="build-lua"
    LUA_CLEAN="clean-lua"
    LUA_DIST_CLEAN="distclean-lua"
	have_lua="yes"
	
  ;;
  no)
    no_lua="yes"
  ;;
  *)
    CPPFLAGS="-I$with_liblua/include $CPPFLAGS"
    LDFLAGS="-L$with_liblua/lib $LDFLAGS"
  ;;
  esac]
)

LUA_CFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN"
AC_SUBST(LUA_CFLAGS)

# They don't want lua
if test "$no_lua" = "yes"; then
  CPPFLAGS="-DNOLUA $CPPFLAGS"
  LIBLUA_LIBS=""
  LUA_DEPENDS=""
  LUA_BUILD=""
  LUA_CLEAN=""
  LUA_DIST_CLEAN=""
  INSTALLNSE=""

else 

  # If they didn't specify it, we try to find it
  if test $have_lua != yes; then
    AC_CHECK_HEADERS([lua5.3/lua.h lua/5.3/lua.h lua.h lua/lua.h],
      AC_CHECK_LIB(lua5.3, lua_isyieldable, [have_lua=yes; LIBLUA_LIBS="-llua5.3"; CPPFLAGS="-I/usr/include/lua5.3 $CPPFLAGS"; break],, [-lm])
      AC_CHECK_LIB(lua53, lua_isyieldable, [have_lua=yes; LIBLUA_LIBS="-llua53"; CPPFLAGS="-I/usr/include/lua53 $CPPFLAGS"; break],, [-lm])
      AC_CHECK_LIB(lua, lua_isyieldable, [have_lua=yes; LIBLUA_LIBS="-llua"; CPPFLAGS="-I/usr/include/lua $CPPFLAGS"; break],, [-lm])
    )

    AC_LANG_PUSH(C++)
    AC_MSG_CHECKING([for lua version >= 503])
    AC_RUN_IFELSE([ AC_LANG_PROGRAM(
      [[#include <lua.h>]],
      [[if(LUA_VERSION_NUM < 503) return 1;]])],
      have_lua=yes, have_lua=no, AC_MSG_RESULT(cross-compiling -- assuming yes); have_lua=yes)
    AC_LANG_POP(C++)

    LUA_DEPENDS=""
    LUA_BUILD=""
    LUA_CLEAN=""
    LUA_DIST_CLEAN=""
  fi

  # if we didn't find we use our own
  if test $have_lua != yes; then
    AC_MSG_RESULT(no) 
    CPPFLAGS="-I\$(top_srcdir)/$LIBLUADIR $CPPFLAGS"
    LIBLUA_LIBS="\$(top_srcdir)/$LIBLUADIR/liblua.a"
    LUA_DEPENDS="\$(top_srcdir)/$LIBLUADIR/liblua.a"
    LUA_BUILD="build-lua"
    LUA_CLEAN="clean-lua"
    LUA_DIST_CLEAN="distclean-lua"
    AC_DEFINE(LUA_INCLUDED)
  else
    AC_MSG_RESULT(yes) 
  fi

  INSTALLNSE="install-nse"
fi

AC_SUBST(LIBLUA_LIBS)
AC_SUBST(LIBLUADIR)
AC_SUBST(LUA_DEPENDS)
AC_SUBST(LUA_BUILD)
AC_SUBST(LUA_CLEAN)
AC_SUBST(LUA_DIST_CLEAN)



AC_CONFIG_FILES(Makefile)
AC_OUTPUT
# NCAT ASCII ART
if test -f docs/ncat-ascii-art.txt; then
	cat docs/ncat-ascii-art.txt
fi

echo "Configuration complete."