Connecting Tech Pros Worldwide Forums | Help | Site Map

How to use automake to generate a Makefile

Newbie
 
Join Date: Oct 2006
Posts: 10
#1: Feb 15 '08
I am using an open source library called IGI_UDP for measure the available bandwidth of a link (http://www.cs.cmu.edu/%7Ehnn/igi/ ).
with that library they have provided a "Makefile" which is not an auto generated one.

the following is the given Makefile,

************************************************** ***************
CC = gcc
INCS = -I.
CFLAGS = -g -Wall $(DEFS) $(INCS)

# for linux
DEFS = -DLINUX -DRETSIGTYPE=void -DHAVE_SIGACTION=1
LIBS = -lpthread


CLIOBJS = nbs_setsignal.o nbs_client.o nbs_client_test.o
SRVOBJS = nbs_setsignal.o nbs_server.o

.c.o:
@rm -f $@
$(CC) $(CFLAGS) -c $*.c

all: igi_server igi_client

igi_client: $(CLIOBJS)
@rm -f $@
$(CC) $(CFLAGS) -o $@ $(CLIOBJS) $(LIBS)

igi_server: $(SRVOBJS)
@rm -f $@
$(CC) $(CFLAGS) -o $@ $(SRVOBJS) $(LIBS)

clean:
rm -f *.o igi_client igi_server
************************************************** ***************


But now I want to generate this Makefile through the automake tool (for using with my application)
So that I created the following Makefile.am file


************************************************** ***************
CC = gcc
INCS = -I.


# for linux
DEFS = -DLINUX -DRETSIGTYPE=void -DHAVE_SIGACTION=1
LIBS = -lpthread


bin_PROGRAMS = igi_server igi_client


igi_server_SOURCES = nbs_server.c nbs_setsignal.c
igi_server_LDADD = $(LIBS)
igi_server_CFLAGS = -g -Wall $(DEFS) $(INCS)


igi_client_SOURCES = nbs_setsignal.c nbs_client.c nbs_client_test.c
igi_client_LDADD = $(LIBS)
igi_client_CFLAGS = -g -Wall $(DEFS) $(INCS)
************************************************** ***************

the configure.in file is as follow.
************************************************** ***************
AC_INIT(igi_server.c)
AM_INIT_AUTOMAKE(igi_server, 1.0)
AC_PROG_CC
#indicate where to create make files
AC_OUTPUT(Makefile)
************************************************** ***************

By using this Makefile.am and configure.in, I can just compile the sources and create the executables. But the problem is those compiled code does not give the expected result (it is highly differ form when it is used the previous Makefile)

It is obvious that the problem is with my Makefile.am file or configure.in, (I guess that required macro has not been used)
So please can anyone help me to create the proper Makefile.am file and configure.in file.

Newbie
 
Join Date: Oct 2006
Posts: 10
#2: Feb 16 '08

re: How to use automake to generate a Makefile


I just able to fix the bug, but unfortunately I can not explain the reasons for it.

new Makefile.am
************************************************** ******************************

DEFS = -DLINUX -DRETSIGTYPE=void -DHAVE_SIGACTION=1
LIBS = -lpthread



CFLAGS = -g -Wall $(DEFS) $(INCS)



bin_PROGRAMS = igi_server igi_client


igi_server_SOURCES = nbs_server.c nbs_setsignal.c
igi_server_LDADD = $(LIBS)

igi_client_SOURCES = nbs_setsignal.c nbs_client.c nbs_client_test.c
igi_client_LDADD = $(LIBS)


************************************************** ******************************

I suggest that the main reason for this is the line
CFLAGS = -g -Wall $(DEFS) $(INCS)

Please if anyone know the reason, you are highly appreciate.
Reply