aboutsummaryrefslogtreecommitdiff
path: root/pcap-config.in
diff options
context:
space:
mode:
Diffstat (limited to 'pcap-config.in')
-rw-r--r--pcap-config.in98
1 files changed, 81 insertions, 17 deletions
diff --git a/pcap-config.in b/pcap-config.in
index 54ca42f0..6039ef33 100644
--- a/pcap-config.in
+++ b/pcap-config.in
@@ -12,13 +12,15 @@ prefix="@prefix@"
exec_prefix="@exec_prefix@"
includedir="@includedir@"
libdir="@libdir@"
-V_RPATH_OPT="@V_RPATH_OPT@"
LIBS="@LIBS@"
-PACKAGE_NAME="@PACKAGE_NAME@"
+LIBS_STATIC="@LIBS_STATIC@"
+VERSION="@PACKAGE_VERSION@"
static=0
+static_pcap_only=0
show_cflags=0
show_libs=0
+show_additional_libs=0
while [ "$#" != 0 ]
do
case "$1" in
@@ -27,6 +29,10 @@ do
static=1
;;
+ --static-pcap-only)
+ static_pcap_only=1
+ ;;
+
--cflags)
show_cflags=1
;;
@@ -38,49 +44,107 @@ do
--additional-libs)
show_additional_libs=1
;;
+
+ -h|--help)
+ echo "Usage: pcap-config [ --help ] [--version] [ --static | --static-pcap-only ] [ --libs | --additional-libs ]"
+ exit 0
+ ;;
+
+ --version)
+ echo "$VERSION"
+ 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 [ "$V_RPATH_OPT" != "" ]
+
+#
+# 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
#
- # If libdir isn't /usr/lib, add it to the run-time linker path.
+ # 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 [ "$libdir" != "/usr/lib" ]
+ 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
- RPATH=$V_RPATH_OPT$libdir
+ echo "$LIBS_STATIC"
fi
-fi
-if [ "$static" = 1 ]
+elif [ "$static_pcap_only" = 1 ]
then
#
- # Include LIBS so that the flags include libraries containing
- # routines that libpcap uses.
+ # 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 -L$libdir -lpcap $LIBS"
+ echo "-I$includedir $LPATH -l@PACKAGE_NAME@ $LIBS"
elif [ "$show_cflags" = 1 -a "$show_additional_libs" = 1 ]
then
- echo "-I$includedir -L$libdir $LIBS"
+ echo "-I$includedir $LPATH $LIBS"
elif [ "$show_cflags" = 1 ]
then
echo "-I$includedir"
elif [ "$show_libs" = 1 ]
then
- echo "-L$libdir -lpcap $LIBS"
+ 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
+ # libpcap can find it at run time.
#
if [ "$show_cflags" = 1 -a "$show_libs" = 1 ]
then
- echo "-I$includedir -L$libdir $RPATH -l$PACKAGE_NAME"
+ echo "-I$includedir $LPATH @RPATH@ -l@PACKAGE_NAME@"
elif [ "$show_cflags" = 1 -a "$show_additional_libs" = 1 ]
then
echo "-I$includedir"
@@ -89,6 +153,6 @@ else
echo "-I$includedir"
elif [ "$show_libs" = 1 ]
then
- echo "-L$libdir $RPATH -l$PACKAGE_NAME"
+ echo "$LPATH @RPATH@ -l@PACKAGE_NAME@"
fi
fi