# Here is where we check for all the nonsense that people put in sources files that
# shouldn't be done that way.
#
# Errors we check for and what they mean.
#
# BLD1000 - LINKLIB abuse
# BLD1001 - vccomsup.lib listed explicitly - should be USE_VCCOM=1
# BLD1002 - IOSTREAM lib listed explicitly - should be USE_IOSTREAM=1
# BLD1003 - STL lib listed explicitly - should be USE_STL=1
# BLD1004 - MSVCRT lib listed explicitly - should be USE_MSVCRT=1
# BLD1005 - LIBCMT lib listed explicitly - should be USE_LIBCMT=1
# BLD1006 - LIBC lib listed explicitly
# BLD1007 - BROWSER_INFO defined in sources file (this is a user environment setting)
# BLD1008 - SXS_ASSEMBLY_VERSION contains invalid characters
# BLD1009 - SXS_ASSEMBLY_NAME contains invalid characters
# BLD1010 - ASSERT(SXS_ASSEMBLY_LANGUAGE xor SXS_ASSEMBLY_LANGUAGE_INDEPENDENT)
# BLD1011 - SXS..
# BLD1012 - SXS..
# BLD1013 - SXS..
# BLD1014 - SXS..
# BLD1015 - SXS..
#

!if "$(TARGETTYPE)" == "DYNLINK"
! if "$(LINKLIBS)" != "$(LINKLIBS:kernel32=)"
!message "BUILDMSG: warning BLD1000 : LINKLIB abuse (kernel32 used by mistake) ($(MAKEDIR))"
! endif

! if "$(LINKLIBS)" != "$(LINKLIBS:advapi32=)"
!message "BUILDMSG: warning BLD1000 : LINKLIB abuse (advapi32 used by mistake) ($(MAKEDIR))"
! endif

! if "$(LINKLIBS)" != "$(LINKLIBS:ole32=)"
!message "BUILDMSG: warning BLD1000 : LINKLIB abuse (ole32 used by mistake) ($(MAKEDIR))"
! endif
!endif

!if "$(TARGETLIBS)" != "$(TARGETLIBS:vccomsup=)"
!message "BUILDMSG: warning BLD1001 : vccomsup.lib listed explicitly - use USE_VCCOM=1 ($(MAKEDIR))"
!endif

!if "$(TARGETLIBS)" != "$(TARGETLIBS:msvcirt=)" || \
    "$(TARGETLIBS)" != "$(TARGETLIBS:libcimt=)" || \
    "$(TARGETLIBS)" != "$(TARGETLIBS:libci=)"
!message "BUILDMSG: warning BLD1002 : IOSTREAM lib listed explicitly - use USE_IOSTREAM=1 ($(MAKEDIR))"
!endif

!if "$(TARGETLIBS)" != "$(TARGETLIBS:msvcprt=)" || \
    "$(TARGETLIBS)" != "$(TARGETLIBS:libcpmt=)" || \
    "$(TARGETLIBS)" != "$(TARGETLIBS:libcp=)"
!message "BUILDMSG: warning BLD1003 : STL lib listed explicitly - use USE_STL=1 ($(MAKEDIR))"
!endif

!if "$(TARGETLIBS)" != "$(TARGETLIBS:msvcrt=)"
!message "BUILDMSG: warning BLD1004 : MSVCRT lib listed explicitly - use USE_MSVCRT=1 ($(MAKEDIR))"
!endif

!if "$(TARGETLIBS)" != "$(TARGETLIBS:libcmt=)"
!message "BUILDMSG: warning BLD1005 : LIBCMT lib listed explicitly - use USE_LIBCMT=1 ($(MAKEDIR))"
!endif

!if "$(TARGETLIBS)" != "$(TARGETLIBS:libc.lib=)"
!message "BUILDMSG: warning BLD1006 : LIBC lib listed explicitly ($(MAKEDIR))"
!endif

!if defined(BROWSER_INFO) && !defined(USER_ENV_BROWSER_INFO)
!message BUILDMSG: warning BLD1007 : BROWSER_INFO defined in sources file - this is a user environment setting ($(MAKEDIR))
!endif

!if "$(SXS_ASSEMBLY_NAME)" != ""
!if defined(SXS_ASSEMBLY_VERSION)
#
# SXS_ASSEMBLY_VERSION may only [0-9.].
# Removing them should leave nothing.
#
SXS_CHECK_ASSEMBLY_VERSION_CHARACTERS=$(SXS_ASSEMBLY_VERSION)
SXS_CHECK_ASSEMBLY_VERSION_CHARACTERS=$(SXS_CHECK_ASSEMBLY_VERSION_CHARACTERS:.=)
SXS_CHECK_ASSEMBLY_VERSION_CHARACTERS=$(SXS_CHECK_ASSEMBLY_VERSION_CHARACTERS:0=)
SXS_CHECK_ASSEMBLY_VERSION_CHARACTERS=$(SXS_CHECK_ASSEMBLY_VERSION_CHARACTERS:1=)
SXS_CHECK_ASSEMBLY_VERSION_CHARACTERS=$(SXS_CHECK_ASSEMBLY_VERSION_CHARACTERS:2=)
SXS_CHECK_ASSEMBLY_VERSION_CHARACTERS=$(SXS_CHECK_ASSEMBLY_VERSION_CHARACTERS:3=)
SXS_CHECK_ASSEMBLY_VERSION_CHARACTERS=$(SXS_CHECK_ASSEMBLY_VERSION_CHARACTERS:4=)
SXS_CHECK_ASSEMBLY_VERSION_CHARACTERS=$(SXS_CHECK_ASSEMBLY_VERSION_CHARACTERS:5=)
SXS_CHECK_ASSEMBLY_VERSION_CHARACTERS=$(SXS_CHECK_ASSEMBLY_VERSION_CHARACTERS:6=)
SXS_CHECK_ASSEMBLY_VERSION_CHARACTERS=$(SXS_CHECK_ASSEMBLY_VERSION_CHARACTERS:7=)
SXS_CHECK_ASSEMBLY_VERSION_CHARACTERS=$(SXS_CHECK_ASSEMBLY_VERSION_CHARACTERS:8=)
SXS_CHECK_ASSEMBLY_VERSION_CHARACTERS=$(SXS_CHECK_ASSEMBLY_VERSION_CHARACTERS:9=)
!if "$(SXS_CHECK_ASSEMBLY_VERSION_CHARACTERS)" != ""
!message BUILDMSG: warning BLD1008 : SXS_ASSEMBLY_VERSION ($(SXS_ASSEMBLY_VERSION)) may only contain [0-9.].
!endif
!endif

!if defined(SXS_ASSEMBLY_NAME)
#
# SXS_ASSEMBLY_NAME may only contain [A-Za-z0-9.-].
# Removing them should leave nothing.
#
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_ASSEMBLY_NAME)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:.=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:-=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:0=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:1=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:2=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:3=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:4=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:5=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:6=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:7=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:8=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:9=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:a=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:b=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:c=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:d=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:e=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:f=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:g=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:h=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:i=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:j=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:k=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:l=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:m=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:n=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:o=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:p=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:q=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:r=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:s=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:t=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:u=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:v=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:w=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:x=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:y=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:z=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:A=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:B=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:C=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:D=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:E=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:F=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:G=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:H=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:I=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:J=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:K=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:L=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:M=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:N=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:O=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:P=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:Q=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:R=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:S=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:T=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:U=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:V=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:W=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:X=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:Y=)
SXS_CHECK_ASSEMBLY_NAME_CHARACTERS=$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS:Z=)
!if "$(SXS_CHECK_ASSEMBLY_NAME_CHARACTERS)" != ""
!message BUILDMSG: warning BLD1009 : SXS_ASSEMBLY_NAME ($(SXS_ASSEMBLY_NAME)) may only contain [A-Za-z0-9.-].
!endif
!endif

# SXS_SHORT_ASSEMBLY_NAME may only contains A-Za-z0-9
# SXS_SHORT_ASSEMBLY_NAME may only contain 8 character elements

#
# ASSERT(SXS_ASSEMBLY_LANGUAGE xor SXS_ASSEMBLY_LANGUAGE_INDEPENDENT)
#
!if    (!defined(SXS_ASSEMBLY_LANGUAGE) && !defined(SXS_ASSEMBLY_LANGUAGE_INDEPENDENT)) \
    || ( defined(SXS_ASSEMBLY_LANGUAGE) &&  defined(SXS_ASSEMBLY_LANGUAGE_INDEPENDENT))
!message BUILDMSG: warning BLD1010 : Must specify SXS_ASSEMBLY_LANGUAGE or SXS_ASSEMBLY_LANGUAGE_INDEPENDENT, not both.
!endif

!if defined(SXS_MANIFEST_IN_RESOURCES) && !defined(SXS_MANIFEST)
!message BUILDMSG: warning BLD1011 : You must specify SXS_MANIFEST if you specify SXS_MANIFEST_IN_RESOURCES.
!endif

!if defined(SXS_ASSEMBLY_VERSION) && !defined(SXS_ASSEMBLY_NAME)
!message BUILDMSG: warning BLD1012 : You may not specify SXS_ASSEMBLY_VERSION without SXS_ASSEMBLY_NAME or SXS_SHORT_ASSEMBLY_NAME.
!endif

!if (defined(SXS_ASSEMBLY_LANGUAGE) || defined(SXS_ASSEMBLY_LANGUAGE_INDEPENDENT)) && !defined(SXS_ASSEMBLY_NAME)
!message BUILDMSG: warning BLD1013 : You may not specify SXS_ASSEMBLY_LANGUAGE or SXS_ASSEMBLY_LANGUAGE_INDEPENDENT without SXS_ASSEMBLY_NAME or SXS_SHORT_ASSEMBLY_NAME.
!endif

!if defined(SXS_BINPLACE_ALSO_ROOT) && !defined(SXS_ASSEMBLY_NAME)
!message BUILDMSG: warning BLD1014 : You may not specify SXS_BINPLACE_ALSO_ROOT without SXS_ASSEMBLY_NAME or SXS_SHORT_ASSEMBLY_NAME.
!endif

!if defined(SXS_MANIFEST)

#
# If removing .manifest or .Manifest from SXS_MANIFEST leaves it unchanged,
# it doesn't contain either one and is invalid.
#
!if "$(SXS_MANIFEST:.Manifest=)" == "$(SXS_MANIFEST)" \
    && "$(SXS_MANIFEST:.manifest=)" == "$(SXS_MANIFEST)"
!message BUILDMSG: warning BLD1015 : SXS_MANIFEST ($(SXS_MANIFEST)) must contain ".Manifest", it must end in ".Manifest or ".Manifest-src"
!endif
!endif

!endif
