]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lib.git/blob - build/Makefile.rules.arm
1a9cc2f70a588862fc1a04c31da6050888fc5cd3
[pes-rpp/rpp-lib.git] / build / Makefile.rules.arm
1 # Copyright (C) 2013-2015 Czech Technical University in Prague
2 #
3 # Authors:
4 #     - Michal Sojka <sojkam1@fel.cvut.cz>
5 #
6 # This document contains proprietary information belonging to Czech
7 # Technical University in Prague. Passing on and copying of this
8 # document, and communication of its contents is not permitted
9 # without prior written authorization.
10 #
11 # File : Makefile.rules.arm
12 #
13 # This file contains variables and rules specific for compilation for
14 # ARM platforms.
15
16 makefile_rules_arm_dir := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
17
18 ifeq ($(TARGET_CFLAGS),)
19 $(error "Makefile.config must be included before this file")
20 endif
21
22 # Code composer studio sets this variable when it invokes make. Let's use it
23 # as a hint for where is the compiler installed.
24 CCS_UTILS_DIR ?= $(or $(wildcard /opt/ti/ccsv5/utils),\
25                                           $(error Please set CCS_UTILS_DIR variable, e.g. by running 'make CCS_UTILS_DIR=$$HOME/ti/ccsv5/utils'))
26
27 ARM_COMPILER_DIR ?= $(dir $(CCS_UTILS_DIR))/tools/compiler/arm_5.1.1
28
29 CC=$(ARM_COMPILER_DIR)/bin/armcl
30 AR=$(ARM_COMPILER_DIR)/bin/armar
31 LD=$(CC)
32
33 # Include definition of $(rpp_lib_INCLUDES)
34 include $(makefile_rules_arm_dir)/../Makefile.var
35
36 # Include UPPERCASE function
37 include $(makefile_rules_dir)/../common.mk
38
39 # Construct target specific CFLAGS. Start from what's in Makefile.config.
40 RPP_TARGET_CFLAGS = $(TARGET_CFLAGS)
41
42 # Add -DTARGET_<NAME>
43 RPP_TARGET_CFLAGS += -DTARGET_$(call UPPERCASE,$(TARGET))
44
45 # Then add -DTARGET_HAS_xxx for each make variable named TARGET_HAS_*
46 # having value 'y'
47 TARGET_HAS_NAMES = $(filter TARGET_HAS_%,$(.VARIABLES))
48 RPP_TARGET_CFLAGS += $(foreach name,$(TARGET_HAS_NAMES),$(if $(filter y,$($(name))),-D$(name)))
49
50 ARM_COMPILER_CFLAGS = --gcc --diag_error=225 --display_error_number     \
51                                           --diag_wrap=off --gen_func_subsections=on --enum_type=packed
52
53 RPP_CFLAGS = $(RPP_TARGET_CFLAGS) -I$(ARM_COMPILER_DIR)/include \
54                 $(rpp_lib_INCLUDES:%=-I$(makefile_rules_arm_dir)/../%)  \
55                 $(ARM_COMPILER_CFLAGS)
56
57 RPP_MAKE_CFLAGS = \
58                 --preproc_dependency=$(@:%=%.dep) --obj_directory=$(dir $@)     \
59                 --preproc_with_compile
60
61 RPP_COMPILE_CMD = $(CC) $(RPP_CFLAGS) $(RPP_MAKE_CFLAGS) $<
62
63 BUILD_DIR ?= Debug
64 RPP_LIB_DIR = $(makefile_rules_arm_dir)/$(TARGET)/$(BUILD_DIR)
65
66 RPP_LDFLAGS = \
67                 --run_linker -m"${@:%=%.map}" $(TARGET_LDFLAGS) --diag_wrap=on  \
68                 --reread_libs --warn_sections --display_error_number                    \
69                 --rom_model --search_path=$(ARM_COMPILER_DIR)/lib                               \
70                 --generate_dead_funcs_list=$(@:%=%.deadfuncs.xml)                               \
71                 --stack_size=0x800
72
73 RPP_LDLIBS = $(makefile_rules_arm_dir)/$(TARGET)/$(TARGET_LDCMD) -l$(RPP_LIB_DIR)/rpp-lib.lib $(TARGET_LDLIBS)
74
75 # Do not define any rules when compiling Simulink models
76 ifeq ($(MATLAB_ROOT),)
77 $(RPP_LIB_DIR)/rpp-lib.lib:
78         $(MAKE) -C $(dir $@)
79 endif