]> The Tcpdump Group git mirrors - libpcap/commitdiff
By default, don't include DEPLIBS in the libraries flags, as a
authorGuy Harris <[email protected]>
Fri, 27 Mar 2009 07:41:53 +0000 (00:41 -0700)
committerGuy Harris <[email protected]>
Fri, 27 Mar 2009 07:41:53 +0000 (00:41 -0700)
dynamically-linked libpcap should have been linked with them (if there
are any of them), so it shouldn't be necessary for a program or library
to explicitly link with them if it links with libpcap.

Add a -static flag that includes DEPLIBS, as, on most if not all
platforms, static libraries can't be linked with dynamic libraries, so
programs would have to link with libraries on which libpcap depends if
it links statically with libpcap.

If both --cflags and --libs are given, print both sets of flags, on the
same line (as pkg-config does).

pcap-config.1
pcap-config.in

index 0cac1054111183e05d7b6c32c6e48a14566d5487..aa20d0ce328c5f719ae136f1cfd03276cb20c6f0 100644 (file)
 .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 .\"
-.TH PCAP-CONFIG 1 "23 September 2008"
+.TH PCAP-CONFIG 1 "26 March 2009"
 .SH NAME
 pcap-config \- write libpcap compiler and linker flags to standard output
 .SH SYNOPSIS
 .na
 .B pcap-config
 [
+.B \-\-static
+]
+[
 .B \-\-cflags | \-\-libs
 ]
 .ad
@@ -50,5 +53,11 @@ and
 linker required to link with libpcap, including
 .B \-l
 flags for libraries required by libpcap.
+.LP
+By default, it writes flags appropriate for compiling with a
+dynamically-linked version of libpcap; the
+.B \-\-static
+flag causes it to write flags appropriate for compiling with a
+statically-linked version of libpcap.
 .SH "SEE ALSO"
 pcap(3PCAP)
index 19f21141ddf228ba79d19e430ccc28dac9e7e10a..16f4fcb39fb79d7cf595983f23f18a0a35336822 100644 (file)
@@ -4,13 +4,56 @@
 # Script to give the appropriate compiler flags and linker flags
 # to use when building code that uses libpcap.
 #
-case "$1" in
+static=0
+show_cflags=0
+show_libs=0
+while [ "$#" != 0 ]
+do
+       case "$1" in
 
---cflags)
-       echo "-I @includedir@"
-       ;;
+       --static)
+               static=1
+               ;;
 
---libs)
-       echo "-L @libdir@ -lpcap @DEPLIBS@"
-       ;;
-esac
+       --cflags)
+               show_cflags=1
+               ;;
+
+       --libs)
+               show_libs=1
+               ;;
+       esac
+       shift
+done
+if [ "$static" = 1 ]
+then
+       #
+       # Include DEPLIBS so that the flags include libraries containing
+       # routines that libpcap uses.
+       #
+       if [ "$show_cflags" = 1 -a "$show_libs" = 1 ]
+       then
+               echo "-I @includedir@ -L @libdir@ -lpcap @DEPLIBS@"
+       elif [ "$show_cflags" = 1 ]
+       then
+               echo "-I @includedir@"
+       elif [ "$show_libs" = 1 ]
+       then
+               echo "-L @libdir@ -lpcap @DEPLIBS@"
+       fi
+else
+       #
+       # Omit DEPLIBS - libpcap is assumed to be linked with those
+       # libraries, so there's no need to do so explicitly.
+       #
+       if [ "$show_cflags" = 1 -a "$show_libs" = 1 ]
+       then
+               echo "-I @includedir@ -L @libdir@ -lpcap"
+       elif [ "$show_cflags" = 1 ]
+       then
+               echo "-I @includedir@"
+       elif [ "$show_libs" = 1 ]
+       then
+               echo "-L @libdir@ -lpcap"
+       fi
+fi