| 1 | |
|---|
| 2 | MEMISOSIZE="(&_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 |
|---|
| 5 | PRIMARY_ROOT=$(topdir)platform |
|---|
| 6 | include $(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 |
|---|
| 11 | include $(topdir)version.inc |
|---|
| 12 | -include $(topdir)revision.inc |
|---|
| 13 | |
|---|
| 14 | ifndef OPT_DE_VERSION |
|---|
| 15 | VER=CHDK |
|---|
| 16 | ifndef OPT_DEFAULT_LANG |
|---|
| 17 | OPT_DEFAULT_LANG=english |
|---|
| 18 | endif |
|---|
| 19 | else |
|---|
| 20 | VER=CHDK_DE |
|---|
| 21 | ifndef OPT_DEFAULT_LANG |
|---|
| 22 | OPT_DEFAULT_LANG=german |
|---|
| 23 | endif |
|---|
| 24 | endif |
|---|
| 25 | |
|---|
| 26 | ifdef PLATFORM |
|---|
| 27 | ifdef PLATFORMSUB |
|---|
| 28 | include $(topdir)platform/$(PLATFORM)/sub/$(PLATFORMSUB)/makefile.inc |
|---|
| 29 | ifeq ($(PLATFORMOSVER),) |
|---|
| 30 | PLATFORMOSVER=0 |
|---|
| 31 | endif |
|---|
| 32 | endif |
|---|
| 33 | endif |
|---|
| 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 |
|---|
| 37 | ifdef MAXRAMADDR |
|---|
| 38 | PLFLAGS+=-DMAXRAMADDR=$(MAXRAMADDR) |
|---|
| 39 | else |
|---|
| 40 | PLFLAGS+=-DMAXRAMADDR=0x1FFFFFF |
|---|
| 41 | endif |
|---|
| 42 | ifdef ROMBASEADDR |
|---|
| 43 | PLFLAGS+=-DROMBASEADDR=$(ROMBASEADDR) |
|---|
| 44 | else |
|---|
| 45 | PLFLAGS+=-DROMBASEADDR=0xFFC00000 |
|---|
| 46 | endif |
|---|
| 47 | |
|---|
| 48 | ifdef OPT_FI2 |
|---|
| 49 | include $(topdir)platform/fi2.inc |
|---|
| 50 | endif |
|---|
| 51 | |
|---|
| 52 | SILENT=SILENT |
|---|
| 53 | |
|---|
| 54 | NOZERO100K=TRUE |
|---|
| 55 | |
|---|
| 56 | ########################################################################## |
|---|
| 57 | ########################################################################## |
|---|
| 58 | ########################################################################## |
|---|
| 59 | |
|---|
| 60 | ESED = sed -r |
|---|
| 61 | |
|---|
| 62 | # keep sort order consistent |
|---|
| 63 | export LC_ALL=C |
|---|
| 64 | |
|---|
| 65 | ifndef 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 |
|---|
| 99 | else |
|---|
| 100 | EXE = |
|---|
| 101 | SH = |
|---|
| 102 | DEVNULL = /dev/null |
|---|
| 103 | SORT = sort |
|---|
| 104 | endif |
|---|
| 105 | |
|---|
| 106 | ########################################################################## |
|---|
| 107 | ########################################################################## |
|---|
| 108 | ########################################################################## |
|---|
| 109 | |
|---|
| 110 | HOSTCC=gcc |
|---|
| 111 | HOSTCFLAGS=-g -O2 -Wall |
|---|
| 112 | HOSTAR=ar |
|---|
| 113 | |
|---|
| 114 | PAKWIF=$(topdir)tools/pakwif$(EXE) |
|---|
| 115 | PAKFI2=$(topdir)tools/packfi2/fi2enc$(EXE) |
|---|
| 116 | ENCODE_DISKBOOT=$(topdir)tools/dancingbits$(EXE) |
|---|
| 117 | |
|---|
| 118 | ########################################################################## |
|---|
| 119 | |
|---|
| 120 | CC=arm-elf-gcc |
|---|
| 121 | OBJCOPY=arm-elf-objcopy |
|---|
| 122 | OBJDUMP=arm-elf-objdump |
|---|
| 123 | STRIP=arm-elf-strip |
|---|
| 124 | NM=arm-elf-nm |
|---|
| 125 | AR=arm-elf-ar |
|---|
| 126 | RANLIB=arm-elf-ranlib |
|---|
| 127 | SIZE=arm-elf-size |
|---|
| 128 | |
|---|
| 129 | GCC_VERSION=$(shell $(CC) -dumpversion) |
|---|
| 130 | GCC_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 |
|---|
| 136 | CFLAGS=-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 |
|---|
| 140 | ifeq ($(GCC_VERSION_MAJOR),3) |
|---|
| 141 | CFLAGS+=-march=armv5te |
|---|
| 142 | else |
|---|
| 143 | ifeq ($(GCC_VERSION_MAJOR),4) |
|---|
| 144 | # TODO should be -mcpu, but breaks things ATM |
|---|
| 145 | CFLAGS+=-mtune=arm946e-s |
|---|
| 146 | endif |
|---|
| 147 | endif |
|---|
| 148 | |
|---|
| 149 | |
|---|
| 150 | CTHUMB=-mthumb |
|---|
| 151 | CFLAGS+=-mthumb-interwork |
|---|
| 152 | CFLAGS+=-I$(topdir)include -I$(topdir)core -I$(topdir)modules -I$(topdir)platform/$(PLATFORM) $(PLFLAGS) $(CPPFLAGS) |
|---|
| 153 | ifndef SKIPPLATFORMCHECK |
|---|
| 154 | CFLAGS+=-DPLATFORM=\"$(PLATFORM)\" -DPLATFORMSUB=\"$(PLATFORMSUB)\" -DPLATFORMID=$(PLATFORMID) -DCAMERA_$(PLATFORM)=1 |
|---|
| 155 | endif |
|---|
| 156 | CFLAGS+=-DVER_$(VER) -DHDK_VERSION=\"$(VER)\" -DBUILD_NUMBER=\"$(BUILD_NUMBER)\" -DBUILD_SVNREV=\"$(BUILD_SVNREV)\" |
|---|
| 157 | CFLAGS+=-Wall -Wno-unused -Wno-format |
|---|
| 158 | LDFLAGS=-L$(topdir)lib/math -L$(topdir)lib/font |
|---|
| 159 | LDFLAGS+=-L$(topdir)lib/libc -L$(topdir)lib/ubasic |
|---|
| 160 | LDFLAGS+=-L$(topdir)platform/$(PLATFORM) -L$(topdir)platform/$(PLATFORM)/sub/$(PLATFORMSUB) |
|---|
| 161 | |
|---|
| 162 | ifdef OPT_GAMES |
|---|
| 163 | CFLAGS+=-DOPT_GAMES |
|---|
| 164 | endif |
|---|
| 165 | |
|---|
| 166 | ifdef OPT_CURVES |
|---|
| 167 | CFLAGS+=-DOPT_CURVES |
|---|
| 168 | endif |
|---|
| 169 | |
|---|
| 170 | ifdef OPT_EDGEOVERLAY |
|---|
| 171 | CFLAGS+=-DOPT_EDGEOVERLAY |
|---|
| 172 | endif |
|---|
| 173 | |
|---|
| 174 | ifdef OPT_MD_DEBUG |
|---|
| 175 | CFLAGS+=-DOPT_MD_DEBUG |
|---|
| 176 | endif |
|---|
| 177 | |
|---|
| 178 | ifdef OPT_DEBUGGING |
|---|
| 179 | CFLAGS+=-DOPT_DEBUGGING |
|---|
| 180 | endif |
|---|
| 181 | |
|---|
| 182 | ifdef OPT_PTP |
|---|
| 183 | CFLAGS+=-DOPT_PTP |
|---|
| 184 | endif |
|---|
| 185 | |
|---|
| 186 | ifdef OPT_FORCE_LUA_CALL_NATIVE |
|---|
| 187 | CFLAGS+=-DOPT_FORCE_LUA_CALL_NATIVE |
|---|
| 188 | endif |
|---|
| 189 | |
|---|
| 190 | ifdef OPT_EXMEM_MALLOC |
|---|
| 191 | CFLAGS+=-DOPT_EXMEM_MALLOC |
|---|
| 192 | # Only allow OPT_CHDK_IN_EXMEM when OPT_EXMEM_MALLOC is also defined |
|---|
| 193 | ifdef OPT_CHDK_IN_EXMEM |
|---|
| 194 | CFLAGS+=-DOPT_CHDK_IN_EXMEM |
|---|
| 195 | endif |
|---|
| 196 | endif # OPT_EXMEM_MALLOC |
|---|
| 197 | |
|---|
| 198 | ifdef OPT_EXMEM_TESTING |
|---|
| 199 | CFLAGS+=-DOPT_EXMEM_TESTING |
|---|
| 200 | endif |
|---|
| 201 | |
|---|
| 202 | ifdef EXMEM_HEAP_SKIP |
|---|
| 203 | CFLAGS+=-DEXMEM_HEAP_SKIP=$(EXMEM_HEAP_SKIP) |
|---|
| 204 | endif |
|---|
| 205 | |
|---|
| 206 | ifdef EXMEM_BUFFER_SIZE |
|---|
| 207 | CFLAGS+=-DEXMEM_BUFFER_SIZE=$(EXMEM_BUFFER_SIZE) |
|---|
| 208 | endif |
|---|
| 209 | |
|---|
| 210 | ifdef OPT_DBG_LUA_ASSERT |
|---|
| 211 | CFLAGS+=-DOPT_DBG_LUA_ASSERT |
|---|
| 212 | endif |
|---|
| 213 | |
|---|
| 214 | ifdef 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 |
|---|
| 223 | endif |
|---|
| 224 | |
|---|
| 225 | ########################################################################## |
|---|
| 226 | |
|---|
| 227 | .PHONY: default |
|---|
| 228 | default: all |
|---|
| 229 | |
|---|
| 230 | ifndef 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 | |
|---|
| 268 | endif |
|---|
| 269 | |
|---|
| 270 | .PHONY: all |
|---|
| 271 | all: all-recursive |
|---|
| 272 | |
|---|
| 273 | .PHONY: clean |
|---|
| 274 | clean: clean-recursive |
|---|
| 275 | |
|---|
| 276 | .PHONY: distclean |
|---|
| 277 | distclean: distclean-recursive |
|---|
| 278 | |
|---|
| 279 | .dep: |
|---|
| 280 | mkdir .dep |
|---|
| 281 | |
|---|
| 282 | clean-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 | |
|---|
| 288 | distclean-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 | |
|---|
| 294 | all-recursive: |
|---|
| 295 | ifndef SKIPPLATFORMCHECK |
|---|
| 296 | ifndef PLATFORM |
|---|
| 297 | $(error PLATFORM has not been defined. Specify the PLATFORM to build on the command line or in localbuildconf.inc) |
|---|
| 298 | endif |
|---|
| 299 | ifndef PLATFORMSUB |
|---|
| 300 | $(error PLATFORMSUB has not been defined. Specify the PLATFORMSUB to build on the command line or in localbuildconf.inc) |
|---|
| 301 | endif |
|---|
| 302 | endif |
|---|
| 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 | |
|---|
| 309 | depend-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 | |
|---|
| 316 | ifdef SILENT |
|---|
| 317 | .SILENT: |
|---|
| 318 | endif |
|---|
| 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 |
|---|
| 323 | Makefile: ; |
|---|
| 324 | makefile: ; |
|---|
| 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: ; |
|---|
| 335 | reversebytes.S: ; |
|---|
| 336 | callfunc.S: ; |
|---|
| 337 | setjmp.S: ; |
|---|
| 338 | stubs_min.S: ; |
|---|
| 339 | stubs_entry_2.S: ; |
|---|
| 340 | |
|---|