libpcap pet package with shared library

July 25, 2008 at 8:56 pm (pet_packages)

Hi all,

Last feburary I learned how to create pet package. Its simple and easy to create pet package in puppy so that a dump also can create package. So, I decided to create tcpdump for puppy 4.00.

while compiling tcpdump, ‘make all’ fails with ‘pcap’ library not found error. Then I decided to compile libpcap. This time I also created libpcap.so.0.8.1 shared library. Thanks to ‘jcoder24’ for giving me valuable suggession in my previous libpcap compilation. I did some tweeks in libpcap’s Makefile.in file.

CLEANFILES = $(OBJ) libpcap.a libpcap.so.0.8.1 $(GENSRC) $(GENHDR) lex.yy.c

all: libpcap.a libpcap.so.0.8.1

libpcap.so.0.8.1: $(OBJ)
@rm -f $@
gcc -shared -WI,-soname,libpcap.so.0 -o libpcap.so.0.8.1 $(OBJ)

install:
$(INSTALL_DATA) libpcap.so.0.8.1 $(DESTDIR)$(libdir)/libpcap.so.0.8.1
ldconfig $(DESTDIR)$(libdir)

uninstall:
rm -f $(DESTDIR)$(libdir)/libpcap.so.0.8.1
ldconfig $(DESTDIR)$(libdir)

So, here are the steps I followed to successfully compile libpcap with shared library.

1. Untar source tarball.
2. Edit Makefile.in as I mentioned above.
3. ./configure –prefix=”`pwd`-i686/usr” –enable–yydebug
4. make all
5. make install

To prevent ‘pcap_debug’ symbol not found error I used –enable-yydebug option with ./configure. This option is used to enable yydebug feature. I don’t know what it is doing. Perhaps guru’s can help me to understand. –prefix=”`pwd`-i686/usr” will create another directory tree as libpcap-0.8.1-i686/usr and ‘make all’ and ‘make install’ will install files in libpcap-0.8.1-i686/usr directory.

To load libpcap.so.0.8.1 in ldconfig automatically, I created pinstall.sh script.

6. cat > pinstall.sh
ln -s /usr/lib/libpcap.so.0.8.1 /usr/lib/libpcap.so.0
ln -s /usr/lib/libpcap.so /usr/lib/libpcap.so
ldconfig
7. chmod 755 pinstall.sh

to unload libpcap.so.0.8.1 from ldconfig while uninstalling, I created puninstall.sh.

8. cat > puninstall.sh
rm /usr/lib/libpcap.so.0
rm /usr/lib/libpcap.so
ldconfig

I moved both pinstall.sh and puninstall.sh into libpcap-0.8.1-i686. I didn’t use ‘new2dir’, It’s not working properly while using –prefix option with ./configure. So I used the same –prefix option to create libpcap-0.8.1-i686 directory and wrote one small script ‘prepare-dir2pet’ to generate libpcap-0.8.1-i686.files file. we need to give package directory name(libpcap-0.8.1-i686) as first argument without trailing ‘/’ to this script.

9. cat prepare-dir2pet
find “${1}” | sed -e”s/${1}\/*//g” | grep -v ‘^$’ | tee “${1}”.files

10. dir2pet libpcap-0.8.1-i686

I hope libpcap folks will provide shared library in their future release.

libpcap-0.8.1-i686.pet

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: