####
# makefile - Makefile for Microsoft Visual C++ Run-Time Libraries
#
#   Copyright (c) Microsoft Corporation. All rights reserved.
#
# Purpose:
#   This makefile builds the Visual C++ run-time release libraries.
#   Just type NMAKE in the \MSDEV\CRT\SRC directory to build all target
#   libraries. Set environment variable LLP64=1 if you want to build for
#   IA64, LLP64=2 if you want to build for X64, or LLP64=0 if you want to
#   build for x86 hosted on a 64-bit platform.
#
###############################################################################

# If your MSVC++ 9.0 installation is not in the default installation path
# of "\Program Files\Microsoft Visual Studio 9\VC" on the current drive,
# set the environment variable VCTOOLS to point to the main directory
# of your installation.  (For example, "set VCTOOLS=C:\VS.NET\VC9")

VCTOOLS=C:\Program Files\Microsoft Visual Studio 10.0\VC

#
# Directories, Tools and Misc Definitions:
#
###############################################################################

#
# Determine target CPU, defaulting to same as host CPU.
#
###############################################################################

HOST_CPU = i386
TARGET_CPU = i386

# Source directories:
#
# These are the directories in which to run NMAKE to update the source
# objects and libraries they provide.  Note that there are slight
# differences between the ST/MT models and the DLL model.
#
# In order to allow for auto source library calculation, each directory
# name must be preceded by a tilde (~) and followed by an asterisk (*).

MAKE_DIRS = .

MAKE_DIRS_MT = .

MAKE_DIRSP = .

# Source Objects: These are the objects and/or libraries which constitute
# the statically linked library flavors (LIBC.LIB and LIBCMT.LIB).

SOURCE_OBJS = \
 *\convert.lib \
 *\direct.lib \
 *\dos.lib \
 *\eh.lib \
 *\heap.lib \
 *\helper.lib \
 *\lowio.lib \
 *\crtplus.lib \
 *\misc.lib \
 *\rtc.lib \
 *\startup.lib \
 *\stdio.lib \
 *\string.lib \
 *\time.lib \
 *\conv.lib \
 *\tran.lib

CPPSRC_OBJS = *\stdcpp.lib

#
# Define names for the primary targets of this makefile.
#
###############################################################################

IFLAG=-i

RELEASEDIR=..\Lib
RELEASEDIR_DBG=..\Lib\Debug

#
# Tools:
#

LINKER=link -nologo
LINKLIB=link -lib -nologo
LINKIMPLIB=link -lib -nologo
BSCMAKE=bscmake -nologo

ADDITIONAL_LINK_OPT=

COMMON_DEFS=-D_CRTBLD -D_FN_WIDE -D_RTC
COMMON_DEFS=$(COMMON_DEFS) -D_HAS_EXCEPTIONS=0

# this version of the CRT targets Winxp and later
WINDOWS_H_DEFS=-DNOSERVICE

CC_OPTS_BASE=-c -nologo -Zlp8 -W3 -WX -GFy

CC_OPTS_BASE=$(CC_OPTS_BASE) -GS
AS_OPTS=-c -nologo -coff -Cx -Zm -DQUIET -D?QUIET -Di386 -D_WIN32 -DWIN32

CC_OPTS_BASE=$(CC_OPTS_BASE) -Zc:wchar_t

CC_OPTS=$(CC_OPTS_BASE) $(WINDOWS_H_DEFS)


LINKER=$(LINKER) -NXCOMPAT -DYNAMICBASE
LINKLIB=$(LINKLIB)
LINKIMPLIB=$(LINKIMPLIB)

MT_DEFINES=$(COMMON_DEFS) -D_MT

PDBDIR_PREFIX          =  #

RELEASE_LIBCMT          = $(RELEASEDIR)\libcmt.lib
RELEASE_LIBCPPMT        = $(RELEASEDIR)\libcpmt.lib

RELEASE_LIBCMT_PDB      = $(RELEASEDIR)\libcmt.pdb
RELEASE_LIBCPPMT_PDB    = $(RELEASEDIR)\libcpmt.pdb

RELEASE_LIBCMT_DBG      = $(RELEASEDIR_DBG)\libcmtd.lib
RELEASE_LIBCPPMT_DBG    = $(RELEASEDIR_DBG)\libcpmtd.lib

RELEASE_LIBCMT_DBG_PDB  = $(RELEASEDIR_DBG)\libcmtd.pdb
RELEASE_LIBCPPMT_DBG_PDB 	= $(RELEASEDIR_DBG)\libcpmtd.pdb


FD_REL_MT=-Fd$(PDBDIR_PREFIX)$(RELEASE_LIBCMT_PDB)
FD_REL_MTP=-Fd$(PDBDIR_PREFIX)$(RELEASE_LIBCPPMT_PDB)
FD_REL_MT_DBG=-Fd$(PDBDIR_PREFIX)$(RELEASE_LIBCMT_DBG_PDB)
FD_REL_MTP_DBG=-Fd$(PDBDIR_PREFIX)$(RELEASE_LIBCPPMT_DBG_PDB)

#
# Locate the scratch location for object files of various flavors.
#
###############################################################################

OBJDIR_MT  = Release
OBJDIR_MTP  = Release\P

OBJDIR_MT_DBG  = Debug
OBJDIR_MTP_DBG  = Debug\P

all : mt xmt

####
#
# Directory Targets
#
####

$(OBJDIR_MT) \
$(OBJDIR_MTP) \
$(OBJDIR_MT_DBG) \
$(OBJDIR_MTP_DBG) \
$(RELEASEDIR) \
$(RELEASEDIR_DBG) :
    if not exist $@\* mkdir $@

####
#
# Define the path to return to the main directory where nmake is revoked
#
####

CD_ROOT=.


####
#
# Pseudo-target user interface:
#
####

mt_env :
    !@-echo. \
    & echo # *** These are the compiler switches for the MT model (LIBCMT.LIB): \
    & echo # \
    & echo # CL = $(CC_OPTS_BASE) \ \
    & echo # $(WINDOWS_H_DEFS) $(FD_REL_MT) \ \
    & echo # $(MT_DEFINES) \
    & echo # \
    & echo # ML = $(AS_OPTS) \ \
    & echo # $(MT_DEFINES) \
    & echo.

mtp_env :
    !@-echo. \
    & echo # *** These are the compiler switches for the MT model (LIBCPMT.LIB): \
    & echo # \
    & echo # CL = $(CC_OPTS_BASE) \ \
    & echo # $(WINDOWS_H_DEFS) $(FD_REL_MTP) \ \
    & echo # $(MT_DEFINES) \
    & echo # \
    & echo # ML = $(AS_OPTS) \ \
    & echo # $(MT_DEFINES) \
    & echo.

mt : $(OBJDIR_MT) $(OBJDIR_MTP) $(RELEASEDIR) \
	mt_env mt_ mtp_env mt_p

mt_ :: $(MAKE_DIRS_MT)
    !@-cd $** \
    & set CL=$(CC_OPTS) $(MT_DEFINES) $(FD_REL_MT) \
    & set ML=$(AS_OPTS) $(MT_DEFINES) \
    & $(MAKE) -nologo $(IFLAG) -f makefile.sub DIR=$** \
        OBJDIR=$(OBJDIR_MT) \
        TARGET_CPU=$(TARGET_CPU) HOST_CPU=$(HOST_CPU) \
		BLD_CPP="NO" \
    & cd $(CD_ROOT)

mt_p :: $(MAKE_DIRSP)
    !@-cd $** \
    & set CL=$(CC_OPTS) $(MT_DEFINES) $(FD_REL_MTP) \
    & set ML=$(AS_OPTS) $(MT_DEFINES) \
    & $(MAKE) -nologo $(IFLAG) -f makefile.sub DIR=$** \
        OBJDIR=$(OBJDIR_MTP) \
        TARGET_CPU=$(TARGET_CPU) HOST_CPU=$(HOST_CPU) \
		BLD_CPP="YES" \
    & cd $(CD_ROOT)

mt_ :: $(RELEASE_LIBCMT)

mt_p :: $(RELEASE_LIBCPPMT)

xmt_env :
    !@-echo. \
    & echo # *** These are the compiler switches for the XMT model (LIBCMTD.LIB): \
    & echo # \
    & echo # CL = $(CC_OPTS_BASE) \ \
    & echo # $(WINDOWS_H_DEFS) $(FD_REL_MT_DBG) \ \
    & echo # $(MT_DEFINES) \
    & echo # \
    & echo # ML = $(AS_OPTS) \ \
    & echo # $(MT_DEFINES) \
    & echo.

xmtp_env :
    !@-echo. \
    & echo # *** These are the compiler switches for the XMT model (LIBCPMTD.LIB): \
    & echo # \
    & echo # CL = $(CC_OPTS_BASE) \ \
    & echo # $(WINDOWS_H_DEFS) $(FD_REL_MTP_DBG) \ \
    & echo # $(MT_DEFINES) \
    & echo # \
    & echo # ML = $(AS_OPTS) \ \
    & echo # $(MT_DEFINES) \
    & echo.

xmt : $(OBJDIR_MT_DBG) $(OBJDIR_MTP_DBG) $(RELEASEDIR_DBG) \
	xmt_env xmt_ xmtp_env xmt_p

xmt_ :: $(MAKE_DIRS)
    !@-cd $** \
    & set CL=$(CC_OPTS) $(MT_DEFINES) $(FD_REL_MT_DBG) \
    & set ML=$(AS_OPTS) $(MT_DEFINES) \
    & $(MAKE) -nologo $(IFLAG) -f makefile.sub DIR=$** \
        BLD_DBG=1 OBJDIR=$(OBJDIR_MT_DBG) \
        TARGET_CPU=$(TARGET_CPU) HOST_CPU=$(HOST_CPU) \
		BLD_CPP="NO" \
    & cd $(CD_ROOT)

xmt_p :: $(MAKE_DIRSP)
    !@-cd $** \
    & set CL=$(CC_OPTS) $(MT_DEFINES) $(FD_REL_MTP_DBG) \
    & set ML=$(AS_OPTS) $(MT_DEFINES) \
    & $(MAKE) -nologo $(IFLAG) -f makefile.sub DIR=$** \
        BLD_DBG=1 OBJDIR=$(OBJDIR_MTP_DBG) \
        TARGET_CPU=$(TARGET_CPU) HOST_CPU=$(HOST_CPU) \
		BLD_CPP="YES" \
    & cd $(CD_ROOT)

xmt_ :: $(RELEASE_LIBCMT_DBG)

xmt_p :: $(RELEASE_LIBCPPMT_DBG)

#
# Make Process for Static Libraries
#
###############################################################################

$(RELEASE_LIBCMT): $(RELEASEDIR) $(SOURCE_OBJS:*=Release) \
 $(OBJDIR_MT)\link.rsp
	$(LINKLIB) $(ADDITIONAL_LINK_OPT) -out:$@ @$(OBJDIR_MT)\link.rsp

$(RELEASE_LIBCPPMT): $(RELEASEDIR) $(CPPSRC_OBJS:*=Release\P) \
 $(OBJDIR_MTP)\linkcpp.rsp
	$(LINKLIB) -out:$@ @$(OBJDIR_MTP)\linkcpp.rsp

$(OBJDIR_MT)\link.rsp: makefile
	@echo *** Creating linker response file <<$@
$(SOURCE_OBJS:*=Release)
<<keep

$(OBJDIR_MTP)\linkcpp.rsp: makefile
	@echo *** Creating linker response file <<$@
$(CPPSRC_OBJS:*=Release\P)
<<keep

$(RELEASE_LIBCMT_DBG): $(RELEASEDIR_DBG) $(SOURCE_OBJS:*=Debug) \
 $(OBJDIR_MT_DBG)\link.rsp
	$(LINKLIB) $(ADDITIONAL_LINK_OPT) -out:$@ @$(OBJDIR_MT_DBG)\link.rsp

$(RELEASE_LIBCPPMT_DBG): $(RELEASEDIR_DBG) $(CPPSRC_OBJS:*=Debug\P) \
 $(OBJDIR_MTP_DBG)\linkcpp.rsp
	$(LINKLIB) -out:$@ @$(OBJDIR_MTP_DBG)\linkcpp.rsp

$(OBJDIR_MT_DBG)\link.rsp: makefile
	@echo *** Creating linker response file <<$@
$(SOURCE_OBJS:*=Debug)
<<keep

$(OBJDIR_MTP_DBG)\linkcpp.rsp: makefile
	@echo *** Creating linker response file <<$@
$(CPPSRC_OBJS:*=Debug\P)
<<keep

#<eof>
