From 3b18056404fe9fdeade920e5e72ead3d40feb7ef Mon Sep 17 00:00:00 2001
From: Martin Oldfield <m@mjo.tc>
Date: Fri, 27 Apr 2012 12:48:36 +0100
Subject: [PATCH] Add NO_CORE_MAIN_CPP flag to remove main.cpp, after Peplin

---
 arduino-mk/Arduino.mk | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk
index bf2def7..2d88e43 100644
--- a/arduino-mk/Arduino.mk
+++ b/arduino-mk/Arduino.mk
@@ -67,6 +67,8 @@
 #                          - Allow the punter to specify boards.txt file
 #                            and parser independently (after Peplin on github)
 #			   - Support user libraries (Peplin's patch)
+#                          - Remove main.cpp if NO_CORE_MAIN_CPP is
+#                            defined (ex Peplin)
 #
 ########################################################################
 #
@@ -308,6 +310,11 @@ ifeq ($(strip $(NO_CORE)),)
 ifdef ARDUINO_CORE_PATH
 CORE_C_SRCS     = $(wildcard $(ARDUINO_CORE_PATH)/*.c)
 CORE_CPP_SRCS   = $(wildcard $(ARDUINO_CORE_PATH)/*.cpp)
+
+ifneq ($(strip $(NO_CORE_MAIN_CPP)),)
+CORE_CPP_SRCS := $(filter-out %main.cpp, $(CORE_CPP_SRCS))
+endif
+
 CORE_OBJ_FILES  = $(CORE_C_SRCS:.c=.o) $(CORE_CPP_SRCS:.cpp=.o)
 CORE_OBJS       = $(patsubst $(ARDUINO_CORE_PATH)/%,  \
 			$(OBJDIR)/%,$(CORE_OBJ_FILES))