This repository has been archived by the owner on May 26, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
makefile.inc
319 lines (267 loc) · 7.56 KB
/
makefile.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
MEMISOSIZE="(&_end-&_start)"
# override this on the command line or in buildconf to use PRIMARY.BIN from a different tree
# should be an absolute path
PRIMARY_ROOT=$(topdir)platform
include $(topdir)buildconf.inc
# optional local version of buildconf.inc, not in SVN so it can be used in autobuilds
# and to avoid getting accidentally included in svn diffs
# you may also set your default camera here
-include $(topdir)localbuildconf.inc
include $(topdir)version.inc
-include $(topdir)revision.inc
ifndef OPT_DE_VERSION
VER=CHDK
else
VER=CHDK_DE
ifndef OPT_DEFAULT_LANG
OPT_DEFAULT_LANG=german
endif
endif
ifdef PLATFORM
ifdef PLATFORMSUB
include $(topdir)platform/$(PLATFORM)/sub/$(PLATFORMSUB)/makefile.inc
ifeq ($(PLATFORMOSVER),)
PLATFORMOSVER=0
endif
endif
endif
# Used in gui_debug.c for controlling memory browser allowed address ranges
# override in platform/$(PLATFORM)/sub/$(PLATFORMSUB)/makefile.inc to set camera specific value
ifdef MAXRAMADDR
PLFLAGS+=-DMAXRAMADDR=$(MAXRAMADDR)
else
PLFLAGS+=-DMAXRAMADDR=0x1FFFFFF
endif
ifdef ROMBASEADDR
PLFLAGS+=-DROMBASEADDR=$(ROMBASEADDR)
else
PLFLAGS+=-DROMBASEADDR=0xFFC00000
endif
ifdef OPT_FI2
include $(topdir)platform/fi2.inc
endif
SILENT=SILENT
NOZERO100K=TRUE
##########################################################################
##########################################################################
##########################################################################
ESED = sed -r
# keep sort order consistent
export LC_ALL=C
ifndef OSTYPE
HOSTPLATFORM:=$(patsubst MINGW%,MINGW,$(shell uname -s))
ifeq ($(HOSTPLATFORM),MINGW)
OSTYPE = Windows
EXE = .exe
SH = sh
DEVNULL = NUL
OLDSEPARATOR = \\\\
NEWSEPARATOR = /
SORT := $(dir $(shell which uniq.exe | sed 's_$(OLDSEPARATOR)_$(NEWSEPARATOR)_g'))/sort.exe
else
ifeq ($(HOSTPLATFORM),Linux)
OSTYPE = Linux
EXE =
SH =
DEVNULL = /dev/null
SORT = sort
else
ifeq ($(HOSTPLATFORM),Darwin)
OSTYPE = Darwin
EXE =
SH =
DEVNULL = /dev/null
SORT = sort
ESED = sed -E
else
OSTYPE = Other
EXE =
SH =
DEVNULL = /dev/null
SORT = sort
endif
endif
endif
else
EXE =
SH =
DEVNULL = /dev/null
SORT = sort
endif
##########################################################################
##########################################################################
##########################################################################
HOSTCC=gcc
HOSTCFLAGS=-g -O2 -Wall
HOSTAR=ar
PAKWIF=$(topdir)tools/pakwif$(EXE)
PAKFI2=$(topdir)tools/packfi2/fi2enc$(EXE)
ENCODE_DISKBOOT=$(topdir)tools/dancingbits$(EXE)
##########################################################################
CC=arm-elf-gcc
OBJCOPY=arm-elf-objcopy
OBJDUMP=arm-elf-objdump
STRIP=arm-elf-strip
NM=arm-elf-nm
AR=arm-elf-ar
RANLIB=arm-elf-ranlib
SIZE=arm-elf-size
GCC_VERSION=$(shell $(CC) -dumpversion)
GCC_VERSION_MAJOR=$(firstword $(subst ., ,$(GCC_VERSION)))
# -msoft-float is used per default but object files are marked as hard-float
CFLAGS=-fno-inline -Os -fno-strict-aliasing
# flags for gcc v4
# CFLAGS+=-mcpu=arm946e-s
# for gcc v3, we use to allow use of strd etc
ifeq ($(GCC_VERSION_MAJOR),3)
CFLAGS+=-march=armv5te
else
ifeq ($(GCC_VERSION_MAJOR),4)
# TODO should be -mcpu, but breaks things ATM
CFLAGS+=-mtune=arm946e-s
endif
endif
CTHUMB=-mthumb
CFLAGS+=-mthumb-interwork
CFLAGS+=-I$(topdir)include -I$(topdir)core -I$(topdir)platform/$(PLATFORM) $(PLFLAGS) $(CPPFLAGS)
CFLAGS+=-DPLATFORM=\"$(PLATFORM)\" -DPLATFORMSUB=\"$(PLATFORMSUB)\" -DPLATFORMID=$(PLATFORMID) -DHDK_VERSION=\"$(VER)\" -DBUILD_NUMBER=\"$(BUILD_NUMBER)\" -DBUILD_SVNREV=\"$(BUILD_SVNREV)\" -DCAMERA_$(PLATFORM)=1
CFLAGS+=-Wall -Wno-unused -Wno-format
LDFLAGS=-L$(topdir)lib/math -L$(topdir)lib/font
LDFLAGS+=-L$(topdir)lib/libc -L$(topdir)lib/ubasic
LDFLAGS+=-L$(topdir)platform/$(PLATFORM) -L$(topdir)platform/$(PLATFORM)/sub/$(PLATFORMSUB)
ifndef OPT_DE_VERSION
CFLAGS+=-DVER_CHDK
else
CFLAGS+=-DVER_CHDK_DE
endif
ifdef OPT_DEBUGGING
CFLAGS+=-DOPT_DEBUGGING
endif
ifdef OPT_PTP
CFLAGS+=-DOPT_PTP
endif
ifdef OPT_LUA
CFLAGS+=-DOPT_LUA
OPT_SCRIPTING=1
endif
ifdef OPT_UBASIC
CFLAGS+=-DOPT_UBASIC
OPT_SCRIPTING=1
endif
ifdef OPT_SCRIPTING
CFLAGS+=-DOPT_SCRIPTING
endif
ifdef OPT_EXMEM_MALLOC
CFLAGS+=-DOPT_EXMEM_MALLOC
# Only allow OPT_CHDK_IN_EXMEM when OPT_EXMEM_MALLOC is also defined
ifdef OPT_CHDK_IN_EXMEM
CFLAGS+=-DOPT_CHDK_IN_EXMEM
endif
endif # OPT_EXMEM_MALLOC
ifdef OPT_EXMEM_TESTING
CFLAGS+=-DOPT_EXMEM_TESTING
endif
ifdef EXMEM_HEAP_SKIP
CFLAGS+=-DEXMEM_HEAP_SKIP=$(EXMEM_HEAP_SKIP)
endif
ifdef EXMEM_BUFFER_SIZE
CFLAGS+=-DEXMEM_BUFFER_SIZE=$(EXMEM_BUFFER_SIZE)
endif
ifdef OPT_DBG_DUMP
CFLAGS+=-DOPT_DBG_DUMP
endif
ifdef OPT_DBG_LUA_ASSERT
CFLAGS+=-DOPT_DBG_LUA_ASSERT
endif
ifdef OPT_WARNINGS
ifeq ($(GCC_VERSION_MAJOR),3)
CFLAGS+=-Wwrite-strings -Wsign-compare -Wunused -Wno-unused-parameter
HOSTCFLAGS+=-Wwrite-strings -Wsign-compare -Wunused -Wno-unused-parameter
endif
ifeq ($(GCC_VERSION_MAJOR),4)
CFLAGS+=-Wextra -fdiagnostics-show-option -Wno-missing-field-initializers -Wunused -Wno-unused-parameter
#HOSTCFLAGS+=-Wextra -fdiagnostics-show-option -Wno-missing-field-initializers -Wunused -Wno-unused-parameter
endif
endif
##########################################################################
.PHONY: default
default: all
ifndef SKIPBUILDRULES
%.o: %.c
@echo $< \-\> $@
$(CC) $(CFLAGS) -nostdinc -c -o $@ $<
%.o: %.S
@echo $< \-\> $@
$(CC) $(CFLAGS) -nostdinc -c -o $@ $<
%.a:
@echo $^ \-\> $@
$(AR) rcs $@ $^
.dep/%.d: %.c .dep
$(CC) $(CFLAGS) -M $< > $@.$$$$; \
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
rm -f $@.$$$$
.dep/%.d: %.S .dep
$(CC) $(CFLAGS) -M $< > $@.$$$$; \
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
rm -f $@.$$$$
endif
.PHONY: all
all: all-recursive
.PHONY: clean
clean: clean-recursive
.PHONY: distclean
distclean: distclean-recursive
.dep:
mkdir .dep
clean-recursive:
@for i in $(SUBDIRS); do \
echo \>\> Cleaning in $(FOLDER)$$i; \
$(MAKE) -C $$i FOLDER="$(FOLDER)$$i/" clean || exit 1; \
done
distclean-recursive:
@for i in $(SUBDIRS); do \
echo \>\> Distcleaning in $(FOLDER)$$i; \
$(MAKE) -C $$i FOLDER="$(FOLDER)$$i/" distclean || exit 1; \
done
all-recursive:
ifndef SKIPPLATFORMCHECK
ifndef PLATFORM
$(error PLATFORM has not been defined. Specify the PLATFORM to build on the command line or in localbuildconf.inc)
endif
ifndef PLATFORMSUB
$(error PLATFORMSUB has not been defined. Specify the PLATFORMSUB to build on the command line or in localbuildconf.inc)
endif
endif
@for i in $(SUBDIRS); do \
echo \>\> Entering to $(FOLDER)$$i; \
$(MAKE) -C $$i FOLDER="$(FOLDER)$$i/" || exit 1; \
echo \<\< Leaving $(FOLDER)$$i; \
done
depend-recursive:
@for i in $(SUBDIRS); do \
echo \>\> Entering to $(FOLDER)$$i; \
$(MAKE) -C $$i FOLDER="$(FOLDER)$$i/" depend || exit 1; \
echo \<\< Leaving $(FOLDER)$$i; \
done
ifdef SILENT
.SILENT:
endif
# Define empty recipes for source files (including the makefiles)
# to prevent make from trying implicit rules to create them. Speeds up build process
Makefile: ;
makefile: ;
$(topdir)makefile.inc: ;
$(topdir)buildconf.inc: ;
$(topdir)localbuildconf.inc: ;
$(topdir)version.inc: ;
$(topdir)revision.inc: ;
$(topdir)platform/$(PLATFORM)/sub/$(PLATFORMSUB)/makefile.inc: ;
$(topdir)platform/fi2.inc: ;
*.c: ;
*.txt: ;
*.sh: ;
reversebytes.S: ;
callfunc.S: ;
setjmp.S: ;
stubs_min.S: ;
stubs_entry_2.S: ;