libopencm3/mk
Denis Feklushkin f5192dbcb5 mk: genlink: simplify variable usage 2020-11-28 22:13:25 +00:00
..
README mk/genlink: change devices.data format to remove gcc specific options 2016-08-18 22:07:36 +00:00
gcc-config.mk [BUILD] Add build system module makefiles, add README how to use it. 2014-02-07 07:47:54 +01:00
gcc-rules.mk [BUILD] Add build system module makefiles, add README how to use it. 2014-02-07 07:47:54 +01:00
genlink-config.mk genlinkk-config: fix missing .a suffix 2019-05-25 21:28:04 +00:00
genlink-rules.mk mk: genlink: simplify variable usage 2020-11-28 22:13:25 +00:00

README

-------------------------------------------------------------------------------
README
-------------------------------------------------------------------------------

  This directory contains makefile modular support files, that can be used in
your project.

  Each module is packaged with two inclusion makefiles, <module>-config.mk and
<module>-rules.mk. The first one defines some new variables for the make, or
appends values to the existing variables for the make. The second defines rules
for support building.

  So in your project, the <module>-config.mk should be included at some place,
where you are defining variables (near the beginning of the file), and file
<module>-rules.mk should be included in the rules part of makefile (somewhere
near to the end of file).

Example makefile using the gcc compiler module together with the linker script
generator module:

>>>>>>
DEVICE          =
OPENCM3_DIR     =
OBJS            += foo.o

CFLAGS          += -Os -ggdb3
CPPFLAGS	+= -MD
LDFLAGS         += -static -nostartfiles
LDLIBS          += -Wl,--start-group -lc -lgcc -lnosys -Wl,--end-group

include $(OPENCM3_DIR)/mk/genlink-config.mk
include $(OPENCM3_DIR)/mk/gcc-config.mk

.PHONY: clean all

all: binary.elf binary.hex

clean:
	$(Q)$(RM) -rf binary.* *.o

include $(OPENCM3_DIR)/mk/genlink-rules.mk
include $(OPENCM3_DIR)/mk/gcc-rules.mk
<<<<<<


MODULES
=======

-------------------------------------------------------------------------------
gcc
-------------------------------------------------------------------------------

  This module adds an extended support for GCC toolchain. This adds rules,
necessary for compiling C and C++ files into elf binary, and rules for
generation of bin, hex, or srec output files for flashing.

Variables to control the build process (should be set in your makefile):
------------------------------------------------------------------------

CFLAGS		C compiler flags
CXXFLAGS	C++ compiler flags
CPPFLAGS	C preprocessor flags (used for C and for C++ compiler)
LDFLAGS		Linker flags
ARCH_FLAGS	Architecture specification flags (-mcpu, -march etc )

Variables to tell gcc about project dependencies and input files
----------------------------------------------------------------

LDSCRIPT	Linker script file name (can be generated or fixed)
LIBDEPS		Array of library filenames that shoud be rebuilt if needed
LDLIBS		Array of libraries to be linked with (array of -l<libname>)
OBJS		Array of object files to be built


-------------------------------------------------------------------------------
genlink
-------------------------------------------------------------------------------

  This module adds an support for the user to the linker script generator. The
linker script will be generated as the file $(DEVICE).ld in the project folder,
and automatically be used for the linking process.
Additionally the matching library is added to the LDLIBS variable.

Variables to control the build process (should be set in your makefile):
------------------------------------------------------------------------

DEVICE		The full device part name used for the compilation process.
OPENCM3_DIR	The root path of libopencm3 library.

Output variables from this module:
----------------------------------

CPPFLAGS		(appended)
 - Appends the chip family to the CPPFLAGS. For example -DSTM32F1
 - Appends the include path for libopencm3

ARCH_FLAGS	(replaced)
 - Architecture build flags for specified chip.
 * No needed to handle this variable if you use module <gcc> too.

LDSCRIPT	(replaced)
 - Linker script generated file.
 * No needed to handle this variable if you use module <gcc> too.

LDLIBS (appended)
 - LDLIBS += -lopencm3_$(family) is appended to link against the
   matching library.

LDFLAGS (appended)
 - LDFLAGS += -L$(OPENCM3_DIR)/lib is appended to make sure the
   matching library can be found.

family,cpu,fpu (replaced)
 - these are used internally to create the above variables

Temporary variables that you should not use in your makefile:
-------------------------------------------------------------

GENLINK_DEFS
GENLINK_ARCH
GENLINK_LIB