aboutsummaryrefslogtreecommitdiff
path: root/makefiles
diff options
context:
space:
mode:
authorpx4dev <px4@purgatory.org>2013-02-23 15:11:57 -0800
committerpx4dev <px4@purgatory.org>2013-02-23 22:01:00 -0800
commitddc405935e006569241be6a4aa02d4a6d6d5c56e (patch)
treeed5c1e1e34d2f4a78fc62b5e36da3e575d0b1a1f /makefiles
parentcde70da262bd8c48057024f952255ff8d9882e55 (diff)
downloadpx4-firmware-ddc405935e006569241be6a4aa02d4a6d6d5c56e.tar.gz
px4-firmware-ddc405935e006569241be6a4aa02d4a6d6d5c56e.tar.bz2
px4-firmware-ddc405935e006569241be6a4aa02d4a6d6d5c56e.zip
Cosmetic tweaks to variable output.
Comment on the need to retain the double-slash at the WORK_DIR boundary. More toolchain documentation.
Diffstat (limited to 'makefiles')
-rw-r--r--makefiles/firmware.mk19
-rw-r--r--makefiles/module.mk15
-rw-r--r--makefiles/nuttx.mk4
-rw-r--r--makefiles/setup.mk1
-rw-r--r--makefiles/toolchain_gnu-arm-eabi.mk84
5 files changed, 79 insertions, 44 deletions
diff --git a/makefiles/firmware.mk b/makefiles/firmware.mk
index 6eada6353..12fc20926 100644
--- a/makefiles/firmware.mk
+++ b/makefiles/firmware.mk
@@ -65,7 +65,7 @@ MK_DIR ?= $(dir $(lastword $(MAKEFILE_LIST)))
ifeq ($(PX4_BASE),)
export PX4_BASE := $(abspath $(MK_DIR)/..)
endif
-$(info PX4_BASE $(PX4_BASE))
+$(info % PX4_BASE = $(PX4_BASE))
#
# Set a default target so that included makefiles or errors here don't
@@ -93,7 +93,7 @@ $(error Can't find a config file called $(CONFIG) or $(PX4_MK_DIR)/config_$(CONF
endif
export CONFIG
include $(CONFIG_FILE)
-$(info CONFIG $(CONFIG))
+$(info % CONFIG = $(CONFIG))
#
# Sanity-check the BOARD variable and then get the board config.
@@ -110,7 +110,7 @@ $(error Config $(CONFIG) references board $(BOARD), but no board definition file
endif
export BOARD
include $(BOARD_FILE)
-$(info BOARD $(BOARD))
+$(info % BOARD = $(BOARD))
#
# If WORK_DIR is not set, create a 'build' directory next to the
@@ -120,7 +120,7 @@ PARENT_MAKEFILE := $(lastword $(filter-out $(lastword $(MAKEFILE_LIST)),$(MAKEF
ifeq ($(WORK_DIR),)
export WORK_DIR := $(dir $(PARENT_MAKEFILE))build/
endif
-$(info WORK_DIR $(WORK_DIR))
+$(info % WORK_DIR = $(WORK_DIR))
#
# Things that, if they change, might affect everything
@@ -164,7 +164,10 @@ ifneq ($(MISSING_MODULES),)
$(error Can't find module(s): $(MISSING_MODULES))
endif
-# make a list of the object files we expect to build from modules
+# Make a list of the object files we expect to build from modules
+# Note that this path will typically contain a double-slash at the WORK_DIR boundary; this must be
+# preserved as it is used below to get the absolute path for the module.mk file correct.
+#
MODULE_OBJS := $(foreach path,$(dir $(MODULE_MKFILES)),$(WORK_DIR)$(path)module.pre.o)
# rules to build module objects
@@ -252,7 +255,8 @@ endif
BUILTIN_CSRC = $(WORK_DIR)builtin_commands.c
# add command definitions from modules
-BUILTIN_COMMANDS += $(subst COMMAND.,,$(notdir $(wildcard $(WORK_DIR)builtin_commands/COMMAND.*)))
+BUILTIN_COMMAND_FILES := $(wildcard $(WORK_DIR)builtin_commands/COMMAND.*)
+BUILTIN_COMMANDS += $(subst COMMAND.,,$(notdir $(BUILTIN_COMMAND_FILES)))
ifneq ($(BUILTIN_COMMANDS),)
@@ -266,7 +270,8 @@ define BUILTIN_DEF
$(ECHO) ' {"$(word 1,$1)", $(word 2,$1), $(word 3,$1), $(word 4,$1)},' >> $2;
endef
-$(BUILTIN_CSRC): $(GLOBAL_DEPS)
+# Don't generate until modules have updated their command files
+$(BUILTIN_CSRC): $(GLOBAL_DEPS) $(BUILTIN_COMMAND_FILES)
@$(ECHO) %% generating $@
$(Q) $(ECHO) '/* builtin command list - automatically generated, do not edit */' > $@
$(Q) $(ECHO) '#include <nuttx/config.h>' >> $@
diff --git a/makefiles/module.mk b/makefiles/module.mk
index bf54362e6..c6ef90578 100644
--- a/makefiles/module.mk
+++ b/makefiles/module.mk
@@ -59,7 +59,7 @@
ifeq ($(MODULE_MK),)
$(error No module makefile specified)
endif
-$(info MODULE_MK $(MODULE_MK))
+$(info % MODULE_MK = $(MODULE_MK))
#
# Get path and tool config
@@ -76,8 +76,9 @@ include $(PX4_MK_DIR)/board_$(BOARD).mk
#
include $(MODULE_MK)
MODULE_SRC := $(dir $(MODULE_MK))
-$(info MODULE_SRC $(MODULE_SRC))
-$(info MODULE_WORK_DIR $(MODULE_WORK_DIR))
+$(info % MODULE_SRC = $(MODULE_SRC))
+$(info % MODULE_OBJ = $(MODULE_OBJ))
+$(info % MODULE_WORK_DIR = $(MODULE_WORK_DIR))
#
# Things that, if they change, might affect everything
@@ -98,9 +99,15 @@ endif
ifneq ($(MODULE_COMMANDS),)
MODULE_COMMAND_FILES := $(addprefix $(WORK_DIR)/builtin_commands/COMMAND.,$(MODULE_COMMANDS))
+# Create the command files
+# Ensure that there is only one entry for each command
+#
.PHONY: $(MODULE_COMMAND_FILES)
+$(MODULE_COMMAND_FILES): command = $(word 2,$(subst ., ,$(notdir $(@))))
+$(MODULE_COMMAND_FILES): exclude = $(dir $@)COMMAND.$(command).*
$(MODULE_COMMAND_FILES): $(GLOBAL_DEPS)
- @$(ECHO) COMMAND $(word 2,$(subst ., ,$(notdir $(@))))
+ @$(ECHO) COMMAND: $(command)
+ @$(REMOVE) -f $(exclude)
@$(MKDIR) -p $(dir $@)
$(Q) $(TOUCH) $@
endif
diff --git a/makefiles/nuttx.mk b/makefiles/nuttx.mk
index e71993916..f21ba9eda 100644
--- a/makefiles/nuttx.mk
+++ b/makefiles/nuttx.mk
@@ -18,8 +18,8 @@ endif
#
NUTTX_EXPORT_DIR = $(WORK_DIR)nuttx-export/
NUTTX_CONFIG_HEADER = $(NUTTX_EXPORT_DIR)include/nuttx/config.h
-$(info NUTTX_EXPORT_DIR $(NUTTX_EXPORT_DIR))
-$(info NUTTX_CONFIG_HEADER $(NUTTX_CONFIG_HEADER))
+$(info % NUTTX_EXPORT_DIR = $(NUTTX_EXPORT_DIR))
+$(info % NUTTX_CONFIG_HEADER = $(NUTTX_CONFIG_HEADER))
GLOBAL_DEPS += $(NUTTX_CONFIG_HEADER)
diff --git a/makefiles/setup.mk b/makefiles/setup.mk
index f67ab7bb0..e9e591cd7 100644
--- a/makefiles/setup.mk
+++ b/makefiles/setup.mk
@@ -48,4 +48,3 @@ endif
# Makefile debugging.
#
export Q := $(if $(V),,@)
-
diff --git a/makefiles/toolchain_gnu-arm-eabi.mk b/makefiles/toolchain_gnu-arm-eabi.mk
index 108476782..ac53b0369 100644
--- a/makefiles/toolchain_gnu-arm-eabi.mk
+++ b/makefiles/toolchain_gnu-arm-eabi.mk
@@ -4,6 +4,8 @@
#$(info TOOLCHAIN gnu-arm-eabi)
+# Toolchain commands. Normally only used inside this file.
+#
CROSSDEV = arm-none-eabi-
CC = $(CROSSDEV)gcc
@@ -19,7 +21,8 @@ OBJDUMP = $(CROSSDEV)objdump
MAXOPTIMIZATION = -O3
-# base CPU flags
+# Base CPU flags for each of the supported architectures.
+#
ARCHCPUFLAGS_CORTEXM4F = -mcpu=cortex-m4 \
-mthumb \
-march=armv7e-m \
@@ -36,12 +39,15 @@ ARCHCPUFLAGS_CORTEXM3 = -mcpu=cortex-m3 \
-march=armv7-m \
-mfloat-abi=soft
+# Pick the right set of flags for the architecture.
+#
ARCHCPUFLAGS = $(ARCHCPUFLAGS_$(CONFIG_ARCH))
ifeq ($(ARCHCPUFLAGS),)
$(error Must set CONFIG_ARCH to one of CORTEXM4F, CORTEXM4 or CORTEXM3)
endif
# optimisation flags
+#
ARCHOPTIMIZATION = $(MAXOPTIMIZATION) \
-g \
-fno-strict-aliasing \
@@ -56,9 +62,13 @@ ARCHOPTIMIZATION = $(MAXOPTIMIZATION) \
# note - requires corresponding support in NuttX
INSTRUMENTATIONDEFINES = -finstrument-functions \
-ffixed-r10
-
+# Language-specific flags
+#
ARCHCFLAGS = -std=gnu99
ARCHCXXFLAGS = -fno-exceptions -fno-rtti -std=gnu++0x
+
+# Generic warnings
+#
ARCHWARNINGS = -Wall \
-Wextra \
-Wdouble-promotion \
@@ -74,6 +84,8 @@ ARCHWARNINGS = -Wall \
# -Wconversion - would be nice, but too many "risky-but-safe" conversions in the code
# -Wcast-align - would help catch bad casts in some cases, but generates too many false positives
+# C-specific warnings
+#
ARCHCWARNINGS = $(ARCHWARNINGS) \
-Wbad-function-cast \
-Wstrict-prototypes \
@@ -82,12 +94,17 @@ ARCHCWARNINGS = $(ARCHWARNINGS) \
-Wmissing-prototypes \
-Wnested-externs \
-Wunsuffixed-float-constants
+
+# C++-specific warnings
+#
ARCHWARNINGSXX = $(ARCHWARNINGS)
# pull in *just* libm from the toolchain ... this is grody
LIBM := $(shell $(CC) $(ARCHCPUFLAGS) -print-file-name=libm.a)
EXTRA_LIBS += $(LIBM)
+# Flags we pass to the C compiler
+#
CFLAGS = $(ARCHCFLAGS) \
$(ARCHCWARNINGS) \
$(ARCHOPTIMIZATION) \
@@ -99,6 +116,8 @@ CFLAGS = $(ARCHCFLAGS) \
-fno-common \
$(addprefix -I,$(INCLUDE_DIRS))
+# Flags we pass to the C++ compiler
+#
CXXFLAGS = $(ARCHCXXFLAGS) \
$(ARCHWARNINGSXX) \
$(ARCHOPTIMIZATION) \
@@ -109,76 +128,83 @@ CXXFLAGS = $(ARCHCXXFLAGS) \
$(EXTRADEFINES) \
$(addprefix -I,$(INCLUDE_DIRS))
-CPPFLAGS = $(ARCHINCLUDES) \
- $(INSTRUMENTATIONDEFINES) \
- $(ARCHDEFINES) \
- $(EXTRADEFINES) \
- $(addprefix -I,$(INCLUDE_DIRS))
-
+# Flags we pass to the assembler
+#
AFLAGS = $(CFLAGS) -D__ASSEMBLY__
+# Flags we pass to the linker
+#
LDFLAGS += --warn-common \
--gc-sections \
$(addprefix -T,$(LDSCRIPT)) \
$(addprefix -L,$(LIB_DIRS))
+# Compiler support library
+#
LIBGCC := $(shell $(CC) $(ARCHCPUFLAGS) -print-libgcc-file-name)
-# files that the final link depends on
-# XXX add libraries that we know about here...
+# Files that the final link depends on
+#
LINK_DEPS += $(LDSCRIPT)
-# files to include to get automated dependencies
+# Files to include to get automated dependencies
+#
DEP_INCLUDES = $(subst .o,.d,$(OBJS))
-# compile C source $1 to object $2
+# Compile C source $1 to object $2
# as a side-effect, generate a dependency file
+#
define COMPILE
- @$(ECHO) "CC <- $1"
- @$(ECHO) "CC -> $2"
+ @$(ECHO) "CC: $1"
@$(MKDIR) -p $(dir $2)
$(Q) $(CC) -MD -c $(CFLAGS) $(abspath $1) -o $2
endef
-# compile C++ source $1 to $2
+# Compile C++ source $1 to $2
# as a side-effect, generate a dependency file
+#
define COMPILEXX
- @$(ECHO) "CXX: $1"
+ @$(ECHO) "CXX: $1"
@$(MKDIR) -p $(dir $2)
$(Q) $(CXX) -MD -c $(CXXFLAGS) $(abspath $1) -o $2
endef
-# assemble $1 into $2
+# Assemble $1 into $2
+#
define ASSEMBLE
- @$(ECHO) "AS: $1"
+ @$(ECHO) "AS: $1"
@$(MKDIR) -p $(dir $2)
$(Q) $(CC) -c $(AFLAGS) $(abspath $1) -o $2
endef
-# produce partially-linked $1 from files in $2
+# Produce partially-linked $1 from files in $2
+#
define PRELINK
@$(ECHO) "PRELINK: $1"
@$(MKDIR) -p $(dir $1)
$(Q) $(LD) -Ur -o $1 $2 && $(OBJCOPY) --localize-hidden $1
endef
-# update the archive $1 with the files in $2
+# Update the archive $1 with the files in $2
+#
define ARCHIVE
- @$(ECHO) "AR: $2"
+ @$(ECHO) "AR: $2"
@$(MKDIR) -p $(dir $1)
$(Q) $(AR) $1 $2
endef
-# link the objects in $2 into the binary $1
+# Link the objects in $2 into the binary $1
+#
define LINK
- @$(ECHO) "LINK: $1"
+ @$(ECHO) "LINK: $1"
@$(MKDIR) -p $(dir $1)
$(Q) $(LD) $(LDFLAGS) -o $1 --start-group $2 $(LIBS) $(EXTRA_LIBS) $(LIBGCC) --end-group
endef
-# convert $1 from a linked object to a raw binary in $2
+# Convert $1 from a linked object to a raw binary in $2
+#
define SYM_TO_BIN
- @$(ECHO) "BIN: $2"
+ @$(ECHO) "BIN: $2"
@$(MKDIR) -p $(dir $2)
$(Q) $(OBJCOPY) -O binary $1 $2
endef
@@ -195,15 +221,13 @@ define BIN_SYM_PREFIX
_binary_$(subst /,_,$(subst .,_,$1))
endef
define BIN_TO_OBJ
- @$(ECHO) "WRAP: $2"
+ @$(ECHO) "OBJ: $2"
@$(MKDIR) -p $(dir $2)
$(Q) $(ECHO) > $2.c
$(call COMPILE,$2.c,$2.c.o)
- $(LD) -r -o $2 $2.c.o -b binary $1
- $(OBJCOPY) $2 \
+ $(Q) $(LD) -r -o $2 $2.c.o -b binary $1
+ $(Q) $(OBJCOPY) $2 \
--redefine-sym $(call BIN_SYM_PREFIX,$1)_start=$3 \
--redefine-sym $(call BIN_SYM_PREFIX,$1)_size=$3_len \
--strip-symbol $(call BIN_SYM_PREFIX,$1)_end
endef
-
-# $(Q) $(OBJCOPY) --add-section .rodata.$3=$1 $2