From bcb4b74de959198c29eba5d416a99a1153f3fd27 Mon Sep 17 00:00:00 2001
From: Mark VanderVoord <mvandervoord@gmail.com>
Date: Mon, 3 Nov 2014 19:39:37 -0500
Subject: [PATCH] - updated example makefiles to handle cygwin better

---
 examples/example_1/makefile | 26 +++++++++++++++-----------
 examples/example_2/makefile | 26 +++++++++++++++-----------
 examples/example_3/makefile | 26 +++++++++++++++-----------
 3 files changed, 45 insertions(+), 33 deletions(-)

diff --git a/examples/example_1/makefile b/examples/example_1/makefile
index a9c7566..84696a1 100644
--- a/examples/example_1/makefile
+++ b/examples/example_1/makefile
@@ -4,16 +4,26 @@
 #   [Released under MIT License. Please refer to license.txt for details]
 # ==========================================
 
+#We try to detect the OS we are running on, and adjust commands as needed
+ifeq ($(OSTYPE),cygwin)
+	CLEANUP = rm -f
+	MKDIR = mkdir -p
+	TARGET_EXTENSION=.out
+else ifeq ($(OS),Windows_NT)
+	CLEANUP = del /F /Q
+	MKDIR = mkdir
+	TARGET_EXTENSION=.exe
+else
+	CLEANUP = rm -f
+	MKDIR = mkdir -p
+	TARGET_EXTENSION=.out
+endif
+
 UNITY_ROOT=../..
 C_COMPILER=gcc
 CFLAGS=-std=c99
 TARGET_BASE1=test1
 TARGET_BASE2=test2
-ifeq ($(OS),Windows_NT)
-	TARGET_EXTENSION=.exe
-else
-	TARGET_EXTENSION=.out
-endif
 TARGET1 = $(TARGET_BASE1)$(TARGET_EXTENSION)
 TARGET2 = $(TARGET_BASE2)$(TARGET_EXTENSION)
 SRC_FILES1=$(UNITY_ROOT)/src/unity.c src/ProductionCode.c  test/TestProductionCode.c  test/test_runners/TestProductionCode_Runner.c
@@ -21,12 +31,6 @@ SRC_FILES2=$(UNITY_ROOT)/src/unity.c src/ProductionCode2.c test/TestProductionCo
 INC_DIRS=-Isrc -I$(UNITY_ROOT)/src
 SYMBOLS=-DTEST
 
-ifeq ($(OS),Windows_NT)
-	CLEANUP = del /F /Q $(TARGET1) && del /F /Q $(TARGET2)
-else
-	CLEANUP = rm -f build/*.o ; rm -f $(TARGET1) ; rm -f $(TARGET2)
-endif
-
 all: clean default
 
 default:
diff --git a/examples/example_2/makefile b/examples/example_2/makefile
index 994c7a5..3eaa776 100644
--- a/examples/example_2/makefile
+++ b/examples/example_2/makefile
@@ -4,14 +4,24 @@
 #   [Released under MIT License. Please refer to license.txt for details]
 # ==========================================
 
+#We try to detect the OS we are running on, and adjust commands as needed
+ifeq ($(OSTYPE),cygwin)
+	CLEANUP = rm -f
+	MKDIR = mkdir -p
+	TARGET_EXTENSION=.out
+else ifeq ($(OS),Windows_NT)
+	CLEANUP = del /F /Q
+	MKDIR = mkdir
+	TARGET_EXTENSION=.exe
+else
+	CLEANUP = rm -f
+	MKDIR = mkdir -p
+	TARGET_EXTENSION=.out
+endif
+
 UNITY_ROOT=../..
 C_COMPILER=gcc
 TARGET_BASE1=all_tests
-ifeq ($(OS),Windows_NT)
-	TARGET_EXTENSION=.exe
-else
-	TARGET_EXTENSION=.out
-endif
 TARGET1 = $(TARGET_BASE1)$(TARGET_EXTENSION)
 SRC_FILES1=\
   $(UNITY_ROOT)/src/unity.c \
@@ -26,12 +36,6 @@ SRC_FILES1=\
 INC_DIRS=-Isrc -I$(UNITY_ROOT)/src -I$(UNITY_ROOT)/extras/fixture/src
 SYMBOLS=
 
-ifeq ($(OS),Windows_NT)
-	CLEANUP = del /F /Q $(TARGET1)
-else
-	CLEANUP = rm -f build/*.o ; rm -f $(TARGET1)
-endif
-
 all: clean default
 
 default:
diff --git a/examples/example_3/makefile b/examples/example_3/makefile
index 0d9d0ea..fb5140c 100644
--- a/examples/example_3/makefile
+++ b/examples/example_3/makefile
@@ -4,16 +4,26 @@
 #   [Released under MIT License. Please refer to license.txt for details]
 # ==========================================
 
+#We try to detect the OS we are running on, and adjust commands as needed
+ifeq ($(OSTYPE),cygwin)
+	CLEANUP = rm -f
+	MKDIR = mkdir -p
+	TARGET_EXTENSION=.out
+else ifeq ($(OS),Windows_NT)
+	CLEANUP = del /F /Q
+	MKDIR = mkdir
+	TARGET_EXTENSION=.exe
+else
+	CLEANUP = rm -f
+	MKDIR = mkdir -p
+	TARGET_EXTENSION=.out
+endif
+
 UNITY_ROOT=../..
 C_COMPILER=gcc
 CFLAGS=-std=c99
 TARGET_BASE1=test1
 TARGET_BASE2=test2
-ifeq ($(OS),Windows_NT)
-	TARGET_EXTENSION=.exe
-else
-	TARGET_EXTENSION=.out
-endif
 TARGET1 = $(TARGET_BASE1)$(TARGET_EXTENSION)
 TARGET2 = $(TARGET_BASE2)$(TARGET_EXTENSION)
 SRC_FILES1=$(UNITY_ROOT)/src/unity.c src/ProductionCode.c  test/TestProductionCode.c  test/no_ruby/TestProductionCode_Runner.c
@@ -21,12 +31,6 @@ SRC_FILES2=$(UNITY_ROOT)/src/unity.c src/ProductionCode2.c test/TestProductionCo
 INC_DIRS=-Isrc -I$(UNITY_ROOT)/src
 SYMBOLS=-DTEST
 
-ifeq ($(OS),Windows_NT)
-	CLEANUP = del /F /Q $(TARGET1) && del /F /Q $(TARGET2)
-else
-	CLEANUP = rm -f build/*.o ; rm -f $(TARGET1) ; rm -f $(TARGET2)
-endif
-
 all: clean default
 
 default: