dect
/
libpcap
Archived
13
0
Fork 0

Add a pcap-config script, to handle necessary -I/-L flags and any

libraries required by libpcap.
This commit is contained in:
guy 2008-09-23 18:04:01 +00:00
parent f4af9ed692
commit ad68762c8e
5 changed files with 121 additions and 12 deletions

View File

@ -17,7 +17,7 @@
# WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
# @(#) $Header: /tcpdump/master/libpcap/Makefile.in,v 1.126 2008-08-06 07:45:00 guy Exp $ (LBL)
# @(#) $Header: /tcpdump/master/libpcap/Makefile.in,v 1.127 2008-09-23 18:04:01 guy Exp $ (LBL)
#
# Various configurable paths (remember to edit Makefile.in, not Makefile)
@ -27,11 +27,13 @@
prefix = @prefix@
exec_prefix = @exec_prefix@
datarootdir = @datarootdir@
# Pathname of directory to install the configure program
bindir = @bindir@
# Pathname of directory to install the include files
includedir = @includedir@
# Pathname of directory to install the library
libdir = @libdir@
# Pathname of directory to install the man page
# Pathname of directory to install the man pages
mandir = @mandir@
# VPATH
@ -48,6 +50,7 @@ INCLS = -I. @V_INCLS@
DEFS = @DEFS@ @V_DEFS@
LIBS = @V_LIBS@
DAGLIBS = @DAGLIBS@
DEPLIBS = @DEPLIBS@
DYEXT = @DYEXT@
PROG=libpcap
@ -121,6 +124,8 @@ TAGFILES = \
CLEANFILES = $(OBJ) libpcap.a $(GENSRC) $(GENHDR) lex.yy.c
MAN1 = pcap-config.1
MAN3PCAP = pcap.3pcap \
pcap_activate.3pcap \
pcap_breakloop.3pcap \
@ -247,6 +252,7 @@ EXTRA_DIST = \
pcap-bpf.h \
pcap-bt-linux.c \
pcap-bt-linux.h \
pcap-config.in \
pcap-dag.c \
pcap-dag.h \
pcap-dlpi.c \
@ -296,7 +302,7 @@ EXTRA_DIST = \
Win32/Src/inet_net.c \
Win32/Src/inet_pton.c
all: libpcap.a
all: libpcap.a pcap-config
libpcap.a: $(OBJ)
@rm -f $@
@ -368,6 +374,18 @@ bpf_filter.c: $(srcdir)/bpf/net/bpf_filter.c
bpf_filter.o: bpf_filter.c
$(CC) $(CFLAGS) -c bpf_filter.c
#
# Generate the pcap-config script.
#
pcap-config: pcap-config.in Makefile
@rm -f $@ $@.tmp
sed -e 's|@includedir[@]|$(includedir)|g' \
-e 's|@libdir[@]|$(libdir)|g' \
-e 's|@DEPLIBS[@]|$(DEPLIBS)|g' \
pcap-config.in >$@.tmp
mv $@.tmp $@
chmod a+x $@
#
# Test programs - not built by default, and not installed.
#
@ -377,7 +395,7 @@ filtertest: filtertest.c libpcap.a
findalldevstest: findalldevstest.c libpcap.a
$(CC) $(CFLAGS) -I. -L. -o findalldevstest findalldevstest.c libpcap.a
install: libpcap.a
install: libpcap.a pcap-config
[ -d $(DESTDIR)$(libdir) ] || \
(mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
$(INSTALL_DATA) libpcap.a $(DESTDIR)$(libdir)/libpcap.a
@ -386,10 +404,12 @@ install: libpcap.a
(mkdir -p $(DESTDIR)$(includedir); chmod 755 $(DESTDIR)$(includedir))
[ -d $(DESTDIR)$(includedir)/pcap ] || \
(mkdir -p $(DESTDIR)$(includedir)/pcap; chmod 755 $(DESTDIR)$(includedir)/pcap)
[ -d $(DESTDIR)$(mandir)/man1 ] || \
(mkdir -p $(DESTDIR)$(mandir)/man1; chmod 755 $(DESTDIR)$(mandir)/man1)
[ -d $(DESTDIR)$(mandir)/man3 ] || \
(mkdir -p $(DESTDIR)$(mandir)/man3; chmod 755 $(DESTDIR)$(mandir)/man3)
(mkdir -p $(DESTDIR)$(mandir)/man3; chmod 755 $(DESTDIR)$(mandir)/man3)
[ -d $(DESTDIR)$(mandir)/man4 ] || \
(mkdir -p $(DESTDIR)$(mandir)/man4; chmod 755 $(DESTDIR)$(mandir)/man4)
(mkdir -p $(DESTDIR)$(mandir)/man4; chmod 755 $(DESTDIR)$(mandir)/man4)
$(INSTALL_DATA) $(srcdir)/pcap/pcap.h \
$(DESTDIR)$(includedir)/pcap/pcap.h
$(INSTALL_DATA) $(srcdir)/pcap/bpf.h \
@ -405,6 +425,10 @@ install: libpcap.a
$(DESTDIR)$(includedir)/pcap-bpf.h
$(INSTALL_DATA) $(srcdir)/pcap-namedb.h \
$(DESTDIR)$(includedir)/pcap-namedb.h
$(INSTALL_PROGRAM) pcap-config $(DESTDIR)$(bindir)/pcap-config
for i in $(MAN1); do \
$(INSTALL_DATA) $(srcdir)/$$i \
$(DESTDIR)$(mandir)/man1/$$i; done
for i in $(MAN3PCAP); do \
$(INSTALL_DATA) $(srcdir)/$$i \
$(DESTDIR)$(mandir)/man3/$$i; done
@ -448,6 +472,8 @@ uninstall:
rm -f $(DESTDIR)$(includedir)/pcap.h
rm -f $(DESTDIR)$(includedir)/pcap-bpf.h
rm -f $(DESTDIR)$(includedir)/pcap-namedb.h
for i in $(MAN1); do \
rm -f $(DESTDIR)$(mandir)/man1/$$i; done
for i in $(MAN3PCAP); do \
rm -f $(DESTDIR)$(mandir)/man3/$$i; done
rm -f $(DESTDIR)$(mandir)/man3/pcap_datalink_val_to_description.3pcap
@ -467,7 +493,8 @@ clean:
distclean: clean
rm -f Makefile config.cache config.log config.status \
config.h gnuc.h os-proto.h bpf_filter.c stamp-h stamp-h.in
config.h gnuc.h os-proto.h bpf_filter.c pcap-config \
stamp-h stamp-h.in
rm -rf autom4te.cache
tags: $(TAGFILES)
@ -480,7 +507,7 @@ packaging/pcap.spec: packaging/pcap.spec.in VERSION
releasetar:
@cwd=`pwd` ; dir=`basename $$cwd` ; name=$(PROG)-`cat VERSION` ; \
mkdir $$name; \
tar cf - $(CSRC) $(HDR) $(MAN3PCAP) $(MAN4) $(EXTRA_DIST) | (cd $$name; tar xf -); \
tar cf - $(CSRC) $(HDR) $(MAN1) $(MAN3PCAP) $(MAN4) $(EXTRA_DIST) | (cd $$name; tar xf -); \
tar -c -z -f $$name.tar.gz $$name; \
rm -rf $$name

11
configure vendored
View File

@ -1,5 +1,5 @@
#! /bin/sh
# From configure.in Revision: 1.155 .
# From configure.in Revision: 1.156 .
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.61.
#
@ -687,6 +687,7 @@ V_FINDALLDEVS
SSRC
DYEXT
DAGLIBS
DEPLIBS
PCAP_SUPPORT_USB
USB_SRC
PCAP_SUPPORT_BT
@ -8582,6 +8583,10 @@ cat >>confdefs.h <<\_ACEOF
#define _SUN 1
_ACEOF
# We need "-lodm" and "-lcfg", as libpcap requires them on
# AIX.
DEPLIBS="-lodm -lcfg"
;;
hpux9*)
@ -9126,6 +9131,7 @@ ln -s ${srcdir}/bpf/net net
{ echo "$as_me:$LINENO: checking for USB sniffing support" >&5
echo $ECHO_N "checking for USB sniffing support... $ECHO_C" >&6; }
case "$host_os" in
@ -10087,6 +10093,7 @@ V_FINDALLDEVS!$V_FINDALLDEVS$ac_delim
SSRC!$SSRC$ac_delim
DYEXT!$DYEXT$ac_delim
DAGLIBS!$DAGLIBS$ac_delim
DEPLIBS!$DEPLIBS$ac_delim
PCAP_SUPPORT_USB!$PCAP_SUPPORT_USB$ac_delim
USB_SRC!$USB_SRC$ac_delim
PCAP_SUPPORT_BT!$PCAP_SUPPORT_BT$ac_delim
@ -10097,7 +10104,7 @@ INSTALL_DATA!$INSTALL_DATA$ac_delim
LTLIBOBJS!$LTLIBOBJS$ac_delim
_ACEOF
if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 81; then
if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 82; then
break
elif $ac_last_try; then
{ { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5

View File

@ -1,4 +1,4 @@
dnl @(#) $Header: /tcpdump/master/libpcap/configure.in,v 1.156 2008-09-16 07:10:31 guy Exp $ (LBL)
dnl @(#) $Header: /tcpdump/master/libpcap/configure.in,v 1.157 2008-09-23 18:04:01 guy Exp $ (LBL)
dnl
dnl Copyright (c) 1994, 1995, 1996, 1997
dnl The Regents of the University of California. All rights reserved.
@ -6,7 +6,7 @@ dnl
dnl Process this file with autoconf to produce a configure script.
dnl
AC_REVISION($Revision: 1.156 $)
AC_REVISION($Revision: 1.157 $)
AC_PREREQ(2.50)
AC_INIT(pcap.c)
@ -872,6 +872,10 @@ case "$host_os" in
aix*)
dnl Workaround to enable certain features
AC_DEFINE(_SUN,1,[define on AIX to get certain functions])
# We need "-lodm" and "-lcfg", as libpcap requires them on
# AIX.
DEPLIBS="-lodm -lcfg"
;;
hpux9*)
@ -955,6 +959,7 @@ AC_SUBST(V_YACC)
AC_SUBST(SSRC)
AC_SUBST(DYEXT)
AC_SUBST(DAGLIBS)
AC_SUBST(DEPLIBS)
dnl check for USB sniffing support
AC_MSG_CHECKING(for USB sniffing support)

54
pcap-config.1 Normal file
View File

@ -0,0 +1,54 @@
.\" @(#) $Header: /tcpdump/master/libpcap/pcap-config.1,v 1.1 2008-09-23 18:04:01 guy Exp $ (LBL)
.\"
.\" Copyright (c) 1987, 1988, 1989, 1990, 1991, 1992, 1994, 1995, 1996, 1997
.\" The Regents of the University of California. All rights reserved.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that: (1) source code distributions
.\" retain the above copyright notice and this paragraph in its entirety, (2)
.\" distributions including binary code include the above copyright notice and
.\" this paragraph in its entirety in the documentation or other materials
.\" provided with the distribution, and (3) all advertising materials mentioning
.\" features or use of this software display the following acknowledgement:
.\" ``This product includes software developed by the University of California,
.\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
.\" the University nor the names of its contributors may be used to endorse
.\" or promote products derived from this software without specific prior
.\" written permission.
.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
.\"
.TH PCAP-CONFIG 1 "23 September 2008"
.SH NAME
pcap-config \- write libpcap compiler and linker flags to standard output
.SH SYNOPSIS
.na
.B pcap-config
[
.B \-\-cflags | \-\-libs
]
.ad
.SH DESCRIPTION
.LP
When run with the
.B \-\-cflags
option,
.I pcap-config
writes to the standard output the
.B \-I
compiler flags required to include libpcap's header files.
When run with the
.B \-\-libs
option,
.I pcap-config
writes to the standard output the
.B \-L
and
.B \-l
linker required to link with libpcap, including
.B \-l
flags for libraries required by libpcap.
.SH "SEE ALSO"
pcap(3PCAP)

16
pcap-config.in Normal file
View File

@ -0,0 +1,16 @@
#! /bin/sh
#
# Script to give the appropriate compiler flags and linker flags
# to use when building code that uses libpcap.
#
case "$1" in
--cflags)
echo "-I @includedir@"
;;
--libs)
echo "-L @libdir@ -lpcap @DEPLIBS@"
;;
esac