]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-rtos/edma3_lld.git/blob - makerules/common.mk
Fixed build example applications using CCS projects
[keystone-rtos/edma3_lld.git] / makerules / common.mk
1 # Filename: common.mk
2 #
3 # Common make file - This file has common rules and definitions that are common
4 #                    across platforms/cores/ISAs/SoCs
5 #
6 # This file needs to change when:
7 #     1. common rule/define has to be added or modified
8 #
10 #
11 # Include make paths and options for all supported targets/platforms
12 #
14 include $(ROOTDIR)/makerules/build_config.mk
15 include $(ROOTDIR)/makerules/env.mk
16 include $(ROOTDIR)/makerules/platform.mk
18 #.DEFAULT_GOAL := all
20 .PHONY : all clean gendirs m3video m3vpss c6xdsp a8host arm9
22 all : $(CORE)
24 # Define directories that are going to be created as a part of build process
25 ifdef MODULE_NAME
26   ifeq ($($(MODULE_NAME)_PLATFORM_DEPENDENCY),yes)
27     ifeq ($($(MODULE_NAME)_CORE_DEPENDENCY),yes)
28       DEPENDENCY_SUB_PATH = $(PLATFORM)/$(CORE)
29     else
30       DEPENDENCY_SUB_PATH = $(PLATFORM)/$(ISA)
31     endif
32   else
33     ifeq ($($(MODULE_NAME)_CORE_DEPENDENCY),yes)
34       DEPENDENCY_SUB_PATH = $(CORE)
35     else
36       DEPENDENCY_SUB_PATH = $(ISA)
37     endif
38   endif
39 endif
41 ifeq ($(DEST_ROOT),)
42  ifdef MODULE_NAME
43   OBJDIR = obj/$(DEPENDENCY_SUB_PATH)/$(PROFILE_$(CORE))
44   LIBDIR = lib/$(DEPENDENCY_SUB_PATH)/$(PROFILE_$(CORE))
45  else
46   OBJDIR = obj/$(PLATFORM)/$(CORE)/$(PROFILE_$(CORE))
47   BINDIR = bin/$(PLATFORM)
48  endif
49 else
50   ifdef MODULE_NAME
51     OBJDIR = $(DEST_ROOT)/$($(MODULE_NAME)_RELPATH)/obj/$(DEPENDENCY_SUB_PATH)/$(PROFILE_$(CORE))
52     LIBDIR = $(DEST_ROOT)/$($(MODULE_NAME)_RELPATH)/lib/$(DEPENDENCY_SUB_PATH)/$(PROFILE_$(CORE))
53   else
54     OBJDIR = $(DEST_ROOT)/$(APP_NAME)/obj/$(PLATFORM)/$(CORE)/$(PROFILE_$(CORE))
55     BINDIR = $(DEST_ROOT)/$(APP_NAME)/bin/$(PLATFORM)
56   endif
57 endif
59 CONFIGURO_DIRNAME = $(APP_NAME)_configuro
60 ifeq ($(XDC_CFG_DIR),)
61  CONFIGURO_DIR = $(OBJDIR)/$(CONFIGURO_DIRNAME)
62  XDC_CFG_FILE_NAME = $(XDC_CFG_FILE_$(CORE))
63 else
64  CONFIGURO_DIR = $(XDC_CFG_DIR)/configuro/$(PLATFORM)/$(CORE)/$(PROFILE_$(CORE))/$(CONFIGURO_DIRNAME)
65 # XDC_CFG_FILE_NAME = $(XDC_CFG_DIR)/$(XDC_CFG_FILE_$(CORE))
66  XDC_CFG_FILE_NAME = $(XDC_CFG_FILE_$(CORE))
67 endif
69 DEPDIR = $(OBJDIR)/.deps
70 DEPFILE = $(DEPDIR)/$(*F)
72 # Create directories
73 $(OBJDIR) :
74         $(MKDIR) -p $(OBJDIR)
76 $(DEPDIR) :
77         $(MKDIR) -p $(DEPDIR)
79 $(LIBDIR) :
80         $(MKDIR) -p $(LIBDIR)
81  
82 $(BINDIR) :
83         $(MKDIR) -p $(BINDIR)
85 $(CONFIGURO_DIR) :
86         $(MKDIR) -p $(OBJDIR)
87         $(MKDIR) -p $(DEPDIR)
88         $(MKDIR) -p $(CONFIGURO_DIR)
90 #
91 # Common variables
92 #
94 # Assemble list of source file names
95 SRCS = $(SRCS_COMMON) $(SRCS_$(CORE)) $(SRCS_$(SOC)) $(SRCS_$(PLATFORM))
97 # Define search paths
98 VPATH = $(SRCDIR)
100 # Following 'if...' block is for an application.
101 ifndef MODULE_NAME
102   # Derive list of all packages from each of the components needed by the app
103   PKG_LIST = $(foreach COMP,$(COMP_LIST_$(CORE)),$($(COMP)_PKG_LIST))
105   # For each of the packages (or modules), get a list of source files that are
106   # marked to be compiled in app stage of the build (or in the context in the app)
107   SRCS_APPSTG_FILES = $(foreach PKG, $(PKG_LIST), $($(PKG)_APP_STAGE_FILES))
108   # The app has to compile package cfg source files in its context. The name 
109   # of the file assumed is <MOD>_cfg.c under the top-level directory - i.e. 
110   # specified by <MOD>_PATH variable
111   #SRCS_CFG = $(addsuffix _cfg.c,$(PKG_LIST))
112   SRCS += $(SRCS_APPSTG_FILES)
113   PKG_PATHS = $(foreach PKG,$(PKG_LIST),$($(PKG)_PATH))
114   VPATH += $(PKG_PATHS)
115 endif
117 # Change the extension from C to $(OBJEXT) and also add path 
118 OBJ_PATHS = $(patsubst %.c, $(OBJDIR)/%.$(OBJEXT), $(SRCS))
120 # Assemble include paths here
121 INCLUDE_EXTERNAL = $(foreach INCL,$(INCLUDE_EXERNAL_INTERFACES),$($(INCL)_INCLUDE))
122 INCLUDE_ALL = $(CODEGEN_INCLUDE) $(INCDIR) $(INCLUDE_EXTERNAL)
124 # Add prefix "-I" to each of the include paths in INCLUDE_ALL
125 INCLUDES = $(addprefix -I,$(INCLUDE_ALL))
127 # Create rule to "make" all packages
128 .PHONY : $(PKG_LIST)
129 $(PKG_LIST) : 
130         $(ECHO) \# Making $(PLATFORM):$(CORE):$(PROFILE_$(CORE)):$@...
131         $(MAKE) -C $($@_PATH)
132  
133 # Get libraries for all the packages
134 # LIBS = $(foreach LIB,$(PKG_LIST),$(LIB).$(LIBEXT))
135 define GET_COMP_DEPENDENCY_SUB_PATH
136   ifeq ($$($(1)_PLATFORM_DEPENDENCY),yes)
137     ifeq ($$($(1)_CORE_DEPENDENCY),yes)
138       $(1)_DEPSUBPATH = $(PLATFORM)/$(CORE)
139     else
140       $(1)_DEPSUBPATH = $(PLATFORM)/$(ISA)
141     endif
142    else
143     ifeq ($$($(1)_CORE_DEPENDENCY),yes)
144       $(1)_DEPSUBPATH = $(CORE)
145     else
146       $(1)_DEPSUBPATH = $(ISA)
147     endif
148   endif
149 endef
151 $(foreach LIB,$(PKG_LIST),$(eval $(call GET_COMP_DEPENDENCY_SUB_PATH,$(LIB))))
153 ifeq ($(DEST_ROOT),)
154 LIB_PATHS = $(foreach LIB,$(PKG_LIST),$($(LIB)_PATH)/lib/$($(LIB)_DEPSUBPATH)/$(PROFILE_$(CORE))/$(LIB).$(LIBEXT))
155 else
156 LIB_PATHS = $(foreach LIB,$(PKG_LIST),$(DEST_ROOT)/$($(LIB)_RELPATH)/lib/$($(LIB)_DEPSUBPATH)/$(PROFILE_$(CORE))/$(LIB).$(LIBEXT))
157 endif
159 # XDC Specific defines
160 ifneq ($(XDC_CFG_FILE_$(CORE)),)
161   ifeq ($(PROFILE_$(CORE)),debug)
162     CFG_CFILENAMEPART_XDC =p$(FORMAT_EXT)$(ISA)$(ENDIAN_EXT)
163   endif
164   ifeq ($(PROFILE_$(CORE)),whole_program_debug)
165     CFG_CFILENAMEPART_XDC =p$(FORMAT_EXT)$(ISA)$(ENDIAN_EXT)
166     CFG_LNKFILENAMEPART_XDC=_x
167   endif
168   CFG_CFILE_XDC =$(patsubst %.cfg,%_$(CFG_CFILENAMEPART_XDC).c,$(XDC_CFG_FILE_$(CORE)))
169   CFG_C_XDC = $(addprefix $(CONFIGURO_DIR)/package/cfg/,$(CFG_CFILE_XDC))
170   XDCLNKCMD_FILE =$(patsubst %.c, %$(CFG_LNKFILENAMEPART_XDC).xdl, $(CFG_C_XDC))
171   CFG_COBJ_XDC = $(patsubst %.c,%.$(OBJEXT),$(CFG_CFILE_XDC))
172   XDC_CFG_BASE_FILE_NAME = $(basename $(notdir $(XDC_CFG_FILE_$(CORE))))
173 #  OBJ_PATHS += $(CFG_COBJ_XDC)
174   LNKCMD_FILE = $(CONFIGURO_DIR)/linker_mod.cmd
175   SPACE := 
176   SPACE += 
177   XDC_GREP_STRING = $(CONFIGURO_DIRNAME)
178 #  XDC_GREP_STRING = $(subst $(SPACE),\|,$(COMP_LIST_$(CORE)))
179 #  XDC_GREP_STRING += \|$(CONFIGURO_DIRNAME)
180 endif
182 # Include make rules for ISA that is built in this iteration
183 #   eg: rules_m3.mk
184 ifneq ($(TOOLCHAIN_$(ISA)),)
185   TOOLCHAIN_SELECTION = $(TOOLCHAIN_$(ISA))_
186 endif
187 include $(ROOTDIR)/makerules/rules_$(TOOLCHAIN_SELECTION)$(ISA).mk
189 ifdef MODULE_NAME
190 # Rules for module; this iteration is for a module
192 # Clean Object and Library (archive) directories
193 clean :
194         $(RM) -f $(OBJDIR)/* $(DEPDIR)/* $(LIBDIR)/*
196 # Create dependencies list to ultimately create module archive library file
197 $(CORE) : $(OBJDIR) $(DEPDIR) $(LIBDIR) $(LIBDIR)/$(MODULE_NAME).$(LIBEXT)
199 else
200 # Rules for application; this iteration is for an app
202 # Clean Object, Binary and Configuro generated directories
203 clean :
204         $(RM) -rf $(CONFIGURO_DIR)
205         $(RM) -f $(OBJDIR)/* $(DEPDIR)/*
207 # Create dependencies list to ultimately create application executable binary
208 $(CORE) : $(OBJDIR) $(BINDIR) $(DEPDIR) $(CONFIGURO_DIR) $(PKG_LIST) $(BINDIR)/$(APP_NAME)_$(CORE)_$(PROFILE_$(CORE)).$(EXEEXT)
210 endif
212 # Nothing beyond this point