xref: /aosp_15_r20/external/libpcap/pcap-config.in (revision 8b26181f966a6af5cf6981a6f474313de533bb28)
1*8b26181fSAndroid Build Coastguard Worker#! /bin/sh
2*8b26181fSAndroid Build Coastguard Worker
3*8b26181fSAndroid Build Coastguard Worker#
4*8b26181fSAndroid Build Coastguard Worker# Script to give the appropriate compiler flags and linker flags
5*8b26181fSAndroid Build Coastguard Worker# to use when building code that uses libpcap.
6*8b26181fSAndroid Build Coastguard Worker#
7*8b26181fSAndroid Build Coastguard Worker# These variables come from the configure script, so includedir and
8*8b26181fSAndroid Build Coastguard Worker# libdir may be defined in terms of prefix and exec_prefix, so the
9*8b26181fSAndroid Build Coastguard Worker# latter must be defined as well.
10*8b26181fSAndroid Build Coastguard Worker#
11*8b26181fSAndroid Build Coastguard Workerprefix="@prefix@"
12*8b26181fSAndroid Build Coastguard Workerexec_prefix="@exec_prefix@"
13*8b26181fSAndroid Build Coastguard Workerincludedir="@includedir@"
14*8b26181fSAndroid Build Coastguard Workerlibdir="@libdir@"
15*8b26181fSAndroid Build Coastguard WorkerLIBS="@LIBS@"
16*8b26181fSAndroid Build Coastguard WorkerLIBS_STATIC="@LIBS_STATIC@"
17*8b26181fSAndroid Build Coastguard WorkerVERSION="@PACKAGE_VERSION@"
18*8b26181fSAndroid Build Coastguard Worker
19*8b26181fSAndroid Build Coastguard Workerstatic=0
20*8b26181fSAndroid Build Coastguard Workerstatic_pcap_only=0
21*8b26181fSAndroid Build Coastguard Workershow_cflags=0
22*8b26181fSAndroid Build Coastguard Workershow_libs=0
23*8b26181fSAndroid Build Coastguard Workershow_additional_libs=0
24*8b26181fSAndroid Build Coastguard Workerwhile [ "$#" != 0 ]
25*8b26181fSAndroid Build Coastguard Workerdo
26*8b26181fSAndroid Build Coastguard Worker	case "$1" in
27*8b26181fSAndroid Build Coastguard Worker
28*8b26181fSAndroid Build Coastguard Worker	--static)
29*8b26181fSAndroid Build Coastguard Worker		static=1
30*8b26181fSAndroid Build Coastguard Worker		;;
31*8b26181fSAndroid Build Coastguard Worker
32*8b26181fSAndroid Build Coastguard Worker	--static-pcap-only)
33*8b26181fSAndroid Build Coastguard Worker		static_pcap_only=1
34*8b26181fSAndroid Build Coastguard Worker		;;
35*8b26181fSAndroid Build Coastguard Worker
36*8b26181fSAndroid Build Coastguard Worker	--cflags)
37*8b26181fSAndroid Build Coastguard Worker		show_cflags=1
38*8b26181fSAndroid Build Coastguard Worker		;;
39*8b26181fSAndroid Build Coastguard Worker
40*8b26181fSAndroid Build Coastguard Worker	--libs)
41*8b26181fSAndroid Build Coastguard Worker		show_libs=1
42*8b26181fSAndroid Build Coastguard Worker		;;
43*8b26181fSAndroid Build Coastguard Worker
44*8b26181fSAndroid Build Coastguard Worker	--additional-libs)
45*8b26181fSAndroid Build Coastguard Worker		show_additional_libs=1
46*8b26181fSAndroid Build Coastguard Worker		;;
47*8b26181fSAndroid Build Coastguard Worker
48*8b26181fSAndroid Build Coastguard Worker	-h|--help)
49*8b26181fSAndroid Build Coastguard Worker		echo "Usage: pcap-config [ --help ] [--version] [ --static | --static-pcap-only ] [ --libs | --additional-libs ]"
50*8b26181fSAndroid Build Coastguard Worker		exit 0
51*8b26181fSAndroid Build Coastguard Worker		;;
52*8b26181fSAndroid Build Coastguard Worker
53*8b26181fSAndroid Build Coastguard Worker	--version)
54*8b26181fSAndroid Build Coastguard Worker		echo "$VERSION"
55*8b26181fSAndroid Build Coastguard Worker		exit 0
56*8b26181fSAndroid Build Coastguard Worker		;;
57*8b26181fSAndroid Build Coastguard Worker
58*8b26181fSAndroid Build Coastguard Worker	*)
59*8b26181fSAndroid Build Coastguard Worker		echo "pcap-config: Invalid command-line option $1 specified" 1>&2
60*8b26181fSAndroid Build Coastguard Worker		echo "Usage: pcap-config [ --help ] [ --static | --static-pcap-only ] [ --libs | --additional-libs ]" 1>&2
61*8b26181fSAndroid Build Coastguard Worker		exit 1
62*8b26181fSAndroid Build Coastguard Worker		;;
63*8b26181fSAndroid Build Coastguard Worker	esac
64*8b26181fSAndroid Build Coastguard Worker	shift
65*8b26181fSAndroid Build Coastguard Workerdone
66*8b26181fSAndroid Build Coastguard Worker
67*8b26181fSAndroid Build Coastguard Worker#
68*8b26181fSAndroid Build Coastguard Worker# If we aren't installing in /usr, then provide a -L flag to let build
69*8b26181fSAndroid Build Coastguard Worker# processes find our library.
70*8b26181fSAndroid Build Coastguard Worker#
71*8b26181fSAndroid Build Coastguard Worker# (We must check $prefix, as $libdir isn't necessarily /usr/lib in this
72*8b26181fSAndroid Build Coastguard Worker# case - for example, Linux distributions for 64-bit platforms that
73*8b26181fSAndroid Build Coastguard Worker# also provide support for binaries for a 32-bit version of the
74*8b26181fSAndroid Build Coastguard Worker# platform may put the 64-bit libraries, the 32-bit libraries, or both
75*8b26181fSAndroid Build Coastguard Worker# in directories other than /usr/lib.)
76*8b26181fSAndroid Build Coastguard Worker#
77*8b26181fSAndroid Build Coastguard Workerif [ "$prefix" != "/usr" ]
78*8b26181fSAndroid Build Coastguard Workerthen
79*8b26181fSAndroid Build Coastguard Worker	LPATH=-L$libdir
80*8b26181fSAndroid Build Coastguard Workerfi
81*8b26181fSAndroid Build Coastguard Workerif [ "$static" = 1 ]
82*8b26181fSAndroid Build Coastguard Workerthen
83*8b26181fSAndroid Build Coastguard Worker	#
84*8b26181fSAndroid Build Coastguard Worker	# Include LIBS_STATIC so that the flags include libraries
85*8b26181fSAndroid Build Coastguard Worker	# containing routines that libpcap uses, and libraries
86*8b26181fSAndroid Build Coastguard Worker	# containing routines those libraries use, etc., so that a
87*8b26181fSAndroid Build Coastguard Worker	# completely statically linked program - i.e., linked only with
88*8b26181fSAndroid Build Coastguard Worker	# static libraries - will be linked with all necessary
89*8b26181fSAndroid Build Coastguard Worker	# libraries.
90*8b26181fSAndroid Build Coastguard Worker	#
91*8b26181fSAndroid Build Coastguard Worker	if [ "$show_cflags" = 1 -a "$show_libs" = 1 ]
92*8b26181fSAndroid Build Coastguard Worker	then
93*8b26181fSAndroid Build Coastguard Worker		echo "-I$includedir $LPATH -l@PACKAGE_NAME@ $LIBS_STATIC"
94*8b26181fSAndroid Build Coastguard Worker	elif [ "$show_cflags" = 1 -a "$show_additional_libs" = 1 ]
95*8b26181fSAndroid Build Coastguard Worker	then
96*8b26181fSAndroid Build Coastguard Worker		echo "-I$includedir $LPATH $LIBS_STATIC"
97*8b26181fSAndroid Build Coastguard Worker	elif [ "$show_cflags" = 1 ]
98*8b26181fSAndroid Build Coastguard Worker	then
99*8b26181fSAndroid Build Coastguard Worker		echo "-I$includedir"
100*8b26181fSAndroid Build Coastguard Worker	elif [ "$show_libs" = 1 ]
101*8b26181fSAndroid Build Coastguard Worker	then
102*8b26181fSAndroid Build Coastguard Worker		echo "$LPATH -l@PACKAGE_NAME@ $LIBS_STATIC"
103*8b26181fSAndroid Build Coastguard Worker	elif [ "$show_additional_libs" = 1 ]
104*8b26181fSAndroid Build Coastguard Worker	then
105*8b26181fSAndroid Build Coastguard Worker		echo "$LIBS_STATIC"
106*8b26181fSAndroid Build Coastguard Worker	fi
107*8b26181fSAndroid Build Coastguard Workerelif [ "$static_pcap_only" = 1 ]
108*8b26181fSAndroid Build Coastguard Workerthen
109*8b26181fSAndroid Build Coastguard Worker	#
110*8b26181fSAndroid Build Coastguard Worker	# Include LIBS so that the flags include libraries
111*8b26181fSAndroid Build Coastguard Worker	# containing routines that libpcap uses, but not the libraries
112*8b26181fSAndroid Build Coastguard Worker	# on which libpcap depends, so that an otherwise
113*8b26181fSAndroid Build Coastguard Worker	# dynamically-linked program, linked statically only with
114*8b26181fSAndroid Build Coastguard Worker	# libpcap - i.e., linked with a static libpcap and dynamic
115*8b26181fSAndroid Build Coastguard Worker	# versions of other libraries - will be linked with all
116*8b26181fSAndroid Build Coastguard Worker	# necessary libraries.
117*8b26181fSAndroid Build Coastguard Worker	#
118*8b26181fSAndroid Build Coastguard Worker	if [ "$show_cflags" = 1 -a "$show_libs" = 1 ]
119*8b26181fSAndroid Build Coastguard Worker	then
120*8b26181fSAndroid Build Coastguard Worker		echo "-I$includedir $LPATH -l@PACKAGE_NAME@ $LIBS"
121*8b26181fSAndroid Build Coastguard Worker	elif [ "$show_cflags" = 1 -a "$show_additional_libs" = 1 ]
122*8b26181fSAndroid Build Coastguard Worker	then
123*8b26181fSAndroid Build Coastguard Worker		echo "-I$includedir $LPATH $LIBS"
124*8b26181fSAndroid Build Coastguard Worker	elif [ "$show_cflags" = 1 ]
125*8b26181fSAndroid Build Coastguard Worker	then
126*8b26181fSAndroid Build Coastguard Worker		echo "-I$includedir"
127*8b26181fSAndroid Build Coastguard Worker	elif [ "$show_libs" = 1 ]
128*8b26181fSAndroid Build Coastguard Worker	then
129*8b26181fSAndroid Build Coastguard Worker		echo "$LPATH -l@PACKAGE_NAME@ $LIBS"
130*8b26181fSAndroid Build Coastguard Worker	elif [ "$show_additional_libs" = 1 ]
131*8b26181fSAndroid Build Coastguard Worker	then
132*8b26181fSAndroid Build Coastguard Worker		echo "$LIBS"
133*8b26181fSAndroid Build Coastguard Worker	fi
134*8b26181fSAndroid Build Coastguard Workerelse
135*8b26181fSAndroid Build Coastguard Worker	#
136*8b26181fSAndroid Build Coastguard Worker	# Don't included LIBS or LIBS_STATIC, for building a program
137*8b26181fSAndroid Build Coastguard Worker	# with a dynamic libpcap; libpcap, being a dynamic library, will
138*8b26181fSAndroid Build Coastguard Worker	# cause all of its dynamic-library dependencies to be pulled in
139*8b26181fSAndroid Build Coastguard Worker	# at run time.
140*8b26181fSAndroid Build Coastguard Worker	#
141*8b26181fSAndroid Build Coastguard Worker	# Do, however, include RPATH, to make sure that, on platforms
142*8b26181fSAndroid Build Coastguard Worker	# that require this, programs built with this version of
143*8b26181fSAndroid Build Coastguard Worker	# libpcap can find it at run time.
144*8b26181fSAndroid Build Coastguard Worker	#
145*8b26181fSAndroid Build Coastguard Worker	if [ "$show_cflags" = 1 -a "$show_libs" = 1 ]
146*8b26181fSAndroid Build Coastguard Worker	then
147*8b26181fSAndroid Build Coastguard Worker		echo "-I$includedir $LPATH @RPATH@ -l@PACKAGE_NAME@"
148*8b26181fSAndroid Build Coastguard Worker	elif [ "$show_cflags" = 1 -a "$show_additional_libs" = 1 ]
149*8b26181fSAndroid Build Coastguard Worker	then
150*8b26181fSAndroid Build Coastguard Worker		echo "-I$includedir"
151*8b26181fSAndroid Build Coastguard Worker	elif [ "$show_cflags" = 1 ]
152*8b26181fSAndroid Build Coastguard Worker	then
153*8b26181fSAndroid Build Coastguard Worker		echo "-I$includedir"
154*8b26181fSAndroid Build Coastguard Worker	elif [ "$show_libs" = 1 ]
155*8b26181fSAndroid Build Coastguard Worker	then
156*8b26181fSAndroid Build Coastguard Worker		echo "$LPATH @RPATH@ -l@PACKAGE_NAME@"
157*8b26181fSAndroid Build Coastguard Worker	fi
158*8b26181fSAndroid Build Coastguard Workerfi
159