You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
122 lines
4.0 KiB
122 lines
4.0 KiB
2 months ago
|
-------------------------------------------------------------------------------
|
||
|
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
|