#############################################################################
#
#                   Copyright (C) 1998 SciTech Software.
#                           All rights reserved.
#
# Descripton:   Global makefile to build SciTech MGL libraries and install
#				archive components.
#
#############################################################################

# Comment this out to convert to non-beta build

#BETA_FLAG   = BETA=1

# Define directories for build

SCRIPTS		= c:\private\scripts\mgl
BUILDS      = c:\builds\mgl
SOURCE		= c:\scitech\src

# Define the name of all install archives

MGLVER		= 405
MGLVERS		= 40
MGLBASE		= mglb$(MGLVER).exe
MGLFONT 	= mglf$(MGLVER).exe
MGLSRC		= mgls$(MGLVER).exe
MGLDEMO     = mgldm$(MGLVER).exe
OGLDEMO     = ogldm$(MGLVER).exe
MGLD_BC45	= md$(MGLVERS)bc45.exe
MGLD_DJ20	= md$(MGLVERS)dj2.exe
MGLD_WC10	= md$(MGLVERS)wc10.exe
MGLD_WC11	= md$(MGLVERS)wc11.exe
MGLW_BC45	= mw$(MGLVERS)bc45.exe
MGLW_BC50	= mw$(MGLVERS)bc50.exe
MGLW_DP20	= mw$(MGLVERS)dp20.exe
MGLW_VC42	= mw$(MGLVERS)vc42.exe
MGLW_VC50	= mw$(MGLVERS)vc50.exe
MGLW_WC10	= mw$(MGLVERS)wc10.exe
MGLW_WC11	= mw$(MGLVERS)wc11.exe

# Define command line to build the library

.IF $(SINGLE)
MKALL		= install -u
.ELSE
MKALL		= mkall
.ENDIF

# Only build static link libraries for Mesa and MesaGLU for DOS

.IF $(USE_WIN32)
.ELSE
	MESA_TARGETS = targets\mesa targets\mesaglu
.ENDIF

# Default targets for a full build

all: 	targets\sync targets\pmode targets\ztimer targets\sddhelp \
		targets\wdirect targets\tech targets\mvis targets\fixed \
		targets\quick2d targets\quick3d targets\qmodel targets\mesa \
		targets\mesaglu targets\glut targets\gm targets\libjpeg \
		targets\mgldos targets\mglwin targets\mgldos_s \
		targets\mglwin_s targets\ogldos_s targets\oglwin_s targets\wise \
		targets\buildinc
	@+echo =============================================================================
	@+echo DONE: Full MGL build completed successfully!

all_single: targets\pmode targets\ztimer targets\tech targets\mvis \
		targets\fixed targets\quick2d targets\quick3d targets\qmodel \
		$(MESA_TARGETS)	targets\glut targets\gm targets\libjpeg targets\mgl
	@+echo =============================================================================
	@+echo DONE: Single compiler MGL build completed successfully!

rmtargets:
	@+rm -f targets\*

# Target to build all libraries, for all compilers

buildall:	rmtargets all

# Target to build all libraries for current compiler

.SWAP build: rmtargets
    @+dmake SINGLE=1 all_single

# Target to continue build of all libraries for current compiler

.SWAP single:
    @+dmake SINGLE=1 all_single

targets\sync:
	@+echo =============================================================================
	@+echo START: Syncing files to depot
	@+p4 sync
	@+echo done > targets\sync

.SWAP targets\pmode:
	@+echo =============================================================================
	@+echo START: Building PMODE Library
	@+cdit c:\scitech\src\pmode dmake $(MKALL)
	@+echo done > targets\pmode

.SWAP targets\ztimer:
	@+echo =============================================================================
	@+echo START: Building Zen Timer Library
	@+cdit c:\scitech\src\ztimer dmake $(MKALL)
	@+echo done > targets\ztimer

.SWAP targets\sddhelp:
	@+echo =============================================================================
	@+echo START: Building SDD Helper VxD
    @+cdit c:\private\src\sddhelp dmake mksdd
	@+echo done > targets\sddhelp

.SWAP targets\wdirect:
	@+echo =============================================================================
	@+echo START: Building WinDirect Runtime Libraries
	@+cdit c:\private\src\wdirect dmake mkwin
	@+echo done > targets\wdirect

.SWAP targets\tech:
	@+echo =============================================================================
	@+echo START: Building Techniques Class Library
	@+cdit c:\scitech\src\tech dmake $(MKALL)
	@+echo done > targets\tech

.SWAP targets\mvis:
	@+echo =============================================================================
	@+echo START: Building MegaVision GUI Library
	@+cdit c:\scitech\src\mvis dmake $(MKALL)
	@+echo done > targets\mvis

.SWAP targets\fixed:
	@+echo =============================================================================
	@+echo START: Building Vector/Matrix Library
	@+cdit c:\scitech\src\fixed dmake $(MKALL)
	@+echo done > targets\fixed

.SWAP targets\quick2d:
	@+echo =============================================================================
	@+echo START: Building Quick2D Library
	@+cdit c:\scitech\src\quick2d dmake $(MKALL)
	@+echo done > targets\quick2d

.SWAP targets\quick3d:
	@+echo =============================================================================
	@+echo START: Building Quick3D Library
	@+cdit c:\scitech\src\quick3d dmake $(MKALL)
	@+echo done > targets\quick3d

.SWAP targets\qmodel:
	@+echo =============================================================================
	@+echo START: Building QuickModeller Library
	@+cdit c:\scitech\src\qmodel dmake $(MKALL)
	@+echo done > targets\qmodel

.SWAP targets\mesa:
	@+echo =============================================================================
	@+echo START: Building Mesa OpenGL Library
	@+cdit c:\scitech\src\mesa dmake $(MKALL)
	@+echo done > targets\mesa

.SWAP targets\mesaglu:
	@+echo =============================================================================
	@+echo START: Building Mesa OpenGL Utility Library
	@+cdit c:\scitech\src\mesaglu dmake $(MKALL)
	@+echo done > targets\mesaglu

.SWAP targets\glut:
	@+echo =============================================================================
	@+echo START: Building MGL GLUT Library
	@+cdit c:\scitech\src\glut dmake $(MKALL)
	@+echo done > targets\glut

.SWAP targets\gm:
	@+echo =============================================================================
	@+echo START: Building Game Framework Library
	@+cdit c:\scitech\src\gm dmake $(MKALL)
	@+echo done > targets\gm

.SWAP targets\libjpeg:
	@+echo =============================================================================
	@+echo START: Building JPEG Library
	@+cdit c:\scitech\src\libjpeg dmake $(MKALL)
	@+echo done > targets\libjpeg

.SWAP targets\mgl:
	@+echo =============================================================================
	@+echo START: Building Core MGL Library
	@+cdit c:\scitech\src\mgl dmake install -u
	@+cdit c:\scitech\src\mgl dmake installcpp -u
	@+echo done > targets\mgl

.SWAP targets\mgldos:
	@+echo =============================================================================
	@+echo START: Building Core MGL DOS Library
	@+cdit c:\scitech\src\mgl dmake mkdos
	@+echo done > targets\mgldos

.SWAP targets\mglwin:
	@+echo =============================================================================
    @+echo START: Building Core MGL Windows Library
	@+cdit c:\scitech\src\mgl dmake mkwin
    @+echo done > targets\mglwin

.SWAP targets\mgldos_s:
	@+echo =============================================================================
	@+echo START: Building MGL DOS Samples Programs
	@+cdit c:\scitech\examples\mgl dmake mkdos
	@+echo done > targets\mgldos_s

.SWAP targets\mglwin_s:
	@+echo =============================================================================
	@+echo START: Building MGL Windows Samples Programs
	@+cdit c:\scitech\examples\mgl dmake mkwin
	@+echo done > targets\mglwin_s

.SWAP targets\ogldos_s:
	@+echo =============================================================================
	@+echo START: Building OpenGL DOS Samples Programs
	@+cdit c:\scitech\examples\opengl dmake mkdos
	@+echo done > targets\ogldos_s

.SWAP targets\oglwin_s:
	@+echo =============================================================================
	@+echo START: Building OpenGL Windows Samples Programs
    @+cdit c:\scitech\examples\opengl dmake mkwin
    @+echo done > targets\oglwin_s

.SWAP targets\wise:
	@+echo =============================================================================
	@+echo START: Building Wise install archives
	@+runwise $(SCRIPTS)\mksetup.wse
	@+runwise $(SCRIPTS)\mglbase.wse
	@+copy $(SCRIPTS)\mglbase.exe $(BUILDS)\$(MGLBASE)
	@+runwise $(SCRIPTS)\mglfont.wse
	@+copy $(SCRIPTS)\mglfont.exe $(BUILDS)\$(MGLFONT)
	@+runwise $(SCRIPTS)\mglsrc.wse
	@+copy $(SCRIPTS)\mglsrc.exe $(BUILDS)\$(MGLSRC)
	@+runwise $(SCRIPTS)\mgldm.wse
	@+copy $(SCRIPTS)\mgldm.exe $(BUILDS)\$(MGLDEMO)
	@+runwise $(SCRIPTS)\ogldm.wse
	@+copy $(SCRIPTS)\ogldm.exe $(BUILDS)\$(OGLDEMO)
	@+runwise $(SCRIPTS)\mgldos-bc4.wse
	@+copy $(SCRIPTS)\mgldos-bc4.exe $(BUILDS)\$(MGLD_BC45)
	@+runwise $(SCRIPTS)\mgldos-dj2.wse
	@+copy $(SCRIPTS)\mgldos-dj2.exe $(BUILDS)\$(MGLD_DJ20)
	@+runwise $(SCRIPTS)\mgldos-wc10.wse
	@+copy $(SCRIPTS)\mgldos-wc10.exe $(BUILDS)\$(MGLD_WC10)
	@+runwise $(SCRIPTS)\mgldos-wc11.wse
	@+copy $(SCRIPTS)\mgldos-wc11.exe $(BUILDS)\$(MGLD_WC11)
	@+runwise $(SCRIPTS)\mglwin-bc4.wse
	@+copy $(SCRIPTS)\mglwin-bc4.exe $(BUILDS)\$(MGLW_BC45)
	@+runwise $(SCRIPTS)\mglwin-bc5.wse
	@+copy $(SCRIPTS)\mglwin-bc5.exe $(BUILDS)\$(MGLW_BC50)
	@+runwise $(SCRIPTS)\mglwin-vc4.wse
	@+copy $(SCRIPTS)\mglwin-vc4.exe $(BUILDS)\$(MGLW_VC42)
	@+runwise $(SCRIPTS)\mglwin-vc5.wse
	@+copy $(SCRIPTS)\mglwin-vc5.exe $(BUILDS)\$(MGLW_VC50)
	@+runwise $(SCRIPTS)\mglwin-dp2.wse
	@+copy $(SCRIPTS)\mglwin-dp2.exe $(BUILDS)\$(MGLW_DP20)
	@+runwise $(SCRIPTS)\mglwin-wc10.wse
	@+copy $(SCRIPTS)\mglwin-wc10.exe $(BUILDS)\$(MGLW_WC10)
	@+runwise $(SCRIPTS)\mglwin-wc11.wse
	@+copy $(SCRIPTS)\mglwin-wc11.exe $(BUILDS)\$(MGLW_WC11)
	@+echo done > targets\wise

.SWAP targets\buildinc:
	@+echo =============================================================================
	@+echo START: Incrementing build number
	@+cdit bldinc build bc45-d16 bldinc.exe -u OPT=1 $(BETA_FLAG)
	@-$(SOURCE)\bldinc\bldinc.exe
	@+echo done > targets\buildinc
