From 0416d2faf0207400dd1dc98e098f91ac3ec6a6e7 Mon Sep 17 00:00:00 2001 From: Christopher Peplin Date: Mon, 2 Apr 2012 11:52:27 -0400 Subject: [PATCH] Add a flag for stopping compilation of built-in main() function. If you need to define your own main() function, e.g. if you are using Xcode and want the code sense to work, you can flip this flag on to stop the Makefile from compiling the Arduino's built-in main.cpp file. --- README.md | 8 ++++++++ arduino-mk/Arduino.mk | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/README.md b/README.md index ec38ba9..caa5c07 100644 --- a/README.md +++ b/README.md @@ -8,3 +8,11 @@ documentation](http://mjo.tc/atelier/2009/02/arduino-cli.html "Documentation") exists. If you're using Debian or Ubuntu, you can find this in the arduino-core package. + +## Options + +If you are defining your own `main()` function, you can stop the Ardunio's +built-in `main()` from being compiled with your code by defining the +`NO_CORE_MAIN_FUNCTION` variable: + + NO_CORE_MAIN_FUNCTION = 1 diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 2d39095..4960d23 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -287,6 +287,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_FUNCTION)),) +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))