# ========================================================================
# ==== Set paths to the source and include directories 
# ========================================================================

# Edit the APIDir item to your location
APIDIR = ../
CLIENTDIR = $(APIDIR)APIClient/
COMMONDIR = $(APIDIR)APICommon/

# ========================================================================
# ==== Set compiler, compiler flags, and library/include paths
# ========================================================================
CC = xlc
CCPP = xlC
LINT = lint
CFLAGS = #-Wall -W -Wshadow -Wpointer-arith -Wcast-qual     \
        #-Wcast-align -Wconversion -Waggregate-return      \
        #-Wstrict-prototypes -Wmissing-prototypes          \
        #-Wmissing-declarations -Wnested-externs -Winline  \
       #-Wtraditional -Wbad-function-cast -Wwrite-strings \
        #-pedantic -g -O -ansi

DEFOPTS = -D_BSD=43
INCDIRS = -I$(APIDIR) -I$(COMMONDIR)
#LIBS = -lsocket -lnsl

ALLFLAGS = $(CFLAGS) $(MAKEDEPEND) $(DEFOPTS) $(INCDIRS)

# ========================================================================
# ==== Objects from the APIClient directory
# ========================================================================
COMMONOBJS = $(COMMONDIR)Sockets.o \
        $(COMMONDIR)Utils.o \
        $(COMMONDIR)APIStringData.o \
        $(COMMONDIR)APIStringMsg.o \
        $(COMMONDIR)APISymbolTable.o \
        $(COMMONDIR)String.o
.c.o:
	$(CC) -c $(ALLFLAGS) $<

.C.o:
	$(CCPP) -c $(ALLFLAGS)  $<

$(COMMONOBJS):
	@-cd $(COMMONDIR) ; make all

MakeCommon = @cd $(COMMONDIR); make all; cd $(CLIENTDIR)

# ========================================================================
# ==== Include automatically generated dependency files
# ========================================================================


all: example 

clean:
	@-rm -f *.o
lint:
	@-$(LINT) -I$(COMMONDIR) example.C 

example: example.o $(COMMONOBJS)
	$(MakeCommon)
	$(CCPP) $(ALLFLAGS) -o example example.o $(COMMONOBJS) $(LIBS)

#SubmitAuction: SubmitAuction.o $(COMMONOBJS)
#        $(CCPP) $(ALLFLAGS) -o SubmitAuction SubmitAuction.o $(COMMONOBJS) $(LIBS)

# DO NOT DELETE THIS LINE -- make depend depends on it.
