#For debug build please use: make -f makefile-debian CFG=debug

OUT = ../bin

EXENAME = vrut.exe

# Object files
LIBOBJS = $(OUT)/3dmath.o \
	$(OUT)/BinTreesCulling.o \
	$(OUT)/bvh.o \
	$(OUT)/camera.o \
	$(OUT)/common.o \
	$(OUT)/environment.o \
	$(OUT)/eventhandler.o \
	$(OUT)/flexilog.o \
	$(OUT)/generalmanager.o \
	$(OUT)/imagecommon.o \
	$(OUT)/image.o \
	$(OUT)/imagedds.o \
	$(OUT)/imagrgb.o \
	$(OUT)/imageHDR.o \
	$(OUT)/interpreter.o \
	$(OUT)/iomanager.o \
	$(OUT)/kernel.o \
	$(OUT)/manipmanager.o \
	$(OUT)/rendermodule.o \
	$(OUT)/rendertarget.o \
	$(OUT)/scene.o \
	$(OUT)/scenemanager.o \
	$(OUT)/geometrytriangles.o \
	$(OUT)/geometrypoints.o \
	$(OUT)/geometrytext.o \
	$(OUT)/environmentprobe.o \
	$(OUT)/cameramodule.o \
	$(OUT)/decompose.o \
	$(OUT)/draganddrop.o \
	$(OUT)/colourpicker.o \
	$(OUT)/spinsliderd.o \
	$(OUT)/filecontrol.o \
	$(OUT)/glgetproc.o \
	$(OUT)/guienvironment.o \
	$(OUT)/RenderGlModule.o \
	$(OUT)/FontGlyphsTexture.o \
	$(OUT)/glwindow.o \
	$(OUT)/rendermanager.o \
	$(OUT)/listctrl.o \
	$(OUT)/nodeidcontrol.o \
	$(OUT)/sceneidcontrol.o \
	$(OUT)/console.o \
	$(OUT)/shortcuts.o \
	$(OUT)/mainwindow.o

OBJS = $(OUT)/app.o

BASE_MODULES = internal
OUTMANIP = ../bin/modules/manip
OUTIO = ../bin/modules/io
OUTRENDER = ../bin/modules/render
OUTGENERAL = ../bin/modules
include ../core/makefile.debian.common

include ../base_modules/iofhs/makefile-debian
include ../base_modules/iocsb/makefile-debian
include ../base_modules/ioosb/makefile-debian
include ../base_modules/iostl/makefile-debian
include ../base_modules/iovrml/makefile-debian
include ../base_modules/ioiges/makefile-debian
include ../base_modules/ioobj/makefile-debian
include ../base_modules/ioimage/makefile-debian
include ../base_modules/ioac3d/makefile-debian
include ../base_modules/iodof/makefile-debian
include ../base_modules/iordf/makefile-debian
include ../base_modules/ioply/makefile-debian
#include ../base_modules/iofbx/makefile-debian
include ../base_modules/iojt/makefile-debian
include ../base_modules/iovrut/makefile-debian

include ../base_modules/RayTracer/makefile-debian
include ../base_modules/rendergl/makefile-debian

include ../base_modules/navigation/makefile-debian

include ../base_modules/3Dconnexion/makefile-debian
include ../base_modules/AutoTest/makefile-debian
include ../base_modules/cluster/makefile-debian
include ../base_modules/LightEditor/makefile-debian
include ../base_modules/materialassign/makefile-debian
include ../base_modules/materialeditor/makefile-debian
include ../base_modules/ClippingEditor/makefile-debian
include ../base_modules/optimize/makefile-debian
include ../base_modules/SceneGraph/makefile-debian
include ../base_modules/tesselator/makefile-debian
include ../base_modules/TextureManager/makefile-debian
include ../base_modules/tracking/makefile-debian
include ../base_modules/trackingmanipulator/makefile-debian
include ../base_modules/variants/makefile-debian
include ../base_modules/Wiimote/makefile-debian

$(OUT)/libvrut.a: $(LIBOBJS)
	$(AR) rcs $(OUT)/libvrut.a $(LIBOBJS)
	echo $(OUT)/libvrut.a rebuilded

$(OUT)/$(EXENAME): $(OBJS) $(SPECOBJS) $(OUT)/libvrut.a
	$(LINK) $(OBJS) -lvrut $(LFLAGS) $(SPECLFLAGS) -L$(OUT)/ -o $(OUT)/$(EXENAME)
	echo $(OUT)/$(EXENAME) rebuilded

final: $(OUT)/libvrut.a $(OUT)/$(EXENAME) $(MODULES)
	echo "all done " $(MODULES)
	+ cd ../base_modules/seatstitcher;make -f makefile-debian CFG="$(CFG)" &
	+ cd ../base_modules/adamstodg;make -f makefile-debian CFG="$(CFG)" &
	+ cd ../modules/collision_detection;make -f makefile-debian CFG="$(CFG)" &
	+ cd ../modules/scripting;make -f makefile-debian CFG="$(CFG)"
	+ cd ../modules/carHW;make -f makefile-debian CFG="$(CFG)" &
	+ cd ../modules/SoundRenderer;make -f makefile-debian CFG="$(CFG)" &
	+ cd ../modules/VehicleSimulator;make -f makefile-debian CFG="$(CFG)"
	+ cd ../modules/rendergl2;make -f makefile-debian CFG="$(CFG)" &
	+ cd ../modules/rendergl3;make -f makefile-debian CFG="$(CFG)" &
	+ cd ../modules/traffic;make -f makefile-debian CFG="$(CFG)"
#	+ cd ../modules/argie;make -f makefile-debian CFG="$(CFG)" &
#	+ cd ../modules/render4x;make -f makefile-debian CFG="$(CFG)"
##	+ cd ../modules/terrainEditor;make -f makefile-debian CFG="$(CFG)"
##	+ cd ../modules/treeEditor;make -f makefile-debian CFG="$(CFG)" &
##	+ cd ../base_modules/ioopenarena;make -f makefile-debian CFG="$(CFG)"
##	+ cd ../modules/dynamics;make -f makefile-debian CFG="$(CFG)"
##	+ cd ../modules/cameratopoints;make -f makefile-debian CFG="$(CFG)"
##	+ cd ../modules/aurel;make -f makefile-debian CFG="$(CFG)"

clean:
	rm -f $(OBJS) $(LIBOBJS)
	rm -f $(OUT)/$(EXENAME)
	rm -f $(OUT)/libvrut.a
	rm -f $(MODULES)
	+ cd ../base_modules/seatstitcher;make -f makefile-debian clean
	+ cd ../base_modules/adamstodg;make -f makefile-debian clean
	+ cd ../modules/collision_detection;make -f makefile-debian clean
	+ cd ../modules/dynamics;make -f makefile-debian clean
	+ cd ../modules/scripting;make -f makefile-debian clean
	+ cd ../modules/carHW;make -f makefile-debian clean
	+ cd ../modules/aurel;make -f makefile-debian clean
	+ cd ../modules/SoundRenderer;make -f makefile-debian clean
	+ cd ../modules/VehicleSimulator;make -f makefile-debian clean
	+ cd ../modules/terrainEditor;make -f makefile-debian clean
	+ cd ../modules/treeEditor;make -f makefile-debian clean
	+ cd ../modules/cameratopoints;make -f makefile-debian clean
	+ cd ../modules/render4x;make -f makefile-debian clean
	+ cd ../modules/rendergl2;make -f makefile-debian clean
	+ cd ../modules/rendergl3;make -f makefile-debian clean
	+ cd ../modules/argie;make -f makefile-debian clean
	+ cd ../modules/traffic;make -f makefile-debian clean
	+ cd ../modules/GIRayTracer;make -f makefile-debian clean
#	+ cd ../base_modules/ioopenarena;make -f makefile-debian clean
	