1###############################################################################
2#
3# include file to check version of GHS tools
4#
5# Copyright (C) Nintendo.  All rights reserved.
6#
7# These coded instructions, statements, and computer programs contain
8# proprietary information of Nintendo of America Inc. and/or Nintendo
9# Company Ltd., and are protected by Federal copyright law.  They may
10# not be disclosed to third parties or copied or duplicated in any form,
11# in whole or in part, without the prior written consent of Nintendo.
12#
13###############################################################################
14
15ifeq ($(_@), @)
16	SHOW_GHS_VERSION=$(info Using GHS tools version $(CAFE_GHS_VERSION) ($(GHS_VERSION_NUMBER)))
17else
18	SHOW_GHS_VERSION=
19endif
20
21ifndef GHS_VERSION_CHECK_MK
22 export GHS_VERSION_CHECK_MK := TRUE
23
24 ifndef CAFE_REPORTED_GHS_VERSION
25  export CAFE_REPORTED_GHS_VERSION := 1
26  REQUIRED_GHS_VERSION := "v5.3.25"
27  REQUIRED_GHS_VERSION_OLD := "v5.3.25"
28  MIN_GHS_VERSION_NUMBER := 50302400
29
30  ifndef CAFE_GHS_VERSION
31   $(error error: CAFE_GHS_VERSION not set.  cafe.bat sets this environment variable.)
32  else
33   GHS_VERSION_NUMBER_P1 := $(strip $(subst P,0,$(subst .,0,$(subst Nintendo,,$(subst v,,$(CAFE_GHS_VERSION))))))
34   GHS_VERSION_NUMBER_WORDS := $(words $(GHS_VERSION_NUMBER_P1))
35   ifeq ($(GHS_VERSION_NUMBER_WORDS),1)
36    GHS_VERSION_NUMBER := $(word 1, $(GHS_VERSION_NUMBER_P1))00
37   else
38    ifeq  ($(GHS_VERSION_NUMBER_WORDS),2)
39     GHS_VERSION_NUMBER := $(word 1, $(GHS_VERSION_NUMBER_P1))$(word 2, $(GHS_VERSION_NUMBER_P1))
40    else
41     ifeq ($(GHS_VERSION_NUMBER_WORDS), 8)
42     	GHS_VERSION_NUMBER := $(word 1, $(GHS_VERSION_NUMBER_P1))$(word 2, $(GHS_VERSION_NUMBER_P1))
43     else
44  	    $(error error: can't parse $(CAFE_GHS_VERSION) words = $(GHS_VERSION_NUMBER_WORDS))
45  	 endif
46  	endif
47   endif
48   $(SHOW_GHS_VERSION)
49   ifneq ($(shell if [ $(GHS_VERSION_NUMBER) -ge $(MIN_GHS_VERSION_NUMBER) ]; then echo pass; fi),pass)
50    ifeq ("$(CAFE_GHS_VERSION)","$(REQUIRED_GHS_VERSION_OLD)")
51     $(info === warning: Please update to GHS version "$(REQUIRED_GHS_VERSION)".)
52     $(warning warning: Old GHS version used ($(CAFE_GHS_VERSION)))
53    else
54     $(info === error: Please update to GHS version "$(REQUIRED_GHS_VERSION)".)
55     $(error error: Invalid GHS version used ($(CAFE_GHS_VERSION)))
56    endif
57   endif
58  endif
59 endif
60endif
61
62