#the compiler
CPP = g++
CC = gcc

#compiler options

CPPOPTS = -g -Wall -c $(shell sdl-config --cflags) -Wno-deprecated
#CPPOPTS = -O3 -Wall -c $(shell sdl-config --cflags) -Wno-deprecated
#CPPOPTS = -O3 -g -Wall -c $(shell sdl-config --cflags) -Wno-deprecated

#header files
INCLUDES = \
	-I. \
	$(NULL)

#library directories
LIBDIRS = \
	-L/usr/lib \
	$(NULL)

#libraries to link with
LIBS = \
	-lSDL_net \
	$(NULL)

#all compiler flags
CFLAGS = $(CPPOPTS) $(INCLUDES)

#all linker options and libs
LFLAGS = $(LIBDIRS) $(shell sdl-config --libs)

#default compilation rules
%.o:	%.cpp
	$(CPP) -c $< $(CFLAGS) -o $@

%.o:	%.c
	$(CC) -c $< $(CFLAGS) -o $@

#local headers to depend on
HEADERS = \
	queue.h		\
	net2.h		\
	fastevents.h	\
	trace.h		\
	$(NULL)

#library files to compile
CCLIBS = \
	net2.c		\
	fastevents.c	\
	trace.c		\
	$(NULL)

#all local .o files
OBJS =  ${CPPLIBS:.cpp=.o} ${CCLIBS:.c=.o}
MAINS =  ${CPPMAINS:.cpp=.o} ${CCMAINS:.c=.o}

default: net2_fastevents

net2_fastevents: ${CCLIBS} ${HEADERS} makefile
	${CC} -c net2.c fastevents.c `sdl-config --cflags`

clean:
	rm -f net2.o fastevents.o
