forked from the-tcpdump-group/libpcap
-
Notifications
You must be signed in to change notification settings - Fork 26
/
pcap-config.in
165 lines (153 loc) · 3.84 KB
/
pcap-config.in
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
157
158
159
160
161
162
163
164
165
#! /bin/sh
#
# Script to give the appropriate compiler flags and linker flags
# to use when building code that uses libpcap.
#
# These variables come from the configure script, so includedir and
# libdir may be defined in terms of prefix and exec_prefix, so the
# latter must be defined as well.
#
prefix="@prefix@"
exec_prefix="@exec_prefix@"
includedir="@includedir@"
libdir="@libdir@"
LIBS="@LIBS@"
LIBS_STATIC="@LIBS_STATIC@"
VERSION="@PACKAGE_VERSION@"
usage()
{
echo "Usage: pcap-config [ --help ] [ --version ] [ --cflags ]"
echo " [ --libs | --additional-libs ]"
echo " [ --static | --static-pcap-only ]"
}
static=0
static_pcap_only=0
show_cflags=0
show_libs=0
show_additional_libs=0
while [ "$#" != 0 ]
do
case "$1" in
--static)
static=1
;;
--static-pcap-only)
static_pcap_only=1
;;
--cflags)
show_cflags=1
;;
--libs)
show_libs=1
;;
--additional-libs)
show_additional_libs=1
;;
-h|--help)
usage
exit 0
;;
--version)
echo "$VERSION"
exit 0
;;
*)
echo "pcap-config: Invalid command-line option $1 specified" 1>&2
usage 1>&2
exit 1
;;
esac
shift
done
#
# If we aren't installing in /usr, then provide a -L flag to let build
# processes find our library.
#
# (We must check $prefix, as $libdir isn't necessarily /usr/lib in this
# case - for example, Linux distributions for 64-bit platforms that
# also provide support for binaries for a 32-bit version of the
# platform may put the 64-bit libraries, the 32-bit libraries, or both
# in directories other than /usr/lib.)
#
if [ "$prefix" != "/usr" ]
then
LPATH=-L$libdir
fi
if [ "$static" = 1 ]
then
#
# Include LIBS_STATIC so that the flags include libraries
# containing routines that libpcap uses, and libraries
# containing routines those libraries use, etc., so that a
# completely statically linked program - i.e., linked only with
# static libraries - will be linked with all necessary
# libraries.
#
if [ "$show_cflags" = 1 -a "$show_libs" = 1 ]
then
echo "-I$includedir $LPATH -l@PACKAGE_NAME@ $LIBS_STATIC"
elif [ "$show_cflags" = 1 -a "$show_additional_libs" = 1 ]
then
echo "-I$includedir $LPATH $LIBS_STATIC"
elif [ "$show_cflags" = 1 ]
then
echo "-I$includedir"
elif [ "$show_libs" = 1 ]
then
echo "$LPATH -l@PACKAGE_NAME@ $LIBS_STATIC"
elif [ "$show_additional_libs" = 1 ]
then
echo "$LIBS_STATIC"
fi
elif [ "$static_pcap_only" = 1 ]
then
#
# Include LIBS so that the flags include libraries
# containing routines that libpcap uses, but not the libraries
# on which libpcap depends, so that an otherwise
# dynamically-linked program, linked statically only with
# libpcap - i.e., linked with a static libpcap and dynamic
# versions of other libraries - will be linked with all
# necessary libraries.
#
if [ "$show_cflags" = 1 -a "$show_libs" = 1 ]
then
echo "-I$includedir $LPATH -l@PACKAGE_NAME@ $LIBS"
elif [ "$show_cflags" = 1 -a "$show_additional_libs" = 1 ]
then
echo "-I$includedir $LPATH $LIBS"
elif [ "$show_cflags" = 1 ]
then
echo "-I$includedir"
elif [ "$show_libs" = 1 ]
then
echo "$LPATH -l@PACKAGE_NAME@ $LIBS"
elif [ "$show_additional_libs" = 1 ]
then
echo "$LIBS"
fi
else
#
# Don't included LIBS or LIBS_STATIC, for building a program
# with a dynamic libpcap; libpcap, being a dynamic library, will
# cause all of its dynamic-library dependencies to be pulled in
# at run time.
#
# Do, however, include RPATH, to make sure that, on platforms
# that require this, programs built with this version of
# libpcap can find it at run time.
#
if [ "$show_cflags" = 1 -a "$show_libs" = 1 ]
then
echo "-I$includedir $LPATH @RPATH@ -l@PACKAGE_NAME@"
elif [ "$show_cflags" = 1 -a "$show_additional_libs" = 1 ]
then
echo "-I$includedir"
elif [ "$show_cflags" = 1 ]
then
echo "-I$includedir"
elif [ "$show_libs" = 1 ]
then
echo "$LPATH @RPATH@ -l@PACKAGE_NAME@"
fi
fi