Debian Codegraph @

platforms/armcc/Makefile

raw symbols SCIP
1 # We don't need to clean up when we're making these targets
2 NODEPS := clean debug
3
4 # CPU architecture. Passing to armcc.exe. For list: armcc --cpu list
5 ifndef CPU
6 CPU = ARM7TDMI
7 endif
8
9 # ARM/THUMB mode. Passing to armcc.exe. May be 'thumb' or 'arm'
10 ifndef CPU_MODE
11 CPU_MODE = thumb
12 endif
13
14 # Path to cygwin binary
15 CYGWIN_DIR :=C:/CYGWIN/bin
16
17 # Path to ARMCC of Keil MDK-ARM, with libraries, includes and executables
18 KEIL_DIR :=D:/Keil/ARM/ARMCC
19
20 MKDIR :=$(CYGWIN_DIR)/mkdir
21 RM :=$(CYGWIN_DIR)/rm
22 CC :=@$(KEIL_DIR)/bin/armcc.exe
23 AR :=@$(KEIL_DIR)/bin/armar.exe
24
25
26 # source CppUTest files
27 CPPUTEST_HOME := ../..
28 COMPONENT_NAME := CppUTest
29
30 INCLUDE_DIRS :=\
31 $(CPPUTEST_HOME)/include \
32 $(CPPUTEST_HOME)/include/Platforms/armcc \
33
34 # armcc system include path
35 SYS_INCLUDE_DIRS:=$(KEIL_DIR)/include
36
37 SRC_DIRS :=\
38 $(CPPUTEST_HOME)/src/$(COMPONENT_NAME)\
39 $(CPPUTEST_HOME)/src/Platforms/armcc\
40
41 TARGET_PLATFORM :=armcc_$(CPU)_$(CPU_MODE)
42 CPPUTEST_USE_MEM_LEAK_DETECTION := N
43 CPPUTEST_USE_STD_CPP_LIB := N
44 CPPUTEST_USE_VPATH := Y
45 CPPUTEST_USE_STD_C_LIB := Y
46 CPPUTEST_ENABLE_DEBUG := Y
47
48
49 # Default dir for temporary files (d, o)
50 # Default dir for the outout library
51 CPPUTEST_OBJS_DIR = objs
52 CPPUTEST_LIB_DIR = $(CPPUTEST_HOME)/lib/$(TARGET_PLATFORM)
53
54 TARGET_LIB = \
55 $(CPPUTEST_LIB_DIR)/lib$(COMPONENT_NAME).a
56
57
58 #Helper Functions
59 get_src_from_dir = $(wildcard $1/*.cpp) $(wildcard $1/*.cc) $(wildcard $1/*.c)
60 get_dirs_from_dirspec = $(wildcard $1)
61 get_src_from_dir_list = $(foreach dir, $1, $(call get_src_from_dir,$(dir)))
62 __src_to = $(subst .c,$1, $(subst .cc,$1, $(subst .cpp,$1,$(if $(CPPUTEST_USE_VPATH),$(notdir $2),$2))))
63 src_to = $(addprefix $(CPPUTEST_OBJS_DIR)/,$(call __src_to,$1,$2))
64 src_to_o = $(call src_to,.o,$1)
65 src_to_d = $(call src_to,.d,$1)
66 src_to_gcda = $(call src_to,.gcda,$1)
67 src_to_gcno = $(call src_to,.gcno,$1)
68 time = $(shell date +%s)
69 delta_t = $(eval minus, $1, $2)
70 debug_print_list = $(foreach word,$1,echo " $(word)";) echo;
71
72 #Derived
73 SRC = $(call get_src_from_dir_list, $(SRC_DIRS))
74 OBJ = $(call src_to_o,$(SRC))
75
76 STUFF_TO_CLEAN = $(OBJ)
77
78 ALL_SRC = $(SRC)
79
80 CPUFLAGS =--cpu=$(CPU)
81 ifeq ($(CPU_MODE), thumb)
82 CPUFLAGS +=--apcs=/interwork
83 endif
84 DEPFLAGS =$(CPUFLAGS) -M $(INCLUDES) --depend_format=unix_escaped --depend_single_line --no_depend_system_headers
85 OPTFLAGS =-O1
86 CCFLAGS =$(CPUFLAGS) $(OPTFLAGS) -c $(INCLUDES)\
87 --$(CPU_MODE)\
88 --exceptions\
89 -D__CLK_TCK=1000\
90
91
92 # If we're using VPATH
93 ifeq ($(CPPUTEST_USE_VPATH), Y)
94 # gather all the source directories and add them
95 VPATH += $(sort $(dir $(ALL_SRC)))
96 # Add the component name to the objs dir path, to differentiate between same-name objects
97 CPPUTEST_OBJS_DIR := $(addsuffix /$(COMPONENT_NAME),$(CPPUTEST_OBJS_DIR))
98 endif
99
100 INCLUDES_DIRS_EXPANDED = $(call get_dirs_from_dirspec, $(INCLUDE_DIRS))
101 INCLUDES += $(foreach dir, $(INCLUDES_DIRS_EXPANDED), -I$(dir))
102
103 DEP_FILES = $(call src_to_d, $(ALL_SRC))
104 STUFF_TO_CLEAN += $(DEP_FILES)
105
106
107 # Without the C library, we'll need to disable the C++ library and ...
108 ifeq ($(CPPUTEST_USE_STD_C_LIB), N)
109 CPPUTEST_USE_STD_CPP_LIB = N
110 CPPUTEST_USE_MEM_LEAK_DETECTION = N
111 CCFLAGS += -DCPPUTEST_STD_C_LIB_DISABLED
112 else
113 INCLUDE_DIRS +=$(SYS_INCLUDE_DIRS)
114 endif
115
116 ifeq ($(CPPUTEST_USE_MEM_LEAK_DETECTION), N)
117 CCFLAGS += -DCPPUTEST_MEM_LEAK_DETECTION_DISABLED
118 endif
119
120 ifeq ($(CPPUTEST_ENABLE_DEBUG), Y)
121 CCFLAGS += -g
122 ARFLAGS := --debug_symbols
123 endif
124
125 ifeq ($(CPPUTEST_USE_STD_CPP_LIB), N)
126 CCFLAGS += -DCPPUTEST_STD_CPP_LIB_DISABLED
127 endif
128
129
130 OBJS_DIRS :=$(sort $(dir $(STUFF_TO_CLEAN)))
131
132 $(OBJS_DIRS) $(CPPUTEST_LIB_DIR):
133 @echo Updating directory $@
134 $(MKDIR) -p $@
135
136
137 #This is the rule for creating the dependency files
138 $(CPPUTEST_OBJS_DIR)/%.d: %.c Makefile | $(OBJS_DIRS)
139 @echo Compiling C file $< for dependency. Out file $@.
140 $(CC) $(DEPFLAGS) $< --depend=$@ --depend_target='$(patsubst %.d,%.o,$@)'
141
142 $(CPPUTEST_OBJS_DIR)/%.d: %.cpp Makefile | $(OBJS_DIRS)
143 @echo Compiling C++ file $< for dependency. Out file $@.
144 $(CC) $(DEPFLAGS) $< --depend=$@ --depend_target='$(patsubst %.d,%.o,$@)'
145
146 #This rule does the compilation C++ files
147 $(CPPUTEST_OBJS_DIR)/%.o: %.cpp $(CPPUTEST_OBJS_DIR)/%.d Makefile
148 @echo Compiling C++ file $<. Out file $@
149 $(CC) $(CCFLAGS) $< -o $@
150
151 #This rule does the compilation C files
152 $(CPPUTEST_OBJS_DIR)/%.o: %.c $(CPPUTEST_OBJS_DIR)/%.d Makefile
153 @echo Compiling C file $<. Out file $@
154 $(CC) $(CCFLAGS) $< -o $@
155
156
157 $(TARGET_LIB): $(OBJ) | $(CPPUTEST_LIB_DIR)
158 @echo Archiving to $@
159 $(AR) $(ARFLAGS) --create $@ $^
160
161
162 .PHONY: all
163
164 all: $(TARGET_LIB)
165 @echo Done!
166
167
168 .PHONY: debug
169 debug:
170 @echo
171 @echo "Target Source files:"
172 @$(call debug_print_list,$(SRC))
173 @echo "Target Object files:"
174 @$(call debug_print_list,$(OBJ))
175 @echo "All Input Dependency files:"
176 @$(call debug_print_list,$(DEP_FILES))
177 @echo Stuff to clean:
178 @$(call debug_print_list,$(STUFF_TO_CLEAN))
179 @echo Includes:
180 @$(call debug_print_list,$(INCLUDES))
181 @echo Directories to create:
182 @$(call debug_print_list,$(OBJS_DIRS))
183 @echo Directories of CppUTest object files:
184 @$(call debug_print_list,$(CPPUTEST_OBJS_DIR))
185 @echo Flags:
186 @$(call debug_print_list,$(CCFLAGS))
187
188
189 #Don't create dependencies when we're cleaning, for instance
190 ifeq (0, $(words $(findstring $(MAKECMDGOALS), $(NODEPS))))
191 -include $(DEP_FILES)
192 endif
193
194 clean:
195 @$(RM) -rf $(STUFF_TO_CLEAN)