source: branches/release-1_0/makefile.inc @ 1745

Revision 1745, 7.2 KB checked in by philmoz, 14 months ago (diff)

Re-align CHDK and CHDK-DE code base (part 12) - http://chdk.setepontos.com/index.php?topic=7601.0

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