mirror of https://github.com/ArduPilot/ardupilot
More awk-related changes. mawk hangs on the parser scripts, so try gawk; it's what we'll need for cygwin anyway.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@1367 f9c3cf11-9bcb-44bc-f272-b75c42450872
This commit is contained in:
parent
0620d0c631
commit
6fe8418253
|
@ -116,6 +116,8 @@ endif
|
|||
ifeq ($(SYSTYPE),Darwin)
|
||||
# use the tools that come with Arduino
|
||||
TOOLPATH := $(ARDUINOS)/hardware/tools/avr/bin
|
||||
# use BWK awk
|
||||
AWK = awk
|
||||
endif
|
||||
ifeq ($(SYSTYPE),Linux)
|
||||
# expect that tools are on the path
|
||||
|
@ -123,16 +125,22 @@ ifeq ($(SYSTYPE),Linux)
|
|||
endif
|
||||
|
||||
FIND_TOOL = $(firstword $(wildcard $(addsuffix /$(1),$(TOOLPATH))))
|
||||
CXX = $(call FIND_TOOL,avr-g++)
|
||||
CC = $(call FIND_TOOL,avr-gcc)
|
||||
AS = $(call FIND_TOOL,avr-gcc)
|
||||
AR = $(call FIND_TOOL,avr-ar)
|
||||
LD = $(call FIND_TOOL,avr-gcc)
|
||||
OBJCOPY = $(call FIND_TOOL,avr-objcopy)
|
||||
CXX := $(call FIND_TOOL,avr-g++)
|
||||
CC := $(call FIND_TOOL,avr-gcc)
|
||||
AS := $(call FIND_TOOL,avr-gcc)
|
||||
AR := $(call FIND_TOOL,avr-ar)
|
||||
LD := $(call FIND_TOOL,avr-gcc)
|
||||
OBJCOPY := $(call FIND_TOOL,avr-objcopy)
|
||||
ifeq ($(CXX),)
|
||||
$(error ERROR: cannot find the compiler tools anywhere on the path $(TOOLPATH))
|
||||
endif
|
||||
|
||||
# Find awk
|
||||
AWK ?= gawk
|
||||
ifeq ($(shell which $(AWK)),)
|
||||
$(error ERROR: cannot find $(AWK) - you may need to install GNU awk)
|
||||
endif
|
||||
|
||||
#
|
||||
# Tool options
|
||||
#
|
||||
|
@ -419,11 +427,11 @@ $(CORELIB): $(CORELIBOBJS)
|
|||
#
|
||||
$(SKETCHCPP): $(SKETCHCPP_SRC) $(BUILDROOT)
|
||||
$(RULEHDR)
|
||||
$(v)awk -v mode=header '$(SKETCH_SPLITTER)' $(SKETCHCPP_SRC) > $@
|
||||
$(v)echo "#line 1 \"autogenerated\"" >> $@
|
||||
$(v)echo "#include \"WProgram.h\"" >> $@
|
||||
$(v)awk '$(SKETCH_PROTOTYPER)' $(SKETCHCPP_SRC) >> $@
|
||||
$(v)awk -v mode=body '$(SKETCH_SPLITTER)' $(SKETCHCPP_SRC) >> $@
|
||||
$(v)$(AWK) -v mode=header '$(SKETCH_SPLITTER)' $(SKETCHCPP_SRC) > $@
|
||||
$(v)echo "#line 1 \"autogenerated\"" >> $@
|
||||
$(v)echo "#include \"WProgram.h\"" >> $@
|
||||
$(v)$(AWK) '$(SKETCH_PROTOTYPER)' $(SKETCHCPP_SRC) >> $@
|
||||
$(v)$(AWK) -v mode=body '$(SKETCH_SPLITTER)' $(SKETCHCPP_SRC) >> $@
|
||||
|
||||
# delete the sketch.cpp file if a processing error occurs
|
||||
.DELETE_ON_ERROR: $(SKETCHCPP)
|
||||
|
@ -437,6 +445,8 @@ $(SKETCHCPP): $(SKETCHCPP_SRC) $(BUILDROOT)
|
|||
# Note that # and $ require special treatment here to avoid upsetting
|
||||
# make.
|
||||
#
|
||||
# This script requires BWK or GNU awk.
|
||||
#
|
||||
define SKETCH_SPLITTER
|
||||
BEGIN { \
|
||||
scanning = 1; \
|
||||
|
@ -446,10 +456,10 @@ define SKETCH_SPLITTER
|
|||
(FNR == 1) && printing { \
|
||||
printf "#line %d \"%s\"\n", FNR, FILENAME; \
|
||||
} \
|
||||
/^[ \t\n\r]*\/\*/,/\*\// { \
|
||||
/^[[:space:]]*\/\*/,/\*\// { \
|
||||
toggles = 0; \
|
||||
} \
|
||||
/^[ \t\n\r]*$$/ || /^[ \t\n\r]*\/\/.*/ || /^\#.*$$/ { \
|
||||
/^[[:space:]]*$$/ || /^[[:space:]]*\/\/.*/ || /^\#.*$$/ { \
|
||||
toggles = 0; \
|
||||
} \
|
||||
scanning && toggles { \
|
||||
|
@ -477,23 +487,16 @@ endef
|
|||
# and backslashes are doubled in the partial patterns to satisfy
|
||||
# escaping rules.
|
||||
#
|
||||
# The space/alnum variables are used to work around the lack of the
|
||||
# [:space:] and [:alnum:] classes in mawk, commonly found on Linux
|
||||
# systems. We cheat and sneak _ into the class as well.
|
||||
# This script requires BWK or GNU awk.
|
||||
#
|
||||
define SKETCH_PROTOTYPER
|
||||
BEGIN { \
|
||||
RS="{"; \
|
||||
space = "[ \\t\\n\\r]"; \
|
||||
spaces = space "+"; \
|
||||
spaceok = space "*"; \
|
||||
alnum = "[0-9a-zA-Z_]"; \
|
||||
alnums = alnum "+"; \
|
||||
type = "((\\n)|(^))" spaceok alnums spaces; \
|
||||
qualifiers = "([0-9a-zA-Z_\\*&]+" spaceok ")*"; \
|
||||
name = alnums spaceok; \
|
||||
args = "\\([ \\t\\n\\r0-9a-zA-Z_,&\\*\\[\\]]*\\)"; \
|
||||
bodycuddle = "[ \\t\\n\\r]*$$"; \
|
||||
type = "((\\n)|(^))[[:space:]]*[[:alnum:]_]+[[:space:]]+"; \
|
||||
qualifiers = "([[:alnum:]_\\*&]+[[:space:]]*)*"; \
|
||||
name = "[[:alnum:]_]+[[:space:]]*"; \
|
||||
args = "\\([[:space:][:alnum:]_,&\\*\\[\\]]*\\)"; \
|
||||
bodycuddle = "[[:space:]]*$$"; \
|
||||
pattern = type qualifiers name args bodycuddle; \
|
||||
} \
|
||||
match($$0, pattern) { \
|
||||
|
|
Loading…
Reference in New Issue