2013-03-11 22:39:28 +01:00
|
|
|
#
|
|
|
|
# Copyright (c) 2010-2013, The OpenPilot Team, http://www.openpilot.org
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful, but
|
|
|
|
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
# for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License along
|
|
|
|
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
#
|
|
|
|
|
|
|
|
ifndef OPENPILOT_IS_COOL
|
|
|
|
$(error Top level Makefile must be used to build this target)
|
|
|
|
endif
|
2011-02-23 05:18:53 +01:00
|
|
|
|
|
|
|
# Define toolchain component names.
|
2013-03-11 22:39:28 +01:00
|
|
|
CC = $(ARM_SDK_PREFIX)gcc
|
|
|
|
CXX = $(ARM_SDK_PREFIX)g++
|
|
|
|
AR = $(ARM_SDK_PREFIX)ar
|
|
|
|
OBJCOPY = $(ARM_SDK_PREFIX)objcopy
|
|
|
|
OBJDUMP = $(ARM_SDK_PREFIX)objdump
|
|
|
|
SIZE = $(ARM_SDK_PREFIX)size
|
|
|
|
NM = $(ARM_SDK_PREFIX)nm
|
|
|
|
STRIP = $(ARM_SDK_PREFIX)strip
|
2011-02-23 05:18:53 +01:00
|
|
|
|
|
|
|
THUMB = -mthumb
|
|
|
|
|
2012-06-03 02:31:57 +02:00
|
|
|
# Add a board designator to the terse message text
|
|
|
|
ifeq ($(ENABLE_MSG_EXTRA),yes)
|
2013-03-11 22:39:28 +01:00
|
|
|
MSG_EXTRA := [$(BUILD_TYPE)|$(BOARD_SHORT_NAME)]
|
2012-06-03 02:31:57 +02:00
|
|
|
else
|
2013-03-11 22:39:28 +01:00
|
|
|
MSG_EXTRA :=
|
2012-06-03 02:31:57 +02:00
|
|
|
endif
|
|
|
|
|
2011-02-23 05:18:53 +01:00
|
|
|
# Define Messages
|
Final step: lot of small fixes, last commit in this commit series
This is the first cleanup pass through makefiles and pios.
Probably it is difficult to track changes due to the nature of them.
I would recommend to look at resulting files and compiled code instead.
NOTE: original branch was rebased and lot of conflicts were fixed on
the way. So do not expect that every commit in this series will be
buildable (unlike original branch). Only final result was tested.
The main goal was to remove as much duplication of code (and copy/paste
errors) as possible, moving common parts out of Makefiles. It still is
not perfect, and mostly no code changes made - Makefiles and #ifdefs only.
But please while testing make sure that all code works as before, and no
modules/options are missed by accident.
Brief list of changes:
- Moved common parts of Makefiles into the set of *.mk files.
- Changed method of passing common vars from top Makefile to lower ones.
- Some pios cleanup, mostly #ifdefs, and all pios_config.h files.
- Many obsolete files removed (for instance, AHRS files, op_config.h).
- Many obsolete or unused macros removed or fixed/renamed (ALL_DIGNOSTICS).
- Unified pios_config.h template. Please don't remove lines for board
configs, only comment/uncomment them. Adding new PIOS options, please
propagate them to all board files keeping the same order.
- Some formatting, spacing, indentation (no line endings change yet).
- Some cosmetic fixes (no more C:\X\Y\filename.c printings on Windows).
- Added some library.mk files to move libs into AR achives later.
- EntireFlash target now uses cross-platform python script to generate bin
files. So it works on all supported platforms: Linux, OSX, Windows.
- Top level packaging is completely rewritten. Now it is a part of top
Makefile. As such, all dependencies are checked and accounted, no
more 'make -j' problems should occur.
- Default GCS_BUILD_CONF is release now, may be changed if necessary
using 'make GCS_BUILD_CONF=debug gcs'.
- GCS build paths are separated into debug and release, so no more obj
file clashes. Packaging system supports only release builds.
- New target is introduced: 'clean_package'. Now 'make package' does not
clean build directory. Use clean_package instead for distributable builds.
- Targets like 'all', 'opfw_resource', etc now will print extra contex
in parallel builds too.
- If any of 'package', 'clean_package', 'opfw_resource' targets are given
on command line, GCS build will depend on the resource, so all fw_*.opfw
targets will be built and embedded into GCS. By default GCS does not
depend on resource, and will be built w/o firmware (unless the resource
files already exist and the Qt resource file is generated).
- fw_simposix (ELF executable) is now packaged for linux. Run'n'play!
- Make help is refined and is now up to date.
Still broken:
- UnitTests, should be fixed
- SimPosix: buildable, but should be reworked.
Next planned passes to do:
- toolchain bootstrapping and packaging (including windows - WIP)
- CMSIS/StdPeriph lib cleanup
- more PIOS cleanup
- move libs into AR archives to save build time
- sim targets refactir and cleanup
- move android-related directories under <top>/android
- unit test targets fix
- source code line ending changes (there are many different, were not changed)
- coding style
Merging this, please use --no-ff git option to make it the real commit point
Conflicts:
A lot of... :-)
2013-03-24 12:02:08 +01:00
|
|
|
MSG_FORMATERROR = $(QUOTE) Can not handle output-format$(QUOTE)
|
|
|
|
MSG_MODINIT = $(QUOTE) MODINIT $(MSG_EXTRA) $(QUOTE)
|
|
|
|
MSG_SIZE = $(QUOTE) SIZE $(MSG_EXTRA) $(QUOTE)
|
|
|
|
MSG_LOAD_FILE = $(QUOTE) BIN/HEX $(MSG_EXTRA) $(QUOTE)
|
|
|
|
MSG_BIN_OBJ = $(QUOTE) BINO $(MSG_EXTRA) $(QUOTE)
|
|
|
|
MSG_STRIP_FILE = $(QUOTE) STRIP $(MSG_EXTRA) $(QUOTE)
|
|
|
|
MSG_EXTENDED_LISTING = $(QUOTE) LIS $(MSG_EXTRA) $(QUOTE)
|
|
|
|
MSG_SYMBOL_TABLE = $(QUOTE) NM $(MSG_EXTRA) $(QUOTE)
|
|
|
|
MSG_ARCHIVING = $(QUOTE) AR $(MSG_EXTRA) $(QUOTE)
|
|
|
|
MSG_LINKING = $(QUOTE) LD $(MSG_EXTRA) $(QUOTE)
|
|
|
|
MSG_COMPILING = $(QUOTE) CC $(MSG_EXTRA) $(QUOTE)
|
|
|
|
MSG_COMPILING_ARM = $(QUOTE) CC-ARM $(MSG_EXTRA) $(QUOTE)
|
|
|
|
MSG_COMPILINGCXX = $(QUOTE) CXX $(MSG_EXTRA) $(QUOTE)
|
|
|
|
MSG_COMPILINGCXX_ARM = $(QUOTE) CXX-ARM $(MSG_EXTRA) $(QUOTE)
|
|
|
|
MSG_ASSEMBLING = $(QUOTE) AS $(MSG_EXTRA) $(QUOTE)
|
|
|
|
MSG_ASSEMBLING_ARM = $(QUOTE) AS-ARM $(MSG_EXTRA) $(QUOTE)
|
|
|
|
MSG_CLEANING = $(QUOTE) CLEAN $(MSG_EXTRA) $(QUOTE)
|
|
|
|
MSG_ASMFROMC = $(QUOTE) AS(C) $(MSG_EXTRA) $(QUOTE)
|
|
|
|
MSG_ASMFROMC_ARM = $(QUOTE) AS(C)-ARM $(MSG_EXTRA) $(QUOTE)
|
|
|
|
MSG_PYMITEINIT = $(QUOTE) PY $(MSG_EXTRA) $(QUOTE)
|
|
|
|
MSG_OPFIRMWARE = $(QUOTE) OPFW $(MSG_EXTRA) $(QUOTE)
|
|
|
|
MSG_FWINFO = $(QUOTE) FWINFO $(MSG_EXTRA) $(QUOTE)
|
|
|
|
MSG_JTAG_PROGRAM = $(QUOTE) JTAG-PGM $(MSG_EXTRA) $(QUOTE)
|
|
|
|
MSG_JTAG_WIPE = $(QUOTE) JTAG-WIPE $(MSG_EXTRA) $(QUOTE)
|
|
|
|
MSG_PADDING = $(QUOTE) PADDING $(MSG_EXTRA) $(QUOTE)
|
|
|
|
MSG_FLASH_IMG = $(QUOTE) FLASH_IMG $(MSG_EXTRA) $(QUOTE)
|
2013-03-11 22:39:28 +01:00
|
|
|
|
|
|
|
# Function for converting an absolute path to one relative
|
|
|
|
# to the top of the source tree.
|
|
|
|
toprel = $(subst $(realpath $(ROOT_DIR))/,,$(abspath $(1)))
|
2011-02-23 05:18:53 +01:00
|
|
|
|
|
|
|
# Display compiler version information.
|
|
|
|
.PHONY: gccversion
|
2013-03-11 20:54:36 +01:00
|
|
|
gccversion:
|
2011-02-23 05:18:53 +01:00
|
|
|
@$(CC) --version
|
|
|
|
|
|
|
|
# Create final output file (.hex) from ELF output file.
|
|
|
|
%.hex: %.elf
|
2013-03-11 22:39:28 +01:00
|
|
|
@$(ECHO) $(MSG_LOAD_FILE) $(call toprel, $@)
|
2011-02-23 05:18:53 +01:00
|
|
|
$(V1) $(OBJCOPY) -O ihex $< $@
|
|
|
|
|
2011-04-11 03:34:00 +02:00
|
|
|
# Create stripped output file (.elf.stripped) from ELF output file.
|
|
|
|
%.elf.stripped: %.elf
|
2013-03-11 22:39:28 +01:00
|
|
|
@$(ECHO) $(MSG_STRIP_FILE) $(call toprel, $@)
|
2011-04-11 03:34:00 +02:00
|
|
|
$(V1) $(STRIP) --strip-unneeded $< -o $@
|
|
|
|
|
2011-02-23 05:18:53 +01:00
|
|
|
# Create final output file (.bin) from ELF output file.
|
|
|
|
%.bin: %.elf
|
2013-03-11 22:39:28 +01:00
|
|
|
@$(ECHO) $(MSG_LOAD_FILE) $(call toprel, $@)
|
2011-02-23 05:18:53 +01:00
|
|
|
$(V1) $(OBJCOPY) -O binary $< $@
|
|
|
|
|
2011-05-21 19:55:15 +02:00
|
|
|
%.bin: %.o
|
2013-03-11 22:39:28 +01:00
|
|
|
@$(ECHO) $(MSG_LOAD_FILE) $(call toprel, $@)
|
2011-05-21 19:55:15 +02:00
|
|
|
$(V1) $(OBJCOPY) -O binary $< $@
|
|
|
|
|
2015-02-19 22:23:40 +01:00
|
|
|
replace_special_chars = $(subst ~,_,$(subst @,_,$(subst :,_,$(subst -,_,$(subst .,_,$(subst /,_,$1))))))
|
2011-03-26 13:37:44 +01:00
|
|
|
%.bin.o: %.bin
|
2013-03-11 22:39:28 +01:00
|
|
|
@$(ECHO) $(MSG_BIN_OBJ) $(call toprel, $@)
|
2011-03-26 13:37:44 +01:00
|
|
|
$(V1) $(OBJCOPY) -I binary -O elf32-littlearm --binary-architecture arm \
|
|
|
|
--rename-section .data=.rodata,alloc,load,readonly,data,contents \
|
|
|
|
--wildcard \
|
2013-06-19 17:54:37 +02:00
|
|
|
--redefine-sym _binary_$(call replace_special_chars,$<)_start=_binary_start \
|
|
|
|
--redefine-sym _binary_$(call replace_special_chars,$<)_end=_binary_end \
|
|
|
|
--redefine-sym _binary_$(call replace_special_chars,$<)_size=_binary_size \
|
2011-03-26 13:37:44 +01:00
|
|
|
$< $@
|
|
|
|
|
2011-02-23 05:18:53 +01:00
|
|
|
# Create extended listing file/disassambly from ELF output file.
|
|
|
|
# using objdump testing: option -C
|
|
|
|
%.lss: %.elf
|
2013-03-11 22:39:28 +01:00
|
|
|
@$(ECHO) $(MSG_EXTENDED_LISTING) $(call toprel, $@)
|
2011-02-23 05:18:53 +01:00
|
|
|
$(V1) $(OBJDUMP) -h -S -C -r $< > $@
|
|
|
|
|
|
|
|
# Create a symbol table from ELF output file.
|
|
|
|
%.sym: %.elf
|
2013-03-11 22:39:28 +01:00
|
|
|
@$(ECHO) $(MSG_SYMBOL_TABLE) $(call toprel, $@)
|
2011-02-23 05:18:53 +01:00
|
|
|
$(V1) $(NM) -n $< > $@
|
|
|
|
|
|
|
|
define SIZE_TEMPLATE
|
2011-05-24 07:10:31 +02:00
|
|
|
.PHONY: size
|
|
|
|
size: $(1)_size
|
|
|
|
|
2011-02-23 05:18:53 +01:00
|
|
|
.PHONY: $(1)_size
|
|
|
|
$(1)_size: $(1)
|
2013-03-11 22:39:28 +01:00
|
|
|
@$(ECHO) $(MSG_SIZE) $$(call toprel, $$<)
|
2011-02-23 05:18:53 +01:00
|
|
|
$(V1) $(SIZE) -A $$<
|
|
|
|
endef
|
|
|
|
|
2011-05-21 19:55:15 +02:00
|
|
|
# OpenPilot firmware image template
|
|
|
|
# $(1) = path to bin file
|
|
|
|
# $(2) = boardtype in hex
|
|
|
|
# $(3) = board revision in hex
|
2011-05-25 06:20:02 +02:00
|
|
|
define OPFW_TEMPLATE
|
2011-05-25 06:27:16 +02:00
|
|
|
FORCE:
|
|
|
|
|
2013-05-20 00:12:45 +02:00
|
|
|
$(1).firmware_info.c: $(1) $(ROOT_DIR)/flight/templates/firmware_info.c.template FORCE
|
2013-03-11 22:39:28 +01:00
|
|
|
@$(ECHO) $(MSG_FWINFO) $$(call toprel, $$@)
|
|
|
|
$(V1) $(VERSION_INFO) \
|
2013-05-20 00:12:45 +02:00
|
|
|
--template=$(ROOT_DIR)/flight/templates/firmware_info.c.template \
|
2011-05-21 19:55:15 +02:00
|
|
|
--outfile=$$@ \
|
|
|
|
--image=$(1) \
|
|
|
|
--type=$(2) \
|
2012-09-15 00:31:13 +02:00
|
|
|
--revision=$(3) \
|
2013-03-11 22:39:28 +01:00
|
|
|
--uavodir=$(ROOT_DIR)/shared/uavobjectdefinition
|
2011-05-21 19:55:15 +02:00
|
|
|
|
2013-04-30 02:02:36 +02:00
|
|
|
$(eval $(call COMPILE_C_TEMPLATE, $(1).firmware_info.c))
|
2011-05-21 19:55:15 +02:00
|
|
|
|
2013-04-30 02:02:36 +02:00
|
|
|
$(OUTDIR)/$(notdir $(basename $(1))).opfw : $(1) $(1).firmware_info.bin
|
2013-03-11 22:39:28 +01:00
|
|
|
@$(ECHO) $(MSG_OPFIRMWARE) $$(call toprel, $$@)
|
2013-04-30 02:02:36 +02:00
|
|
|
$(V1) $(CAT) $(1) $(1).firmware_info.bin > $$@
|
2011-05-21 19:55:15 +02:00
|
|
|
endef
|
|
|
|
|
2011-02-23 05:18:53 +01:00
|
|
|
# Assemble: create object files from assembler source files.
|
|
|
|
define ASSEMBLE_TEMPLATE
|
|
|
|
$(OUTDIR)/$(notdir $(basename $(1))).o : $(1)
|
2013-03-11 22:39:28 +01:00
|
|
|
@$(ECHO) $(MSG_ASSEMBLING) $$(call toprel, $$<)
|
2012-03-22 18:50:33 +01:00
|
|
|
$(V1) $(CC) -c $(THUMB) $$(ASFLAGS) $$< -o $$@
|
2011-02-23 05:18:53 +01:00
|
|
|
endef
|
|
|
|
|
|
|
|
# Assemble: create object files from assembler source files. ARM-only
|
|
|
|
define ASSEMBLE_ARM_TEMPLATE
|
|
|
|
$(OUTDIR)/$(notdir $(basename $(1))).o : $(1)
|
2013-03-11 22:39:28 +01:00
|
|
|
@$(ECHO) $(MSG_ASSEMBLING_ARM) $$(call toprel, $$<)
|
2011-02-23 05:18:53 +01:00
|
|
|
$(V1) $(CC) -c $$(ASFLAGS) $$< -o $$@
|
|
|
|
endef
|
|
|
|
|
|
|
|
# Compile: create object files from C source files.
|
|
|
|
define COMPILE_C_TEMPLATE
|
|
|
|
$(OUTDIR)/$(notdir $(basename $(1))).o : $(1)
|
2013-03-11 22:39:28 +01:00
|
|
|
@$(ECHO) $(MSG_COMPILING) $$(call toprel, $$<)
|
2012-03-22 18:50:33 +01:00
|
|
|
$(V1) $(CC) -c $(THUMB) $$(CFLAGS) $$(CONLYFLAGS) $$< -o $$@
|
2011-02-23 05:18:53 +01:00
|
|
|
endef
|
|
|
|
|
|
|
|
# Compile: create object files from C source files. ARM-only
|
|
|
|
define COMPILE_C_ARM_TEMPLATE
|
|
|
|
$(OUTDIR)/$(notdir $(basename $(1))).o : $(1)
|
2013-03-11 22:39:28 +01:00
|
|
|
@$(ECHO) $(MSG_COMPILING_ARM) $$(call toprel, $$<)
|
2011-02-23 05:18:53 +01:00
|
|
|
$(V1) $(CC) -c $$(CFLAGS) $$(CONLYFLAGS) $$< -o $$@
|
|
|
|
endef
|
|
|
|
|
|
|
|
# Compile: create object files from C++ source files.
|
2012-12-18 06:56:40 +01:00
|
|
|
define COMPILE_CXX_TEMPLATE
|
2011-02-23 05:18:53 +01:00
|
|
|
$(OUTDIR)/$(notdir $(basename $(1))).o : $(1)
|
2013-03-11 22:39:28 +01:00
|
|
|
@$(ECHO) $(MSG_COMPILINGCXX) $$(call toprel, $$<)
|
2012-12-18 06:56:40 +01:00
|
|
|
$(V1) $(CXX) -c $(THUMB) $$(CFLAGS) $$(CPPFLAGS) $$(CXXFLAGS) $$< -o $$@
|
2011-02-23 05:18:53 +01:00
|
|
|
endef
|
|
|
|
|
|
|
|
# Compile: create object files from C++ source files. ARM-only
|
2012-12-18 06:56:40 +01:00
|
|
|
define COMPILE_CXX_ARM_TEMPLATE
|
2011-02-23 05:18:53 +01:00
|
|
|
$(OUTDIR)/$(notdir $(basename $(1))).o : $(1)
|
2013-03-11 22:39:28 +01:00
|
|
|
@$(ECHO) $(MSG_COMPILINGCXX_ARM) $$(call toprel, $$<)
|
2012-12-18 06:56:40 +01:00
|
|
|
$(V1) $(CPP) -c $$(CFLAGS) $$(CPPFLAGS) $$(CXXFLAGS) $$< -o $$@
|
2011-02-23 05:18:53 +01:00
|
|
|
endef
|
|
|
|
|
2012-12-30 11:01:41 +01:00
|
|
|
# Archive: create ar library file from object files.
|
|
|
|
# $1 = library file to produce
|
|
|
|
# $2 = list of object files that make up the library file
|
|
|
|
# $3 = optional object files directory
|
|
|
|
define ARCHIVE_TEMPLATE
|
|
|
|
.SECONDARY : $(1)
|
|
|
|
.PRECIOUS : $(2)
|
|
|
|
$(1): $(2)
|
2013-03-11 22:39:28 +01:00
|
|
|
@$(ECHO) $(MSG_ARCHIVING) $$(call toprel, $$@)
|
2012-12-30 11:01:41 +01:00
|
|
|
ifeq ($(3),)
|
|
|
|
$(V1) $(AR) rcs $$@ $(2)
|
|
|
|
else
|
|
|
|
# This is a workaround for Windows CreateProcess() line length
|
|
|
|
# limitation. It is assumed that if the object files directory
|
|
|
|
# is given, all object files are in that directory.
|
|
|
|
$(V1) ( \
|
Final step: lot of small fixes, last commit in this commit series
This is the first cleanup pass through makefiles and pios.
Probably it is difficult to track changes due to the nature of them.
I would recommend to look at resulting files and compiled code instead.
NOTE: original branch was rebased and lot of conflicts were fixed on
the way. So do not expect that every commit in this series will be
buildable (unlike original branch). Only final result was tested.
The main goal was to remove as much duplication of code (and copy/paste
errors) as possible, moving common parts out of Makefiles. It still is
not perfect, and mostly no code changes made - Makefiles and #ifdefs only.
But please while testing make sure that all code works as before, and no
modules/options are missed by accident.
Brief list of changes:
- Moved common parts of Makefiles into the set of *.mk files.
- Changed method of passing common vars from top Makefile to lower ones.
- Some pios cleanup, mostly #ifdefs, and all pios_config.h files.
- Many obsolete files removed (for instance, AHRS files, op_config.h).
- Many obsolete or unused macros removed or fixed/renamed (ALL_DIGNOSTICS).
- Unified pios_config.h template. Please don't remove lines for board
configs, only comment/uncomment them. Adding new PIOS options, please
propagate them to all board files keeping the same order.
- Some formatting, spacing, indentation (no line endings change yet).
- Some cosmetic fixes (no more C:\X\Y\filename.c printings on Windows).
- Added some library.mk files to move libs into AR achives later.
- EntireFlash target now uses cross-platform python script to generate bin
files. So it works on all supported platforms: Linux, OSX, Windows.
- Top level packaging is completely rewritten. Now it is a part of top
Makefile. As such, all dependencies are checked and accounted, no
more 'make -j' problems should occur.
- Default GCS_BUILD_CONF is release now, may be changed if necessary
using 'make GCS_BUILD_CONF=debug gcs'.
- GCS build paths are separated into debug and release, so no more obj
file clashes. Packaging system supports only release builds.
- New target is introduced: 'clean_package'. Now 'make package' does not
clean build directory. Use clean_package instead for distributable builds.
- Targets like 'all', 'opfw_resource', etc now will print extra contex
in parallel builds too.
- If any of 'package', 'clean_package', 'opfw_resource' targets are given
on command line, GCS build will depend on the resource, so all fw_*.opfw
targets will be built and embedded into GCS. By default GCS does not
depend on resource, and will be built w/o firmware (unless the resource
files already exist and the Qt resource file is generated).
- fw_simposix (ELF executable) is now packaged for linux. Run'n'play!
- Make help is refined and is now up to date.
Still broken:
- UnitTests, should be fixed
- SimPosix: buildable, but should be reworked.
Next planned passes to do:
- toolchain bootstrapping and packaging (including windows - WIP)
- CMSIS/StdPeriph lib cleanup
- more PIOS cleanup
- move libs into AR archives to save build time
- sim targets refactir and cleanup
- move android-related directories under <top>/android
- unit test targets fix
- source code line ending changes (there are many different, were not changed)
- coding style
Merging this, please use --no-ff git option to make it the real commit point
Conflicts:
A lot of... :-)
2013-03-24 12:02:08 +01:00
|
|
|
pwd=`pwd` && \
|
|
|
|
cd $(3) && \
|
2012-12-30 11:01:41 +01:00
|
|
|
$(AR) rcs $$@ $(notdir $(2)) && \
|
Final step: lot of small fixes, last commit in this commit series
This is the first cleanup pass through makefiles and pios.
Probably it is difficult to track changes due to the nature of them.
I would recommend to look at resulting files and compiled code instead.
NOTE: original branch was rebased and lot of conflicts were fixed on
the way. So do not expect that every commit in this series will be
buildable (unlike original branch). Only final result was tested.
The main goal was to remove as much duplication of code (and copy/paste
errors) as possible, moving common parts out of Makefiles. It still is
not perfect, and mostly no code changes made - Makefiles and #ifdefs only.
But please while testing make sure that all code works as before, and no
modules/options are missed by accident.
Brief list of changes:
- Moved common parts of Makefiles into the set of *.mk files.
- Changed method of passing common vars from top Makefile to lower ones.
- Some pios cleanup, mostly #ifdefs, and all pios_config.h files.
- Many obsolete files removed (for instance, AHRS files, op_config.h).
- Many obsolete or unused macros removed or fixed/renamed (ALL_DIGNOSTICS).
- Unified pios_config.h template. Please don't remove lines for board
configs, only comment/uncomment them. Adding new PIOS options, please
propagate them to all board files keeping the same order.
- Some formatting, spacing, indentation (no line endings change yet).
- Some cosmetic fixes (no more C:\X\Y\filename.c printings on Windows).
- Added some library.mk files to move libs into AR achives later.
- EntireFlash target now uses cross-platform python script to generate bin
files. So it works on all supported platforms: Linux, OSX, Windows.
- Top level packaging is completely rewritten. Now it is a part of top
Makefile. As such, all dependencies are checked and accounted, no
more 'make -j' problems should occur.
- Default GCS_BUILD_CONF is release now, may be changed if necessary
using 'make GCS_BUILD_CONF=debug gcs'.
- GCS build paths are separated into debug and release, so no more obj
file clashes. Packaging system supports only release builds.
- New target is introduced: 'clean_package'. Now 'make package' does not
clean build directory. Use clean_package instead for distributable builds.
- Targets like 'all', 'opfw_resource', etc now will print extra contex
in parallel builds too.
- If any of 'package', 'clean_package', 'opfw_resource' targets are given
on command line, GCS build will depend on the resource, so all fw_*.opfw
targets will be built and embedded into GCS. By default GCS does not
depend on resource, and will be built w/o firmware (unless the resource
files already exist and the Qt resource file is generated).
- fw_simposix (ELF executable) is now packaged for linux. Run'n'play!
- Make help is refined and is now up to date.
Still broken:
- UnitTests, should be fixed
- SimPosix: buildable, but should be reworked.
Next planned passes to do:
- toolchain bootstrapping and packaging (including windows - WIP)
- CMSIS/StdPeriph lib cleanup
- more PIOS cleanup
- move libs into AR archives to save build time
- sim targets refactir and cleanup
- move android-related directories under <top>/android
- unit test targets fix
- source code line ending changes (there are many different, were not changed)
- coding style
Merging this, please use --no-ff git option to make it the real commit point
Conflicts:
A lot of... :-)
2013-03-24 12:02:08 +01:00
|
|
|
cd $$$${pwd} >/dev/null \
|
2012-12-30 11:01:41 +01:00
|
|
|
)
|
|
|
|
endif
|
|
|
|
endef
|
|
|
|
|
2011-02-23 05:18:53 +01:00
|
|
|
# Link: create ELF output file from object files.
|
|
|
|
# $1 = elf file to produce
|
|
|
|
# $2 = list of object files that make up the elf file
|
2012-12-30 20:14:10 +01:00
|
|
|
# $3 = optional list of libraries to build and link
|
2011-02-23 05:18:53 +01:00
|
|
|
define LINK_TEMPLATE
|
|
|
|
.SECONDARY : $(1)
|
2012-12-30 20:14:10 +01:00
|
|
|
.PRECIOUS : $(2) $(3)
|
|
|
|
$(1): $(2) $(3)
|
2013-03-11 22:39:28 +01:00
|
|
|
@$(ECHO) $(MSG_LINKING) $$(call toprel, $$@)
|
2012-12-30 20:14:10 +01:00
|
|
|
$(V1) $(CC) $(THUMB) $$(CFLAGS) $(2) $(3) --output $$@ $$(LDFLAGS)
|
2011-02-23 05:18:53 +01:00
|
|
|
endef
|
|
|
|
|
2012-12-18 06:56:40 +01:00
|
|
|
# Link: create ELF output file from object files.
|
|
|
|
# $1 = elf file to produce
|
|
|
|
# $2 = list of object files that make up the elf file
|
|
|
|
define LINK_CXX_TEMPLATE
|
|
|
|
.SECONDARY : $(1)
|
|
|
|
.PRECIOUS : $(2)
|
|
|
|
$(1): $(2)
|
2013-03-11 22:39:28 +01:00
|
|
|
@$(ECHO) $(MSG_LINKING) $$(call toprel, $$@)
|
2012-12-18 06:56:40 +01:00
|
|
|
$(V1) $(CXX) $(THUMB) $$(CFLAGS) $(2) --output $$@ $$(LDFLAGS)
|
|
|
|
endef
|
|
|
|
|
2011-02-23 05:18:53 +01:00
|
|
|
# Compile: create assembler files from C source files. ARM/Thumb
|
|
|
|
define PARTIAL_COMPILE_TEMPLATE
|
|
|
|
$($(1):.c=.s) : %.s : %.c
|
2013-03-11 22:39:28 +01:00
|
|
|
@$(ECHO) $(MSG_ASMFROMC) $$(call toprel, $$<)
|
2012-03-22 18:50:33 +01:00
|
|
|
$(V1) $(CC) $(THUMB) -S $$(CFLAGS) $$(CONLYFLAGS) $$< -o $$@
|
2011-02-23 05:18:53 +01:00
|
|
|
endef
|
|
|
|
|
|
|
|
# Compile: create assembler files from C source files. ARM only
|
|
|
|
define PARTIAL_COMPILE_ARM_TEMPLATE
|
|
|
|
$($(1):.c=.s) : %.s : %.c
|
2013-03-11 22:39:28 +01:00
|
|
|
@$(ECHO) $(MSG_ASMFROMC_ARM) $$(call toprel, $$<)
|
2011-02-23 05:18:53 +01:00
|
|
|
$(V1) $(CC) -S $$(CFLAGS) $$(CONLYFLAGS) $$< -o $$@
|
|
|
|
endef
|
|
|
|
|
2011-05-24 07:10:31 +02:00
|
|
|
# $(1) = Name of binary image to write
|
|
|
|
# $(2) = Base of flash region to write/wipe
|
|
|
|
# $(3) = Size of flash region to write/wipe
|
2012-08-12 04:28:43 +02:00
|
|
|
# $(4) = OpenOCD JTAG interface configuration file to use
|
|
|
|
# $(5) = OpenOCD configuration file to use
|
2011-05-24 07:10:31 +02:00
|
|
|
define JTAG_TEMPLATE
|
2011-04-24 17:19:00 +02:00
|
|
|
# ---------------------------------------------------------------------------
|
2011-04-25 00:37:45 +02:00
|
|
|
# Options for OpenOCD flash-programming
|
2011-04-24 17:19:00 +02:00
|
|
|
# see openocd.pdf/openocd.texi for further information
|
2011-04-25 00:37:45 +02:00
|
|
|
|
2011-04-24 17:19:00 +02:00
|
|
|
# debug level
|
2011-05-24 07:10:31 +02:00
|
|
|
OOCD_JTAG_SETUP = -d0
|
2011-04-24 17:19:00 +02:00
|
|
|
# interface and board/target settings (using the OOCD target-library here)
|
2013-03-11 22:39:28 +01:00
|
|
|
OOCD_JTAG_SETUP += -s $(ROOT_DIR)/flight/Project/OpenOCD
|
2012-08-12 04:28:43 +02:00
|
|
|
OOCD_JTAG_SETUP += -f $(4) -f $(5)
|
2011-04-24 17:19:00 +02:00
|
|
|
|
|
|
|
# initialize
|
2011-05-24 07:10:31 +02:00
|
|
|
OOCD_BOARD_RESET = -c init
|
2011-04-24 17:19:00 +02:00
|
|
|
# show the targets
|
2011-05-24 07:10:31 +02:00
|
|
|
#OOCD_BOARD_RESET += -c targets
|
2011-04-24 17:19:00 +02:00
|
|
|
# commands to prepare flash-write
|
2011-05-24 07:10:31 +02:00
|
|
|
OOCD_BOARD_RESET += -c "reset halt"
|
|
|
|
|
|
|
|
.PHONY: program
|
|
|
|
program: $(1)
|
2013-03-11 22:39:28 +01:00
|
|
|
@$(ECHO) $(MSG_JTAG_PROGRAM) $$(call toprel, $$<)
|
|
|
|
$(V1) $(OPENOCD) \
|
2011-05-24 07:10:31 +02:00
|
|
|
$$(OOCD_JTAG_SETUP) \
|
|
|
|
$$(OOCD_BOARD_RESET) \
|
|
|
|
-c "flash write_image erase $$< $(2) bin" \
|
|
|
|
-c "verify_image $$< $(2) bin" \
|
|
|
|
-c "reset run" \
|
|
|
|
-c "shutdown"
|
|
|
|
|
|
|
|
.PHONY: wipe
|
|
|
|
wipe:
|
2013-03-11 22:39:28 +01:00
|
|
|
@$(ECHO) $(MSG_JTAG_WIPE) wiping $(3) bytes starting from $(2)
|
|
|
|
$(V1) $(OPENOCD) \
|
2011-05-24 07:10:31 +02:00
|
|
|
$$(OOCD_JTAG_SETUP) \
|
|
|
|
$$(OOCD_BOARD_RESET) \
|
|
|
|
-c "flash erase_address pad $(2) $(3)" \
|
|
|
|
-c "reset run" \
|
|
|
|
-c "shutdown"
|
2011-08-14 01:03:49 +02:00
|
|
|
endef
|