Automated Builds
by Aspi Havewala


Listing One
#############################################################################
# \DevRoot\Build\Include\Paths.mk
# Include Makefile for automated build process.
# Defines directory paths for stock directories used for the build.
# (c) Aspi Havewala 1998
#############################################################################

!ifndef PATH_HOME
!error Please define a variable called PATH_HOME. The directory
        specified by this variable will be hold your intermediate files.
!endif

_T_PATH_TEMP = $(PATH_HOME)\Temp
_T_PATH_RELEASE = $(PATH_DEVROOT)\Release
!if "$(DEBUG)"=="1"
PATH_TEMP = $(_T_PATH_TEMP)\Debug
PATH_RELEASE = $(_T_PATH_RELEASE)\Debug
!else
PATH_TEMP = $(_T_PATH_TEMP)\Retail
PATH_RELEASE = $(_T_PATH_RELEASE)\Retail
!endif

Listing Two
#############################################################################
# \DevRoot\Build\Include\Shell.mk
# Include Makefile for automated build process.
# Defines shell commands used in the build process.
# (c) Aspi Havewala 1998
##############################################################################

!if "$(VERBOSE)"!="1"
CMDECHO = @
!endif

DISPLAY = $(CMDECHO)echo
IFF = $(CMDECHO)if
COPY = $(CMDECHO)xcopy /S /E
DELETE = $(CMDECHO)del /q
DELTREE = $(CMDECHO)rmdir /S /Q
MAKEDIR = $(CMDECHO)mkdir
CC = $(CMDECHO)cl /nologo
LINK = $(CMDECHO)link /nologo
BROWSERBUILDER = $(CMDECHO)bscmake /nologo

Listing Three
#############################################################################
# \DevRoot\Build\Include\Options.mk
# Include Makefile for automated build process.
# Defines options that modify the build process.
# (c) Aspi Havewala 1998
#############################################################################

# Specify compiler options
# Compile only - /c
# Name temporary file - /Fo
CFLAGS = /c /Fo$*.obj

# If browser option off
#   Name browser file - /Fr
!if "$(NOBROWSE)"!="1"
CFLAGS = $(CFLAGS) /Fr$*.sbr
!endif

# If debug build,
#   Turn off optimizations - /Od
#   Generate debug info - /Zi
# else
#   Enable global optimization - /Og
!if "$(DEBUG)"=="1"
CFLAGS = $(CFLAGS) /Od /Zi
!else
CFLAGS = $(CFLAGS) /Og
!endif

# Define a generic line for compiling a source file
COMPILEME = $(CC) $(CFLAGS) $**

# Specify linker options
# Name output file - /OUT:
LFLAGS = /OUT:$@ /LIBPATH:"$(MSDEVDIR)"\..\Vc\Lib /PDB:$*.pdb /MAP:$*.map

!if "$(DEBUG)"=="1"
LFLAGS = $(LFLAGS) /DEBUG
!else
!endif

# Define a generic line for linking
LINKME = $(LINK) $(LFLAGS) $**

# Define a generic line for building a browser database
!if "$(NOBROWSE)"!="1"
BUILDBROWSERDB = $(BROWSERBUILDER) /o $*.bsc $(PATH_TEMP)\*.sbr
!endif

Listing Four 
##############################################################################
# \DevRoot\Build\Include\Targets.mk
# Include Makefile for automated build process.
# Defines rules for stock targets for the build process.
# (c) Aspi Havewala 1998
##############################################################################

# Rules for building temporary and release directories.
Setup: $(PATH_RELEASE) $(PATH_TEMP)

$(PATH_RELEASE): $(_T_PATH_RELEASE)
    $(IFF) not exist $@ $(MAKEDIR) $@
$(_T_PATH_RELEASE):
    $(IFF) not exist $@ $(MAKEDIR) $@
$(PATH_TEMP): $(_T_PATH_TEMP)
    $(IFF) not exist $@ $(MAKEDIR) $@
$(_T_PATH_TEMP):
    $(IFF) not exist $@ $(MAKEDIR) $@
# Rule to clean up temporary files.
Clean::
    $(IFF) exist $(PATH_TEMP) $(DELTREE) $(PATH_TEMP)
Usage::
    $(DISPLAY) "nmake [Targets] [Options]                                   "
    $(DISPLAY) "Targets                                                     "
    $(DISPLAY) "    All: Builds all targets                                 "
    $(DISPLAY) "    Clean: Cleans all output files                          "
    $(DISPLAY) "    Usage: Displays this message                            "
    $(DISPLAY) "Options                                                     "
    $(DISPLAY) "    VERBOSE = 0/1: Displays trace for build process         "
    $(DISPLAY) "    NOBROWSE = 1/0: Disables building of browser database   "
    $(DISPLAY) "    DEBUG = 0/1: Builds for retail or debug                 "

Listing Five 
##############################################################################
# \DevRoot\Build\Include\Vc.mk
# Include Makefile for version control integration.
# Defines variables for version control command line and flags
# (c) Aspi Havewala 1998
##############################################################################

# Version Control command line to refresh all source.
VC_CMD = -"$(MSDEVDIR)\..\Vss\Win32\Ss.exe" Get $$/

# Version control flags. Note that this requires a special user called
# Builder to be created by the Version Control administrator.
VC_FLAGS =-I-Y -R -YBuilder -GTU

# If clean refresh, specify additional flags.
!if "$(CLEAN)"=="1"
VC_FLAGS = $(VC_FLAGS) -GWR
!endif

Listing Six
##############################################################################
# \DevRoot\AlarmClock\Makefile
# Master Makefile for automated build process.
# (c) Aspi Havewala 1998
##############################################################################
# Define a path for the development root
!ifndef PATH_DEVROOT
PATH_DEVROOT = \Aspi's~1\Articles\Versio~1\DevRoot
!endif
PATH_BUILD_INCLUDE = $(PATH_DEVROOT)\Build\Include

# Set up home directory in predefined variable
PATH_HOME = $(PATH_DEVROOT)\AlarmClock

!include <$(PATH_BUILD_INCLUDE)\Paths.mk>
!include <$(PATH_BUILD_INCLUDE)\Shell.mk>
!include <$(PATH_BUILD_INCLUDE)\Options.mk>
!include <$(PATH_BUILD_INCLUDE)\Vc.mk>

# Specify additional compiler flags
# Optimize for Windows application - /GA
# Add new directories to include path = /I
CFLAGS = $(CFLAGS) /GA /I$(PATH_HOME)\Common\Include

# Specify additional linker flags
# LFLAGS = $(LFLAGS) ...

All: Setup $(PATH_RELEASE)\AlarmClock.exe

# Rule for final executable.
$(PATH_RELEASE)\AlarmClock.exe: \
                $(PATH_TEMP)\Timer.obj \
                $(PATH_TEMP)\Date.obj \
                $(PATH_TEMP)\Time.obj \
                $(PATH_TEMP)\SetDate.obj \
                $(PATH_TEMP)\SetTime.obj \
                $(PATH_TEMP)\Sound.obj
    $(LINKME)
    $(BUILDBROWSERDB)
# Rules for compiling individual source files.
$(PATH_TEMP)\Timer.obj: Alarm\Timer.cpp
    $(COMPILEME)
$(PATH_TEMP)\Date.obj: DateTime\Date.cpp
    $(COMPILEME)
$(PATH_TEMP)\Time.obj: DateTime\Time.cpp
    $(COMPILEME)
$(PATH_TEMP)\SetDate.obj: UserInterface\SetDate.cpp
    $(COMPILEME)
$(PATH_TEMP)\SetTime.obj: UserInterface\SetTime.cpp
    $(COMPILEME)
$(PATH_TEMP)\Sound.obj: UserInterface\Sound.cpp
    $(COMPILEME)
# Clean up all output files.
Clean::
    $(IFF) exist $(PATH_RELEASE)\AlarmClock.exe $(DELETE) 
                                            $(PATH_RELEASE)\AlarmClock.exe
# Get latest copy of source code from version control.
Refresh:
    $(CHANGEDIR) $(PATH_DEVROOT)
    $(VC_CMD) $(VC_FLAGS)
!include <$(PATH_BUILD_INCLUDE)\Targets.mk>



4


