1# configure.ac for sniffit
2# Copyright 1997-1998 Brecht Claerhout
3# Copyright 2016-2020 Joao Eriberto Mota Filho
4# Under BSD-3-CLause license.
5
6AC_PREREQ([2.69])
7AC_INIT([sniffit], [0.5], [https://github.com/resurrecting-open-source-projects/sniffit/issues])
8AC_CONFIG_SRCDIR([src/sn_generation.h])
9AC_CONFIG_HEADERS([config.h])
10
11# Checks for programs.
12AC_PROG_CC
13
14# Checks for libraries.
15AC_CHECK_LIB(ncurses, main, , [AC_MSG_ERROR([Couldn't find libncurses])])
16AC_CHECK_LIB(pcap, pcap_open_live, , [AC_MSG_ERROR([Couldn't find libpcap])])
17
18# Checks for header files.
19AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h netinet/in.h stdlib.h string.h sys/socket.h sys/time.h termios.h unistd.h])
20AC_CHECK_HEADERS([ncurses.h], AC_DEFINE([HAVE_NCURSES_H], 1, [none]), AC_MSG_ERROR([ncurses.h not found]))
21AC_CHECK_HEADERS([pcap.h], , AC_MSG_ERROR([pcap.h not found]))
22
23# Checks for typedefs, structures, and compiler characteristics.
24AC_TYPE_SIZE_T
25
26# Checks for library functions.
27AC_FUNC_FORK
28AC_FUNC_MALLOC
29AC_FUNC_REALLOC
30AC_CHECK_FUNCS([alarm bzero gethostbyname socket strchr strdup strstr])
31
32dnl Check Shared Memory support
33AC_CHECK_FUNCS(shmget)
34
35dnl exit function check
36AC_CHECK_FUNCS(atexit)
37
38# Other checks
39
40dnl Check the datalength
41AC_CHECK_SIZEOF(unsigned short int)
42if test $ac_cv_sizeof_unsigned_short_int -ne 2; then
43    echo "unsigned short is NOT 2 bytes... quiting"
44    exit
45fi
46
47AC_CHECK_SIZEOF(unsigned long int)
48if test $ac_cv_sizeof_unsigned_long_int -eq 4; then
49AC_DEFINE(USE_32_LONG_INT, 1, [none])
50else
51    echo "unsigned long is NOT 4 bytes... hmmm..."
52    AC_CHECK_SIZEOF(unsigned int)
53    if test $ac_cv_sizeof_unsigned_int -ne 4; then
54        echo "unsigned int is NOT 4 bytes either... quiting"
55        exit
56    else
57        AC_DEFINE(USE_32_INT, 1, [none])
58    fi
59fi
60
61AC_CONFIG_FILES([Makefile src/Makefile])
62AM_INIT_AUTOMAKE([foreign])
63
64AC_OUTPUT
65