xref: /netbsd-src/external/bsd/libpcap/dist/pcap-config.in (revision cef8759bd76c1b621f8eab8faa6f208faabc2e15)
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 [ "@includedir@" != "/usr/include" ]
55then
56	i="-I@includedir@"
57fi
58if [ "@libdir@" != "/usr/lib" ]
59then
60	l="-L@libdir@"
61fi
62if [ -n "@LIBS@" ]
63then
64	L="@LIBS@"
65fi
66
67if [ "$static" = 1 ]
68then
69	#
70	# Include LIBS so that the flags include libraries containing
71	# routines that libpcap uses.
72	#
73	if [ "$show_cflags" = 1 -a "$show_libs" = 1 ]
74	then
75		echo "-I$includedir -L$libdir -lpcap $LIBS"
76	elif [ "$show_cflags" = 1 -a "$show_additional_libs" = 1 ]
77	then
78		echo "-I$includedir -L$libdir $LIBS"
79	elif [ "$show_cflags" = 1 ]
80	then
81		echo "-I$includedir"
82	elif [ "$show_libs" = 1 ]
83	then
84		echo "-L$libdir -lpcap $LIBS"
85	elif [ "$show_additional_libs" = 1 ]
86	then
87		echo "$LIBS"
88	fi
89else
90	#
91	# Omit LIBS - libpcap is assumed to be linked with those
92	# libraries, so there's no need to do so explicitly.
93	#
94	if [ "$show_cflags" = 1 -a "$show_libs" = 1 ]
95	then
96		echo "-I$includedir -L$libdir $RPATH -l$PACKAGE_NAME"
97	elif [ "$show_cflags" = 1 -a "$show_additional_libs" = 1 ]
98	then
99		echo "-I$includedir"
100	elif [ "$show_cflags" = 1 ]
101	then
102		echo "-I$includedir"
103	elif [ "$show_libs" = 1 ]
104	then
105		echo "-L$libdir $RPATH -l$PACKAGE_NAME"
106	fi
107fi
108