####
# makefile.sub - Subdirectory-specific makefile for new VCRT build process
#
#   Copyright (c) 1993-1997, Microsoft Corporation. All rights reserved.
#
# Purpose:
#   This makefile builds the C++ runtimes for Multi-thread, Single-Thread
#   and DLL.
#
#   This is a general-purpose makefile.  It is !INCLUDEd by the makefile
#   in each subdirectory (hence the .SUB extension).  All subdirectory-
#   specific make information should be embedded in the SOURCES file in
#   that subdirectory, not in this file.
#
#   Change to the appropriate subdirectory and type NMAKE DEPEND to
#   rebuild the dependencies.  These are stored in DEPEND.DEF in each
#   subdirectory.
#
###############################################################################

# Change this to BLD_ASM=1 if you have MASM 6.11a or later and wish
# to re-build the assembler sources provided in this release.

BLD_ASM=0

#
# Macro definitions:
#
###############################################################################

#
# Add .S suffix for assembler files on platforms other than x86
#

.SUFFIXES: .s

#
!if "$(BLD_DBG)" == "1"
!if "$(PRE_BLD)" == "1"
CFLAGS=-D_DEBUG -Od
!else
CFLAGS=-Zi -D_DEBUG -Od
!endif
!if "$(TARGET_CPU)"!="PPC"
!if "$(PRE_BLD)" == "1"
AFLAGS=-D_DEBUG
!else
AFLAGS=-Zi -D_DEBUG
!endif
!endif
!else
CFLAGS=-O1
AFLAGS=
!endif

# Tool definitions:

CC=cl
LIB=link -lib -nologo
!if "$(TARGET_CPU)"=="i386" || "$(TARGET_CPU)"=="PMAC"
AS=ml
!elseif "$(TARGET_CPU)"=="ALPHA"
AS=asaxp -Ialpha
!elseif "$(TARGET_CPU)"=="PPC"
AS=pas
!else
AS=cl
!endif

#
# Source file definitions:
#
###############################################################################

A_INCLUDES=-I.
C_INCLUDES=-I.
!if	"$(TARGET_CPU)"=="PMAC"
!if "$(POST_BLD)"=="1"
C_INCLUDES=-I./mppc $(C_INCLUDES)
!else
C_INCLUDES=-I./mac $(C_INCLUDES)
!endif
!endif

#
# Inference rules:
#
# (Due to the kind of dependencies used below, we must explicitly define
# inference rules to effect construction of the object files.)
#
###############################################################################

!if	"$(TARGET_CPU)"=="PMAC"
CFLAGS=$(CFLAGS) -Zp2 -DB_END
!endif
CXXFLAGS=$(CFLAGS) -GR -GX -d1Binl
!if "$(UNWINDTAB)"=="1"
!if	"$(TARGET_CPU)"=="PMAC" && "$(DIR)"=="eh"
CXXFLAGS=$(CXXFLAGS) -d2unwindtab
!endif
!endif

!if "$(POST_BLD)"!="1"
CXXFLAGS=$(CXXFLAGS) -Istdhpp
!endif


#
# Rules for end-user source build
#
#
# LSOURCES will override A_INCLUDES and C_INCLUDES for conv/ and tran/ subdirs.
#
###############################################################################

!if "$(POST_BLD)"=="1"
!INCLUDE makefile.inc
!else
!INCLUDE lsources.
!endif

!if "$(TARGET_CPU)"!="PMAC"

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

!if "$(TARGET_CPU)"=="ALPHA"

{alpha}.c{$(OBJDIR)}.obj:
    $(CC) $(CFLAGS) $(C_INCLUDES) -Fo$(OBJDIR)\ $<

!elseif "$(TARGET_CPU)"=="i386"

{intel}.c{$(OBJDIR)}.obj:
    $(CC) $(CFLAGS) $(C_INCLUDES) -Fo$(OBJDIR)\ $<

!elseif "$(TARGET_CPU)"=="mips"

{mips}.c{$(OBJDIR)}.obj:
    $(CC) $(CFLAGS) $(C_INCLUDES) -Fo$(OBJDIR)\ $<

!elseif "$(TARGET_CPU)"=="PPC"

{ppc}.c{$(OBJDIR)}.obj:
    $(CC) $(CFLAGS) $(C_INCLUDES) -Fo$(OBJDIR)\ $<

!endif

.cpp{$(OBJDIR)}.obj:
    $(CC) $(CXXFLAGS) $(C_INCLUDES) -Fo$(OBJDIR)\ $<

!if "$(TARGET_CPU)"=="ALPHA"

{alpha}.cpp{$(OBJDIR)}.obj:
    $(CC) $(CXXFLAGS) $(C_INCLUDES) -Fo$(OBJDIR)\ $<

{alpha}.s{$(OBJDIR)}.obj:
    $(AS) $(AFLAGS) $(A_INCLUDES) -Fo $@ $<

!elseif "$(TARGET_CPU)"=="i386"

{intel}.cpp{$(OBJDIR)}.obj:
    $(CC) $(CXXFLAGS) $(C_INCLUDES) -Fo$(OBJDIR)\ $<

!IF $(BLD_ASM)==1

{intel}.asm{$(OBJDIR)}.obj:
    $(AS) $(AFLAGS) $(A_INCLUDES) -Fo$(OBJDIR)\ $<

!ENDIF

!elseif "$(TARGET_CPU)"=="mips"

{mips}.cpp{$(OBJDIR)}.obj:
    $(CC) $(CXXFLAGS) $(C_INCLUDES) -Fo$(OBJDIR)\ $<

{mips}.s{$(OBJDIR)}.obj:
    $(CC) $(CFLAGS) /QMmips3 $(C_INCLUDES) -Fo$(OBJDIR)\ $<

!elseif "$(TARGET_CPU)"=="PPC"

{ppc}.cpp{$(OBJDIR)}.obj:
    $(CC) $(CXXFLAGS) $(C_INCLUDES) -Fo$(OBJDIR)\ $<

{ppc}.s{$(OBJDIR)}.obj:
    $(CC) -E $(CFLAGS) $(A_INCLUDES) $< > $(OBJDIR)\$(<F)
    $(AS) $(AFLAGS) -o $@ $(OBJDIR)\$(<F)
    del $(OBJDIR)\$(<F)

!endif

!else
!if "$(POST_BLD)"=="1"

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

{mppc}.c{$(OBJDIR)}.obj:
    $(CC) $(CFLAGS) $(C_INCLUDES) -Fo$(OBJDIR)\ $<

.cpp{$(OBJDIR)}.obj:
    $(CC) $(CXXFLAGS) $(C_INCLUDES) -Fo$(OBJDIR)\ $<

{mppc}.cpp{$(OBJDIR)}.obj:
    $(CC) $(CXXFLAGS) $(C_INCLUDES) -Fo$(OBJDIR)\ $<

{mppc}.asm{$(OBJDIR)}.obj:
    $(AS) $(AFLAGS) $(A_INCLUDES) -Fo$(OBJDIR)\ $<

!else
SRCDIR =.
CFILES = $<
CXXFILES = $<
AFILES = $<

SRCPATH = {$(SRCDIR)\$(SRCOS)\$(TARGET_CPU);$(SRCDIR)\$(SRCOS);$(SRCDIR)}

# source dir

{$(SRCDIR)}.cpp{$(OBJDIR)}.obj:
	$(CC) $(CXXFLAGS) $(C_INCLUDES) -Fo$(OBJDIR)\ $(CXXFILES)

{$(SRCDIR)}.c{$(OBJDIR)}.obj:
	$(CC) $(CFLAGS) $(C_INCLUDES) -Fo$(OBJDIR)\ $(CFILES)

# os

{$(SRCDIR)\$(OS)}.cpp{$(OBJDIR)}.obj:
	$(CC) $(CXXFLAGS) $(C_INCLUDES) -Fo$(OBJDIR)\ $(CXXFILES)

{$(SRCDIR)\$(OS)}.c{$(OBJDIR)}.obj:
	$(CC) $(CFLAGS) $(C_INCLUDES) -Fo$(OBJDIR)\ $(CFILES)

# os\cpu

{$(SRCDIR)\$(OS)\$(TARGET_CPU)}.cpp{$(OBJDIR)}.obj:
	$(CC) $(CXXFLAGS) $(C_INCLUDES) -Fo$(OBJDIR)\ $(CXXFILES)

{$(SRCDIR)\$(OS)\$(TARGET_CPU)}.c{$(OBJDIR)}.obj:
	$(CC) $(CFLAGS) $(C_INCLUDES) -Fo$(OBJDIR)\ $(CFILES)

{$(SRCDIR)\$(OS)\$(TARGET_CPU)}.asm{$(OBJDIR)}.obj:
	$(AS) $(AFLAGS) -Fo$(OBJDIR)\ $(AFILES)

{$(SRCDIR)\$(OS)\$(TARGET_CPU)}.a{$(OBJDIR)}.obj:
	$(CPP) $(CPPFLAGS) $(CPPFILES)
	$(AAS) $(AAFLAGS) -Fo$(OBJDIR)\ $(AAFILES)
	-del $(AAFILES) 2>nul
!endif
!endif

#
# Dependencies:
#
# NOTE: The inference rules cause the targets to actually be built; no
# commands are necessary below.
#
###############################################################################

$(OBJDIR)\$(CURDIR).lib: $(OBJS) $(OBJS_NOT_IN_LIB) $(OBJDIR)\$(CURDIR).rsp
!if "$(BLD_MODEL)"=="zdll" && "$(TARGET_CPU)"=="i386"
    sed -f %CRT_BUILDDIR%\crt\prebuild\tools\win32\newline.sed $(OBJDIR)\$(CURDIR).rsp | sed -f %CRT_BUILDDIR%\crt\prebuild\tools\win32\delblank.sed >> temp.lst
    for /F %i in (temp.lst) do %CRT_BUILDDIR%\crt\prebuild\libw32\tools\intel\whackline %i
    del temp.lst
!endif
    $(LIB) -out:$@ @$(OBJDIR)\$(CURDIR).rsp


$(OBJDIR)\$(CURDIR).rsp: lsources
    @echo Creating response file: <<$(OBJDIR)\$(CURDIR).rsp
$(OBJS)
<<keep


!IF EXIST(special.mak)
!    INCLUDE special.mak    # Include special makefile additions, if any
!ENDIF

!IF EXIST(depend.def)
!    INCLUDE depend.def     # Include dependencies on .h files
!ENDIF

#<eof>
