Clarify by adding (space-based) indentation.

Helps simplify understanding all the nested conditionals.
This commit is contained in:
Ryan Pavlik 2012-07-05 14:04:35 -05:00
parent 49cca1da11
commit 744cb5350d

View file

@ -266,28 +266,28 @@ $(call show_separator)
$(info Arduino.mk Configuration:) $(info Arduino.mk Configuration:)
ifndef ARDUINO_DIR ifndef ARDUINO_DIR
NIX_DEFAULT_ARDUINO_DIR := $(call dir_if_exists,/usr/share/arduino) NIX_DEFAULT_ARDUINO_DIR := $(call dir_if_exists,/usr/share/arduino)
ifdef NIX_DEFAULT_ARDUINO_DIR ifdef NIX_DEFAULT_ARDUINO_DIR
ARDUINO_DIR = $(NIX_DEFAULT_ARDUINO_DIR) ARDUINO_DIR = $(NIX_DEFAULT_ARDUINO_DIR)
endif endif
MAC_DEFAULT_ARDUINO_DIR := $(call dir_if_exists,/Applications/Arduino.app/Contents/Resources/Java) MAC_DEFAULT_ARDUINO_DIR := $(call dir_if_exists,/Applications/Arduino.app/Contents/Resources/Java)
ifdef MAC_DEFAULT_ARDUINO_DIR ifdef MAC_DEFAULT_ARDUINO_DIR
ARDUINO_DIR = $(MAC_DEFAULT_ARDUINO_DIR) ARDUINO_DIR = $(MAC_DEFAULT_ARDUINO_DIR)
endif endif
ifdef ARDUINO_DIR ifdef ARDUINO_DIR
$(call show_config_info,ARDUINO_DIR,[AUTODETECTED]) $(call show_config_info,ARDUINO_DIR,[AUTODETECTED])
endif endif
else else
$(call show_config_info,ARDUINO_DIR) $(call show_config_info,ARDUINO_DIR)
endif endif
######################################################################## ########################################################################
# #
# Default TARGET to cwd (ex Daniele Vergini) # Default TARGET to cwd (ex Daniele Vergini)
ifndef TARGET ifndef TARGET
TARGET = $(notdir $(CURDIR)) TARGET = $(notdir $(CURDIR))
endif endif
######################################################################## ########################################################################
@ -296,18 +296,18 @@ endif
# Arduino version number # Arduino version number
ifndef ARDUINO_VERSION ifndef ARDUINO_VERSION
# Remove all the decimals, and right-pad with zeros, and finally grab the first 3 bytes. # Remove all the decimals, and right-pad with zeros, and finally grab the first 3 bytes.
# Works for 1.0 and 1.0.1 # Works for 1.0 and 1.0.1
AUTO_ARDUINO_VERSION := $(shell cat $(ARDUINO_DIR)/lib/version.txt | sed -e 's/[.]//g' -e 's/$$/0000/' | head --bytes=3) AUTO_ARDUINO_VERSION := $(shell cat $(ARDUINO_DIR)/lib/version.txt | sed -e 's/[.]//g' -e 's/$$/0000/' | head --bytes=3)
ifdef AUTO_ARDUINO_VERSION ifdef AUTO_ARDUINO_VERSION
ARDUINO_VERSION = $(AUTO_ARDUINO_VERSION) ARDUINO_VERSION = $(AUTO_ARDUINO_VERSION)
$(call show_config_info,ARDUINO_VERSION,[AUTODETECTED]) $(call show_config_info,ARDUINO_VERSION,[AUTODETECTED])
else
ARDUINO_VERSION = 100
$(call show_config_info,ARDUINO_VERSION,[DEFAULT])
endif
else else
ARDUINO_VERSION = 100 $(call show_config_info,ARDUINO_VERSION)
$(call show_config_info,ARDUINO_VERSION,[DEFAULT])
endif
else
$(call show_config_info,ARDUINO_VERSION)
endif endif
######################################################################## ########################################################################
@ -315,45 +315,45 @@ endif
# #
ifdef ARDUINO_DIR ifdef ARDUINO_DIR
ifndef AVR_TOOLS_DIR ifndef AVR_TOOLS_DIR
BUNDLED_AVR_TOOLS_DIR := $(call dir_if_exists,$(ARDUINO_DIR)/hardware/tools/avr) BUNDLED_AVR_TOOLS_DIR := $(call dir_if_exists,$(ARDUINO_DIR)/hardware/tools/avr)
ifdef BUNDLED_AVR_TOOLS_DIR ifdef BUNDLED_AVR_TOOLS_DIR
AVR_TOOLS_DIR = $(BUNDLED_AVR_TOOLS_DIR) AVR_TOOLS_DIR = $(BUNDLED_AVR_TOOLS_DIR)
# The avrdude bundled with Arduino can't find it's config # The avrdude bundled with Arduino can't find it's config
AVRDUDE_CONF = $(AVR_TOOLS_DIR)/etc/avrdude.conf AVRDUDE_CONF = $(AVR_TOOLS_DIR)/etc/avrdude.conf
$(call show_config_info,AVR_TOOLS_DIR,[BUNDLED],(in Arduino distribution)) $(call show_config_info,AVR_TOOLS_DIR,[BUNDLED],(in Arduino distribution))
else
SYSTEMPATH_AVR_TOOLS_DIR := $(call dir_if_exists,$(abspath $(dir $(shell which avr-gcc))/..))
ifdef SYSTEMPATH_AVR_TOOLS_DIR
AVR_TOOLS_DIR = $(SYSTEMPATH_AVR_TOOLS_DIR)
$(call show_config_info,AVR_TOOLS_DIR,[AUTODETECTED],(found in $$PATH))
endif # SYSTEMPATH_AVR_TOOLS_DIR
endif # BUNDLED_AVR_TOOLS_DIR
else
$(call show_config_info,AVR_TOOLS_DIR)
endif #ndef AVR_TOOLS_DIR
ARDUINO_LIB_PATH = $(ARDUINO_DIR)/libraries
ARDUINO_CORE_PATH = $(ARDUINO_DIR)/hardware/arduino/cores/arduino
ARDUINO_VAR_PATH = $(ARDUINO_DIR)/hardware/arduino/variants
else else
SYSTEMPATH_AVR_TOOLS_DIR := $(call dir_if_exists,$(abspath $(dir $(shell which avr-gcc))/..)) echo $(error "ARDUINO_DIR is not defined")
ifdef SYSTEMPATH_AVR_TOOLS_DIR
AVR_TOOLS_DIR = $(SYSTEMPATH_AVR_TOOLS_DIR)
$(call show_config_info,AVR_TOOLS_DIR,[AUTODETECTED],(found in $$PATH))
endif # SYSTEMPATH_AVR_TOOLS_DIR
endif # BUNDLED_AVR_TOOLS_DIR
else
$(call show_config_info,AVR_TOOLS_DIR)
endif #ndef AVR_TOOLS_DIR
ARDUINO_LIB_PATH = $(ARDUINO_DIR)/libraries
ARDUINO_CORE_PATH = $(ARDUINO_DIR)/hardware/arduino/cores/arduino
ARDUINO_VAR_PATH = $(ARDUINO_DIR)/hardware/arduino/variants
else
echo $(error "ARDUINO_DIR is not defined")
endif endif
ifdef AVR_TOOLS_DIR ifdef AVR_TOOLS_DIR
ifndef AVR_TOOLS_PATH ifndef AVR_TOOLS_PATH
AVR_TOOLS_PATH = $(AVR_TOOLS_DIR)/bin AVR_TOOLS_PATH = $(AVR_TOOLS_DIR)/bin
endif endif
endif endif
@ -361,19 +361,19 @@ endif
# Makefile distribution path # Makefile distribution path
# #
ifdef ARDMK_DIR ifdef ARDMK_DIR
$(call show_config_info,ARDMK_DIR) $(call show_config_info,ARDMK_DIR)
ifndef ARDMK_PATH ifndef ARDMK_PATH
ARDMK_PATH = $(ARDMK_DIR)/bin ARDMK_PATH = $(ARDMK_DIR)/bin
$(call show_config_info,ARDMK_PATH,[COMPUTED],(relative to ARDMK_DIR)) $(call show_config_info,ARDMK_PATH,[COMPUTED],(relative to ARDMK_DIR))
else else
$(call show_config_info,ARDMK_PATH) $(call show_config_info,ARDMK_PATH)
endif endif
else else
echo $(error "ARDMK_DIR is not defined") echo $(error "ARDMK_DIR is not defined")
endif endif
@ -381,14 +381,14 @@ endif
# Miscellanea # Miscellanea
# #
ifndef ARDUINO_SKETCHBOOK ifndef ARDUINO_SKETCHBOOK
ARDUINO_SKETCHBOOK = $(HOME)/sketchbook ARDUINO_SKETCHBOOK = $(HOME)/sketchbook
endif endif
ifndef USER_LIB_PATH ifndef USER_LIB_PATH
USER_LIB_PATH = $(ARDUINO_SKETCHBOOK)/libraries USER_LIB_PATH = $(ARDUINO_SKETCHBOOK)/libraries
$(call show_config_info,USER_LIB_PATH,[DEFAULT],(in user sketchbook)) $(call show_config_info,USER_LIB_PATH,[DEFAULT],(in user sketchbook))
else else
$(call show_config_info,USER_LIB_PATH) $(call show_config_info,USER_LIB_PATH)
endif endif
######################################################################## ########################################################################
@ -399,87 +399,87 @@ endif
# for more information (search for 'character special device'). # for more information (search for 'character special device').
# #
ifndef MONITOR_BAUDRATE ifndef MONITOR_BAUDRATE
MONITOR_BAUDRATE = 9600 MONITOR_BAUDRATE = 9600
endif endif
ifndef MONITOR_CMD ifndef MONITOR_CMD
MONITOR_CMD = screen MONITOR_CMD = screen
endif endif
######################################################################## ########################################################################
# Reset # Reset
ifndef RESET_CMD ifndef RESET_CMD
RESET_CMD = $(ARDMK_PATH)/ard-reset-arduino $(ARD_RESET_OPTS) RESET_CMD = $(ARDMK_PATH)/ard-reset-arduino $(ARD_RESET_OPTS)
endif endif
######################################################################## ########################################################################
# boards.txt parsing # boards.txt parsing
# #
ifndef BOARD_TAG ifndef BOARD_TAG
BOARD_TAG = uno BOARD_TAG = uno
$(call show_config_info,BOARD_TAG,[DEFAULT]) $(call show_config_info,BOARD_TAG,[DEFAULT])
else else
$(call show_config_info,BOARD_TAG) $(call show_config_info,BOARD_TAG)
endif endif
ifndef BOARDS_TXT ifndef BOARDS_TXT
BOARDS_TXT = $(ARDUINO_DIR)/hardware/arduino/boards.txt BOARDS_TXT = $(ARDUINO_DIR)/hardware/arduino/boards.txt
endif endif
ifndef PARSE_BOARD ifndef PARSE_BOARD
PARSE_BOARD = $(ARDMK_PATH)/ard-parse-boards PARSE_BOARD = $(ARDMK_PATH)/ard-parse-boards
endif endif
ifndef PARSE_BOARD_OPTS ifndef PARSE_BOARD_OPTS
PARSE_BOARD_OPTS = --boards_txt=$(BOARDS_TXT) PARSE_BOARD_OPTS = --boards_txt=$(BOARDS_TXT)
endif endif
ifndef PARSE_BOARD_CMD ifndef PARSE_BOARD_CMD
PARSE_BOARD_CMD = $(PARSE_BOARD) $(PARSE_BOARD_OPTS) PARSE_BOARD_CMD = $(PARSE_BOARD) $(PARSE_BOARD_OPTS)
endif endif
# Which variant ? This affects the include path # Which variant ? This affects the include path
ifndef VARIANT ifndef VARIANT
VARIANT = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.variant) VARIANT = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.variant)
endif endif
# processor stuff # processor stuff
ifndef MCU ifndef MCU
MCU = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.mcu) MCU = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.mcu)
endif endif
ifndef F_CPU ifndef F_CPU
F_CPU = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.f_cpu) F_CPU = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.f_cpu)
endif endif
# normal programming info # normal programming info
ifndef AVRDUDE_ARD_PROGRAMMER ifndef AVRDUDE_ARD_PROGRAMMER
AVRDUDE_ARD_PROGRAMMER = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) upload.protocol) AVRDUDE_ARD_PROGRAMMER = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) upload.protocol)
endif endif
ifndef AVRDUDE_ARD_BAUDRATE ifndef AVRDUDE_ARD_BAUDRATE
AVRDUDE_ARD_BAUDRATE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) upload.speed) AVRDUDE_ARD_BAUDRATE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) upload.speed)
endif endif
# fuses if you're using e.g. ISP # fuses if you're using e.g. ISP
ifndef ISP_LOCK_FUSE_PRE ifndef ISP_LOCK_FUSE_PRE
ISP_LOCK_FUSE_PRE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) bootloader.unlock_bits) ISP_LOCK_FUSE_PRE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) bootloader.unlock_bits)
endif endif
ifndef ISP_LOCK_FUSE_POST ifndef ISP_LOCK_FUSE_POST
ISP_LOCK_FUSE_POST = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) bootloader.lock_bits) ISP_LOCK_FUSE_POST = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) bootloader.lock_bits)
endif endif
ifndef ISP_HIGH_FUSE ifndef ISP_HIGH_FUSE
ISP_HIGH_FUSE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) bootloader.high_fuses) ISP_HIGH_FUSE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) bootloader.high_fuses)
endif endif
ifndef ISP_LOW_FUSE ifndef ISP_LOW_FUSE
ISP_LOW_FUSE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) bootloader.low_fuses) ISP_LOW_FUSE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) bootloader.low_fuses)
endif endif
ifndef ISP_EXT_FUSE ifndef ISP_EXT_FUSE
ISP_EXT_FUSE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) bootloader.extended_fuses) ISP_EXT_FUSE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) bootloader.extended_fuses)
endif endif
# Everything gets built in here # Everything gets built in here
@ -504,21 +504,21 @@ DEPS = $(LOCAL_OBJS:.o=.d)
# core sources # core sources
ifeq ($(strip $(NO_CORE)),) ifeq ($(strip $(NO_CORE)),)
ifdef ARDUINO_CORE_PATH ifdef ARDUINO_CORE_PATH
CORE_C_SRCS = $(wildcard $(ARDUINO_CORE_PATH)/*.c) CORE_C_SRCS = $(wildcard $(ARDUINO_CORE_PATH)/*.c)
CORE_CPP_SRCS = $(wildcard $(ARDUINO_CORE_PATH)/*.cpp) CORE_CPP_SRCS = $(wildcard $(ARDUINO_CORE_PATH)/*.cpp)
ifneq ($(strip $(NO_CORE_MAIN_CPP)),) ifneq ($(strip $(NO_CORE_MAIN_CPP)),)
CORE_CPP_SRCS := $(filter-out %main.cpp, $(CORE_CPP_SRCS)) CORE_CPP_SRCS := $(filter-out %main.cpp, $(CORE_CPP_SRCS))
$(call show_config_info,CORE_CPP_SRCS,[MODIFIED],(Modified by the variable NO_CORE_MAIN_CPP)) $(call show_config_info,CORE_CPP_SRCS,[MODIFIED],(Modified by the variable NO_CORE_MAIN_CPP))
endif endif
CORE_OBJ_FILES = $(CORE_C_SRCS:.c=.o) $(CORE_CPP_SRCS:.cpp=.o) CORE_OBJ_FILES = $(CORE_C_SRCS:.c=.o) $(CORE_CPP_SRCS:.cpp=.o)
CORE_OBJS = $(patsubst $(ARDUINO_CORE_PATH)/%, \ CORE_OBJS = $(patsubst $(ARDUINO_CORE_PATH)/%, \
$(OBJDIR)/%,$(CORE_OBJ_FILES)) $(OBJDIR)/%,$(CORE_OBJ_FILES))
endif endif
else else
$(call show_config_info,CORE_CPP_SRCS,[MODIFIED],(Modified by the variable NO_CORE)) $(call show_config_info,CORE_CPP_SRCS,[MODIFIED],(Modified by the variable NO_CORE))
endif endif
@ -575,31 +575,31 @@ LDFLAGS = -mmcu=$(MCU) -Wl,--gc-sections -Os
ARD_PORT = $(firstword $(wildcard $(ARDUINO_PORT))) ARD_PORT = $(firstword $(wildcard $(ARDUINO_PORT)))
ifndef SIZE_UTILITY_TYPE ifndef SIZE_UTILITY_TYPE
# Command for avr_size: do $(call avr_size,elffile,hexfile) # Command for avr_size: do $(call avr_size,elffile,hexfile)
ifneq (,$(findstring AVR,$(shell $(SIZE) --help))) ifneq (,$(findstring AVR,$(shell $(SIZE) --help)))
SIZE_UTILITY_TYPE = AVR_ENHANCED SIZE_UTILITY_TYPE = AVR_ENHANCED
else else
SIZE_UTILITY_TYPE = BASIC SIZE_UTILITY_TYPE = BASIC
endif endif
$(call show_config_info,SIZE_UTILITY_TYPE,[AUTODETECTED]) $(call show_config_info,SIZE_UTILITY_TYPE,[AUTODETECTED])
else else
$(call show_config_info,SIZE_UTILITY_TYPE,[MANUAL OVERRIDE],Warning - Manually overriding this is not recommended!) $(call show_config_info,SIZE_UTILITY_TYPE,[MANUAL OVERRIDE],Warning - Manually overriding this is not recommended!)
endif endif
ifeq ($(SIZE_UTILITY_TYPE),BASIC) ifeq ($(SIZE_UTILITY_TYPE),BASIC)
# We have a plain-old binutils version - just give it the hex. # We have a plain-old binutils version - just give it the hex.
avr_size = $(SIZE) $(2) avr_size = $(SIZE) $(2)
endif endif
ifeq ($(SIZE_UTILITY_TYPE),AVR_ENHANCED) ifeq ($(SIZE_UTILITY_TYPE),AVR_ENHANCED)
# We have a patched version of binutils that mentions AVR - pass the MCU # We have a patched version of binutils that mentions AVR - pass the MCU
# and the elf to get nice output. # and the elf to get nice output.
avr_size = $(SIZE) --mcu=$(MCU) --format=avr $(1) avr_size = $(SIZE) --mcu=$(MCU) --format=avr $(1)
endif endif
ifndef avr_size ifndef avr_size
$(error "We told you not to override SIZE_UTILITY_TYPE!") $(error "We told you not to override SIZE_UTILITY_TYPE!")
endif endif
# end of config output # end of config output
@ -709,18 +709,18 @@ $(OBJDIR)/%.sym: $(OBJDIR)/%.elf
# Avrdude # Avrdude
# #
ifndef AVRDUDE ifndef AVRDUDE
AVRDUDE = $(AVR_TOOLS_PATH)/avrdude AVRDUDE = $(AVR_TOOLS_PATH)/avrdude
endif endif
AVRDUDE_COM_OPTS = -q -V -p $(MCU) AVRDUDE_COM_OPTS = -q -V -p $(MCU)
ifdef AVRDUDE_CONF ifdef AVRDUDE_CONF
AVRDUDE_COM_OPTS += -C $(AVRDUDE_CONF) AVRDUDE_COM_OPTS += -C $(AVRDUDE_CONF)
endif endif
AVRDUDE_ARD_OPTS = -c $(AVRDUDE_ARD_PROGRAMMER) -b $(AVRDUDE_ARD_BAUDRATE) -P $(ARD_PORT) AVRDUDE_ARD_OPTS = -c $(AVRDUDE_ARD_PROGRAMMER) -b $(AVRDUDE_ARD_BAUDRATE) -P $(ARD_PORT)
ifndef ISP_PROG ifndef ISP_PROG
ISP_PROG = -c stk500v2 ISP_PROG = -c stk500v2
endif endif
AVRDUDE_ISP_OPTS = -P $(ISP_PORT) $(ISP_PROG) AVRDUDE_ISP_OPTS = -P $(ISP_PORT) $(ISP_PROG)