| 1 | topdir=./ |
|---|
| 2 | srcdir=./ |
|---|
| 3 | |
|---|
| 4 | tmp:=$(shell echo "BUILD_SVNREV := $(DEF_SVN_REF)" > revision.inc) |
|---|
| 5 | |
|---|
| 6 | # can override on command line or *buildconf.inc for custom subsets |
|---|
| 7 | CAMERA_LIST=camera_list.csv |
|---|
| 8 | |
|---|
| 9 | include makefile.inc |
|---|
| 10 | |
|---|
| 11 | BUILD_SVNREV:=$(shell svnversion -cn $(topdir) | $(ESED) 's/[0-9]*:([0-9]+)[MPS]*/\1/') |
|---|
| 12 | ifeq ($(BUILD_SVNREV), ) |
|---|
| 13 | BUILD_SVNREV:=$(DEF_SVN_REF) |
|---|
| 14 | endif |
|---|
| 15 | #for CHDK-Shell up to svn revision 1.6 |
|---|
| 16 | ifeq ($(BUILD_SVNREV), exported) |
|---|
| 17 | BUILD_SVNREV:=$(DEF_SVN_REF) |
|---|
| 18 | endif |
|---|
| 19 | ifeq ($(BUILD_SVNREV), exportiert) |
|---|
| 20 | BUILD_SVNREV:=$(DEF_SVN_REF) |
|---|
| 21 | endif |
|---|
| 22 | #for CHDK-Shell svn revision 1.7 |
|---|
| 23 | ifeq ($(BUILD_SVNREV), Unversioned directory) |
|---|
| 24 | BUILD_SVNREV:=$(DEF_SVN_REF) |
|---|
| 25 | endif |
|---|
| 26 | tmp:=$(shell echo "BUILD_SVNREV := $(BUILD_SVNREV)" > revision.inc) |
|---|
| 27 | |
|---|
| 28 | # CHDK folder for full package |
|---|
| 29 | ZIPDIRS:=$(shell ls -R CHDK | grep CHDK/ | $(ESED) 's?:?/*?') |
|---|
| 30 | |
|---|
| 31 | SUBDIRS= |
|---|
| 32 | |
|---|
| 33 | # SKIP_TOOLS prevents re-building tools in root level make, to speed up batch builds |
|---|
| 34 | ifndef SKIP_TOOLS |
|---|
| 35 | SUBDIRS+=tools |
|---|
| 36 | endif |
|---|
| 37 | |
|---|
| 38 | # SKIP_MODULES prevents re-building core/modules in root level make, to speed up batch builds |
|---|
| 39 | ifndef SKIP_MODULES |
|---|
| 40 | SUBDIRS+=modules |
|---|
| 41 | endif |
|---|
| 42 | |
|---|
| 43 | # SKIP_CHDK prevents cleaning CHDK in root level make, to speed up batch clean |
|---|
| 44 | ifndef SKIP_CHDK |
|---|
| 45 | SUBDIRS+=CHDK |
|---|
| 46 | endif |
|---|
| 47 | |
|---|
| 48 | # Must do platform before core |
|---|
| 49 | SUBDIRS+=platform/$(PLATFORM) platform/$(PLATFORM)/sub/$(PLATFORMSUB) |
|---|
| 50 | |
|---|
| 51 | # SKIP_CORE prevents cleaning core in root level make, to speed up batch clean |
|---|
| 52 | ifndef SKIP_CORE |
|---|
| 53 | SUBDIRS+=core |
|---|
| 54 | endif |
|---|
| 55 | |
|---|
| 56 | # Must do this last as it builds the final .bin file |
|---|
| 57 | SUBDIRS+=loader/$(PLATFORM) |
|---|
| 58 | |
|---|
| 59 | .PHONY: fir |
|---|
| 60 | fir: version firsub |
|---|
| 61 | |
|---|
| 62 | |
|---|
| 63 | firsub: all |
|---|
| 64 | mkdir -p $(topdir)bin |
|---|
| 65 | cp $(topdir)loader/$(PLATFORM)/main.bin $(topdir)bin/main.bin |
|---|
| 66 | ifndef NOZERO100K |
|---|
| 67 | ifeq ($(OSTYPE),Windows) |
|---|
| 68 | zero | dd bs=1k count=100 >> $(topdir)bin/main.bin 2> $(DEVNULL) |
|---|
| 69 | else |
|---|
| 70 | dd if=/dev/zero bs=1k count=100 >> $(topdir)bin/main.bin 2> $(DEVNULL) |
|---|
| 71 | endif |
|---|
| 72 | endif |
|---|
| 73 | ifdef PLATFORMOS |
|---|
| 74 | ifeq ($(PLATFORMOS),vxworks) |
|---|
| 75 | @echo \-\> PS.FIR |
|---|
| 76 | $(PAKWIF) $(topdir)bin/PS.FIR $(topdir)bin/main.bin $(PLATFORMID) 0x01000101 |
|---|
| 77 | endif |
|---|
| 78 | ifeq ($(PLATFORMOS),dryos) |
|---|
| 79 | ifdef OPT_FI2 |
|---|
| 80 | ifdef FI2KEY |
|---|
| 81 | @echo \-\> PS.FI2 |
|---|
| 82 | $(PAKFI2) $(topdir)bin/main.bin -p $(PLATFORMID) -pv $(PLATFORMOSVER) -key $(FI2KEY) -iv $(FI2IV) $(topdir)bin/PS.FI2 |
|---|
| 83 | else |
|---|
| 84 | @echo WARNING OPT_FI2 set but FI2KEY is not! please read platform/fi2.inc.txt |
|---|
| 85 | endif |
|---|
| 86 | endif |
|---|
| 87 | endif |
|---|
| 88 | endif |
|---|
| 89 | ifdef NEED_ENCODED_DISKBOOT |
|---|
| 90 | @echo dance \-\> DISKBOOT.BIN ver $(NEED_ENCODED_DISKBOOT) |
|---|
| 91 | $(ENCODE_DISKBOOT) $(topdir)bin/main.bin $(topdir)bin/DISKBOOT.BIN $(NEED_ENCODED_DISKBOOT) |
|---|
| 92 | rm $(topdir)bin/main.bin |
|---|
| 93 | else |
|---|
| 94 | mv $(topdir)bin/main.bin $(topdir)bin/DISKBOOT.BIN |
|---|
| 95 | endif |
|---|
| 96 | @echo "**** Firmware creation completed successfully" |
|---|
| 97 | |
|---|
| 98 | |
|---|
| 99 | .PHONY: upload |
|---|
| 100 | upload: fir |
|---|
| 101 | @echo Uploading... |
|---|
| 102 | cp $(topdir)bin/$(PLATFORM)-$(PLATFORMSUB).FIR $(topdir)bin/PS.FIR |
|---|
| 103 | /home/vitalyb/Projects/ch/libptp2-1.1.0/src/ptpcam -u -m 0xbf01 --filename $(topdir)bin/PS.FIR |
|---|
| 104 | |
|---|
| 105 | |
|---|
| 106 | infoline: |
|---|
| 107 | @echo "**** GCC $(GCC_VERSION) : BUILDING CHDK-$(VER), #$(BUILD_NUMBER)$(STATE) FOR $(PLATFORM)-$(PLATFORMSUB)-$(BUILD_SVNREV)" |
|---|
| 108 | |
|---|
| 109 | .PHONY: version |
|---|
| 110 | version: FORCE |
|---|
| 111 | echo "**** Build: $(BUILD_NUMBER)" |
|---|
| 112 | |
|---|
| 113 | |
|---|
| 114 | .PHONY: FORCE |
|---|
| 115 | FORCE: |
|---|
| 116 | |
|---|
| 117 | |
|---|
| 118 | firzip: version firzipsub |
|---|
| 119 | |
|---|
| 120 | |
|---|
| 121 | firzipsub: infoline clean firsub |
|---|
| 122 | @echo \-\> $(VER)-$(PLATFORM)-$(PLATFORMSUB)-$(BUILD_NUMBER)$(STATE).zip |
|---|
| 123 | rm -f $(topdir)bin/$(VER)-$(PLATFORM)-$(PLATFORMSUB)-$(BUILD_NUMBER)$(STATE).zip |
|---|
| 124 | LANG=C echo -e "CHDK-$(VER) for $(PLATFORM) fw:$(PLATFORMSUB) build:$(BUILD_NUMBER) date:`date -R`" | \ |
|---|
| 125 | zip -9jz $(topdir)bin/$(VER)-$(PLATFORM)-$(PLATFORMSUB)-$(BUILD_NUMBER)$(STATE).zip $(topdir)bin/DISKBOOT.BIN > $(DEVNULL) |
|---|
| 126 | ifdef PLATFORMOS |
|---|
| 127 | ifeq ($(PLATFORMOS),vxworks) |
|---|
| 128 | zip -9j $(topdir)bin/$(VER)-$(PLATFORM)-$(PLATFORMSUB)-$(BUILD_NUMBER)$(STATE).zip $(topdir)bin/PS.FIR > $(DEVNULL) |
|---|
| 129 | rm -f $(topdir)bin/PS.FIR |
|---|
| 130 | endif |
|---|
| 131 | ifeq ($(PLATFORMOS),dryos) |
|---|
| 132 | ifdef OPT_FI2 |
|---|
| 133 | ifdef FI2KEY |
|---|
| 134 | zip -9j $(topdir)bin/$(VER)-$(PLATFORM)-$(PLATFORMSUB)-$(BUILD_NUMBER)$(STATE).zip $(topdir)bin/PS.FI2 > $(DEVNULL) |
|---|
| 135 | rm -f $(topdir)bin/PS.FI2 |
|---|
| 136 | endif |
|---|
| 137 | endif |
|---|
| 138 | endif |
|---|
| 139 | endif |
|---|
| 140 | zip -9 $(topdir)bin/$(VER)-$(PLATFORM)-$(PLATFORMSUB)-$(BUILD_NUMBER)$(STATE).zip $(topdir)CHDK/MODULES/* > $(DEVNULL) |
|---|
| 141 | # if COPY_TO is defined then copy this camera/firmware version to the copied firmware version |
|---|
| 142 | # Define COPY_TO in $(topdir)/platform/$(PLATFORM)/sub/$(PLATFORMSUB)/makefile.inc of the source |
|---|
| 143 | # firmware version that needs to be copied to another firmware version |
|---|
| 144 | # For the case where one CHDK version applies to two or more other Canon firmware version place all the |
|---|
| 145 | # 'copy to' firmware versions together seperated by ':' - e.g. "a2000,100c,BETA,100a:100b," |
|---|
| 146 | ifdef COPY_TO |
|---|
| 147 | @echo "**** Copying duplicate Firmwares" |
|---|
| 148 | $(foreach COPY_PLATFORMSUB, $(subst :, ,$(COPY_TO)), \ |
|---|
| 149 | cp $(topdir)bin/$(VER)-$(PLATFORM)-$(PLATFORMSUB)-$(BUILD_NUMBER)$(STATE).zip $(topdir)bin/$(VER)-$(PLATFORM)-$(COPY_PLATFORMSUB)-$(BUILD_NUMBER)$(STATE).zip ; \ |
|---|
| 150 | ) |
|---|
| 151 | endif |
|---|
| 152 | rm -f $(topdir)bin/DISKBOOT.BIN |
|---|
| 153 | |
|---|
| 154 | |
|---|
| 155 | firzipsubcomplete: infoline clean firsub |
|---|
| 156 | @echo \-\> $(PLATFORM)-$(PLATFORMSUB)-$(BUILD_NUMBER)-full$(STATE).zip |
|---|
| 157 | rm -f $(topdir)bin/$(PLATFORM)-$(PLATFORMSUB)-$(BUILD_NUMBER)-full$(STATE).zip |
|---|
| 158 | @echo \-\> $(PLATFORM)-$(PLATFORMSUB)-$(BUILD_NUMBER)$(STATE).zip |
|---|
| 159 | rm -f $(topdir)bin/$(PLATFORM)-$(PLATFORMSUB)-$(BUILD_NUMBER)$(STATE).zip |
|---|
| 160 | LANG=C echo -e "CHDK-$(VER) for $(PLATFORM) fw:$(PLATFORMSUB) build:$(BUILD_NUMBER)$(STATE) date:`date -R`" | \ |
|---|
| 161 | zip -9jz $(topdir)bin/$(PLATFORM)-$(PLATFORMSUB)-$(BUILD_NUMBER)-full$(STATE).zip $(topdir)bin/DISKBOOT.BIN > $(DEVNULL) |
|---|
| 162 | LANG=C echo -e "CHDK-$(VER) for $(PLATFORM) fw:$(PLATFORMSUB) build:$(BUILD_NUMBER)$(STATE) date:`date -R`" | \ |
|---|
| 163 | zip -9jz $(topdir)bin/$(PLATFORM)-$(PLATFORMSUB)-$(BUILD_NUMBER)$(STATE).zip $(topdir)bin/DISKBOOT.BIN > $(DEVNULL) |
|---|
| 164 | $(foreach ZIPDIR, $(ZIPDIRS), \ |
|---|
| 165 | zip -9 $(topdir)bin/$(PLATFORM)-$(PLATFORMSUB)-$(BUILD_NUMBER)-full$(STATE).zip $(topdir)$(ZIPDIR) > $(DEVNULL) ; \ |
|---|
| 166 | ) |
|---|
| 167 | zip -9 $(topdir)bin/$(PLATFORM)-$(PLATFORMSUB)-$(BUILD_NUMBER)-full$(STATE).zip $(topdir)CHDK/syscurves.CVF > $(DEVNULL) |
|---|
| 168 | zip -9j $(topdir)bin/$(PLATFORM)-$(PLATFORMSUB)-$(BUILD_NUMBER)-full$(STATE).zip $(topdir)doc/changelog.txt > $(DEVNULL) |
|---|
| 169 | zip -9j $(topdir)bin/$(PLATFORM)-$(PLATFORMSUB)-$(BUILD_NUMBER)$(STATE).zip $(topdir)doc/changelog.txt > $(DEVNULL) |
|---|
| 170 | zip -9j $(topdir)bin/$(PLATFORM)-$(PLATFORMSUB)-$(BUILD_NUMBER)-full$(STATE).zip $(topdir)tools/vers.req > $(DEVNULL) |
|---|
| 171 | cat $(topdir)doc/1_intro.txt $(topdir)platform/$(PLATFORM)/notes.txt $(topdir)doc/2_installation.txt $(topdir)doc/3_faq.txt $(topdir)doc/4_urls.txt $(topdir)doc/5_gpl.txt $(topdir)doc/6_ubasic_copyright.txt > $(topdir)doc/readme.txt |
|---|
| 172 | zip -9j $(topdir)bin/$(PLATFORM)-$(PLATFORMSUB)-$(BUILD_NUMBER)-full$(STATE).zip $(topdir)doc/readme.txt > $(DEVNULL) |
|---|
| 173 | zip -9j $(topdir)bin/$(PLATFORM)-$(PLATFORMSUB)-$(BUILD_NUMBER)$(STATE).zip $(topdir)doc/readme.txt > $(DEVNULL) |
|---|
| 174 | zip -9 $(topdir)bin/$(PLATFORM)-$(PLATFORMSUB)-$(BUILD_NUMBER)$(STATE).zip $(topdir)CHDK/MODULES/* > $(DEVNULL) |
|---|
| 175 | |
|---|
| 176 | ifdef PLATFORMOS |
|---|
| 177 | ifeq ($(PLATFORMOS),vxworks) |
|---|
| 178 | zip -9j $(topdir)bin/$(PLATFORM)-$(PLATFORMSUB)-$(BUILD_NUMBER)-full$(STATE).zip $(topdir)bin/PS.FIR > $(DEVNULL) |
|---|
| 179 | zip -9j $(topdir)bin/$(PLATFORM)-$(PLATFORMSUB)-$(BUILD_NUMBER)$(STATE).zip $(topdir)bin/PS.FIR > $(DEVNULL) |
|---|
| 180 | rm -f $(topdir)bin/PS.FIR |
|---|
| 181 | endif |
|---|
| 182 | ifeq ($(PLATFORMOS),dryos) |
|---|
| 183 | ifdef OPT_FI2 |
|---|
| 184 | ifdef FI2KEY |
|---|
| 185 | zip -9j $(topdir)bin/$(PLATFORM)-$(PLATFORMSUB)-$(BUILD_NUMBER)-full$(STATE).zip $(topdir)bin/PS.FI2 > $(DEVNULL) |
|---|
| 186 | zip -9j $(topdir)bin/$(PLATFORM)-$(PLATFORMSUB)-$(BUILD_NUMBER)$(STATE).zip $(topdir)bin/PS.FI2 > $(DEVNULL) |
|---|
| 187 | rm -f $(topdir)bin/PS.FI2 |
|---|
| 188 | endif |
|---|
| 189 | endif |
|---|
| 190 | endif |
|---|
| 191 | endif |
|---|
| 192 | # if COPY_TO is defined then copy this camera/firmware version to the copied firmware version |
|---|
| 193 | # Define COPY_TO in $(topdir)/platform/$(PLATFORM)/sub/$(PLATFORMSUB)/makefile.inc of the source |
|---|
| 194 | # firmware version that needs to be copied to another firmware version |
|---|
| 195 | # For the case where one CHDK version applies to two or more other Canon firmware version place all the |
|---|
| 196 | # 'copy to' firmware versions together seperated by ':' - e.g. "a2000,100c,BETA,100a:100b," |
|---|
| 197 | ifdef COPY_TO |
|---|
| 198 | @echo "**** Copying duplicate Firmwares" |
|---|
| 199 | $(foreach COPY_PLATFORMSUB, $(subst :, ,$(COPY_TO)), \ |
|---|
| 200 | cp $(topdir)bin/$(PLATFORM)-$(PLATFORMSUB)-$(BUILD_NUMBER)-full$(STATE).zip $(topdir)bin/$(PLATFORM)-$(COPY_PLATFORMSUB)-$(BUILD_NUMBER)-full$(STATE).zip ; \ |
|---|
| 201 | cp $(topdir)bin/$(PLATFORM)-$(PLATFORMSUB)-$(BUILD_NUMBER)$(STATE).zip $(topdir)bin/$(PLATFORM)-$(COPY_PLATFORMSUB)-$(BUILD_NUMBER)$(STATE).zip ; \ |
|---|
| 202 | ) |
|---|
| 203 | endif |
|---|
| 204 | rm -f $(topdir)bin/DISKBOOT.BIN |
|---|
| 205 | |
|---|
| 206 | print-missing-dump: |
|---|
| 207 | if [ ! -s $(PRIMARY_ROOT)/$(PLATFORM)/sub/$(PLATFORMSUB)/PRIMARY.BIN ] ; then \ |
|---|
| 208 | echo "missing primary for $(PLATFORM) $(PLATFORMSUB)" ; \ |
|---|
| 209 | fi |
|---|
| 210 | |
|---|
| 211 | rebuild-stubs: |
|---|
| 212 | if [ -s $(PRIMARY_ROOT)/$(PLATFORM)/sub/$(PLATFORMSUB)/PRIMARY.BIN ] ; then \ |
|---|
| 213 | echo "rebuild stubs for $(PLATFORM)-$(PLATFORMSUB)" ;\ |
|---|
| 214 | $(MAKE) -C $(topdir)platform/$(PLATFORM)/sub/$(PLATFORMSUB) stubs_entry.S ;\ |
|---|
| 215 | else \ |
|---|
| 216 | echo "!!! missing primary for $(PLATFORM)-$(PLATFORMSUB)"; \ |
|---|
| 217 | fi |
|---|
| 218 | |
|---|
| 219 | # for batch builds, build tools for vx and dryos once, instead of once for every firmware |
|---|
| 220 | alltools: |
|---|
| 221 | $(MAKE) -C tools clean all |
|---|
| 222 | |
|---|
| 223 | # for batch builds, build modules once, instead of once for every firmware |
|---|
| 224 | allmodules: |
|---|
| 225 | $(MAKE) -C modules clean all |
|---|
| 226 | $(MAKE) -C CHDK clean all |
|---|
| 227 | |
|---|
| 228 | # note assumes PLATFORMOS is always in same case! |
|---|
| 229 | os-camera-list-entry: |
|---|
| 230 | echo $(PLATFORM),$(PLATFORMSUB),$(subst _,,$(STATE)),$(COPY_TO),$(SKIP_AUTOBUILD) >> camera_list_$(PLATFORMOS).csv |
|---|
| 231 | |
|---|
| 232 | # define targets to batch build all cameras & firmware versions |
|---|
| 233 | # list of cameras/firmware versions is in 'camera_list.csv' |
|---|
| 234 | # each row in 'camera_list.csv' has 5 entries: |
|---|
| 235 | # - camera (mandatory) :- name of camera to build |
|---|
| 236 | # - firmware (mandatory) :- firmware version to build |
|---|
| 237 | # - beta status (optional) :- set to BETA for cameras still in beta status |
|---|
| 238 | # - copy to (optional) :- if this firmware version can also be used for another version on the same |
|---|
| 239 | # camera define the alternate firmware here. see COPY_TO comments above. |
|---|
| 240 | # - skip auto build (optional) :- any value in this column will exclude the camera/firmware from the auto build |
|---|
| 241 | |
|---|
| 242 | batch-zip: version alltools allmodules |
|---|
| 243 | SKIP_TOOLS=1 SKIP_MODULES=1 SKIP_CHDK=1 sh tools/auto_build.sh $(MAKE) firzipsub $(CAMERA_LIST) |
|---|
| 244 | @echo "**** Summary of memisosizes" |
|---|
| 245 | cat $(topdir)bin/caminfo.txt |
|---|
| 246 | rm -f $(topdir)bin/caminfo.txt > $(DEVNULL) |
|---|
| 247 | |
|---|
| 248 | batch-zip-complete: version alltools allmodules |
|---|
| 249 | SKIP_TOOLS=1 SKIP_MODULES=1 SKIP_CHDK=1 sh tools/auto_build.sh $(MAKE) firzipsubcomplete $(CAMERA_LIST) |
|---|
| 250 | @echo "**** Summary of memisosizes" |
|---|
| 251 | cat $(topdir)bin/caminfo.txt |
|---|
| 252 | rm -f $(topdir)bin/caminfo.txt > $(DEVNULL) |
|---|
| 253 | |
|---|
| 254 | # note, this will include cameras with SKIP_AUTOBUILD set |
|---|
| 255 | os-camera-lists: |
|---|
| 256 | echo 'CAMERA,FIRMWARE,BETA_STATUS,COPY_TO,SKIP_AUTOBUILD' > camera_list_dryos.csv |
|---|
| 257 | echo 'CAMERA,FIRMWARE,BETA_STATUS,COPY_TO,SKIP_AUTOBUILD' > camera_list_vxworks.csv |
|---|
| 258 | sh tools/auto_build.sh $(MAKE) os-camera-list-entry $(CAMERA_LIST) -noskip |
|---|
| 259 | |
|---|
| 260 | # make sure each enabled firmware/sub has a PRIMARY.BIN |
|---|
| 261 | # Note this will not fail, just prints all the missing ones |
|---|
| 262 | batch-print-missing-dumps: |
|---|
| 263 | sh tools/auto_build.sh $(MAKE) print-missing-dump $(CAMERA_LIST) -noskip |
|---|
| 264 | |
|---|
| 265 | # rebuild all the stubs_entry.S files |
|---|
| 266 | batch-rebuild-stubs: alltools |
|---|
| 267 | sh tools/auto_build.sh $(MAKE) rebuild-stubs $(CAMERA_LIST) -noskip |
|---|
| 268 | |
|---|
| 269 | # rebuild all the stubs_entry.S files |
|---|
| 270 | # parallel version, starts each camera/firmware version build in a seperate session |
|---|
| 271 | # Note:- Windows only, this will use all available CPU and a fair amount of memory |
|---|
| 272 | # but will rebuild much faster on a machine with many CPU cores |
|---|
| 273 | batch-rebuild-stubs-parallel: alltools |
|---|
| 274 | sh tools/auto_build_parallel.sh $(MAKE) rebuild-stubs $(CAMERA_LIST) -noskip |
|---|
| 275 | |
|---|
| 276 | batch-clean: |
|---|
| 277 | $(MAKE) -C tools clean |
|---|
| 278 | $(MAKE) -C core clean |
|---|
| 279 | $(MAKE) -C modules clean |
|---|
| 280 | $(MAKE) -C CHDK clean |
|---|
| 281 | SKIP_CORE=1 SKIP_MODULES=1 SKIP_CHDK=1 SKIP_TOOLS=1 sh tools/auto_build.sh $(MAKE) clean $(CAMERA_LIST) -noskip |
|---|