Below is the Makefile that I am currently using for the programs for this class. You should make one like it, replacing the program names with your own program names for the four programs.
# this flag says to compile for the debugger CFLAGS=-g # edit this list to match your set of programs TARGETS=client-rdv server-wiki-rdv server-udp-rdv client-udp-rdv \ client-udp-wiki all: ${TARGETS} # edit the lines below this to match your set of programs server-wiki-rdv: server-wiki-rdv.c client-rdv: client-rdv.c server-udp-rdv: server-udp-rdv.c client-udp-rdv: client-udp-rdv.c client-udp-wiki: client-udp-wiki.c clean: rm ${TARGETS}
# this flag says to compile for the debugger CFLAGS=-g # edit this list to match your set of programs TARGETSOURCES=client-rdv.c server-wiki-rdv.c server-udp-rdv.c \ client-udp-rdv.c client-udp-wiki.c LIBRARIES=mylib.a # edit this list to match your set of library source files LIBSOURCES=mylib.c #edit this list to match your set of test programs TESTSOURCES=mylibtest.c gai.c # header files HEADERFILES=prototypes.h LIBOBJS=$(subst .c,.o,$(LIBSOURCES)) ALLSOURCES=$(LIBSOURCES) $(TESTSOURCES) $(TARGETSOURCES) TESTBINARIES=$(subst .c,,$(TESTSOURCES)) TARGETBINARIES=$(subst .c,,$(TARGETSOURCES)) ALLBINARIES=$(TARGETBINARIES) $(TESTBINARIES) all: $(ALLBINARIES) # the four main programs we have discussed server-wiki-rdv: server-wiki-rdv.c $(LIBRARIES) $(CC) $(CFLAGS) -o server-wiki-rdv server-wiki-rdv.c $(LIBRARIES) client-rdv: client-rdv.c $(LIBRARIES) $(CC) $(CFLAGS) -o client-rdv client-rdv.c $(LIBRARIES) server-udp-rdv: server-udp-rdv.c $(LIBRARIES) $(CC) $(CFLAGS) -o server-udp-rdv server-udp-rdv.c $(LIBRARIES) client-udp-wiki: client-udp-wiki.c $(LIBRARIES) $(CC) $(CFLAGS) -o client-udp-wiki client-udp-wiki.c $(LIBRARIES) # this was a short test program I wrote; you probably don't need it gai: gai.c $(LIBRARIES) $(CC) $(CFLAGS) -o gai gai.c $(LIBRARIES) # here is the library mylib.a: $(LIBOBJS) ar r mylib.a $(LIBOBJS) clean: rm -f *.o *.a *.d $(ALLBINARIES) TAGS # automatically generated dependency files include $(subst .c,.d,$(ALLSOURCES)) # rules for generating dependency files %.d: %.c $(CC) -M $(CFLAGS) $< > $@.$$$$; \ sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ rm -f $@.$$$$
By now, you should have a complete system fairly well under way. It should consist of the following:
Note: this homework has been somewhat modified from the originals from Lectures 3 and 4.
This week's homework (submit via email):
[rdv@localhost network-programming-in-c]$ ./a.out elementNumber: 10 elementNumber: 9 elementNumber: 8 elementNumber: 7 elementNumber: 6 elementNumber: 5 elementNumber: 4 elementNumber: 3 elementNumber: 2 elementNumber: 1 elementNumber: 0