1dnl Copyright (C) 2004-2012 by Carnegie Mellon University.
2dnl
3dnl @OPENSOURCE_HEADER_START@
4dnl
5dnl Use of the SILK system and related source code is subject to the terms
6dnl of the following licenses:
7dnl
8dnl GNU Public License (GPL) Rights pursuant to Version 2, June 1991
9dnl Government Purpose License Rights (GPLR) pursuant to DFARS 252.227.7013
10dnl
11dnl NO WARRANTY
12dnl
13dnl ANY INFORMATION, MATERIALS, SERVICES, INTELLECTUAL PROPERTY OR OTHER
14dnl PROPERTY OR RIGHTS GRANTED OR PROVIDED BY CARNEGIE MELLON UNIVERSITY
15dnl PURSUANT TO THIS LICENSE (HEREINAFTER THE "DELIVERABLES") ARE ON AN
16dnl "AS-IS" BASIS. CARNEGIE MELLON UNIVERSITY MAKES NO WARRANTIES OF ANY
17dnl KIND, EITHER EXPRESS OR IMPLIED AS TO ANY MATTER INCLUDING, BUT NOT
18dnl LIMITED TO, WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE,
19dnl MERCHANTABILITY, INFORMATIONAL CONTENT, NONINFRINGEMENT, OR ERROR-FREE
20dnl OPERATION. CARNEGIE MELLON UNIVERSITY SHALL NOT BE LIABLE FOR INDIRECT,
21dnl SPECIAL OR CONSEQUENTIAL DAMAGES, SUCH AS LOSS OF PROFITS OR INABILITY
22dnl TO USE SAID INTELLECTUAL PROPERTY, UNDER THIS LICENSE, REGARDLESS OF
23dnl WHETHER SUCH PARTY WAS AWARE OF THE POSSIBILITY OF SUCH DAMAGES.
24dnl LICENSEE AGREES THAT IT WILL NOT MAKE ANY WARRANTY ON BEHALF OF
25dnl CARNEGIE MELLON UNIVERSITY, EXPRESS OR IMPLIED, TO ANY PERSON
26dnl CONCERNING THE APPLICATION OF OR THE RESULTS TO BE OBTAINED WITH THE
27dnl DELIVERABLES UNDER THIS LICENSE.
28dnl
29dnl Licensee hereby agrees to defend, indemnify, and hold harmless Carnegie
30dnl Mellon University, its trustees, officers, employees, and agents from
31dnl all claims or demands made against them (and any related losses,
32dnl expenses, or attorney's fees) arising out of, or relating to Licensee's
33dnl and/or its sub licensees' negligent use or willful misuse of or
34dnl negligent conduct or willful misconduct regarding the Software,
35dnl facilities, or other rights or assistance granted by Carnegie Mellon
36dnl University under this License, including, but not limited to, any
37dnl claims of product liability, personal injury, death, damage to
38dnl property, or violation of any laws or regulations.
39dnl
40dnl Carnegie Mellon University Software Engineering Institute authored
41dnl documents are sponsored by the U.S. Department of Defense under
42dnl Contract FA8721-05-C-0003. Carnegie Mellon University retains
43dnl copyrights in all material produced under this contract. The U.S.
44dnl Government retains a non-exclusive, royalty-free license to publish or
45dnl reproduce these documents, or allow others to do so, for U.S.
46dnl Government purposes only pursuant to the copyright license under the
47dnl contract clause at 252.227.7013.
48dnl
49dnl @OPENSOURCE_HEADER_END@
50
51dnl RCSIDENT("$Id$")
52
53
54# ---------------------------------------------------------------------------
55# AX_LIB_SKIPSET
56#
57#    Determine how to use skipset.  Output variable: SKIPSET_LDFLAGS
58#    Output definition: HAVE_SKIPSET
59#
60AC_DEFUN([AX_LIB_SKIPSET],[
61	AC_SUBST(SKIPSET_LDFLAGS)
62
63	silk_header_names="silk/skipset.h silk-ipset/skipset.h"
64	silk_library_names="silk skipset"
65
66	AC_ARG_WITH([skipset],[AS_HELP_STRING([--with-skipset=SKIPSET_DIR],
67	[specify location of SiLK or SiLK IPSet Library; find "silk-ipset/skipset.h" or "silk/silk.h" in SKIPSET_DIR/include/; find "libskipset.so" or "libsilk.so" in SKIPSET_DIR/lib/
68	])],[
69	   if test "x$withval" != "xyes"
70           then
71	      skipset_dir="$withval"
72              skipset_includes="$skipset_dir/include"
73	      skipset_libs="$skipset_dir/lib"
74           fi
75        ])
76
77
78	ENABLE_SKIPSET=0;
79
80
81	if test "x$skipset_dir" != "xno"
82	then
83	    skip_save_LDFLAGS="$LDFLAGS"
84	    skip_save_LIBS="$LIBS"
85	    skip_save_CFLAGS="$CFLAGS"
86	    skip_save_CPPFLAGS="$CPPFLAGS"
87
88	    if test "x$skipset_libs" != "x"
89	    then
90	      SKIPSET_LDFLAGS="-L$skipset_libs"
91	      LDFLAGS="$SKIPSET_LDFLAGS $skip_save_LDFLAGS"
92	    fi
93
94	    if test "x$skipset_includes" != "x"
95  	    then
96		SKIPSET_CFLAGS="-I$skipset_includes"
97		CPPFLAGS="$SKIPSET_CFLAGS $skip_save_CPPFLAGS"
98	    fi
99
100	    for sk_ip_hdr in $silk_header_names
101	    do
102		AC_CHECK_HEADER([$sk_ip_hdr], [
103		    sk_ip_hdr="<$sk_ip_hdr>"
104		    ENABLE_SKIPSET=1
105		    break])
106	    done
107
108	    if test "x$ENABLE_SKIPSET" = "x1"
109	    then
110	        AC_CHECK_HEADERS([silk/skipaddr.h silk/utils.h])
111
112	    	AC_SEARCH_LIBS([skIPSetLoad],[$silk_library_names],[ENABLE_SKIPSET=1],[ENABLE_SKIPSET=0])
113
114	    	if test "x$ENABLE_SKIPSET" = "x1"
115	    	then
116			case "(X$ac_cv_search_skIPSetLoad" in *X-l*)
117		     	SKIPSET_LDFLAGS="$SKIPSET_LDFLAGS $ac_cv_search_skIPSetLoad" ;;
118			esac
119            	fi
120	    fi
121
122	     # Restore cached values
123             LDFLAGS="$skip_save_LDFLAGS"
124             LIBS="$skip_save_LIBS"
125             CFLAGS="$skip_save_CFLAGS"
126             CPPFLAGS="$skip_save_CPPFLAGS"
127
128	fi
129
130        if test "x$ENABLE_SKIPSET" != "x1"
131	   then
132	       AC_MSG_NOTICE([Not building IPSET support due to missing skipset headers or libraries])
133	       SKIPSET_LDFLAGS=
134               SKIPSET_CLAGS=
135           else
136	      AC_DEFINE_UNQUOTED([SKIPSET_HEADER_NAME],[$sk_ip_hdr],
137	          [When ENABLE_SKIPSET is set, this is the path to the skipset.h header file])
138	fi
139
140	AM_CONDITIONAL(HAVE_SKIPSET, [test "x$ENABLE_SKIPSET" = "x1"])
141	if test "x$ENABLE_SKIPSET" = "x1"
142	then
143	    AC_DEFINE(ENABLE_SKIPSET, [1],
144                      [Define to 1 if SiLK IPSet libraries are available])
145            RPM_CONFIG_FLAGS="${RPM_CONFIG_FLAGS} --with-skipset"
146	    AC_SUBST(SM_REQ_SKIPSET, [1])
147	fi
148])
149