]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lib.git/blobdiff - build/Makefile.rules.arm
Unify compilation for POSIX and ARM
[pes-rpp/rpp-lib.git] / build / Makefile.rules.arm
diff --git a/build/Makefile.rules.arm b/build/Makefile.rules.arm
new file mode 100644 (file)
index 0000000..694b5b8
--- /dev/null
@@ -0,0 +1,72 @@
+# Copyright (C) 2013-2015 Czech Technical University in Prague
+#
+# Authors:
+#     - Michal Sojka <sojkam1@fel.cvut.cz>
+#
+# This document contains proprietary information belonging to Czech
+# Technical University in Prague. Passing on and copying of this
+# document, and communication of its contents is not permitted
+# without prior written authorization.
+#
+# File : Makefile.rules.arm
+#
+# This file contains variables and rules specific for compilation for
+# ARM platforms.
+
+makefile_rules_arm_dir := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
+
+ifeq ($(TARGET_CFLAGS),)
+$(error "Makefile.config must be included before this file")
+endif
+
+# Code composer studio sets this variable when it invokes make. Let's use it
+# as a hint for where is the compiler installed.
+CCS_UTILS_DIR ?= /opt/ti/ccsv5/utils
+
+ARM_COMPILER_DIR ?= $(dir $(CCS_UTILS_DIR))/tools/compiler/arm_5.1.1
+
+ifeq ($(wildcard $(CCS_UTILS_DIR)),)
+define msg
+'$(CCS_UTILS_DIR)' directory does not exist.
+Please set CCS_UTILS_DIR variable, e.g. by running 'make CCS_UTILS_DIR=$$HOME/ti/ccsv5/utils'
+endef
+$(error $(msg))
+endif
+
+include $(makefile_rules_arm_dir)/../common.mk
+
+CC=$(ARM_COMPILER_DIR)/bin/armcl
+AR=$(ARM_COMPILER_DIR)/bin/armar
+LD=$(CC)
+
+# Include definition of $(rpp_lib_INCLUDES)
+include $(makefile_rules_arm_dir)/../Makefile.var
+
+RPP_CFLAGS = $(TARGET_CFLAGS) --gcc -I$(ARM_COMPILER_DIR)/include      \
+               $(rpp_lib_INCLUDES:%=-I$(makefile_rules_arm_dir)/../%)                  \
+               --diag_warning=225 --display_error_number --diag_wrap=off               \
+               --gen_func_subsections=on --enum_type=packed
+
+RPP_MAKE_CFLAGS = \
+               --preproc_dependency=$(@:%=%.dep) --obj_directory=$(dir $@)     \
+               --preproc_with_compile
+
+define rpp_c_obj_cmds
+       $(call mkdir,$(dir $@))
+       $(CC) $(RPP_CFLAGS) $(RPP_MAKE_CFLAGS) $<
+endef
+
+BUILD_DIR ?= Debug
+RPP_LIB_DIR = $(makefile_rules_arm_dir)/$(TARGET)/$(BUILD_DIR)
+
+RPP_LDFLAGS = \
+               --run_linker -m"${@:%=%.map}" $(TARGET_LDFLAGS) --diag_wrap=on  \
+               --reread_libs --warn_sections --display_error_number                    \
+               --rom_model --search_path=$(ARM_COMPILER_DIR)/lib                               \
+               --generate_dead_funcs_list=$(@:%=%.deadfuncs.xml)                               \
+               --stack_size=0x800
+
+RPP_LDLIBS = $(TARGET_LDCMD) -l$(RPP_LIB_DIR)/rpp-lib.lib $(TARGET_LDLIBS)
+
+$(RPP_LIB_DIR)/rpp-lib.lib:
+       $(MAKE) -C $(dir $@)