build: cope with Arduino 1.0 in command line build

this should autodetect 1.0 versus older builds
This commit is contained in:
Andrew Tridgell 2012-04-27 15:27:26 +10:00
parent 453cb93c6f
commit 4f90e6e844
2 changed files with 32 additions and 15 deletions

View File

@ -0,0 +1,22 @@
#!/bin/sh
# find arduino version
ARDUINO=$1
if test -f $ARDUINO/lib/version.txt; then
# arduino 1.0 uses this file
ver=$(head -1 $ARDUINO/lib/version.txt | cut -c1-4)
# cope with pre 1.0 versions
leading=$(echo $ver | cut -c1)
if [ "$leading" = "0" ]; then
echo $ver
exit 0
fi
major=$(echo $ver | cut -d. -f1)
minor=$(echo $ver | cut -d. -f2)
v=$(expr $major \* 100 + $minor)
echo $v
elif test -f $ARDUINO/revisions.txt; then
ARDUINO_VER=$(head -1 $ARDUINO/revisions.txt | cut -d' ' -f 2)
else
echo "UNKNOWN"
fi

View File

@ -333,17 +333,8 @@ LIBOBJS := $(SKETCHLIBOBJS) $(ARDUINOLIBOBJS)
# *duino core
#
# Pull the Arduino version from the revisions.txt file
#
# XXX can we count on this? If not, what?
ARDUINO_VERS := $(shell expr `head -1 $(ARDUINO)/revisions.txt | cut -d ' ' -f 2`)
# If the version is not a number, try it again, using another file
ifneq ($(ARDUINO_VERS),$(shell echo $(ARDUINO_VERS) | sed 's/[^0-9]*//g'))
ARDUINO_VERS := $(shell expr `head -1 $(ARDUINO)/lib/version.txt | cut -d ' ' -f 2`)
endif
ifneq ($(ARDUINO_VERS),$(shell echo $(ARDUINO_VERS) | sed 's/[^0-9]*//g'))
$(warning Could not determine Arduino version)
endif
# Pull the Arduino version
ARDUINO_VERS := $(shell $(SKETCHBOOK)/Tools/scripts/arduino_version.sh $(ARDUINO))
# Find the hardware directory to use
HARDWARE_DIR := $(firstword $(wildcard $(SKETCHBOOK)/hardware/$(HARDWARE) \
@ -384,7 +375,7 @@ CORESRC_PATTERNS = $(foreach suffix,/*.cpp /*.c /*.S,$(addsuffix $(suffix),$(COR
CORESRCS := $(wildcard $(CORESRC_PATTERNS))
# Include spec for core includes
COREINCLUDES = -I$(CORESRC_DIR)
COREINCLUDES = -I$(CORESRC_DIR) -I$(HARDWARE_DIR)/variants/mega
# Hardware object files
CORELIBOBJS := $(subst $(CORESRC_DIR),$(BUILDROOT)/$(HARDWARE),$(CORESRCS))
@ -543,15 +534,15 @@ $(BUILDROOT)/libraries/%.o: $(ARDUINO)/libraries/%.S
#
$(BUILDROOT)/$(HARDWARE)/%.o: $(CORESRC_DIR)/%.cpp
$(RULEHDR)
$(v)$(CXX) $(filter-out -W%,$(CXXFLAGS)) -c -o $@ $< -I$(CORESRC_DIR)
$(v)$(CXX) $(filter-out -W%,$(CXXFLAGS)) -c -o $@ $< $(COREINCLUDES)
$(BUILDROOT)/$(HARDWARE)/%.o: $(CORESRC_DIR)/%.c
@mkdir -p $(dir $@)
$(v)$(CC) $(filter-out -W%,$(CFLAGS)) -c -o $@ $< -I$(CORESRC_DIR)
$(v)$(CC) $(filter-out -W%,$(CFLAGS)) -c -o $@ $< $(COREINCLUDES)
$(BUILDROOT)/$(HARDWARE)/%.o: $(CORESRC_DIR)/%.S
$(RULEHDR)
$(v)$(AS) $(ASFLAGS) -c -o $@ $< -I$(CORESRC_DIR)
$(v)$(AS) $(ASFLAGS) -c -o $@ $< $(COREINCLUDES)
#
# Build the core library
@ -581,7 +572,11 @@ $(SKETCHCPP): $(SKETCHCPP_SRC)
$(RULEHDR)
$(v)$(AWK) -v mode=header '$(SKETCH_SPLITTER)' $(SKETCHCPP_SRC) > $@
$(v)echo "#line 1 \"autogenerated\"" >> $@
$(v)echo "#if defined(ARDUINO) && ARDUINO >= 100" >> $@
$(v)echo "#include \"Arduino.h\"" >> $@
$(v)echo "#else" >> $@
$(v)echo "#include \"WProgram.h\"" >> $@
$(v)echo "#endif" >> $@
$(v)$(AWK) '$(SKETCH_PROTOTYPER)' $(SKETCHCPP_SRC) >> $@
$(v)$(AWK) -v mode=body '$(SKETCH_SPLITTER)' $(SKETCHCPP_SRC) >> $@