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 a warning when HEX_MAXIMUM_SIZE is not specified
- Add the ability to configure avrdude options. Fix issue #53 - Add the ability to configure avrdude options. Fix issue #53
- Handle cases where certain fuse bits are not present. Fix issue #61 - 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) ### 0.10.6 (2013-06-14)
- Fix whitespace and add /dev/null redirection (https://github.com/sej7278) - Fix whitespace and add /dev/null redirection (https://github.com/sej7278)

View file

@ -431,72 +431,78 @@ ifndef PARSE_BOARD_OPTS
PARSE_BOARD_OPTS = --boards_txt=$(BOARDS_TXT) PARSE_BOARD_OPTS = --boards_txt=$(BOARDS_TXT)
endif endif
ifndef PARSE_BOARD_CMD # If NO_CORE is set, then we don't have to parse boards.txt file
PARSE_BOARD_CMD = $(PARSE_BOARD) $(PARSE_BOARD_OPTS) # But the user might have to define MCU, F_CPU etc
endif ifeq ($(strip $(NO_CORE)),)
# Which variant ? This affects the include path ifndef PARSE_BOARD_CMD
ifndef VARIANT PARSE_BOARD_CMD = $(PARSE_BOARD) $(PARSE_BOARD_OPTS)
VARIANT = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.variant)
endif
# processor stuff
ifndef MCU
MCU = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.mcu)
endif
ifndef F_CPU
F_CPU = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.f_cpu)
endif
ifeq ($(VARIANT),leonardo)
# USB IDs for the Leonardo
ifndef USB_VID
USB_VID = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.vid 2>/dev/null)
endif endif
ifndef USB_PID # Which variant ? This affects the include path
USB_PID = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.pid 2>/dev/null) ifndef VARIANT
VARIANT = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.variant)
endif endif
endif
# normal programming info # processor stuff
ifndef AVRDUDE_ARD_PROGRAMMER ifndef MCU
AVRDUDE_ARD_PROGRAMMER = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) upload.protocol) MCU = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.mcu)
endif endif
ifndef AVRDUDE_ARD_BAUDRATE ifndef F_CPU
AVRDUDE_ARD_BAUDRATE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) upload.speed) F_CPU = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.f_cpu)
endif endif
# fuses if you're using e.g. ISP ifeq ($(VARIANT),leonardo)
ifndef ISP_LOCK_FUSE_PRE # USB IDs for the Leonardo
ISP_LOCK_FUSE_PRE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) bootloader.unlock_bits) ifndef USB_VID
endif USB_VID = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.vid 2>/dev/null)
endif
ifndef ISP_LOCK_FUSE_POST ifndef USB_PID
ISP_LOCK_FUSE_POST = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) bootloader.lock_bits) USB_PID = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.pid 2>/dev/null)
endif endif
endif
ifndef ISP_HIGH_FUSE # normal programming info
ISP_HIGH_FUSE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) bootloader.high_fuses) ifndef AVRDUDE_ARD_PROGRAMMER
endif AVRDUDE_ARD_PROGRAMMER = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) upload.protocol)
endif
ifndef ISP_LOW_FUSE ifndef AVRDUDE_ARD_BAUDRATE
ISP_LOW_FUSE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) bootloader.low_fuses) AVRDUDE_ARD_BAUDRATE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) upload.speed)
endif endif
# fuses if you're using e.g. ISP
ifndef ISP_LOCK_FUSE_PRE
ISP_LOCK_FUSE_PRE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) bootloader.unlock_bits)
endif
ifndef ISP_HIGH_FUSE
ISP_HIGH_FUSE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) bootloader.high_fuses)
endif
ifndef ISP_LOW_FUSE
ISP_LOW_FUSE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) bootloader.low_fuses)
endif
ifndef ISP_EXT_FUSE
ISP_EXT_FUSE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) bootloader.extended_fuses)
endif
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
ifndef ISP_EXT_FUSE
ISP_EXT_FUSE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) bootloader.extended_fuses)
endif endif
# Everything gets built in here (include BOARD_TAG now) # Everything gets built in here (include BOARD_TAG now)
ifndef OBJDIR ifndef OBJDIR
OBJDIR = build-$(BOARD_TAG) OBJDIR = build-$(BOARD_TAG)
endif
ifndef HEX_MAXIMUM_SIZE
HEX_MAXIMUM_SIZE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) upload.maximum_size)
endif endif
######################################################################## ########################################################################
@ -516,9 +522,21 @@ LOCAL_OBJ_FILES = $(LOCAL_C_SRCS:.c=.o) $(LOCAL_CPP_SRCS:.cpp=.o) \
$(LOCAL_INO_SRCS:.ino=.o) $(LOCAL_AS_SRCS:.S=.o) $(LOCAL_INO_SRCS:.ino=.o) $(LOCAL_AS_SRCS:.S=.o)
LOCAL_OBJS = $(patsubst %,$(OBJDIR)/%,$(LOCAL_OBJ_FILES)) LOCAL_OBJS = $(patsubst %,$(OBJDIR)/%,$(LOCAL_OBJ_FILES))
ifneq ($(words $(LOCAL_PDE_SRCS) $(LOCAL_INO_SRCS)), 1) # If NO_CORE is not set, then we need exactly one .pde or .ino file
#TODO: Support more than one file. https://github.com/sudar/Arduino-Makefile/issues/49 ifeq ($(strip $(NO_CORE)),)
$(error Need exactly one .pde or .ino file)
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 endif
# core sources # core sources
@ -558,22 +576,24 @@ endif
# to the command we're using (here screen). So, read the screen docs # to the command we're using (here screen). So, read the screen docs
# for more information (search for 'character special device'). # for more information (search for 'character special device').
# #
ifndef MONITOR_BAUDRATE ifeq ($(strip $(NO_CORE)),)
SPEED = $(shell egrep -h 'Serial.begin\([0-9]+\)' $(LOCAL_PDE_SRCS) $(LOCAL_INO_SRCS) | sed -e 's/[^0-9]//g'| head -n1) ifndef MONITOR_BAUDRATE
MONITOR_BAUDRATE = $(findstring $(SPEED),300 1200 2400 4800 9600 14400 19200 28800 38400 57600 115200) 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)
ifeq ($(MONITOR_BAUDRATE),) ifeq ($(MONITOR_BAUDRATE),)
MONITOR_BAUDRATE = 9600 MONITOR_BAUDRATE = 9600
$(call show_config_variable,MONITOR_BAUDRATE,[ASSUMED]) $(call show_config_variable,MONITOR_BAUDRATE,[ASSUMED])
else
$(call show_config_variable,MONITOR_BAUDRATE,[DETECTED], (in sketch))
endif
else else
$(call show_config_variable,MONITOR_BAUDRATE,[DETECTED], (in sketch)) $(call show_config_variable,MONITOR_BAUDRATE, [USER])
endif endif
else
$(call show_config_variable,MONITOR_BAUDRATE, [USER])
endif
ifndef MONITOR_CMD ifndef MONITOR_CMD
MONITOR_CMD = screen MONITOR_CMD = screen
endif
endif endif
######################################################################## ########################################################################