| 1 | include $(topdir)chdk_ver.inc |
|---|
| 2 | |
|---|
| 3 | MEMISOSIZE="(&_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 |
|---|
| 6 | PRIMARY_ROOT=$(topdir)platform |
|---|
| 7 | include $(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 |
|---|
| 12 | include $(topdir)version.inc |
|---|
| 13 | -include $(topdir)revision.inc |
|---|
| 14 | |
|---|
| 15 | ifdef PLATFORM |
|---|
| 16 | ifdef PLATFORMSUB |
|---|
| 17 | include $(topdir)platform/$(PLATFORM)/sub/$(PLATFORMSUB)/makefile.inc |
|---|
| 18 | endif |
|---|
| 19 | endif |
|---|
| 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 |
|---|
| 23 | ifdef MAXRAMADDR |
|---|
| 24 | PLFLAGS+=-DMAXRAMADDR=$(MAXRAMADDR) |
|---|
| 25 | else |
|---|
| 26 | PLFLAGS+=-DMAXRAMADDR=0x1FFFFFF |
|---|
| 27 | endif |
|---|
| 28 | ifdef ROMBASEADDR |
|---|
| 29 | PLFLAGS+=-DROMBASEADDR=$(ROMBASEADDR) |
|---|
| 30 | else |
|---|
| 31 | PLFLAGS+=-DROMBASEADDR=0xFFC00000 |
|---|
| 32 | endif |
|---|
| 33 | |
|---|
| 34 | ifdef OPT_FI2 |
|---|
| 35 | include $(topdir)platform/fi2.inc |
|---|
| 36 | endif |
|---|
| 37 | |
|---|
| 38 | SILENT=SILENT |
|---|
| 39 | |
|---|
| 40 | NOZERO100K=TRUE |
|---|
| 41 | |
|---|
| 42 | ########################################################################## |
|---|
| 43 | ########################################################################## |
|---|
| 44 | ########################################################################## |
|---|
| 45 | |
|---|
| 46 | ESED = sed -r |
|---|
| 47 | |
|---|
| 48 | # keep sort order consistent |
|---|
| 49 | export LC_ALL=C |
|---|
| 50 | |
|---|
| 51 | ifndef 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 |
|---|
| 85 | else |
|---|
| 86 | EXE = |
|---|
| 87 | SH = |
|---|
| 88 | DEVNULL = /dev/null |
|---|
| 89 | SORT = sort |
|---|
| 90 | endif |
|---|
| 91 | |
|---|
| 92 | ########################################################################## |
|---|
| 93 | ########################################################################## |
|---|
| 94 | ########################################################################## |
|---|
| 95 | |
|---|
| 96 | HOSTCC=gcc |
|---|
| 97 | HOSTCFLAGS=-g -O2 -Wall |
|---|
| 98 | HOSTAR=ar |
|---|
| 99 | |
|---|
| 100 | PAKWIF=$(topdir)tools/pakwif$(EXE) |
|---|
| 101 | PAKFI2=$(topdir)tools/packfi2/fi2enc$(EXE) |
|---|
| 102 | ENCODE_DISKBOOT=$(topdir)tools/dancingbits$(EXE) |
|---|
| 103 | |
|---|
| 104 | ########################################################################## |
|---|
| 105 | |
|---|
| 106 | CC=arm-elf-gcc |
|---|
| 107 | OBJCOPY=arm-elf-objcopy |
|---|
| 108 | OBJDUMP=arm-elf-objdump |
|---|
| 109 | STRIP=arm-elf-strip |
|---|
| 110 | NM=arm-elf-nm |
|---|
| 111 | AR=arm-elf-ar |
|---|
| 112 | RANLIB=arm-elf-ranlib |
|---|
| 113 | SIZE=arm-elf-size |
|---|
| 114 | |
|---|
| 115 | GCC_VERSION=$(shell $(CC) -dumpversion) |
|---|
| 116 | GCC_VERSION_MAJOR=$(firstword $(subst ., ,$(GCC_VERSION))) |
|---|
| 117 | |
|---|
| 118 | # -msoft-float is used per default but object files are marked as hard-float |
|---|
| 119 | CFLAGS=-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 |
|---|
| 123 | ifeq ($(GCC_VERSION_MAJOR),3) |
|---|
| 124 | CFLAGS+=-march=armv5te |
|---|
| 125 | else |
|---|
| 126 | ifeq ($(GCC_VERSION_MAJOR),4) |
|---|
| 127 | # TODO should be -mcpu, but breaks things ATM |
|---|
| 128 | CFLAGS+=-mtune=arm946e-s |
|---|
| 129 | endif |
|---|
| 130 | endif |
|---|
| 131 | |
|---|
| 132 | |
|---|
| 133 | CTHUMB=-mthumb |
|---|
| 134 | CFLAGS+=-mthumb-interwork |
|---|
| 135 | CFLAGS+=-I$(topdir)include -I$(topdir)core -I$(topdir)platform/$(PLATFORM) $(PLFLAGS) $(CPPFLAGS) |
|---|
| 136 | CFLAGS+=-DPLATFORM=\"$(PLATFORM)\" -DPLATFORMSUB=\"$(PLATFORMSUB)\" -DPLATFORMID=$(PLATFORMID) -DHDK_VERSION=\"$(VER)\" -DBUILD_NUMBER=\"$(BUILD_NUMBER)\" -DBUILD_SVNREV=\"$(BUILD_SVNREV)\" -DCAMERA_$(PLATFORM)=1 |
|---|
| 137 | CFLAGS+=-Wall -Wno-unused -Wno-format |
|---|
| 138 | LDFLAGS=-L$(topdir)lib/math -L$(topdir)lib/font |
|---|
| 139 | LDFLAGS+=-L$(topdir)lib/libc -L$(topdir)lib/ubasic |
|---|
| 140 | LDFLAGS+=-L$(topdir)platform/$(PLATFORM) -L$(topdir)platform/$(PLATFORM)/sub/$(PLATFORMSUB) |
|---|
| 141 | |
|---|
| 142 | ifeq ($(VER),CHDK) |
|---|
| 143 | CFLAGS+=-DVER_CHDK |
|---|
| 144 | else |
|---|
| 145 | CFLAGS+=-DVER_CHDK_DE |
|---|
| 146 | endif |
|---|
| 147 | |
|---|
| 148 | ifdef OPT_DEBUGGING |
|---|
| 149 | CFLAGS+=-DOPT_DEBUGGING |
|---|
| 150 | endif |
|---|
| 151 | |
|---|
| 152 | ifdef OPT_PTP |
|---|
| 153 | CFLAGS+=-DOPT_PTP |
|---|
| 154 | endif |
|---|
| 155 | |
|---|
| 156 | ifdef OPT_LUA |
|---|
| 157 | CFLAGS+=-DOPT_LUA |
|---|
| 158 | OPT_SCRIPTING=1 |
|---|
| 159 | endif |
|---|
| 160 | |
|---|
| 161 | ifdef OPT_UBASIC |
|---|
| 162 | CFLAGS+=-DOPT_UBASIC |
|---|
| 163 | OPT_SCRIPTING=1 |
|---|
| 164 | endif |
|---|
| 165 | |
|---|
| 166 | ifdef OPT_SCRIPTING |
|---|
| 167 | CFLAGS+=-DOPT_SCRIPTING |
|---|
| 168 | endif |
|---|
| 169 | |
|---|
| 170 | ifdef OPT_EXMEM_MALLOC |
|---|
| 171 | CFLAGS+=-DOPT_EXMEM_MALLOC |
|---|
| 172 | endif |
|---|
| 173 | |
|---|
| 174 | ifdef OPT_EXMEM_TESTING |
|---|
| 175 | CFLAGS+=-DOPT_EXMEM_TESTING |
|---|
| 176 | endif |
|---|
| 177 | |
|---|
| 178 | ifdef EXMEM_HEAP_SKIP |
|---|
| 179 | CFLAGS+=-DEXMEM_HEAP_SKIP=$(EXMEM_HEAP_SKIP) |
|---|
| 180 | endif |
|---|
| 181 | |
|---|
| 182 | ifdef EXMEM_BUFFER_SIZE |
|---|
| 183 | CFLAGS+=-DEXMEM_BUFFER_SIZE=$(EXMEM_BUFFER_SIZE) |
|---|
| 184 | endif |
|---|
| 185 | |
|---|
| 186 | ifdef OPT_CHDK_IN_EXMEM |
|---|
| 187 | CFLAGS+=-DOPT_CHDK_IN_EXMEM |
|---|
| 188 | endif |
|---|
| 189 | |
|---|
| 190 | ifdef 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 |
|---|
| 199 | endif |
|---|
| 200 | |
|---|
| 201 | ########################################################################## |
|---|
| 202 | |
|---|
| 203 | .PHONY: default |
|---|
| 204 | default: all |
|---|
| 205 | |
|---|
| 206 | ifndef 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 | |
|---|
| 228 | endif |
|---|
| 229 | |
|---|
| 230 | .PHONY: all |
|---|
| 231 | all: all-recursive |
|---|
| 232 | |
|---|
| 233 | .PHONY: clean |
|---|
| 234 | clean: clean-recursive |
|---|
| 235 | |
|---|
| 236 | .PHONY: distclean |
|---|
| 237 | distclean: distclean-recursive |
|---|
| 238 | |
|---|
| 239 | .dep: |
|---|
| 240 | mkdir .dep |
|---|
| 241 | |
|---|
| 242 | clean-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 | |
|---|
| 248 | distclean-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 | |
|---|
| 254 | all-recursive: |
|---|
| 255 | ifndef PLATFORM |
|---|
| 256 | $(error PLATFORM has not been defined. Specify the PLATFORM to build on the command line or in localbuildconf.inc) |
|---|
| 257 | endif |
|---|
| 258 | ifndef PLATFORMSUB |
|---|
| 259 | $(error PLATFORMSUB has not been defined. Specify the PLATFORMSUB to build on the command line or in localbuildconf.inc) |
|---|
| 260 | endif |
|---|
| 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 | |
|---|
| 267 | depend-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 | |
|---|
| 274 | ifdef SILENT |
|---|
| 275 | .SILENT: |
|---|
| 276 | endif |
|---|
| 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 |
|---|
| 281 | Makefile: ; |
|---|
| 282 | makefile: ; |
|---|
| 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: ; |
|---|
| 293 | reversebytes.S: ; |
|---|
| 294 | callfunc.S: ; |
|---|
| 295 | setjmp.S: ; |
|---|
| 296 | stubs_min.S: ; |
|---|
| 297 | stubs_entry_2.S: ; |
|---|
| 298 | |
|---|