1##############################################
2#                                            #
3# Nast - Network Analyzer Sniffer Tool       #
4#	                                     #
5# configure.ac - written by embyte@madlab.it #
6#                modified by Snifth@box.it   #
7#                                            #
8##############################################
9
10AC_INIT(nast, 0.2.0, embyte@madlab.it)
11AC_CONFIG_SRCDIR(main.c)
12AC_CONFIG_HEADER(config.h)
13
14# Print a banner
15echo "
16Please wait, I'm going to configure Nast 0.2.0
17"
18
19#########
20# Subst #
21#########
22
23AC_SUBST(NCURSES)
24AC_SUBST(GETOPT)
25
26
27#################
28# Checks for OS #
29#################
30
31AC_CANONICAL_TARGET
32case "$target" in
33*linux*)
34	AC_MSG_NOTICE([Found Linux, happy day!])
35        ;;
36*freebsd*)
37    	AC_MSG_NOTICE([Found FreeBSD, are you a nerd?])
38   	;;
39*openbsd*)
40	AC_MSG_WARN([
41	OpenBSD port: we are working on...
42	Nast could not run correctly
43	])
44  	;;
45*netbsd*)
46	AC_MSG_WARN([
47	NetBSD port: we are working on...
48	Nast could not run correctly
49	])
50	;;
51*)
52        AC_MSG_WARN([
53
54        Your OS seems to be officially unsupported yet, please send an email authors
55
56        ])
57	;;
58esac
59
60
61################
62# Setup prefix #
63################
64
65AC_PREFIX_DEFAULT(/usr/local)
66if test "$prefix" = "NONE"; then
67   prefix="/usr/local"
68   fi
69
70
71#######################
72# Checks for compiler #
73#######################
74
75AC_PROG_CC
76
77
78#########################
79# Checks for libraries. #
80#########################
81
82#
83# -- libnet --
84#
85
86filechk="yes"
87AC_CHECK_FILE(/usr/lib/libnet.a,, filechk="no")
88if test "$filechk" = "no"; then
89 AC_CHECK_FILE(/usr/local/lib/libnet.a, filechk="yes" ; LDFLAGS="-L/usr/local/lib"; CPPFLAGS="-I/usr/local/include")
90fi
91
92if test "$filechk" = "no"; then AC_MSG_ERROR([
93
94Libnet archive file (libnet.a) not found in /usr or /usr/local!
95
96Libnet-1.1.x Packet Shaping Library is required.
97You can download it from official web site: http://www.packetfactory.net/libnet
98
99])
100fi
101
102AC_CHECK_LIB(net, libnet_name2addr4,, AC_MSG_ERROR([
103
104Libnet-1.1.x Packet Shaping Library not found! It's required.
105You can download it from official web site: http://www.packetfactory.net/libnet
106
107]))
108
109#
110# -- libpcap --
111#
112
113filechk="yes"
114AC_CHECK_FILE(/usr/lib/libpcap.a,, filechk="no")
115if test "$filechk" = "no"; then
116 AC_CHECK_FILE(/usr/local/lib/libpcap.a, filechk="yes" ; LDFLAGS="-L/usr/local/lib"; CPPFLAGS="-I/usr/local/include")
117fi
118
119if test "$filechk" = "no"; then AC_MSG_ERROR([
120
121Libpcap archive file (libpcap.a) not found in /usr or /usr/local!
122
123Libpcap-0.7.1 Packet Capture Library is required.
124You can download it from official web site: http://www.tcpdump.org/#current
125
126])
127fi
128
129AC_CHECK_LIB(pcap, pcap_dispatch,, AC_MSG_ERROR([
130
131Libpcap-0.7.1 Packet Capture Library not found! It's required.
132You can download it from official web site: http://www.tcpdump.org/#current
133
134]))
135
136#
137# -- libncurses support --
138#
139
140filechk="yes"
141AC_CHECK_FILE(/usr/lib/libncurses.a,, filechk="no")
142if test "$filechk" = "no"; then
143 AC_CHECK_FILE(/usr/local/lib/libncurses.a, filechk="yes" ; LDFLAGS="-L/usr/local/lib"; CPPFLAGS="-I/usr/local/include")
144fi
145
146if test "$filechk" = "no";
147then AC_MSG_WARN([
148
149Libncurses archive file (libncurses.a) not found in /usr or /usr/local!
150
151Ncurses library (*) not found in your system.
152You can download it from official web site: http://www.gnu.org/software/ncurses/ncurses.html
153(*): CRT screen handling and optimization package
154
155Building without ncurses menu support (-G flag will doesn't work)
156
157])
158fi
159
160ENABLE_NCRS="no"
161AC_CHECK_LIB(ncurses, initscr, ENABLE_NCRS="yes"; NCURSES=ncurses/n_nast.o; LIBS="-lncurses $LIBS"; AC_DEFINE(HAVE_LIBNCURSES), AC_MSG_RESULT([
162
163Ncurses library (*) not found in your system.
164You can download it from official web site: http://www.gnu.org/software/ncurses/ncurses.html
165(*): CRT screen handling and optimization package
166
167Building without ncurses menu support (-G flag will doesn't work)
168
169]))
170#fi
171
172#
173#  --lmenu support--
174#
175
176filechk="yes"
177AC_CHECK_FILE(/usr/lib/libmenu.a,, filechk="no")
178if test "$filechk" = "no"; then
179 AC_CHECK_FILE(/usr/local/lib/libmenu.a, filechk="yes" ; LDFLAGS="-L/usr/local/lib"; CPPFLAGS="-I/usr/local/include")
180fi
181
182if test "$filechk" = "no";
183then AC_MSG_WARN([
184
185Menu archive file (libncurses.a) not found in /usr or /usr/local!
186
187
188Menu library (*) not found in your system.
189You can download it from official web site: http://www.gnu.org/software/ncurses/ncurses.html
190(*): CRT screen handling and optimization package
191
192
193Building without ncurses menu support (-G flag will doesn't work)
194])
195
196fi
197
198ENABLE_NCRS="no"
199AC_CHECK_LIB(menu, menu_opts_off, ENABLE_NCRS="yes"; MENU=ncurses/n_menu.o; LIBS="-lmenu $LIBS"; AC_DEFINE(HAVE_LIBMENU), AC_MSG_RESULT([
200
201Menu library (*) not found in your system.
202You can download it from official web site: http://www.gnu.org/software/ncurses/ncurses.html
203(*): CRT screen handling and optimization package
204
205Building without ncurses menu support (-G flag will doesn't work)
206
207]))
208
209
210
211
212
213
214############################
215# Checks for linux pthread #
216############################
217
218case "$target" in
219*linux*)
220	AC_CHECK_LIB(pthread, pthread_create, , AC_MSG_ERROR([
221
222	Linux threads library not found in your linux-box! Strange..
223
224	]))
225
226	CFLAGS="-Wall -O2"
227	;;
228*bsd*)
229	CFLAGS="-Wall -O2 -pthread"
230	;;
231esac
232
233
234##############################################
235# Checks for headers and common libs/headers #
236##############################################
237
238AC_HEADER_STDC
239AC_CHECK_HEADERS(errno.h sys/utsname.h,, AC_MSG_WARN(This headers are required!))
240
241AH_TEMPLATE(HAVE_GETOPT, define if the getopt.h header is present, OpenBSD for ex. doesn't have one)
242AC_CHECK_FUNC(getopt_long, AC_DEFINE(HAVE_GETOPT), GETOPT="getopt.o getopt1.o")
243#AC_CHECK_HEADER(getopt.h, AC_DEFINE(HAVE_GETOPT), GETOPT="getopt.o getopt1.o")
244
245# Checks for typedefs, structures, and compiler characteristics.
246AC_C_CONST
247AC_HEADER_TIME
248AC_STRUCT_TM
249
250# Checks for library functions.
251AC_FUNC_MALLOC
252AC_TYPE_SIGNAL
253AC_FUNC_VPRINTF
254
255
256##################
257# Write Makefile #
258##################
259
260AC_OUTPUT(Makefile)
261
262
263#################
264# Print results #
265#################
266
267echo "
268Ok. I have done with all.
269
270Results are:
271
272PLATFORM ...... : `uname -mp`
273O.S. .......... : `uname -rs` (`uname -n`)
274COMPILER ...... : ${CC}
275CFLAGS ........ : ${CFLAGS}
276CPPFLAGS ...... : ${CPPFLAGS}
277LDFLAGS ....... : ${LDFLAGS}
278LIBS .......... : ${LIBS}
279PREFIX ........ : ${prefix}
280
281NCURSES SUPPORT : ${ENABLE_NCRS}
282
283Type 'make' to compile or 'make help' to show accepted options.
284"
285
286# ok we have done
287