#Troy Rosin tjr760 11200680

CC				=gcc
CFLAGS		=-g
CPPFLAGS	=-c -g -Wall -pedantic
LDFLAGS		=-lSDL2 -lSDL2_net

BIN				=build/bin/
LIB				=build/lib/
OBJ				=build/obj/
DIRS			=$(BIN) $(LIB) $(OBJ)

debug			?=on
ifeq ($(debug),on)
CPPFLAGS += -Ddebug
endif

BINARIES	= client server

all : $(BINARIES)

clean :
	rm -rf build/ lib/ bin/ $(BINARIES)

$(DIRS) :
	mkdir -p $@

$(BIN)% : $(OBJ)%.o | $(BIN)
	$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)

$(OBJ)%.o : %.c net.h | $(OBJ)
	$(CC) $(CPPFLAGS) -o $@ $< -I.

  
$(BINARIES) : % : $(BIN)%
	ln -sf $< $@ 
