aboutsummaryrefslogtreecommitdiff
path: root/pcap-config.in
diff options
context:
space:
mode:
authorGuy Harris <gharris@sonic.net>2022-09-28 15:37:26 -0700
committerGuy Harris <gharris@sonic.net>2022-09-28 15:37:26 -0700
commitd0cba780dc2b2bb4f3ca9427d1a0f03479f45707 (patch)
treed7849747524a812d2f56a21f344ddee4a58179d1 /pcap-config.in
parenteedad18ebf1d800ee7266250f8d0f4d59a91fd5e (diff)
pcap-config: add a --static-pcap-only flag.
That flag, when combined with --libs or --additional-libs, shows only the libraries needed when linking statically with libpcap and dynamically with all other libraries, including libpcap's dependencies. While we're at it, add a -h/--help flag giving a usage message, and a check for invalid arguments.
Diffstat (limited to 'pcap-config.in')
-rw-r--r--pcap-config.in60
1 files changed, 56 insertions, 4 deletions
diff --git a/pcap-config.in b/pcap-config.in
index 5df96d20..afa8919d 100644
--- a/pcap-config.in
+++ b/pcap-config.in
@@ -12,11 +12,14 @@ prefix="@prefix@"
exec_prefix="@exec_prefix@"
includedir="@includedir@"
libdir="@libdir@"
+LIBS="@LIBS@"
LIBS_STATIC="@LIBS_STATIC@"
static=0
+static_pcap_only=0
show_cflags=0
show_libs=0
+show_additional_libs=0
while [ "$#" != 0 ]
do
case "$1" in
@@ -25,6 +28,10 @@ do
static=1
;;
+ --static-pcap-only)
+ static_pcap_only=1
+ ;;
+
--cflags)
show_cflags=1
;;
@@ -36,9 +43,21 @@ do
--additional-libs)
show_additional_libs=1
;;
+
+ -h|--help)
+ echo "Usage: pcap-config [ --help ] [ --static | --static-pcap-only ] [ --libs | --additional-libs ]"
+ exit 0
+ ;;
+
+ *)
+ echo "pcap-config: Invalid command-line option $1 specified" 1>&2
+ echo "Usage: pcap-config [ --help ] [ --static | --static-pcap-only ] [ --libs | --additional-libs ]" 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.
@@ -56,8 +75,12 @@ fi
if [ "$static" = 1 ]
then
#
- # Include LIBS so that the flags include libraries containing
- # routines that libpcap uses.
+ # 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
@@ -75,10 +98,39 @@ then
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
#
- # Omit LIBS - libpcap is assumed to be linked with those
- # libraries, so there's no need to do so explicitly.
+ # 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