Code Comments
Programming Forum and web based access to our favorite programming groups.hi, i had a few question about porting a project to GNU standarts: my program use libpcap and compile on latest linux with: gcc -D_GNU_SOURCE -DPACKETS_TIME=-1 snif.c -o snif -lpcap first question is simpliest : how can i tell autotools to add -lpcap to use lipcap at linking, i finally add this in Makefile.am: LIBS = -lpcap so my Makefile.am looks like that: bin_PROGRAMS = snif snif_SOURCES = snif.c snif.h ethernet.h tokenring.h ppp.h loopback.h ip.h icmp.h tcp.h udp.h terminal.h color.h LIBS = -lpcap but isn't it an other solution? second question is: i have to change the value of PACKETS_TIME according to the architecture, example : set it to -1 on linux and to 255 on Mac os X, how can i do that with autotools again?? more : on older linux system my program compile with this: gcc -DNO_MULTI_HASH_TABLE -DPACKETS_TIME=-1 snif.c -o snif -lpcap -I/usr/include/pcap/ how can i use autotools to add the include -I/usr/include/pcap/ if it exist a directory /usr/include/pcap/ ? and how can i add the definition of the macro NO_MULTI_HASH_TABLE if it exist a function hcreate_r in the libc which is not on older linux where only exist hcreate, i think i can test it whith autoconf with running then C preprocessor but don't know exactly how. i must add a file dnscache.h if the macro NO_MULTI_HASH_TABLE is defined and my Makefile.am looks like that: bin_PROGRAMS = snif snif_SOURCES = snif.c snif.h ethernet.h tokenring.h ppp.h loopback.h ip.h icmp.h tcp.h udp.h dnscache.h terminal.h color.h LIBS = -lpcap i read lots of howto and doc on autoconf and automake but it doesn't bring light to my questions... any helps greatly appreciate! Damien email: mattei@unice.fr , damien_mattei@yahoo.com
Post Follow-up to this messagedamien_mattei@yahoo.com (Damien MATTEI) writes: > how can i tell autotools to add -lpcap to use lipcap at linking, i > finally add this in Makefile.am: > > LIBS = -lpcap > > so my Makefile.am looks like that: > > bin_PROGRAMS = snif > snif_SOURCES = snif.c snif.h ethernet.h tokenring.h ppp.h loopback.h > ip.h icmp.h tcp.h udp.h terminal.h color.h > LIBS = -lpcap > > but isn't it an other solution? snif_LDADD = -lpcap > second question is: > > i have to change the value of PACKETS_TIME according to the > architecture, example : set it to -1 on linux and to 255 on Mac os X, > how can i do that with autotools again?? AC_CONFIG_HEADER AC_DEFINE_UNQUOTED then run autoheader and #include <config.h>. You set the value in configure.ac. > on older linux system my program compile with this: > > gcc -DNO_MULTI_HASH_TABLE -DPACKETS_TIME=-1 snif.c -o snif -lpcap > -I/usr/include/pcap/ > > how can i use autotools to add the include -I/usr/include/pcap/ if it > exist a directory /usr/include/pcap/ ? Add it to AM_CPPFLAGS. You can AC_SUBST it from configure.ac if you like. > and how can i add the definition of the macro NO_MULTI_HASH_TABLE if > it exist a function hcreate_r in the libc which is not on older linux > where only exist hcreate, i think i can test it whith autoconf with > running then C preprocessor but don't know exactly how. AC_CHECK_FUNC > i must add a file dnscache.h if the macro NO_MULTI_HASH_TABLE is > defined and my Makefile.am looks like that: > > bin_PROGRAMS = snif > snif_SOURCES = snif.c snif.h ethernet.h tokenring.h ppp.h loopback.h > ip.h icmp.h tcp.h udp.h dnscache.h terminal.h color.h > LIBS = -lpcap What do you mean by "add"? To install on the system? To include during compliation? #ifndef NO_MULTI_HASH_TABLE # include "dnscache.h" #endif HTH, Roger -- Roger Leigh Printing on GNU/Linux? http://gimp-print.sourceforge.net/ GPG Public Key: 0x25BFB848. Please sign and encrypt your mail.
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.