Add support for compiling plain AVR C files

To compile plain AVR C files, the variable NO_CORE should be initialized
to a non-empty value.

When NO_CORE is set, the following changes happen
- boards.txt file is not parsed. The user should explicitly set MCU,
  F_CPU, fuse bits etc.
- MONITOR_BAUDRATE is not calculated

Fix #63
This commit is contained in:
Sudar 2013-06-15 19:30:39 +05:30
parent 78f2363dd5
commit 0028fabc64
2 changed files with 87 additions and 66 deletions

View file

@ -9,6 +9,7 @@ The following is the rough list of changes that went into different versions. I
- Add a warning when HEX_MAXIMUM_SIZE is not specified
- Add the ability to configure avrdude options. Fix issue #53
- Handle cases where certain fuse bits are not present. Fix issue #61
- Add support for compiling plain AVR C files. Fix issue #63
### 0.10.6 (2013-06-14)
- Fix whitespace and add /dev/null redirection (https://github.com/sej7278)

View file

@ -431,6 +431,10 @@ ifndef PARSE_BOARD_OPTS
PARSE_BOARD_OPTS = --boards_txt=$(BOARDS_TXT)
endif
# If NO_CORE is set, then we don't have to parse boards.txt file
# But the user might have to define MCU, F_CPU etc
ifeq ($(strip $(NO_CORE)),)
ifndef PARSE_BOARD_CMD
PARSE_BOARD_CMD = $(PARSE_BOARD) $(PARSE_BOARD_OPTS)
endif
@ -474,10 +478,6 @@ ifndef ISP_LOCK_FUSE_PRE
ISP_LOCK_FUSE_PRE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) bootloader.unlock_bits)
endif
ifndef ISP_LOCK_FUSE_POST
ISP_LOCK_FUSE_POST = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) bootloader.lock_bits)
endif
ifndef ISP_HIGH_FUSE
ISP_HIGH_FUSE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) bootloader.high_fuses)
endif
@ -490,15 +490,21 @@ ifndef ISP_EXT_FUSE
ISP_EXT_FUSE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) bootloader.extended_fuses)
endif
# Everything gets built in here (include BOARD_TAG now)
ifndef OBJDIR
OBJDIR = build-$(BOARD_TAG)
ifndef ISP_LOCK_FUSE_POST
ISP_LOCK_FUSE_POST = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) bootloader.lock_bits)
endif
ifndef HEX_MAXIMUM_SIZE
HEX_MAXIMUM_SIZE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) upload.maximum_size)
endif
endif
# Everything gets built in here (include BOARD_TAG now)
ifndef OBJDIR
OBJDIR = build-$(BOARD_TAG)
endif
########################################################################
# Local sources
#
@ -516,11 +522,23 @@ LOCAL_OBJ_FILES = $(LOCAL_C_SRCS:.c=.o) $(LOCAL_CPP_SRCS:.cpp=.o) \
$(LOCAL_INO_SRCS:.ino=.o) $(LOCAL_AS_SRCS:.S=.o)
LOCAL_OBJS = $(patsubst %,$(OBJDIR)/%,$(LOCAL_OBJ_FILES))
# If NO_CORE is not set, then we need exactly one .pde or .ino file
ifeq ($(strip $(NO_CORE)),)
ifeq ($(words $(LOCAL_PDE_SRCS) $(LOCAL_INO_SRCS)), 0)
ifeq ($(strip $(NO_CORE)),)
$(error No .pde or .ino files found. If you want to compile .c or .cpp files, then set NO_CORE)
endif
endif
# Ideally, this should just check if there are more than one file
ifneq ($(words $(LOCAL_PDE_SRCS) $(LOCAL_INO_SRCS)), 1)
#TODO: Support more than one file. https://github.com/sudar/Arduino-Makefile/issues/49
$(error Need exactly one .pde or .ino file)
endif
endif
# core sources
ifeq ($(strip $(NO_CORE)),)
ifdef ARDUINO_CORE_PATH
@ -558,6 +576,7 @@ endif
# to the command we're using (here screen). So, read the screen docs
# for more information (search for 'character special device').
#
ifeq ($(strip $(NO_CORE)),)
ifndef MONITOR_BAUDRATE
SPEED = $(shell egrep -h 'Serial.begin\([0-9]+\)' $(LOCAL_PDE_SRCS) $(LOCAL_INO_SRCS) | sed -e 's/[^0-9]//g'| head -n1)
MONITOR_BAUDRATE = $(findstring $(SPEED),300 1200 2400 4800 9600 14400 19200 28800 38400 57600 115200)
@ -575,6 +594,7 @@ endif
ifndef MONITOR_CMD
MONITOR_CMD = screen
endif
endif
########################################################################
# Include file to use for old .pde files