OUT = bin
SRC = src
OBJDIR = bin

!IF "$(CFG)"=="debug"
EXENAME = RemoteDashboard_d.exe
!ELSE
EXENAME = RemoteDashboard.exe
!ENDIF

CPPS =  Config.cpp 	\
		Error.cpp	\
		Font.cpp	\
		Gui.cpp		\
		GuiElements.cpp	\
		Image.cpp	\
		Listener.cpp	\
		main.cpp	\
		Renderer.cpp	\
		Texture.cpp

OBJS =  $(OBJDIR)\Config.obj 	\
		$(OBJDIR)\Error.obj	\
		$(OBJDIR)\Font.obj	\
		$(OBJDIR)\Gui.obj		\
		$(OBJDIR)\GuiElements.obj	\
		$(OBJDIR)\Image.obj	\
		$(OBJDIR)\Listener.obj	\
		$(OBJDIR)\main.obj	\
		$(OBJDIR)\Renderer.obj	\
		$(OBJDIR)\Texture.obj


default:
	nmake -f makefile.win final CFG=$(CFG) _64bit=$(_64bit)

.phony: release
release:
	nmake -f makefile.win final CFG=release

.phony: debug
debug:
	nmake -f makefile.win final CFG=debug

release64:
	nmake -f makefile.win final CFG=release _64bit=_64bit

debug64:
	nmake -f makefile.win final CFG=debug _64bit=_64bit

.cpp.obj:
	rem $<
	$(CC) $(CFLAGS) $(SPECCFLAGS) -c $<

{$(SRC)}.cpp{$(OBJDIR)}.obj:
	$(CC) $(CFLAGS) $(SPECCFLAGS) -Fo$(OBJDIR)\ -c $<

!IF "$(CFG)"=="debug"
#DEBUG
CFLAGS = -I"$(GLUT)$(_64bit)\include" -D__WINDOWS__ -D_CRT_SECURE_NO_WARNINGS -D_UNICODE -DUNICODE /EHsc /W3 /nologo /c /TP /errorReport:prompt /RTC1 /Od /MDd /Z7 -DGLUT_BUILDING_LIB /D_CRT_SECURE_NO_DEPRECATE -I"$(SRC)"
LFLAGS = /DEBUG /LIBPATH:"$(GLUT)$(_64bit)" \
	wsock32.lib opengl32.lib glu32.lib glut32.lib /NODEFAULTLIB:LIBCMTD /NODEFAULTLIB:LIBCMT /NODEFAULTLIB:LIBC

!ELSE

#RELEASE
CFLAGS = -I"$(GLUT)$(_64bit)\include" -D__WINDOWS__ -D_CRT_SECURE_NO_WARNINGS -D_UNICODE -DUNICODE /EHsc /W3 /O2 /nologo /c /TP /errorReport:prompt /MD -DGLUT_BUILDING_LIB /D_CRT_SECURE_NO_DEPRECATE -I"$(SRC)" /DNDEBUG
LFLAGS = /LIBPATH:"$(GLUT)$(_64bit)" \
	wsock32.lib opengl32.lib glu32.lib glut32.lib /NODEFAULTLIB:LIBCMT /NODEFAULTLIB:LIBC

!ENDIF

!IF "$(__64bit)"!=""
CFLAGS = $(CFLAGS) -D__WIN64__
!ELSE
LFLAGS = $(LFLAGS) /LARGEADDRESSAWARE
!ENDIF

$(OUT)\$(EXENAME): $(OBJS)
	link $(OBJS) $(LFLAGS) /OUT:$(OUT)\$(EXENAME)
	mt.exe -manifest $(OUT)\$(EXENAME).manifest -outputresource:$(OUT)\$(EXENAME);1
		
clean:
	del $(OBJS)
	del $(OUT)\RemoteDashboard.exe
	del $(OUT)\RemoteDashboard.ilk
	del $(OUT)\RemoteDashboard.pdb
	del $(OUT)\RemoteDashboard.exe.manifest
	del $(OUT)\RemoteDashboard_d.exe
	del $(OUT)\RemoteDashboard_d.ilk
	del $(OUT)\RemoteDashboard_d.pdb
	del $(OUT)\RemoteDashboard_d.exe.manifest

final: $(OUT)\$(EXENAME)
	
