| 227 |
dpurdie |
1 |
# -*- mode: mak -*-
|
|
|
2 |
###############################################################################
|
|
|
3 |
# Module name : TOOLSET/KeilC51V41
|
|
|
4 |
# Module type : Makefile system
|
|
|
5 |
# Environment(s): KeilC51V41
|
|
|
6 |
#
|
|
|
7 |
# Version Who Date Description
|
|
|
8 |
# DDP 04-Jan-05 Created
|
|
|
9 |
#
|
|
|
10 |
###################################################################
|
|
|
11 |
|
|
|
12 |
###############################################################################
|
|
|
13 |
#.. Remove "undef" warnings
|
|
|
14 |
#
|
|
|
15 |
cc_includes +=
|
|
|
16 |
cc_defines +=
|
|
|
17 |
cxx_include +=
|
|
|
18 |
cxx_defines +=
|
|
|
19 |
as_includes +=
|
|
|
20 |
as_defines +=
|
|
|
21 |
|
|
|
22 |
###############################################################################
|
|
|
23 |
#.. Parse user options
|
|
|
24 |
# Global options already parsed
|
|
|
25 |
# These options extend the global options
|
|
|
26 |
#
|
|
|
27 |
|
|
|
28 |
ifdef OPTIONS
|
|
|
29 |
|
|
|
30 |
ifneq "$(findstring wall,$(OPTIONS))" "" # Enable all warnings
|
|
|
31 |
USE_WALL = 1
|
|
|
32 |
endif
|
|
|
33 |
|
|
|
34 |
endif
|
|
|
35 |
|
|
|
36 |
cc_filter := $(wildcard $(GBE_ROOT)/warnings.keil)
|
|
|
37 |
ifdef cc_filter
|
|
|
38 |
cc_redirect = 1
|
|
|
39 |
cc_error_filter = $(awk) -f $(GBE_ROOT)/warnings.keil
|
|
|
40 |
endif
|
|
|
41 |
|
|
|
42 |
###############################################################################
|
|
|
43 |
#.. C Compiler definition
|
|
|
44 |
# Notes:
|
|
|
45 |
# The Keil compiler has a specific ordering of files on the command line
|
|
|
46 |
# The standard definitions are bent to fit
|
|
|
47 |
#
|
|
|
48 |
# The compiler does not support specification of include directories
|
|
|
49 |
# on the command line. They are done via the C51INC environment variable
|
|
|
50 |
#
|
|
|
51 |
# The compiler defines __C51__
|
|
|
52 |
#
|
|
|
53 |
# The shell used by make needs the XX() constructs to be esacped
|
|
|
54 |
#
|
|
|
55 |
# The compiler does not take include files on the command line
|
|
|
56 |
# These MUST be passed via the environment variable C51INC
|
|
|
57 |
#
|
|
|
58 |
# Convert user CFLAGS from -Dxxxx -> DF(xxxx)
|
|
|
59 |
#
|
|
|
60 |
# The command line is VERY limited
|
|
|
61 |
# Use abbreviations at all times
|
|
|
62 |
#
|
|
|
63 |
#
|
|
|
64 |
|
|
|
65 |
cc = $(CC_PRE) export C51INC;\
|
|
|
66 |
C51INC="$(subst $(space),$(semicolon),$(INCDIRS) $(strip $(cc_includes) $(keil_includes)))";\
|
|
|
67 |
$(C51BIN)/C51.EXE
|
|
|
68 |
cc_init =
|
|
|
69 |
cc_o_switch =
|
|
|
70 |
cc_source =
|
|
|
71 |
cc_flags = $(cc_ksource) $(cc_kflags) 'OJ($@)'
|
|
|
72 |
cc_term = ; rv=$$?;if [ $$rv -gt 1 ] ; then false; else true; fi
|
|
|
73 |
cc_ksource = $<
|
|
|
74 |
|
|
|
75 |
#
|
|
|
76 |
# Process CFLAGS into those with a -D prefix and all others
|
|
|
77 |
# Merge the -Ddefinition into one argument to save command line space
|
|
|
78 |
#
|
|
|
79 |
cc_kdefs = $(subst $(space),$(comma),$(patsubst -D%,%,$(filter -D%,$(CFLAGS)$(cc_defines))))
|
|
|
80 |
cc_kother = $(filter-out -D%,$(CFLAGS))
|
|
|
81 |
|
|
|
82 |
cc_kflags = \
|
|
|
83 |
$(patsubst %,'DF(%),$(cc_kdefs))' \
|
|
|
84 |
$(patsubst %,'%',$(cc_kother)) \
|
|
|
85 |
$(patsubst %,'%',$(keil_flags))
|
|
|
86 |
|
|
|
87 |
keil_flags = LA RB(0)
|
|
|
88 |
|
|
|
89 |
ifdef USE_WALL
|
|
|
90 |
keil_flags +=
|
|
|
91 |
endif
|
|
|
92 |
|
|
|
93 |
ifdef USE_STRICT_ANSI
|
|
|
94 |
keil_flags += NOEXTEND
|
|
|
95 |
endif
|
|
|
96 |
|
|
|
97 |
ifdef USE_OPTIMISE
|
|
|
98 |
keil_flags += OT(5,SIZE)
|
|
|
99 |
else
|
|
|
100 |
keil_flags += OT(5,SIZE)
|
|
|
101 |
endif
|
|
|
102 |
|
|
|
103 |
ifdef USE_DEBUGINFO
|
|
|
104 |
keil_flags += DB
|
|
|
105 |
cc_defines += -DDEBUG
|
|
|
106 |
else
|
|
|
107 |
cc_defines += -DNDEBUG
|
|
|
108 |
endif
|
|
|
109 |
|
|
|
110 |
ifeq "$(DEBUG)" "1"
|
|
|
111 |
keil_flags +=
|
|
|
112 |
else
|
|
|
113 |
keil_flags +=
|
|
|
114 |
endif
|
|
|
115 |
|
|
|
116 |
# Removed due to command line limitations
|
|
|
117 |
#
|
|
|
118 |
#ifdef ALVL
|
|
|
119 |
#cc_defines += ALVL=$(ALVL)
|
|
|
120 |
#endif
|
|
|
121 |
#
|
|
|
122 |
#ifdef DLVL
|
|
|
123 |
#cc_defines += DLVL=$(DLVL)
|
|
|
124 |
#endif
|
|
|
125 |
#
|
|
|
126 |
#cc_defines += __SOURCE__=\"$(notdir $<)\"
|
|
|
127 |
|
|
|
128 |
ifdef LEAVETMP
|
|
|
129 |
#keil_flags += PRINT
|
|
|
130 |
else
|
|
|
131 |
keil_flags += NOPR
|
|
|
132 |
endif
|
|
|
133 |
|
|
|
134 |
define cc_pre
|
| 6177 |
dpurdie |
135 |
@echo '[$<] compiling..'
|
| 227 |
dpurdie |
136 |
endef
|
|
|
137 |
|
|
|
138 |
define cc_post
|
|
|
139 |
endef
|
|
|
140 |
|
|
|
141 |
###############################################################################
|
|
|
142 |
#.. C/C++ dependencies
|
|
|
143 |
# depend and depend.err
|
|
|
144 |
#
|
|
|
145 |
# -M Generate make dependencies
|
|
|
146 |
# -MM As -M, but ignore system header files
|
|
|
147 |
# -MG Treat missing header files as generated
|
|
|
148 |
#
|
|
|
149 |
|
|
|
150 |
ifeq "$(DEBUG)" "1"
|
|
|
151 |
cc_depend += -DDEBUG
|
|
|
152 |
endif
|
|
|
153 |
ifdef ALVL
|
|
|
154 |
cc_depend += -DALVL=$(ALVL)
|
|
|
155 |
endif
|
|
|
156 |
ifdef DLVL
|
|
|
157 |
cc_depend += -DDLVL=$(DLVL)
|
|
|
158 |
endif
|
|
|
159 |
|
|
|
160 |
ccdep = $(XX_PRE) $(GBE_BIN)/mkdepend
|
|
|
161 |
ccdep_o_switch = -f -
|
|
|
162 |
ccdep_init =
|
|
|
163 |
#ccdep_source = $(filter %.c %.cc %.cpp, $+) > $(subst /,/,$@).tmp 2> $@.err
|
|
|
164 |
ccdep_source = $(filter %.c %.cc %.cpp, $+) > $@ 2> $@.err
|
|
|
165 |
ccdep_flags = -MM -b -p '$$(OBJDIR)/' -o ".$(o)" \
|
|
|
166 |
-D__C51__ \
|
|
|
167 |
$(patsubst %,%,$(CFLAGS)) \
|
|
|
168 |
$(patsubst %,-D%,$(cc_defines)) \
|
|
|
169 |
$(patsubst %,%,$(cc_depend)) \
|
|
|
170 |
$(patsubst %,-I %,$(INCDIRS)) \
|
|
|
171 |
$(patsubst %,-I %,$(cc_includes)) \
|
|
|
172 |
$(patsubst %,-Y %,$(keil_includes))
|
|
|
173 |
ccdep_pre =
|
|
|
174 |
ccdep_post =
|
|
|
175 |
|
|
|
176 |
|
|
|
177 |
###############################################################################
|
|
|
178 |
#.. Archiver
|
|
|
179 |
# The librarian appears to only handle one command at a time
|
|
|
180 |
# The librarian has severe command line length limits
|
|
|
181 |
#
|
|
|
182 |
ar = $(XX_PRE) $(C51BIN)/LIB51 create $@ ;\
|
|
|
183 |
for obj in $(filter %.o51, $^); do \
|
|
|
184 |
$(C51BIN)/LIB51 ADD $$obj to $@ ;\
|
|
|
185 |
rv=$$?;\
|
|
|
186 |
if [ $$rv -gt 0 ] ; then \
|
|
|
187 |
echo "Error creating library: $@";\
|
|
|
188 |
rm -f $@;\
|
|
|
189 |
exit 1 ;\
|
|
|
190 |
fi;\
|
|
|
191 |
done
|
|
|
192 |
ar_init =
|
|
|
193 |
ar_flags =
|
|
|
194 |
ar_o_switch =
|
|
|
195 |
ar_term =
|
|
|
196 |
|
|
|
197 |
define ar_pre
|
| 6177 |
dpurdie |
198 |
$(echo) '[$@] Creating library archive..' ; \
|
| 227 |
dpurdie |
199 |
$(rm) -f $@
|
|
|
200 |
endef
|
|
|
201 |
|
|
|
202 |
ar_post =
|
|
|
203 |
|
|
|
204 |
###############################################################################
|
|
|
205 |
#.. Archive Merge
|
|
|
206 |
# The librarian appears to only handle one command at a time
|
|
|
207 |
# It does not appear to handle multiple libraries in a merge
|
|
|
208 |
#
|
|
|
209 |
armerge = $(XX_PRE) $(C51BIN)/LIB51 create $@ ;\
|
|
|
210 |
for lib in $(filter %.lib, $^); do \
|
|
|
211 |
$(C51BIN)/LIB51 ADD $$lib to $@ ;\
|
|
|
212 |
rv=$$?;\
|
|
|
213 |
if [ $$rv -gt 0 ] ; then \
|
|
|
214 |
echo "Error creating Merge library: $@";\
|
|
|
215 |
rm -f $@;\
|
|
|
216 |
exit 1 ;\
|
|
|
217 |
fi;\
|
|
|
218 |
done
|
|
|
219 |
armerge_init =
|
|
|
220 |
armerge_flags =
|
|
|
221 |
armerge_o_switch=
|
|
|
222 |
|
|
|
223 |
define armerge_pre
|
| 6177 |
dpurdie |
224 |
@$(echo) '[$@] Merging library archive..'
|
| 227 |
dpurdie |
225 |
$(XX_PRE) rm -f $@
|
|
|
226 |
endef
|
|
|
227 |
|
|
|
228 |
armerge_post =
|
|
|
229 |
|
|
|
230 |
###############################################################################
|
|
|
231 |
#.. Assembler definition
|
|
|
232 |
# Although the assembler is not currently supported the following
|
|
|
233 |
# definition is required by the make system
|
|
|
234 |
#
|
|
|
235 |
as_init =
|
|
|
236 |
|
|
|
237 |
|
|
|
238 |
|
|
|
239 |
#
|