first: all
!include "Make.inc"

CPPFLAGS = $(CPPGLOBAL) /I . /I ./include /D _WINDOWS /D _WIN32_WINDOWS=0x0410 /D _TC_STATIC /D LDVIEW_APP /c 

COBJS = 
CCOBJS = $(OBJDIR)\BoolOptionUI.obj \
	 $(OBJDIR)\BoundingBoxDialog.obj \
	 $(OBJDIR)\EnumOptionUI.obj \
	 $(OBJDIR)\ExportOptionsDialog.obj \
	 $(OBJDIR)\FloatOptionUI.obj \
	 $(OBJDIR)\GroupOptionUI.obj \
	 $(OBJDIR)\LDVExtensionsSetup.obj \
	 $(OBJDIR)\LDViewMain.obj \
	 $(OBJDIR)\LDViewPreferences.obj \
	 $(OBJDIR)\LDViewWindow.obj \
	 $(OBJDIR)\LongOptionUI.obj \
	 $(OBJDIR)\JpegOptionsDialog.obj \
	 $(OBJDIR)\ModelLoader.obj \
	 $(OBJDIR)\ModelTreeDialog.obj \
	 $(OBJDIR)\ModelWindow.obj \
	 $(OBJDIR)\NumberOptionUI.obj \
	 $(OBJDIR)\OptionsCanvas.obj \
	 $(OBJDIR)\OptionsScroller.obj \
	 $(OBJDIR)\OptionUI.obj \
	 $(OBJDIR)\PathOptionUI.obj \
	 $(OBJDIR)\SSConfigure.obj \
	 $(OBJDIR)\StringOptionUI.obj \
	 $(OBJDIR)\StepDialog.obj \
	 $(OBJDIR)\SSModelWindow.obj \
	 $(OBJDIR)\SSPassword.obj \
	 $(OBJDIR)\SSPreview.obj \
	 $(OBJDIR)\TbButtonInfo.obj \
	 $(OBJDIR)\ToolbarStrip.obj \
	 $(OBJDIR)\PartsListDialog.obj \
	 $(OBJDIR)\LatLonDialog.obj \
       $(OBJDIR)\MpdDialog.obj

all: $(OBJDIR) $(OBJDIR)\LDView.exe launcher thumbs help

distclean:
	cd Help
	-del LDView.hlp
	cd ..
	cd TRE 
	if exist $(OBJDIR) $(MAKE) -nologo -f Makefile.vc clean
	cd ..
	cd CUI
	if exist $(OBJDIR) $(MAKE) -nologo -f Makefile.vc clean
	cd ..
	cd TCFoundation
	if exist $(OBJDIR) $(MAKE) -nologo -f Makefile.vc clean
	cd ..
	cd LDLib 
	if exist $(OBJDIR) $(MAKE) -nologo -f Makefile.vc clean
	cd ..
	cd LDLoader
	if exist $(OBJDIR) $(MAKE) -nologo -f Makefile.vc clean
	cd ..
	cd LDExporter
	if exist $(OBJDIR) $(MAKE) -nologo -f Makefile.vc clean
      cd ..
	cd gl2ps
	if exist $(OBJDIR) $(MAKE) -nologo -f Makefile.vc clean
	cd ..
	cd Translations\Hungarian
	if exist $(OBJDIR) $(MAKE) -nologo -f Makefile.vc clean
	cd ..\..
	cd Translations\German
	if exist $(OBJDIR) $(MAKE) -nologo -f Makefile.vc clean
	cd ..\..
	cd Translations\Italian
	if exist $(OBJDIR) $(MAKE) -nologo -f Makefile.vc clean
	cd ..\..
	cd Translations\Czech
	if exist $(OBJDIR) $(MAKE) -nologo -f Makefile.vc clean
	cd ..\..
	if exist $(OBJDIR) $(MAKE) -nologo -f Makefile.vc clean
	cd LDViewThumbs
	if exist $(OBJDIR) $(MAKE) -nologo -f Makefile.vc clean
	cd ..
	cd Launcher
	if exist $(OBJDIR) $(MAKE) -nologo -f Makefile.vc clean
	cd ..
	-rmdir Build\CUI
	-rmdir Build\LDLib
	-rmdir Build\LDLoader
	-rmdir Build\LDExporter
	-rmdir Build\TCFoundation
	-rmdir Build\TRE
	-rmdir Build\gl2ps
	-for /d /r . %%i in (Release* Debug*) do rd /s /q %%i

Build\CUI\$(CONFIG)\CUI.lib: CUI\*.cpp CUI\*.h
	cd CUI
	$(MAKE) -nologo -f Makefile.vc 
	cd ..

Build\TRE\$(CONFIG)\TRE.lib: TRE\*.cpp TRE\*.h
	cd TRE
	$(MAKE) -nologo -f Makefile.vc 
	cd ..

Build\LDLib\$(CONFIG)\LDLib.lib: LDLib\*.cpp LDLib\*.h
	cd LDLib
	$(MAKE) -nologo -f Makefile.vc 
	cd ..

Build\LDLoader\$(CONFIG)\LDLoader.lib: LDLoader\*.cpp LDLoader\*.h LDLoader\*.c
	cd LDLoader
	$(MAKE) -nologo -f Makefile.vc 
	cd ..

Build\TCFoundation\$(CONFIG)\TCFoundation.lib: TCFoundation\*.cpp TCFoundation\*.h
	cd TCFoundation
	$(MAKE) -nologo -f Makefile.vc 
	cd ..

Build\LDExporter\$(CONFIG)\LDExporter.lib: LDExporter\*.cpp LDExporter\*.h
	cd LDExporter
	$(MAKE) -nologo -f Makefile.vc
	cd ..

Build\gl2ps\$(CONFIG)\gl2ps.lib: gl2ps\*.c gl2ps\*.h
	cd gl2ps
	$(MAKE) -nologo -f Makefile.vc 
	cd ..

Build\tinyxml\$(CONFIG)\tinyxml.lib: 3rdParty\tinyxml\*.cpp 3rdParty\tinyxml\*.h
	cd 3rdParty\tinyxml
	$(MAKE) -nologo -f Makefile.vc 
	cd ..\..

!IF DEFINED(X64)
LFLAGS= $(LFLAGS) /LIBPATH:lib\x64
!ELSE
LFLAGS= $(LFLAGS) /LIBPATH:lib
!ENDIF

$(OBJDIR)\LDView.exe:	Build\CUI\$(CONFIG)\CUI.lib Build\TRE\$(CONFIG)\TRE.lib 
$(OBJDIR)\LDView.exe:	Build\LDLib\$(CONFIG)\LDLib.lib Build\LDLoader\$(CONFIG)\LDLoader.lib 
$(OBJDIR)\LDView.exe:	Build\TCFoundation\$(CONFIG)\TCFoundation.lib $(CCOBJS) 
$(OBJDIR)\LDView.exe:	Build\gl2ps\$(CONFIG)\gl2ps.lib
$(OBJDIR)\LDView.exe:	Build\LDExporter\$(CONFIG)\LDExporter.lib
$(OBJDIR)\LDView.exe:	$(OBJDIR)\LDView.res Build\tinyxml\$(CONFIG)\tinyxml.lib
	link -nologo -out:$(OBJDIR)\LDView.exe $** $(LFLAGS) zlib.lib unzip32.lib \
	user32.lib gdi32.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib \
	opengl32.lib glu32.lib ws2_32.lib \
	winmm.lib shlwapi.lib comctl32.lib version.lib lib3ds.lib \
	/subsystem:windows /incremental:no /nodefaultlib:"libc.lib" \
	/pdb:$(OBJDIR)\LDView.pdb /libpath:lib $(SPECLIBS)  $(EXTRALFLAGS) 

translations:	hungarian czech german italian

hungarian:		Build\Hungarian\$(CONFIG)\LDView-Hungarian.dll
Build\Hungarian\$(CONFIG)\LDView-Hungarian.dll: Translations\Hungarian\*.cpp Translations\Hungarian\*.rc Translations\Hungarian\*.h*
			cd Translations\Hungarian
			$(MAKE) -nologo /f Makefile.vc all
			cd ..\..

czech:		Build\Czech\$(CONFIG)\LDView-Czech.dll
Build\Czech\$(CONFIG)\LDView-Czech.dll: Translations\Czech\*.cpp Translations\Czech\*.rc Translations\Czech\*.h*
			cd Translations\Czech
			$(MAKE) -nologo /f Makefile.vc all
			cd ..\..

german:		Build\German\$(CONFIG)\LDView-German.dll
Build\German\$(CONFIG)\LDView-German.dll: Translations\German\*.cpp Translations\German\*.rc Translations\German\*.h*
			cd Translations\German
			$(MAKE) -nologo /f Makefile.vc all
			cd ..\..

italian:		Build\Italian\$(CONFIG)\LDView-Italian.dll
Build\Italian\$(CONFIG)\LDView-Italian.dll: Translations\Italian\*.cpp Translations\Italian\*.rc Translations\Italian\*.h*
			cd Translations\Italian
			$(MAKE) -nologo /f Makefile.vc all
			cd ..\..

installer:	Help\LDVIEW.HLP Build\Release\LDView.exe LDView.iss Build\Release\LDViewThumbs.dll
	if exist "$(PROGRAMFILES)\Inno Setup 5\iscc.exe" "$(PROGRAMFILES)\Inno Setup 5\iscc.exe" LDView.iss
	if exist "..\Inno Setup 5\iscc.exe" "..\Inno Setup 5\iscc.exe" LDView.iss

thumbs:		Build\$(CONFIG)\LDViewThumbs.dll
Build\$(CONFIG)\LDViewThumbs.dll: LDViewThumbs\*.cpp Build\TCFoundation\$(CONFIG)\TCFoundation.lib
	cd LDViewThumbs
	$(MAKE) -nologo -f Makefile.vc all
	cd ..

launcher:	Build\$(CONFIG)\LDView.com

Build\$(CONFIG)\LDView.com:
	cd Launcher
	$(MAKE) -nologo -f Makefile.vc all
	cd ..
		
!IF DEFINED(QTDIR)
all: QT\Release\LDView.exe

QT\Release\LDView.exe:	Build\TRE\$(CONFIG)\TRE.lib Build\TCFoundation\$(CONFIG)\TCFoundation.lib
QT\Release\LDView.exe:	Build\LDLib\$(CONFIG)\LDLib.lib Build\LDLoader\$(CONFIG)\LDLoader.lib
QT\Release\LDView.exe:	QT\*.cpp QT\*.h QT\*.ui
	cd QT
	$(QTDIR)\bin\qmake
	nmake /nologo
	cd ..

qtclean:
	cd QT
	nmake /nologo clean
	-del LDView.exe
	cd ..

clean: qtclean

!ENDIF

all:			translations

help:		Help\LDVIEW.HLP

Help\LDVIEW.HLP:	Help\*.rtf Help\LDView.hpj
	cd Help
	if exist "$(HCW)" "$(HCW)" /c /e LDView.hpj
	if exist "..\..\Help Workshop\hcw.exe" "..\..\Help Workshop\hcw.exe"  /c /e LDView.hpj
	cd ..

$(OBJDIR)\LDView.res:	LDView.rc LDViewMessages.ini
	$(RC) $(RFLAGS) /d LDVIEW_APP /fo$(OBJDIR)\LDView.res LDView.rc
