#
# VCProject file to Makefile converter
#
# November 2004, alfred@valvesoftware.com
#

VCPM_SRC_DIR=$(SOURCE_DIR)/utils/vprojtomake
UTIL_COMMON_SRC_DIR=$(SOURCE_DIR)/utils/common
TIER0_PUBLIC_SRC_DIR=$(SOURCE_DIR)/public/tier0
TIER1_PUBLIC_SRC_DIR=$(SOURCE_DIR)/public/tier1
PUBLIC_SRC_DIR=$(SOURCE_DIR)/public
TIER1_SRC_DIR=$(SOURCE_DIR)/tier1

VCPM_OBJ_DIR=$(BUILD_OBJ_DIR)/vcpm
TIER1_OBJ_DIR=$(BUILD_OBJ_DIR)/vcpm/public
TIER0_OBJ_DIR=$(BUILD_OBJ_DIR)/vcpm/public

#we use custome CFLAGS because the base ones interfere with XERCES
CFLAGS= -w -fpermissive -D_LINUX -DNDEBUG $(ARCH_CFLAGS) 
#DEBUG = -g -ggdb
#CFLAGS+= $(DEBUG)

INCLUDEDIRS=-I$(PUBLIC_SRC_DIR) -I$(XERCES_INC_DIR) -I$(UTIL_COMMON_SRC_DIR) -I$(TIER1_PUBLIC_SRC_DIR) -I$(TIER0_PUBLIC_SRC_DIR)
LDFLAGS_VC=-lm -ldl -Wl,-rpath $(GAME_DIR)/bin -L$(XERCES_LIB_DIR) -lxerces-c $(GAME_DIR)/bin/tier0_i486.so $(GAME_DIR)/bin/vstdlib_i486.so -Wl,-rpath-link $(GAME_DIR)/bin

DO_CC=$(CPLUS) $(INCLUDEDIRS) -w $(CFLAGS) -DARCH=$(ARCH) -o $@ -c $<

#####################################################################

VCPM_OBJS = \
	$(VCPM_OBJ_DIR)/makefilecreator.o \
	$(VCPM_OBJ_DIR)/vprojtomake.o \
	$(VCPM_OBJ_DIR)/vcprojconvert.o \

TIER1_OBJS = \
	$(TIER1_OBJ_DIR)/characterset.o \
	$(TIER1_OBJ_DIR)/interface.o \
	$(TIER1_OBJ_DIR)/generichash.o \
	$(TIER1_OBJ_DIR)/KeyValues.o \
	$(TIER1_OBJ_DIR)/stringpool.o \
	$(TIER1_OBJ_DIR)/utlbuffer.o \
	$(TIER1_OBJ_DIR)/utlsymbol.o \
	$(TIER1_OBJ_DIR)/strtools.o \


all: dirs vcpm

dirs:
	-mkdir $(BUILD_OBJ_DIR)
	-mkdir $(VCPM_OBJ_DIR)
	-mkdir $(TIER1_OBJ_DIR)
	-mkdir $(TIER0_OBJ_DIR)

vcpm: $(VCPM_OBJS) $(TIER1_OBJS) 
	$(CLINK) $(DEBUG) -o $(BUILD_DIR)/$@ $(VCPM_OBJS) $(TIER1_OBJS) $(CPP_LIB) $(LDFLAGS_VC)

$(VCPM_OBJ_DIR)/%.o: $(VCPM_SRC_DIR)/%.cpp
	$(DO_CC)

$(TIER1_OBJ_DIR)/%.o: $(TIER1_SRC_DIR)/%.cpp
	$(DO_CC)

clean:
	-rm -rf $(VCPM_OBJ_DIR)
	-rm -f vcpm
