Useful Build Macros


Here some useful macros for use in the sources file for building modules using the WDK command line build environment

DDK_TARGET_OS determines if the module is being built for a particular version of Windows

!if defined(DDK_TARGET_OS) && ( "$(DDK_TARGET_OS)"=="WinXP" )
    TARGETLIBS=lib\x86\FileExtD.lib
!endif

_BUILDARCH determines if module is being built for a particular CPU architecture

!if "$(_BUILDARCH)"=="AMD64"
    USER_C_FLAGS= $(USER_C_FLAGS) /homeparams
!endif

DDKBUILDENV determines if the checked or free version of the module is being built

!if "$(DDKBUILDENV)"=="chk"
    C_DEFINES= $(C_DEFINES) -D_MYDEBUG
!endif

To link to libraries that match the current build environment, but reside in other build output directories, use the $(O) macro. In the following example the $(O) macro expands to "\objchk_win7_amd64\amd64" or "\objchk_win7_x86\i386" depending on whether the Windows 64-bit or 32-bit Checked build environment is being used.

TARGETLIBS=..\library\$(O)\mylib.lib

Display a message in the build console Window

!message "Building for Legacy OS"