include toprules.make

coredirs = .
coresrcs = $(wildcard $(patsubst %,%/*.cpp,$(coredirs)))
corehdrs = $(wildcard $(patsubst %,%/*.h,$(coredirs)))
coreobjs = $(shell ls $(coresrcs) | \
		perl -pne 's|(.*)/([^/]*)\.cpp|$$1/.$$2.o|') \
		$(verobjs)

APPDIRS = # apps/deltatest apps/q3mini
SUBDIRS = quake3 

INCLUDES += -I$(TOPDIR)/quake3 -I$(MERC_DIR) -I$(COLY_DIR)
LDFLAGS += -L$(TOPDIR)/quake3 -L. -L$(MERC_DIR) -L$(COLY_DIR)
COMMON_LIBS = -lpthread -lm -lz -lgmp -ldl

TOPDIR = .
SCHEMA = schema_test.cfg schema_test_load.cfg

TARGET = colyquake3
Q3LIB  = $(TOPDIR)/quake3/libq3ded.a

all: $(SUBDIRS) $(TARGET) $(APPDIRS)

instrumented: $(SUBDIRS)
	$(MAKE) -C apps/iquake3 

$(Q3LIB): $(SUBDIRS)

$(APPDIRS): $(SUBDIRS) $(TARGET)

objs = $(coreobjs)
$(TARGET): $(objs) $(merc_libs) $(Q3LIB)
	$(CPP) $(CFLAGS) $(LDFLAGS) $(objs) $(LIBS) -lq3ded -o $@

###############################################################
cleanlinks:
	rm -f libqagamei386.so libcgamei386.so libuii386.so

clean: $(SUBDIRS) cleanlinks

DIST_FILES = *.cpp *.h quake3 Makefile* *.make

include botrules.make
