# You can define the following debug messages:
#
# - DEBUG_TIMERS : prints TIMER related messages
# - DEBUG_NET_MSGS: prints sent/received packages related messages
# - DEBUG_CACHE : prints cache related messages
# - DEBUG_EVENTS: prints event list handler messages
# - DEBUG_SHOW : Warning: this can generate lots of data!: Shows program stuctures content (cache, event list, etc).
# - DEBUG_PCKT : prints mount/unmount package info
# - DEBUG_MSG_QUEUE : prints message queue info
# - DEBUG_TCP: tcp connection debug (see rmtcp.c)
# - REFRESH : enables refresh messages
# - SUPPORT_FOR_NEW_USERS : enables support for new users
# - DONT_SEND_NACK_AGAIN_IMMEDIATLY : a second NAK is sent only when the first one was received by the user himself who sent the NAK

OBJECTS = rmevent.o rmcache.o rmmsgpckt.o rminternals.o rmmsg.o rmcast.o rmtcp.o

LIBDIR= 
LIBS= -lpthread -lm

CC	= gcc
LDFLAGS =
CFLAGS	= -Wall -g
INCDIR  =
DEFINES = -D_REENTRANT -DMALLOC_CHECK_ -DREFRESH -D_POSIX_PTHREAD_SEMANTICS -DSUPPORT_FOR_NEW_USERS

all: clean librmcast.a

with_loss_sim: all
	$(CC) $(DEFINES) $(CFLAGS) $(INCDIR) -c -o rminternals_with_loss.o rminternals.c -DLOSS_SIM
	ar -rcv librmcast.a rmevent.o rmcache.o rmmsgpckt.o rminternals_with_loss.o rmmsg.o rmcast.o
	ranlib librmcast.a
	$(CC) server.c  $(DEFINES) $(CFLAGS)  -lpthread -lm -lrmcast -L. -Wall -o server_with_loss
        
.SUFFIXES: .o .c

.c.o:
	$(CC) $(DEFINES) $(CFLAGS) $(INCDIR) -c -o $@ $<


librmcast.a: $(OBJECTS)
	ar -rcv $@ $(OBJECTS)
	ranlib $@

server: server.c $(OBJECTS) 
	$(CC) server.c  $(DEFINES) $(CFLAGS)  -lpthread -lm -lrmcast -L. -Wall -o server

client: client.c $(OBJECTS)
	$(CC) client.c $(DEFINES) $(CFLAGS)  -lpthread -lm -lrmcast -L. -Wall -o client


clean:
	\rm -f $(OBJECTS) *core *~ *.bak *% rmcast *.o *.a server client
  

