xref: /freebsd/contrib/libpcap/pcap-config.in (revision faf25f48d601ae39f5752602f3020e2e92605625)
1#! /bin/sh
2
3#
4# Script to give the appropriate compiler flags and linker flags
5# to use when building code that uses libpcap.
6#
7# These variables come from the configure script, so includedir and
8# libdir may be defined in terms of prefix and exec_prefix, so the
9# latter must be defined as well.
10#
11prefix="@prefix@"
12exec_prefix="@exec_prefix@"
13includedir="@includedir@"
14libdir="@libdir@"
15V_RPATH_OPT="@V_RPATH_OPT@"
16LIBS="@LIBS@"
17PACKAGE_NAME="@PACKAGE_NAME@"
18
19static=0
20show_cflags=0
21show_libs=0
22while [ "$#" != 0 ]
23do
24	case "$1" in
25
26	--static)
27		static=1
28		;;
29
30	--cflags)
31		show_cflags=1
32		;;
33
34	--libs)
35		show_libs=1
36		;;
37
38	--additional-libs)
39		show_additional_libs=1
40		;;
41	esac
42	shift
43done
44if [ "$V_RPATH_OPT" != "" ]
45then
46	#
47	# If libdir isn't /usr/lib, add it to the run-time linker path.
48	#
49	if [ "$libdir" != "/usr/lib" ]
50	then
51		RPATH=$V_RPATH_OPT$libdir
52	fi
53fi
54if [ "$static" = 1 ]
55then
56	#
57	# Include LIBS so that the flags include libraries containing
58	# routines that libpcap uses.
59	#
60	if [ "$show_cflags" = 1 -a "$show_libs" = 1 ]
61	then
62		echo "-I$includedir -L$libdir -lpcap $LIBS"
63	elif [ "$show_cflags" = 1 -a "$show_additional_libs" = 1 ]
64	then
65		echo "-I$includedir -L$libdir $LIBS"
66	elif [ "$show_cflags" = 1 ]
67	then
68		echo "-I$includedir"
69	elif [ "$show_libs" = 1 ]
70	then
71		echo "-L$libdir -lpcap $LIBS"
72	elif [ "$show_additional_libs" = 1 ]
73	then
74		echo "$LIBS"
75	fi
76else
77	#
78	# Omit LIBS - libpcap is assumed to be linked with those
79	# libraries, so there's no need to do so explicitly.
80	#
81	if [ "$show_cflags" = 1 -a "$show_libs" = 1 ]
82	then
83		echo "-I$includedir -L$libdir $RPATH -l$PACKAGE_NAME"
84	elif [ "$show_cflags" = 1 -a "$show_additional_libs" = 1 ]
85	then
86		echo "-I$includedir"
87	elif [ "$show_cflags" = 1 ]
88	then
89		echo "-I$includedir"
90	elif [ "$show_libs" = 1 ]
91	then
92		echo "-L$libdir $RPATH -l$PACKAGE_NAME"
93	fi
94fi
95