source: trunk/makefile.inc @ 2798

Revision 2762, 8.3 KB checked in by reyalp, 2 weeks ago (diff)

add -fno-schedule-insns2 to fix intermittent lua errors, gcc bug http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38644 see http://chdk.setepontos.com/index.php?topic=8273.msg100205#msg100205 for discussion

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