| 1 | # Hey Emacs, this is a -*- makefile -*- |
| 2 | #---------------------------------------------------------------------------- |
| 3 | # WinAVR Makefile Template written by Eric B. Weddington, Jg Wunsch, et al. |
| 4 | # |
| 5 | # Released to the Public Domain |
| 6 | # |
| 7 | # Additional material for this makefile was written by: |
| 8 | # Peter Fleury |
| 9 | # Tim Henigan |
| 10 | # Colin O'Flynn |
| 11 | # Reiner Patommel |
| 12 | # Markus Pfaff |
| 13 | # Sander Pool |
| 14 | # Frederik Rouleau |
| 15 | # Carlos Lamas |
| 16 | # |
| 17 | |
| 18 | # Enable vpath seraching for source files only |
| 19 | # Without this, output files, could be read from the wrong .build directories |
| 20 | VPATH_SRC := $(VPATH) |
| 21 | vpath %.c $(VPATH_SRC) |
| 22 | vpath %.h $(VPATH_SRC) |
| 23 | vpath %.cpp $(VPATH_SRC) |
| 24 | vpath %.cc $(VPATH_SRC) |
| 25 | vpath %.hpp $(VPATH_SRC) |
| 26 | vpath %.S $(VPATH_SRC) |
| 27 | VPATH := |
| 28 | |
| 29 | # Convert all SRC to OBJ |
| 30 | define OBJ_FROM_SRC |
| 31 | $(patsubst %.c,$1/%.o,$(patsubst %.cpp,$1/%.o,$(patsubst %.cc,$1/%.o,$(patsubst %.S,$1/%.o,$(patsubst %.clib,$1/%.a,$($1_SRC)))))) |
| 32 | endef |
| 33 | $(foreach OUTPUT,$(OUTPUTS),$(eval $(OUTPUT)_OBJ +=$(call OBJ_FROM_SRC,$(OUTPUT)))) |
| 34 | |
| 35 | # Define a list of all objects |
| 36 | OBJ := $(foreach OUTPUT,$(OUTPUTS),$($(OUTPUT)_OBJ)) |
| 37 | NO_LTO_OBJ := $(filter %.a,$(OBJ)) |
| 38 | |
| 39 | MASTER_OUTPUT := $(firstword $(OUTPUTS)) |
| 40 | |
| 41 | |
| 42 | |
| 43 | # Output format. (can be srec, ihex, binary) |
| 44 | FORMAT = ihex |
| 45 | |
| 46 | # Optimization level, can be [0, 1, 2, 3, s]. |
| 47 | # 0 = turn off optimization. s = optimize for size. |
| 48 | # (Note: 3 is not always the best optimization level. See avr-libc FAQ.) |
| 49 | OPT = s |
| 50 | |
| 51 | # Compiler flag to set the C Standard level. |
| 52 | # c89 = "ANSI" C |
| 53 | # gnu89 = c89 plus GCC extensions |
| 54 | # c99 = ISO C99 standard (not yet fully implemented) |
| 55 | # gnu99 = c99 plus GCC extensions |
| 56 | CSTANDARD = -std=gnu99 |
| 57 | |
| 58 | |
| 59 | # Place -D or -U options here for C sources |
| 60 | #CDEFS += |
| 61 | |
| 62 | |
| 63 | # Place -D or -U options here for ASM sources |
| 64 | #ADEFS += |
| 65 | |
| 66 | |
| 67 | # Place -D or -U options here for C++ sources |
| 68 | #CXXDEFS += -D__STDC_LIMIT_MACROS |
| 69 | #CXXDEFS += -D__STDC_CONSTANT_MACROS |
| 70 | #CXXDEFS += |
| 71 | |
| 72 | |
| 73 | |
| 74 | |
| 75 | #---------------- Compiler Options C ---------------- |
| 76 | # -g*: generate debugging information |
| 77 | # -O*: optimization level |
| 78 | # -f...: tuning, see GCC manual and avr-libc documentation |
| 79 | # -Wall...: warning level |
| 80 | # -Wa,...: tell GCC to pass this to the assembler. |
| 81 | # -adhlns...: create assembler listing |
| 82 | ifndef SKIP_DEBUG_INFO |
| 83 | CFLAGS += -g$(DEBUG) |
| 84 | endif |
| 85 | CFLAGS += $(CDEFS) |
| 86 | CFLAGS += -O$(OPT) |
| 87 | # add color |
| 88 | ifeq ($(COLOR),true) |
| 89 | ifeq ("$(shell echo "int main(){}" | $(CC) -fdiagnostics-color -x c - -o /dev/null 2>&1)", "") |
| 90 | CFLAGS+= -fdiagnostics-color |
| 91 | endif |
| 92 | endif |
| 93 | CFLAGS += -Wall |
| 94 | CFLAGS += -Wstrict-prototypes |
| 95 | ifneq ($(strip $(ALLOW_WARNINGS)), yes) |
| 96 | CFLAGS += -Werror |
| 97 | endif |
| 98 | #CFLAGS += -mshort-calls |
| 99 | #CFLAGS += -fno-unit-at-a-time |
| 100 | #CFLAGS += -Wundef |
| 101 | #CFLAGS += -Wunreachable-code |
| 102 | #CFLAGS += -Wsign-compare |
| 103 | CFLAGS += -Wa,-adhlns=$(@:%.o=%.lst) |
| 104 | CFLAGS += $(CSTANDARD) |
| 105 | |
| 106 | #---------------- Compiler Options C++ ---------------- |
| 107 | # -g*: generate debugging information |
| 108 | # -O*: optimization level |
| 109 | # -f...: tuning, see GCC manual and avr-libc documentation |
| 110 | # -Wall...: warning level |
| 111 | # -Wa,...: tell GCC to pass this to the assembler. |
| 112 | # -adhlns...: create assembler listing |
| 113 | ifndef SKIP_DEBUG_INFO |
| 114 | CXXFLAGS += -g$(DEBUG) |
| 115 | endif |
| 116 | CXXFLAGS += $(CXXDEFS) |
| 117 | CXXFLAGS += -O$(OPT) |
| 118 | # to supress "warning: only initialized variables can be placed into program memory area" |
| 119 | CXXFLAGS += -w |
| 120 | CXXFLAGS += -Wall |
| 121 | CXXFLAGS += -Wundef |
| 122 | ifneq ($(strip $(ALLOW_WARNINGS)), yes) |
| 123 | CXXFLAGS += -Werror |
| 124 | endif |
| 125 | #CXXFLAGS += -mshort-calls |
| 126 | #CXXFLAGS += -fno-unit-at-a-time |
| 127 | #CXXFLAGS += -Wstrict-prototypes |
| 128 | #CXXFLAGS += -Wunreachable-code |
| 129 | #CXXFLAGS += -Wsign-compare |
| 130 | CXXFLAGS += -Wa,-adhlns=$(@:%.o=%.lst) |
| 131 | #CXXFLAGS += $(CSTANDARD) |
| 132 | |
| 133 | #---------------- Assembler Options ---------------- |
| 134 | # -Wa,...: tell GCC to pass this to the assembler. |
| 135 | # -adhlns: create listing |
| 136 | # -gstabs: have the assembler create line number information; note that |
| 137 | # for use in COFF files, additional information about filenames |
| 138 | # and function names needs to be present in the assembler source |
| 139 | # files -- see avr-libc docs [FIXME: not yet described there] |
| 140 | # -listing-cont-lines: Sets the maximum number of continuation lines of hex |
| 141 | # dump that will be displayed for a given single line of source input. |
| 142 | ASFLAGS += $(ADEFS) |
| 143 | ifndef SKIP_DEBUG_INFO |
| 144 | ASFLAGS += -Wa,-adhlns=$(@:%.o=%.lst),-gstabs,--listing-cont-lines=100 |
| 145 | else |
| 146 | ASFLAGS += -Wa,-adhlns=$(@:%.o=%.lst),--listing-cont-lines=100 |
| 147 | endif |
| 148 | |
| 149 | #---------------- Library Options ---------------- |
| 150 | # Minimalistic printf version |
| 151 | PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min |
| 152 | |
| 153 | # Floating point printf version (requires MATH_LIB = -lm below) |
| 154 | PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt |
| 155 | |
| 156 | # If this is left blank, then it will use the Standard printf version. |
| 157 | PRINTF_LIB = |
| 158 | #PRINTF_LIB = $(PRINTF_LIB_MIN) |
| 159 | #PRINTF_LIB = $(PRINTF_LIB_FLOAT) |
| 160 | |
| 161 | |
| 162 | # Minimalistic scanf version |
| 163 | SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min |
| 164 | |
| 165 | # Floating point + %[ scanf version (requires MATH_LIB = -lm below) |
| 166 | SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt |
| 167 | |
| 168 | # If this is left blank, then it will use the Standard scanf version. |
| 169 | SCANF_LIB = |
| 170 | #SCANF_LIB = $(SCANF_LIB_MIN) |
| 171 | #SCANF_LIB = $(SCANF_LIB_FLOAT) |
| 172 | |
| 173 | |
| 174 | MATH_LIB = -lm |
| 175 | CREATE_MAP ?= yes |
| 176 | |
| 177 | |
| 178 | #---------------- Linker Options ---------------- |
| 179 | # -Wl,...: tell GCC to pass this to linker. |
| 180 | # -Map: create map file |
| 181 | # --cref: add cross reference to map file |
| 182 | # |
| 183 | # Comennt out "--relax" option to avoid a error such: |
| 184 | # (.vectors+0x30): relocation truncated to fit: R_AVR_13_PCREL against symbol `__vector_12' |
| 185 | # |
| 186 | |
| 187 | ifeq ($(CREATE_MAP),yes) |
| 188 | LDFLAGS += -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref |
| 189 | endif |
| 190 | #LDFLAGS += -Wl,--relax |
| 191 | LDFLAGS += $(EXTMEMOPTS) |
| 192 | LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS)) |
| 193 | LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB) |
| 194 | #LDFLAGS += -T linker_script.x |
| 195 | # You can give EXTRALDFLAGS at 'make' command line. |
| 196 | LDFLAGS += $(EXTRALDFLAGS) |
| 197 | |
| 198 | # Define programs and commands. |
| 199 | SHELL = sh |
| 200 | REMOVE = rm -f |
| 201 | REMOVEDIR = rmdir |
| 202 | COPY = cp |
| 203 | WINSHELL = cmd |
| 204 | SECHO = $(SILENT) || echo |
| 205 | |
| 206 | |
| 207 | # Compiler flags to generate dependency files. |
| 208 | #GENDEPFLAGS = -MMD -MP -MF .dep/$(@F).d |
| 209 | GENDEPFLAGS = -MMD -MP -MF $(patsubst %.o,%.td,$@) |
| 210 | |
| 211 | |
| 212 | # Combine all necessary flags and optional flags. |
| 213 | # Add target processor to flags. |
| 214 | # You can give extra flags at 'make' command line like: make EXTRAFLAGS=-DFOO=bar |
| 215 | ALL_CFLAGS = $(MCUFLAGS) $(CFLAGS) $(EXTRAFLAGS) |
| 216 | ALL_CXXFLAGS = $(MCUFLAGS) -x c++ $(CXXFLAGS) $(EXTRAFLAGS) |
| 217 | ALL_ASFLAGS = $(MCUFLAGS) -x assembler-with-cpp $(ASFLAGS) $(EXTRAFLAGS) |
| 218 | |
| 219 | define NO_LTO |
| 220 | $(patsubst %.a,%.o,$1): NOLTO_CFLAGS += -fno-lto |
| 221 | endef |
| 222 | $(foreach LOBJ, $(NO_LTO_OBJ), $(eval $(call NO_LTO,$(LOBJ)))) |
| 223 | |
| 224 | MOVE_DEP = mv -f $(patsubst %.o,%.td,$@) $(patsubst %.o,%.d,$@) |
| 225 | |
| 226 | # Add QMK specific flags |
| 227 | DFU_SUFFIX ?= dfu-suffix |
| 228 | DFU_SUFFIX_ARGS ?= |
| 229 | |
| 230 | |
| 231 | elf: $(BUILD_DIR)/$(TARGET).elf |
| 232 | hex: $(BUILD_DIR)/$(TARGET).hex |
| 233 | cpfirmware: $(FIRMWARE_FORMAT) |
| 234 | $(SILENT) || printf "Copying $(TARGET).$(FIRMWARE_FORMAT) to qmk_firmware folder" | $(AWK_CMD) |
| 235 | $(COPY) $(BUILD_DIR)/$(TARGET).$(FIRMWARE_FORMAT) $(TARGET).$(FIRMWARE_FORMAT) && $(PRINT_OK) |
| 236 | eep: $(BUILD_DIR)/$(TARGET).eep |
| 237 | lss: $(BUILD_DIR)/$(TARGET).lss |
| 238 | sym: $(BUILD_DIR)/$(TARGET).sym |
| 239 | LIBNAME=lib$(TARGET).a |
| 240 | lib: $(LIBNAME) |
| 241 | |
| 242 | # Display size of file. |
| 243 | HEXSIZE = $(SIZE) --target=$(FORMAT) $(BUILD_DIR)/$(TARGET).hex |
| 244 | #ELFSIZE = $(SIZE) --mcu=$(MCU) --format=avr $(TARGET).elf |
| 245 | ELFSIZE = $(SIZE) $(BUILD_DIR)/$(TARGET).elf |
| 246 | |
| 247 | sizebefore: |
| 248 | @if test -f $(BUILD_DIR)/$(TARGET).hex; then $(SECHO) $(MSG_SIZE_BEFORE); $(SILENT) || $(HEXSIZE); \ |
| 249 | 2>/dev/null; $(SECHO); fi |
| 250 | |
| 251 | sizeafter: $(BUILD_DIR)/$(TARGET).hex |
| 252 | @if test -f $(BUILD_DIR)/$(TARGET).hex; then $(SECHO); $(SECHO) $(MSG_SIZE_AFTER); $(SILENT) || $(HEXSIZE); \ |
| 253 | 2>/dev/null; $(SECHO); fi |
| 254 | |
| 255 | # Display compiler version information. |
| 256 | gccversion : |
| 257 | @$(SILENT) || $(CC) --version |
| 258 | |
| 259 | # Create final output files (.hex, .eep) from ELF output file. |
| 260 | %.hex: %.elf |
| 261 | @$(SILENT) || printf "$(MSG_FLASH) $@" | $(AWK_CMD) |
| 262 | $(eval CMD=$(HEX) $< $@) |
| 263 | @$(BUILD_CMD) |
| 264 | |
| 265 | %.eep: %.elf |
| 266 | @$(SILENT) || printf "$(MSG_EEPROM) $@" | $(AWK_CMD) |
| 267 | $(eval CMD=$(EEP) $< $@ || exit 0) |
| 268 | @$(BUILD_CMD) |
| 269 | |
| 270 | # Create extended listing file from ELF output file. |
| 271 | %.lss: %.elf |
| 272 | @$(SILENT) || printf "$(MSG_EXTENDED_LISTING) $@" | $(AWK_CMD) |
| 273 | $(eval CMD=$(OBJDUMP) -h -S -z $< > $@) |
| 274 | @$(BUILD_CMD) |
| 275 | |
| 276 | # Create a symbol table from ELF output file. |
| 277 | %.sym: %.elf |
| 278 | @$(SILENT) || printf "$(MSG_SYMBOL_TABLE) $@" | $(AWK_CMD) |
| 279 | $(eval CMD=$(NM) -n $< > $@ ) |
| 280 | @$(BUILD_CMD) |
| 281 | |
| 282 | %.bin: %.elf |
| 283 | @$(SILENT) || printf "$(MSG_BIN) $@" | $(AWK_CMD) |
| 284 | $(eval CMD=$(BIN) $< $@ || exit 0) |
| 285 | @$(BUILD_CMD) |
| 286 | if [ ! -z "$(DFU_SUFFIX_ARGS)" ]; then \ |
| 287 | $(DFU_SUFFIX) $(DFU_SUFFIX_ARGS) -a $(BUILD_DIR)/$(TARGET).bin 1>/dev/null ;\ |
| 288 | fi |
| 289 | $(COPY) $(BUILD_DIR)/$(TARGET).bin $(TARGET).bin; |
| 290 | |
| 291 | BEGIN = gccversion sizebefore |
| 292 | |
| 293 | # Link: create ELF output file from object files. |
| 294 | .SECONDARY : $(BUILD_DIR)/$(TARGET).elf |
| 295 | .PRECIOUS : $(OBJ) |
| 296 | # Note the obj.txt depeendency is there to force linking if a source file is deleted |
| 297 | %.elf: $(OBJ) $(MASTER_OUTPUT)/cflags.txt $(MASTER_OUTPUT)/ldflags.txt $(MASTER_OUTPUT)/obj.txt | $(BEGIN) |
| 298 | @$(SILENT) || printf "$(MSG_LINKING) $@" | $(AWK_CMD) |
| 299 | $(eval CMD=$(CC) $(ALL_CFLAGS) $(filter-out %.txt,$^) --output $@ $(LDFLAGS)) |
| 300 | @$(BUILD_CMD) |
| 301 | |
| 302 | |
| 303 | define GEN_OBJRULE |
| 304 | $1_INCFLAGS := $$(patsubst %,-I%,$$($1_INC)) |
| 305 | ifdef $1_CONFIG |
| 306 | $1_CONFIG_FLAGS += $$(patsubst %,-include %,$$($1_CONFIG)) |
| 307 | endif |
| 308 | $1_CFLAGS = $$(ALL_CFLAGS) $$($1_DEFS) $$($1_INCFLAGS) $$($1_CONFIG_FLAGS) $$(NOLTO_CFLAGS) |
| 309 | $1_CXXFLAGS= $$(ALL_CXXFLAGS) $$($1_DEFS) $$($1_INCFLAGS) $$($1_CONFIG_FLAGS) $$(NOLTO_CFLAGS) |
| 310 | $1_ASFLAGS= $$(ALL_ASFLAGS) $$($1_DEFS) $$($1_INCFLAGS) $$($1_CONFIG_FLAGS) |
| 311 | |
| 312 | # Compile: create object files from C source files. |
| 313 | $1/%.o : %.c $1/%.d $1/cflags.txt $1/compiler.txt | $(BEGIN) |
| 314 | @mkdir -p $$(@D) |
| 315 | @$$(SILENT) || printf "$$(MSG_COMPILING) $$<" | $$(AWK_CMD) |
| 316 | $$(eval CMD := $$(CC) -c $$($1_CFLAGS) $$(GENDEPFLAGS) $$< -o $$@ && $$(MOVE_DEP)) |
| 317 | @$$(BUILD_CMD) |
| 318 | |
| 319 | # Compile: create object files from C++ source files. |
| 320 | $1/%.o : %.cpp $1/%.d $1/cxxflags.txt $1/compiler.txt | $(BEGIN) |
| 321 | @mkdir -p $$(@D) |
| 322 | @$$(SILENT) || printf "$$(MSG_COMPILING_CXX) $$<" | $$(AWK_CMD) |
| 323 | $$(eval CMD=$$(CC) -c $$($1_CXXFLAGS) $$(GENDEPFLAGS) $$< -o $$@ && $$(MOVE_DEP)) |
| 324 | @$$(BUILD_CMD) |
| 325 | |
| 326 | $1/%.o : %.cc $1/%.d $1/cxxflags.txt $1/compiler.txt | $(BEGIN) |
| 327 | @mkdir -p $$(@D) |
| 328 | @$$(SILENT) || printf "$$(MSG_COMPILING_CXX) $$<" | $$(AWK_CMD) |
| 329 | $$(eval CMD=$$(CC) -c $$($1_CXXFLAGS) $$(GENDEPFLAGS) $$< -o $$@ && $$(MOVE_DEP)) |
| 330 | @$$(BUILD_CMD) |
| 331 | |
| 332 | # Assemble: create object files from assembler source files. |
| 333 | $1/%.o : %.S $1/asflags.txt $1/compiler.txt | $(BEGIN) |
| 334 | @mkdir -p $$(@D) |
| 335 | @$(SILENT) || printf "$$(MSG_ASSEMBLING) $$<" | $$(AWK_CMD) |
| 336 | $$(eval CMD=$$(CC) -c $$($1_ASFLAGS) $$< -o $$@) |
| 337 | @$$(BUILD_CMD) |
| 338 | |
| 339 | $1/%.a : $1/%.o |
| 340 | @mkdir -p $$(@D) |
| 341 | @$(SILENT) || printf "Archiving: $$<" | $$(AWK_CMD) |
| 342 | $$(eval CMD=$$(AR) rcs $$@ $$<) |
| 343 | @$$(BUILD_CMD) |
| 344 | |
| 345 | $1/force: |
| 346 | |
| 347 | $1/cflags.txt: $1/force |
| 348 | echo '$$($1_CFLAGS)' | cmp -s - $$@ || echo '$$($1_CFLAGS)' > $$@ |
| 349 | |
| 350 | $1/cxxflags.txt: $1/force |
| 351 | echo '$$($1_CXXFLAGS)' | cmp -s - $$@ || echo '$$($1_CXXFLAGS)' > $$@ |
| 352 | |
| 353 | $1/asflags.txt: $1/force |
| 354 | echo '$$($1_ASFLAGS)' | cmp -s - $$@ || echo '$$($1_ASFLAGS)' > $$@ |
| 355 | |
| 356 | $1/compiler.txt: $1/force |
| 357 | $$(CC) --version | cmp -s - $$@ || $$(CC) --version > $$@ |
| 358 | endef |
| 359 | |
| 360 | .PRECIOUS: $(MASTER_OUTPUT)/obj.txt |
| 361 | $(MASTER_OUTPUT)/obj.txt: $(MASTER_OUTPUT)/force |
| 362 | echo '$(OBJ)' | cmp -s - $@ || echo '$(OBJ)' > $@ |
| 363 | |
| 364 | .PRECIOUS: $(MASTER_OUTPUT)/ldflags.txt |
| 365 | $(MASTER_OUTPUT)/ldflags.txt: $(MASTER_OUTPUT)/force |
| 366 | echo '$(LDFLAGS)' | cmp -s - $@ || echo '$(LDFLAGS)' > $@ |
| 367 | |
| 368 | |
| 369 | # We have to use static rules for the .d files for some reason |
| 370 | DEPS = $(patsubst %.o,%.d,$(patsubst %.a,%.o,$(OBJ))) |
| 371 | # Keep the .d files |
| 372 | .PRECIOUS: $(DEPS) |
| 373 | # Empty rule to force recompilation if the .d file is missing |
| 374 | $(DEPS): |
| 375 | |
| 376 | |
| 377 | $(foreach OUTPUT,$(OUTPUTS),$(eval $(call GEN_OBJRULE,$(OUTPUT)))) |
| 378 | |
| 379 | # Create preprocessed source for use in sending a bug report. |
| 380 | %.i : %.c | $(BEGIN) |
| 381 | $(CC) -E -mmcu=$(MCU) $(CFLAGS) $< -o $@ |
| 382 | |
| 383 | # Target: clean project. |
| 384 | clean: |
| 385 | $(foreach OUTPUT,$(OUTPUTS), $(REMOVE) -r $(OUTPUT) 2>/dev/null) |
| 386 | $(REMOVE) $(BUILD_DIR)/$(TARGET).* |
| 387 | |
| 388 | show_path: |
| 389 | @echo VPATH=$(VPATH) |
| 390 | @echo SRC=$(SRC) |
| 391 | @echo OBJ=$(OBJ) |
| 392 | |
| 393 | objs-size: |
| 394 | for i in $(OBJ); do echo $$i; done | sort | xargs $(SIZE) |
| 395 | |
| 396 | ifeq ($(findstring avr-gcc,$(CC)),avr-gcc) |
| 397 | SIZE_MARGIN = 1024 |
| 398 | |
| 399 | check-size: |
| 400 | $(eval MAX_SIZE=$(shell n=`$(CC) -E -mmcu=$(MCU) $(CFLAGS) $(OPT_DEFS) tmk_core/common/avr/bootloader_size.c 2> /dev/null | sed -ne 's/\r//;/^#/n;/^AVR_SIZE:/,$${s/^AVR_SIZE: //;p;}'` && echo $$(($$n)) || echo 0)) |
| 401 | $(eval CURRENT_SIZE=$(shell if [ -f $(BUILD_DIR)/$(TARGET).hex ]; then $(SIZE) --target=$(FORMAT) $(BUILD_DIR)/$(TARGET).hex | $(AWK) 'NR==2 {print $$4}'; else printf 0; fi)) |
| 402 | $(eval FREE_SIZE=$(shell expr $(MAX_SIZE) - $(CURRENT_SIZE))) |
| 403 | $(eval OVER_SIZE=$(shell expr $(CURRENT_SIZE) - $(MAX_SIZE))) |
| 404 | $(eval PERCENT_SIZE=$(shell expr $(CURRENT_SIZE) \* 100 / $(MAX_SIZE))) |
| 405 | if [ $(MAX_SIZE) -gt 0 ] && [ $(CURRENT_SIZE) -gt 0 ]; then \ |
| 406 | $(SILENT) || printf "$(MSG_CHECK_FILESIZE)" | $(AWK_CMD); \ |
| 407 | if [ $(CURRENT_SIZE) -gt $(MAX_SIZE) ]; then \ |
| 408 | printf "\n * $(MSG_FILE_TOO_BIG)"; $(PRINT_ERROR_PLAIN); \ |
| 409 | else \ |
| 410 | if [ $(FREE_SIZE) -lt $(SIZE_MARGIN) ]; then \ |
| 411 | $(PRINT_WARNING_PLAIN); printf " * $(MSG_FILE_NEAR_LIMIT)"; \ |
| 412 | else \ |
| 413 | $(PRINT_OK); $(SILENT) || printf " * $(MSG_FILE_JUST_RIGHT)"; \ |
| 414 | fi \ |
| 415 | fi \ |
| 416 | fi |
| 417 | else |
| 418 | check-size: |
| 419 | $(SILENT) || echo "(Firmware size check does not yet support $(MCU) microprocessors; skipping.)" |
| 420 | endif |
| 421 | |
| 422 | # Create build directory |
| 423 | $(shell mkdir -p $(BUILD_DIR) 2>/dev/null) |
| 424 | |
| 425 | # Create object files directory |
| 426 | $(eval $(foreach OUTPUT,$(OUTPUTS),$(shell mkdir -p $(OUTPUT) 2>/dev/null))) |
| 427 | |
| 428 | # Include the dependency files. |
| 429 | -include $(patsubst %.o,%.d,$(patsubst %.a,%.o,$(OBJ))) |
| 430 | |
| 431 | |
| 432 | # Listing of phony targets. |
| 433 | .PHONY : all finish sizebefore sizeafter qmkversion \ |
| 434 | gccversion build elf hex eep lss sym coff extcoff \ |
| 435 | clean clean_list debug gdb-config show_path \ |
| 436 | program teensy dfu flip dfu-ee flip-ee dfu-start \ |
| 437 | flash dfu-split-left dfu-split-right \ |
| 438 | avrdude-split-left avrdude-split-right \ |
| 439 | avrdude-loop usbasp |