Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

autoconf automake
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

Report this thread to moderator Post Follow-up to this message
Old Post
Damien MATTEI
09-18-04 01:56 PM


Re: autoconf automake
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.

Report this thread to moderator Post Follow-up to this message
Old Post
Roger Leigh
09-18-04 01:56 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Unix Programming archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:15 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.