Skip to content

Commit

Permalink
patches to make building RPMs and shared libraries easier.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcr committed Nov 30, 2003
1 parent b7a5a71 commit 75ce5b9
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 19 deletions.
3 changes: 3 additions & 0 deletions FILES
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ README.tru64
SUNOS4/nit_if.o.sparc
SUNOS4/nit_if.o.sun3
SUNOS4/nit_if.o.sun4c.4.0.3c
TODO
VERSION
aclocal.m4
arcnet.h
Expand Down Expand Up @@ -96,4 +97,6 @@ Win32/Src/getservent.c
Win32/Src/inet_aton.c
Win32/Src/inet_net.c
Win32/Src/inet_pton.c
packaging/pcap.spec
packaging/pcap.spec.in

47 changes: 39 additions & 8 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -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.96 2003-07-23 05:29:20 guy Exp $ (LBL)
# @(#) $Header: /tcpdump/master/libpcap/Makefile.in,v 1.97 2003-11-30 04:45:02 mcr Exp $ (LBL)

#
# Various configurable paths (remember to edit Makefile.in, not Makefile)
Expand Down Expand Up @@ -46,6 +46,7 @@ CCOPT = @V_CCOPT@
INCLS = -I. @V_INCLS@
DEFS = @DEFS@ @V_DEFS@
LIBS = @V_LIBS@
DYEXT = @DYEXT@

# Standard CFLAGS
CFLAGS = $(CCOPT) $(INCLS) $(DEFS)
Expand Down Expand Up @@ -103,6 +104,19 @@ libpcap.a: $(OBJ)
ar rc $@ $(OBJ) $(LIBS)
$(RANLIB) $@

shared: libpcap.$(DYEXT)
libpcap.so: $(OBJ)
@rm -f $@
ld -shared -o $@.`cat VERSION` $(OBJ)

# the following rule succeeds, but the result is untested.
libpcap.dylib: $(OBJ)
rm -f libpcap*.dylib
$(CC) -dynamiclib -undefined error -o libpcap.`cat VERSION`.dylib $(OBJ) \
-install_name $(libdir)/libpcap.0.dylib -compatibility_version `cat VERSION` \
-current_version `cat VERSION`


scanner.c: $(srcdir)/scanner.l
@rm -f $@
$(LEX) -t $< > $$$$.$@; mv $$$$.$@ $@
Expand Down Expand Up @@ -151,7 +165,7 @@ bpf_filter.c: $(srcdir)/bpf/net/bpf_filter.c
bpf_filter.o: bpf_filter.c
$(CC) $(CFLAGS) -c bpf_filter.c

install:
install: libpcap.a
[ -d $(DESTDIR)$(libdir) ] || \
(mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
$(INSTALL_DATA) libpcap.a $(DESTDIR)$(libdir)/libpcap.a
Expand All @@ -168,6 +182,13 @@ install:
$(INSTALL_DATA) $(srcdir)/pcap.3 \
$(DESTDIR)$(mandir)/man3/pcap.3

install-shared: install-shared-$(DYEXT)
install-shared-so: libpcap.so
$(INSTALL_PROGRAM) libpcap.so.`cat VERSION` $(DESTDIR)$(libdir)/libpcap.so.`cat VERSION`
install-shared-dylib: libpcap.dylib
$(INSTALL_PROGRAM) libpcap.`cat VERSION`.dylib $(DESTDIR)$(libdir)/libpcap.`cat VERSION`.dylib
VER=`cat VERSION`; cd $(DESTDIR)$(libdir) && ln -sf libpcap.$$VER.dylib libpcap.0.dylib; ln -sf libpcap.0.dylib libpcap.dylib

uninstall:
rm -f $(DESTDIR)$(libdir)/libpcap.a
rm -f $(DESTDIR)$(includedir)/pcap.h
Expand All @@ -176,28 +197,38 @@ uninstall:
rm -f $(DESTDIR)$(mandir)/man3/pcap.3

clean:
rm -f $(CLEANFILES)
rm -f $(CLEANFILES) libpcap*.dylib libpcap.so*

distclean:
rm -f $(CLEANFILES) Makefile config.cache config.log config.status \
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
rm -rf autom4te.cache

tags: $(TAGFILES)
ctags -wtd $(TAGFILES)

tar:
packaging/pcap.spec: packaging/pcap.spec.in VERSION
RPMVERSION=`cat VERSION | sed s/-.*//g`; \
sed -e s/@VERSION@/$$RPMVERSION/ -e s/@NAME@/libpcap-`cat VERSION`/ $< > $@

tar: Makefile packaging/pcap.spec
@cwd=`pwd` ; dir=`basename $$cwd` ; name=libpcap-`cat VERSION` ; \
list="" ; tar="tar chf" ; \
for i in `cat FILES` ; do list="$$list $$name/$$i" ; done; \
echo \
"rm -f ../$$name; ln -s $$dir ../$$name" ; \
rm -f ../$$name; ln -s $$dir ../$$name ; \
echo \
"(cd .. ; $$tar - [lots of files]) | compress > /tmp/$$name.tar.Z" ; \
(cd .. ; $$tar - $$list) | compress > /tmp/$$name.tar.Z ; \
"(cd .. ; $$tar - [lots of files]) | gzip -c > /tmp/$$name.tar.gz" ; \
(cd .. ; $$tar - $$list) | gzip -c > /tmp/$$name.tar.gz ; \
echo \
"rm -f ../$$name" ; \
rm -f ../$$name

depend: $(GENSRC) $(GENHDR) bpf_filter.c
./mkdep -c $(CC) $(DEFS) $(INCLS) $(SRC)

Makefile: Makefile.in config.status
./config.status
@echo your Makefile was out of date, now run $(MAKE) again
exit 1
10 changes: 8 additions & 2 deletions configure.in
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
dnl @(#) $Header: /tcpdump/master/libpcap/configure.in,v 1.100 2003-10-14 07:46:57 guy Exp $ (LBL)
dnl @(#) $Header: /tcpdump/master/libpcap/configure.in,v 1.101 2003-11-30 04:45:03 mcr Exp $ (LBL)
dnl
dnl Copyright (c) 1994, 1995, 1996, 1997
dnl The Regents of the University of California. All rights reserved.
dnl
dnl Process this file with autoconf to produce a configure script.
dnl

AC_REVISION($Revision: 1.100 $)
AC_REVISION($Revision: 1.101 $)
AC_INIT(pcap.c)

AC_CANONICAL_SYSTEM
Expand Down Expand Up @@ -340,6 +340,7 @@ if test "$V_LEX" = lex ; then
fi
fi

DYEXT="so"
case "$host_os" in

aix*)
Expand Down Expand Up @@ -379,6 +380,10 @@ sinix*)
solaris*)
AC_DEFINE(HAVE_SOLARIS,1,[On solaris])
;;
darwin*)
DYEXT="dylib"
V_CCOPT="$V_CCOPT -fno-common"
;;
esac

AC_PROG_RANLIB
Expand Down Expand Up @@ -406,6 +411,7 @@ AC_SUBST(V_FINDALLDEVS)
AC_SUBST(V_RANLIB)
AC_SUBST(V_YACC)
AC_SUBST(SSRC)
AC_SUBST(DYEXT)

AC_PROG_INSTALL

Expand Down
33 changes: 24 additions & 9 deletions packaging/pcap.spec
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
%define prefix /usr
%define version 2003.02.10
%define version 0.8

Summary: packet capture library
Name: libpcap
Version: %version
Release: 1
Group: Development/Libraries
Copyright: BSD
Source: libpcap-current.tar.gz
Source: libpcap-0.8.tar.gz
BuildRoot: /tmp/%{name}-buildroot
URL: http://www.tcpdump.org

Expand All @@ -29,22 +29,37 @@ make

%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/usr/{lib,include,man}
mkdir -p $RPM_BUILD_ROOT/usr/{lib,include}
mkdir -p $RPM_BUILD_ROOT/usr/share/man
mkdir -p $RPM_BUILD_ROOT/usr/include/net
mkdir -p $RPM_BUILD_ROOT/usr/man/man3
install -m 755 -o root libpcap.a $RPM_BUILD_ROOT/usr/lib
install -m 644 -o root pcap.3 $RPM_BUILD_ROOT/usr/man/man3
install -m 644 -o root pcap.h $RPM_BUILD_ROOT/usr/include
install -m 644 -o root pcap-bpf.h $RPM_BUILD_ROOT/usr/include/net
install -m 644 -o root pcap-namedb.h $RPM_BUILD_ROOT/usr/include
make install DESTDIR=$RPM_BUILD_ROOT mandir=/usr/share/man
cd $RPM_BUILD_ROOT/usr/lib
V1=`echo 0.8 | sed 's/\\.[^\.]*$//g'`
V2=`echo 0.8 | sed 's/\\.[^\.]*\.[^\.]*$//g'`
ln -sf libpcap.so.0.8 libpcap.so.$V1
if test "$V2" -ne "$V1"; then
ln -sf libpcap.so.$V1 libpcap.so.$V2
ln -sf libpcap.so.$V2 libpcap.so
else
ln -sf libpcap.so.$V1 libpcap.so
fi

#install -m 755 -o root libpcap.a $RPM_BUILD_ROOT/usr/lib
#install -m 644 -o root pcap.3 $RPM_BUILD_ROOT/usr/man/man3
#install -m 644 -o root pcap.h $RPM_BUILD_ROOT/usr/include
#install -m 644 -o root pcap-bpf.h $RPM_BUILD_ROOT/usr/include/net
#install -m 644 -o root pcap-namedb.h $RPM_BUILD_ROOT/usr/include

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root)
%doc LICENSE CHANGES INSTALL README.linux TODO VERSION CREDITS pcap.spec
%doc LICENSE CHANGES INSTALL.txt README.linux TODO VERSION CREDITS packaging/pcap.spec
/usr/lib/libpcap.a
/usr/share/man/man3/*
/usr/include/pcap.h
/usr/include/pcap-bpf.h
/usr/include/pcap-namedb.h
/usr/lib/libpcap.so*
65 changes: 65 additions & 0 deletions packaging/pcap.spec.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
%define prefix /usr
%define version @VERSION@

Summary: packet capture library
Name: libpcap
Version: %version
Release: 1
Group: Development/Libraries
Copyright: BSD
Source: @[email protected]
BuildRoot: /tmp/%{name}-buildroot
URL: http://www.tcpdump.org

%description
Packet-capture library LIBPCAP @VERSION@
Now maintained by "The Tcpdump Group"
See http://www.tcpdump.org
Please send inquiries/comments/reports to [email protected]

%prep
%setup

%post
ldconfig

%build
CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=%prefix
make

%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/usr/{lib,include}
mkdir -p $RPM_BUILD_ROOT/usr/share/man
mkdir -p $RPM_BUILD_ROOT/usr/include/net
mkdir -p $RPM_BUILD_ROOT/usr/man/man3
make install DESTDIR=$RPM_BUILD_ROOT mandir=/usr/share/man
cd $RPM_BUILD_ROOT/usr/lib
V1=`echo @VERSION@ | sed 's/\\.[^\.]*$//g'`
V2=`echo @VERSION@ | sed 's/\\.[^\.]*\.[^\.]*$//g'`
ln -sf libpcap.so.@VERSION@ libpcap.so.$V1
if test "$V2" -ne "$V1"; then
ln -sf libpcap.so.$V1 libpcap.so.$V2
ln -sf libpcap.so.$V2 libpcap.so
else
ln -sf libpcap.so.$V1 libpcap.so
fi

#install -m 755 -o root libpcap.a $RPM_BUILD_ROOT/usr/lib
#install -m 644 -o root pcap.3 $RPM_BUILD_ROOT/usr/man/man3
#install -m 644 -o root pcap.h $RPM_BUILD_ROOT/usr/include
#install -m 644 -o root pcap-bpf.h $RPM_BUILD_ROOT/usr/include/net
#install -m 644 -o root pcap-namedb.h $RPM_BUILD_ROOT/usr/include

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root)
%doc LICENSE CHANGES INSTALL.txt README.linux TODO VERSION CREDITS packaging/pcap.spec
/usr/lib/libpcap.a
/usr/share/man/man3/*
/usr/include/pcap.h
/usr/include/pcap-bpf.h
/usr/include/pcap-namedb.h
/usr/lib/libpcap.so*

0 comments on commit 75ce5b9

Please sign in to comment.