hi, i have the following program

see the attachment

when i try to compile through the command line {with the scipt compile} everything works fine...

when i try to use my makefile...i get tons of errors.... It is my first serious try with makefiles and i would like some assistance figuring it out.... I have used before the make command but it is the first time i try to use the automatic dependency inclusion, so i am a bit lost...

thanks in advance,
nicolas

PS:: i would love to hear comments about the code also,especially from the elder members of the forum {salem, ancient dragon, narue, vijayan121,...} end everyone else!!
PS2:: this is a university assignement so any copying is prohibited until midnight{this goes to fellow classmates}! afterwards feel free to do anything you want...

Recommended Answers

All 4 Replies

i cant unzip it on my machine, just use the windows compress utility feature. Or perhaps just post the make file contents

ssharish

basically i zipped it with fedora...

i solved the problem after all.... it seems that the options std=c99 created the problem with the inclusions{unfortunately i don't know why} plus me forgeting to include list.o ... now everything works like a charm...

here is my makefile

#Project:: Simple Client-Server mail application with threads
#
#variables
CC = gcc
CFLAGS = -Wall -std=c99 -O3
LFLAGS = -lpthread 
LD = $(CC)

#sources needed by client and server...
global_sources= wrapper_functions.c list.c
OBJS = wrapper_functions.o list.o
# The object files we need to build the server part...
server_sources= server.c server_functions.c 
server_include = $(server_sources) $(global_sources)

SERVER_OBJS = server.o server_functions.o
SERVER_NAME = server

#the object files we need to build the client part
client_sources= client.c client_functions.c 
client_include = $(client_sources) $(global_sources)

CLIENT_OBJS = client.o client_functions.o
CLIENT_NAME = client

#all: $(SERVER_NAME) $(CLIENT_NAME)
all: $(SERVER_NAME) $(CLIENT_NAME) 
#all: $(CLIENT_NAME)
#all: $(SERVER_NAME)

#server part
$(SERVER_NAME): $(SERVER_OBJS) $(OBJS) 
	$(LD) $(LFLAGS) $^ -o $@


#CLIENT part
$(CLIENT_NAME): $(CLIENT_OBJS) $(OBJS) 
	$(LD) $(LFLAGS) $^ -o $@


#implicit rule for handling object files
%.o : %.c
	$(CC) $(CFLAGS) -c $< -o $@

#automatic dependency tracking....
-include $(server_include:.c=.d)
-include $(client_include:.c=.d)

%.d: %.c
	set -e; \
	$(CC) -MM $(CFLAGS) $< \
	| sed 's/\($*\)\.o[ :]*/\1.o $@ : /g' > $@; \
	[ -s $@ ] || rm -f $@ 

.PHONY : all clean clean_objects

clean_objects :
	rm -f *~ *.o *.d
	rm -f *~ *.o *.d

clean :
	rm -f *~ *.o $(SERVER_NAME) core *.d
	rm -f *~ *.o $(CLIENT_NAME) core *.d

also i attach the final version that can be compiled with this makefile...
I would really like to hear some comments on the code {bad or good}!

-nicolas

PS: ssharish2005 thanks for your answer, i hope that you will be able to open this zip file...

Edit: well looks like you fixed it. No need for my reply :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.