|
Home > Archive > Unix Programming > September 2004 > autoconf automake
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| Damien MATTEI 2004-09-22, 9:21 pm |
| 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
| |
| Roger Leigh 2004-09-22, 9:21 pm |
| damien_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.
|
|
|
|
|