autoconf automake
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > autoconf automake




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    autoconf automake  
Damien MATTEI


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-23-04 02:21 AM

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 a follow-up to this message ]



    Re: autoconf automake  
Roger Leigh


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-23-04 02:21 AM

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.





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 11:52 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register