From 42a45b51aa9748c67654a9f7f4546b464856ca99 Mon Sep 17 00:00:00 2001
From: Evan Lloyd <evan.lloyd@arm.com>
Date: Thu, 3 Dec 2015 11:35:40 +0000
Subject: [PATCH] Make:Allow for extension in tool names.

In some build environments executable programs have a specific file
extension.  The value of BIN_EXT is appended to the relevant tool file
names to allow for this.
The value of BIN_EXT is set, where appropriate, by the build environment
specific make helper (to .exe for Windows build environments).

.gitignore is updated to hide the new (.exe) files.

Change-Id: Icc32f64b750e425265075ad4e0dea18129640b86
---
 .gitignore                 | 2 ++
 Makefile                   | 4 ++--
 make_helpers/cygwin.mk     | 3 +++
 make_helpers/msys.mk       | 3 +++
 make_helpers/windows.mk    | 4 ++--
 tools/cert_create/Makefile | 2 +-
 tools/fip_create/Makefile  | 2 +-
 7 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/.gitignore b/.gitignore
index a3b5e391d8..74472273a8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,9 +11,11 @@ build/
 # Ignore build products from tools
 tools/**/*.o
 tools/fip_create/fip_create
+tools/fip_create/fip_create.exe
 tools/cert_create/src/*.o
 tools/cert_create/src/**/*.o
 tools/cert_create/cert_create
+tools/cert_create/cert_create.exe
 
 # Ignore header files copied.
 tools/fip_create/firmware_image_package.h
diff --git a/Makefile b/Makefile
index c20bf912ae..828ff57286 100644
--- a/Makefile
+++ b/Makefile
@@ -377,11 +377,11 @@ endif
 
 # Variables for use with Certificate Generation Tool
 CRTTOOLPATH		?=	tools/cert_create
-CRTTOOL			?=	${CRTTOOLPATH}/cert_create
+CRTTOOL			?=	${CRTTOOLPATH}/cert_create${BIN_EXT}
 
 # Variables for use with Firmware Image Package
 FIPTOOLPATH		?=	tools/fip_create
-FIPTOOL			?=	${FIPTOOLPATH}/fip_create
+FIPTOOL			?=	${FIPTOOLPATH}/fip_create${BIN_EXT}
 
 
 ################################################################################
diff --git a/make_helpers/cygwin.mk b/make_helpers/cygwin.mk
index f99be134a3..e69c0b1bab 100644
--- a/make_helpers/cygwin.mk
+++ b/make_helpers/cygwin.mk
@@ -37,4 +37,7 @@ ifndef CYGWIN_MK
 
     include ${MAKE_HELPERS_DIRECTORY}unix.mk
 
+    # In cygwin executable files have the Windows .exe extension type.
+    BIN_EXT := .exe
+
 endif
diff --git a/make_helpers/msys.mk b/make_helpers/msys.mk
index ca0f72b0fd..188dc6ca78 100644
--- a/make_helpers/msys.mk
+++ b/make_helpers/msys.mk
@@ -37,5 +37,8 @@ ifndef MSYS_MK
 
     include ${MAKE_HELPERS_DIRECTORY}unix.mk
 
+    # In MSYS executable files have the Windows .exe extension type.
+    BIN_EXT := .exe
+
 endif
 
diff --git a/make_helpers/windows.mk b/make_helpers/windows.mk
index 92cc8f64d0..394df3a0b1 100644
--- a/make_helpers/windows.mk
+++ b/make_helpers/windows.mk
@@ -38,9 +38,9 @@ ifndef WINDOWS_MK
     WINDOWS_MK := $(lastword $(MAKEFILE_LIST))
 
     ECHO_BLANK_LINE := @cmd /c echo.
-
     DIR_DELIM := $(strip \)
-    PATH_SEP := ;
+    BIN_EXT   := .exe
+    PATH_SEP  := ;
 
     # For some Windows native commands there is a problem with the directory delimiter.
     # Make uses / (slash) and the commands expect \ (backslash)
diff --git a/tools/cert_create/Makefile b/tools/cert_create/Makefile
index 8218ab71d9..27545bae88 100644
--- a/tools/cert_create/Makefile
+++ b/tools/cert_create/Makefile
@@ -32,7 +32,7 @@ PROJECT		:= cert_create
 PLAT		:= none
 V		:= 0
 DEBUG		:= 0
-BINARY		:= ${PROJECT}
+BINARY		:= ${PROJECT}${BIN_EXT}
 OPENSSL_DIR	:= /usr
 
 OBJECTS := src/cert.o \
diff --git a/tools/fip_create/Makefile b/tools/fip_create/Makefile
index b12e063848..2e367c2fa2 100644
--- a/tools/fip_create/Makefile
+++ b/tools/fip_create/Makefile
@@ -32,7 +32,7 @@ MAKE_HELPERS_DIRECTORY := ../../make_helpers/
 include ${MAKE_HELPERS_DIRECTORY}build_macros.mk
 include ${MAKE_HELPERS_DIRECTORY}build_env.mk
 
-PROJECT := fip_create
+PROJECT := fip_create${BIN_EXT}
 OBJECTS := fip_create.o
 COPIED_H_FILES := uuid.h firmware_image_package.h
 
-- 
GitLab