summaryrefslogtreecommitdiff
blob: cb47ad0d2ac29d4baf53f009ecba6e6cce54ba68 (plain)
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
--- a/configure.ac
+++ b/configure.ac
@@ -14,6 +14,8 @@
 AC_HEADER_STDC
 AC_HEADER_ASSERT
 
+PKG_PROG_PKG_CONFIG
+
 AX_CXX_COMPILE_STDCXX_11
 
 # Checks for header files.
@@ -32,40 +34,13 @@
 AC_FUNC_FORK
 AC_CHECK_FUNCS([gettimeofday memset select socket strtol])
 
-AC_ARG_WITH(lua,
-[  --with-lua=DIR      use lua in DIR],
-[ case "$withval" in
-  yes|no)
-     AC_MSG_RESULT(no)
-     ;;
-  *)
-     AC_MSG_RESULT($withval)
-     if test -f $withval/lua.h -a -f $withval/liblua.a; then
-        owd=`pwd`
-        if cd $withval; then withval=`pwd`; cd $owd; fi
-        LUA_INCLUDE="-I$withval"
-        LUA_LIB="-L$withval -llua"
-        LIBS="$LIBS -lm"
-     elif test -f $withval/include/lua.h -a -f $withval/lib/liblua.a; then
-        owd=`pwd`
-        if cd $withval; then withval=`pwd`; cd $owd; fi
-        LUA_INCLUDE="-I$withval/include"
-        LUA_LIB="-L$withval/lib -llua"
-        LIBS="$LIBS -lm"
-     else
-        AC_ERROR("lua.h or liblua.a not found in $withval")
-     fi
-     ;;
-  esac ],
-    [
-        AX_PROG_LUA
-        AX_LUA_HEADERS
-        AX_LUA_LIBS
-        if test x"$LUA_LIB" = x; then
-            AC_MSG_ERROR([Lua library not found. You may try option --with-lua-suffix.])
-        fi
-    ]
-)
+PKG_CHECK_MODULES([LUA53], [lua-5.3], [LUA_INCLUDE="${LUA53_CFLAGS}"; LUA_LIB="${LUA53_LIBS}"],AC_MSG_WARN([lua 5.3 not found]))
+PKG_CHECK_MODULES([LUA52], [lua-5.2], [LUA_INCLUDE="${LUA52_CFLAGS}"; LUA_LIB="${LUA52_LIBS}"],AC_MSG_WARN([lua 5.2 not found]))
+PKG_CHECK_MODULES([LUA51], [lua5.1], [LUA_INCLUDE="${LUA51_CFLAGS}"; LUA_LIB="${LUA51_LIBS}"],AC_MSG_WARN([lua 5.1 not found]))
+
+if test -z "$LUA_INCLUDE" -o -z "$LUA_LIB"; then
+     AC_MSG_ERROR([lua 5.3, 5.2 or 5.1 is required])
+fi
 AC_SUBST(LUA_INCLUDE)
 AC_SUBST(LUA_LIB)
 
@@ -121,24 +96,12 @@
 AC_ARG_WITH(json,
 [  --with-json=DIR      use json-c in DIR],
 [ case "$withval" in
-  yes|no)
+  no)
      AC_MSG_RESULT(no)
      ;;
   *)
      AC_MSG_RESULT($withval)
-     if test -f $withval/json.h -a -f $withval/libjson-c.a; then
-        owd=`pwd`
-        if cd $withval; then withval=`pwd`; cd $owd; fi
-        JSON_INCLUDE="-I$withval"
-        JSON_LIB="-L$withval -ljson-c"
-     elif test -f $withval/include/json-c/json.h -a -f $withval/lib/libjson-c.a; then
-        owd=`pwd`
-        if cd $withval; then withval=`pwd`; cd $owd; fi
-        JSON_INCLUDE="-I$withval/include"
-        JSON_LIB="-L$withval/lib -ljson-c"
-     else
-        AC_ERROR("json.h or libjson-c.a not found in $withval")
-     fi
+     PKG_CHECK_MODULES([JSON], [json-c], [JSON_INCLUDE="${JSON_CFLAGS}"; JSON_LIB="${JSON_LIBS}"],AC_MSG_ERROR([json-c was requested but not found]))
      AC_SUBST(JSON_INCLUDE)
      AC_SUBST(JSON_LIB)
      AC_DEFINE([HAVE_JSONC], [1], [Using json-c])
@@ -153,41 +116,7 @@
     ]
 )
 
-AC_MSG_CHECKING(for libpcap)
-AC_ARG_WITH(libpcap,
-[  --with-libpcap=DIR      use libpcap in DIR],
-[ case "$withval" in
-  yes|no)
-     AC_MSG_RESULT(no)
-     ;;
-  *)
-     AC_MSG_RESULT($withval)
-     if test -f $withval/pcap.h -a \
-         -f $withval/libpcap.a -a \
-         -d $withval/pcap; then
-        owd=`pwd`
-        if cd $withval; then withval=`pwd`; cd $owd; fi
-        PCAPINC="-I$withval -I$withval/bpf"
-        PCAPLIB="-L$withval -lpcap"
-     else
-        AC_ERROR(pcap.h, net/bpf.h, or libpcap.a not found in $withval)
-     fi
-     ;;
-  esac ],
-[ if test -f ${prefix}/include/pcap.h; then
-     PCAPINC="-I${prefix}/include"
-     PCAPLIB="-L${prefix}/lib -lpcap"
-  elif test -f /usr/include/pcap/pcap.h; then
-     PCAPINC="-I/usr/include/pcap"
-     PCAPLIB="-lpcap"
-  elif test -f /usr/include/pcap.h; then
-     PCAPLIB="-lpcap"
-  else
-     AC_MSG_RESULT(no)
-     AC_ERROR(libpcap not found)
-  fi
-  AC_MSG_RESULT(yes) ]
-)
+PKG_CHECK_MODULES([PCAP], [libpcap], [PCAPINC="${PCAP_CFLAGS}"; PCAPLIB="${PCAP_LIBS}"],AC_MSG_ERROR([libpcap is required]))
 AC_SUBST(PCAPINC)
 AC_SUBST(PCAPLIB)
 
@@ -234,17 +163,7 @@
     AC_CHECK_LIB([pthread], [pthread_create])
 ])
 
-# Make sure libcrafter build a static library by adding the --disable-shared
-# argument to the configure script.
-ac_configure_args_pre="$ac_configure_args"
-ac_configure_args_post="$ac_configure_args --disable-shared"
-ac_configure_args="$ac_configure_args_post"
-
-AC_CONFIG_COMMANDS_PRE([ac_configure_args="$ac_configure_args_pre"])
-AC_CONFIG_COMMANDS_POST([ac_configure_args="$ac_configure_args_post"])
-AC_CONFIG_SUBDIRS(noinst/libcrafter/libcrafter)
-
-ac_configure_args="$ac_configure_args_pre"
+PKG_CHECK_MODULES([crafter], [crafter], [LIBS="$LIBS $crafter_LIBS"],AC_MSG_ERROR([libcrafter is required]))
 
 # Enable click submodule
 AS_IF([test "x$enable_tests" = "xyes"], [
@@ -254,7 +173,6 @@
 
     AC_CONFIG_COMMANDS_PRE([ac_configure_args="$ac_configure_args_pre"])
     AC_CONFIG_COMMANDS_POST([ac_configure_args="$ac_configure_args_post"])
-    AC_CONFIG_SUBDIRS(tests/tools/click)
 
     ac_configure_args="$ac_configure_args_pre"
 ])