1 # Hey Emacs, this is a -*- makefile -*-
2 #----------------------------------------------------------------------------
3 # WinAVR Makefile Template written by Eric B. Weddington, Jg Wunsch, et al.
5 # Released to the Public Domain
7 # Additional material for this makefile was written by:
20 # Output format. (can be srec, ihex, binary)
25 # Object files directory
26 # To put object files in current directory, use a dot (.), do NOT make
27 # this an empty or blank macro!
28 OBJDIR = $(BUILD_DIR)/obj_$(TARGET)
31 # Optimization level, can be [0, 1, 2, 3, s].
32 # 0 = turn off optimization. s = optimize for size.
33 # (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
38 # Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs.
39 # AVR Studio 4.10 requires dwarf-2.
40 # AVR [Extended] COFF format requires stabs, plus an avr-objcopy run.
48 ERROR_COLOR=\033[31;01m
49 WARN_COLOR=\033[33;01m
61 ifneq ($(shell awk --version 2>/dev/null),)
67 OK_STRING=$(OK_COLOR)[OK]$(NO_COLOR)\n
68 ERROR_STRING=$(ERROR_COLOR)[ERRORS]$(NO_COLOR)\n
69 WARN_STRING=$(WARN_COLOR)[WARNINGS]$(NO_COLOR)\n
75 TAB_LOG = printf "\n$$LOG\n\n" | $(AWK) '{ sub(/^/," | "); print }'
76 TAB_LOG_PLAIN = printf "$$LOG\n"
77 AWK_STATUS = $(AWK) '{ printf " %-10s\n", $$1; }'
78 AWK_CMD = $(AWK) '{ printf "%-69s", $$0; }'
79 PRINT_ERROR = ($(SILENT) ||printf " $(ERROR_STRING)" | $(AWK_STATUS)) && $(TAB_LOG) && false
80 PRINT_WARNING = ($(SILENT) || printf " $(WARN_STRING)" | $(AWK_STATUS)) && $(TAB_LOG)
81 PRINT_ERROR_PLAIN = ($(SILENT) ||printf " $(ERROR_STRING)" | $(AWK_STATUS)) && $(TAB_LOG_PLAIN) && false
82 PRINT_WARNING_PLAIN = ($(SILENT) || printf " $(WARN_STRING)" | $(AWK_STATUS)) && $(TAB_LOG_PLAIN)
83 PRINT_OK = $(SILENT) || printf " $(OK_STRING)" | $(AWK_STATUS)
84 BUILD_CMD = LOG=$$($(CMD) 2>&1) ; if [ $$? -gt 0 ]; then $(PRINT_ERROR); elif [ "$$LOG" != "" ] ; then $(PRINT_WARNING); else $(PRINT_OK); fi;
86 # List any extra directories to look for include files here.
87 # Each directory must be seperated by a space.
88 # Use forward slashes for directory separators.
89 # For a directory that has spaces, enclose it in quotes.
90 EXTRAINCDIRS = $(subst :, ,$(VPATH))
93 # Compiler flag to set the C Standard level.
95 # gnu89 = c89 plus GCC extensions
96 # c99 = ISO C99 standard (not yet fully implemented)
97 # gnu99 = c99 plus GCC extensions
98 CSTANDARD = -std=gnu99
101 # Place -D or -U options here for C sources
102 CDEFS = -DF_CPU=$(F_CPU)UL
106 # Place -D or -U options here for ASM sources
107 ADEFS = -DF_CPU=$(F_CPU)
111 # Place -D or -U options here for C++ sources
112 CPPDEFS = -DF_CPU=$(F_CPU)UL
113 #CPPDEFS += -D__STDC_LIMIT_MACROS
114 #CPPDEFS += -D__STDC_CONSTANT_MACROS
115 CPPDEFS += $(OPT_DEFS)
119 #---------------- Compiler Options C ----------------
120 # -g*: generate debugging information
121 # -O*: optimization level
122 # -f...: tuning, see GCC manual and avr-libc documentation
123 # -Wall...: warning level
124 # -Wa,...: tell GCC to pass this to the assembler.
125 # -adhlns...: create assembler listing
129 CFLAGS += -funsigned-char
130 CFLAGS += -funsigned-bitfields
131 CFLAGS += -ffunction-sections
132 CFLAGS += -fdata-sections
133 CFLAGS += -fno-inline-small-functions
134 CFLAGS += -fpack-struct
135 CFLAGS += -fshort-enums
136 CFLAGS += -fno-strict-aliasing
139 ifeq ("$(shell echo "int main(){}" | $(CC) -fdiagnostics-color -x c - -o /dev/null 2>&1)", "")
140 CFLAGS+= -fdiagnostics-color
144 CFLAGS += -Wstrict-prototypes
145 #CFLAGS += -mshort-calls
146 #CFLAGS += -fno-unit-at-a-time
148 #CFLAGS += -Wunreachable-code
149 #CFLAGS += -Wsign-compare
150 CFLAGS += -Wa,-adhlns=$(@:%.o=%.lst)
151 CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
152 CFLAGS += $(CSTANDARD)
154 CFLAGS += -include $(CONFIG_H)
158 #---------------- Compiler Options C++ ----------------
159 # -g*: generate debugging information
160 # -O*: optimization level
161 # -f...: tuning, see GCC manual and avr-libc documentation
162 # -Wall...: warning level
163 # -Wa,...: tell GCC to pass this to the assembler.
164 # -adhlns...: create assembler listing
165 CPPFLAGS = -g$(DEBUG)
166 CPPFLAGS += $(CPPDEFS)
168 CPPFLAGS += -funsigned-char
169 CPPFLAGS += -funsigned-bitfields
170 CPPFLAGS += -fpack-struct
171 CPPFLAGS += -fshort-enums
172 CPPFLAGS += -fno-exceptions
173 CPPFLAGS += -ffunction-sections
174 CPPFLAGS += -fdata-sections
175 # to supress "warning: only initialized variables can be placed into program memory area"
179 #CPPFLAGS += -mshort-calls
180 #CPPFLAGS += -fno-unit-at-a-time
181 #CPPFLAGS += -Wstrict-prototypes
182 #CPPFLAGS += -Wunreachable-code
183 #CPPFLAGS += -Wsign-compare
184 CPPFLAGS += -Wa,-adhlns=$(@:%.o=%.lst)
185 CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
186 #CPPFLAGS += $(CSTANDARD)
188 CPPFLAGS += -include $(CONFIG_H)
192 #---------------- Assembler Options ----------------
193 # -Wa,...: tell GCC to pass this to the assembler.
194 # -adhlns: create listing
195 # -gstabs: have the assembler create line number information; note that
196 # for use in COFF files, additional information about filenames
197 # and function names needs to be present in the assembler source
198 # files -- see avr-libc docs [FIXME: not yet described there]
199 # -listing-cont-lines: Sets the maximum number of continuation lines of hex
200 # dump that will be displayed for a given single line of source input.
201 ASFLAGS = $(ADEFS) -Wa,-adhlns=$(@:%.o=%.lst),-gstabs,--listing-cont-lines=100
202 ASFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
204 ASFLAGS += -include $(CONFIG_H)
207 #---------------- Library Options ----------------
208 # Minimalistic printf version
209 PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
211 # Floating point printf version (requires MATH_LIB = -lm below)
212 PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
214 # If this is left blank, then it will use the Standard printf version.
216 #PRINTF_LIB = $(PRINTF_LIB_MIN)
217 #PRINTF_LIB = $(PRINTF_LIB_FLOAT)
220 # Minimalistic scanf version
221 SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
223 # Floating point + %[ scanf version (requires MATH_LIB = -lm below)
224 SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
226 # If this is left blank, then it will use the Standard scanf version.
228 #SCANF_LIB = $(SCANF_LIB_MIN)
229 #SCANF_LIB = $(SCANF_LIB_FLOAT)
235 # List any extra directories to look for libraries here.
236 # Each directory must be seperated by a space.
237 # Use forward slashes for directory separators.
238 # For a directory that has spaces, enclose it in quotes.
243 #---------------- External Memory Options ----------------
245 # 64 KB of external RAM, starting after internal RAM (ATmega128!),
246 # used for variables (.data/.bss) and heap (malloc()).
247 #EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff
249 # 64 KB of external RAM, starting after internal RAM (ATmega128!),
250 # only used for heap (malloc()).
251 #EXTMEMOPTS = -Wl,--section-start,.data=0x801100,--defsym=__heap_end=0x80ffff
257 #---------------- Linker Options ----------------
258 # -Wl,...: tell GCC to pass this to linker.
259 # -Map: create map file
260 # --cref: add cross reference to map file
262 # Comennt out "--relax" option to avoid a error such:
263 # (.vectors+0x30): relocation truncated to fit: R_AVR_13_PCREL against symbol `__vector_12'
265 LDFLAGS = -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref
266 #LDFLAGS += -Wl,--relax
267 LDFLAGS += -Wl,--gc-sections
268 LDFLAGS += $(EXTMEMOPTS)
269 LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
270 LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
271 #LDFLAGS += -T linker_script.x
272 # You can give EXTRALDFLAGS at 'make' command line.
273 LDFLAGS += $(EXTRALDFLAGS)
277 #---------------- Debugging Options ----------------
279 # For simulavr only - target MCU frequency.
280 DEBUG_MFREQ = $(F_CPU)
282 # Set the DEBUG_UI to either gdb or insight.
286 # Set the debugging back-end to either avarice, simulavr.
287 DEBUG_BACKEND = avarice
288 #DEBUG_BACKEND = simulavr
291 GDBINIT_FILE = __avr_gdbinit
293 # When using avarice settings for the JTAG
296 # Debugging port used to communicate between GDB / avarice / simulavr.
299 # Debugging host used to communicate between GDB / avarice / simulavr, normally
300 # just set to localhost unless doing some sort of crazy debugging when
301 # avarice is running on a different computer.
302 DEBUG_HOST = localhost
306 #============================================================================
309 # Define programs and commands.
312 OBJCOPY = avr-objcopy
313 OBJDUMP = avr-objdump
321 SECHO = $(SILENT) || echo
322 # Autodecct teensy loader
323 ifneq (, $(shell which teensy-loader-cli 2>/dev/null))
324 TEENSY_LOADER_CLI = teensy-loader-cli
326 TEENSY_LOADER_CLI = teensy_loader_cli
331 MSG_ERRORS_NONE = Errors: none
332 MSG_BEGIN = -------- begin --------
333 MSG_END = -------- end --------
334 MSG_SIZE_BEFORE = Size before:
335 MSG_SIZE_AFTER = Size after:
336 MSG_COFF = Converting to AVR COFF:
337 MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
338 MSG_FLASH = Creating load file for Flash:
339 MSG_EEPROM = Creating load file for EEPROM:
340 MSG_EXTENDED_LISTING = Creating Extended Listing:
341 MSG_SYMBOL_TABLE = Creating Symbol Table:
342 MSG_LINKING = Linking:
343 MSG_COMPILING = Compiling:
344 MSG_COMPILING_CPP = Compiling:
345 MSG_ASSEMBLING = Assembling:
346 MSG_CLEANING = Cleaning project:
347 MSG_CREATING_LIBRARY = Creating library:
352 # Define all object files.
353 OBJ = $(patsubst %.c,$(OBJDIR)/%.o,$(patsubst %.cpp,$(OBJDIR)/%.o,$(patsubst %.S,$(OBJDIR)/%.o,$(SRC))))
355 # Define all listing files.
356 LST = $(patsubst %.c,$(OBJDIR)/%.lst,$(patsubst %.cpp,$(OBJDIR)/%.lst,$(patsubst %.S,$(OBJDIR)/%.lst,$(SRC))))
359 # Compiler flags to generate dependency files.
360 #GENDEPFLAGS = -MMD -MP -MF .dep/$(@F).d
361 GENDEPFLAGS = -MMD -MP -MF $(BUILD_DIR)/.dep/$(subst /,_,$@).d
364 # Combine all necessary flags and optional flags.
365 # Add target processor to flags.
366 # You can give extra flags at 'make' command line like: make EXTRAFLAGS=-DFOO=bar
367 ALL_CFLAGS = -mmcu=$(MCU) $(CFLAGS) $(GENDEPFLAGS) $(EXTRAFLAGS)
368 ALL_CPPFLAGS = -mmcu=$(MCU) -x c++ $(CPPFLAGS) $(GENDEPFLAGS) $(EXTRAFLAGS)
369 ALL_ASFLAGS = -mmcu=$(MCU) -x assembler-with-cpp $(ASFLAGS) $(EXTRAFLAGS)
376 @$(MAKE) clean_list # force clean each time
381 # Quick make that doesn't clean
390 # Change the build target to build a HEX file or a library.
392 #build: elf hex eep lss sym
396 elf: $(BUILD_DIR)/$(TARGET).elf
397 hex: $(BUILD_DIR)/$(TARGET).hex
398 eep: $(BUILD_DIR)/$(TARGET).eep
399 lss: $(BUILD_DIR)/$(TARGET).lss
400 sym: $(BUILD_DIR)/$(TARGET).sym
401 LIBNAME=lib$(TARGET).a
407 # AVR Studio 3.x does not check make's exit code but relies on
408 # the following magic strings to be generated by the compile job.
410 @$(SECHO) $(MSG_BEGIN)
416 # Display size of file.
417 HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
418 #ELFSIZE = $(SIZE) --mcu=$(MCU) --format=avr $(TARGET).elf
419 ELFSIZE = $(SIZE) $(BUILD_DIR)/$(TARGET).elf
422 @if test -f $(TARGET).hex; then $(SECHO) $(MSG_SIZE_BEFORE); $(SILENT) || $(HEXSIZE); \
423 2>/dev/null; $(SECHO); fi
426 @if test -f $(TARGET).hex; then $(SECHO); $(SECHO) $(MSG_SIZE_AFTER); $(SILENT) || $(HEXSIZE); \
427 2>/dev/null; $(SECHO); fi
428 # test file sizes eventually
429 # @if [[ $($(SIZE) --target=$(FORMAT) $(TARGET).hex | $(AWK) 'NR==2 {print "0x"$5}') -gt 0x200 ]]; then $(SECHO) "File is too big!"; fi
431 # Display compiler version information.
433 @$(SILENT) || $(CC) --version
437 # Program the device.
438 program: $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).eep
441 teensy: $(BUILD_DIR)/$(TARGET).hex
442 $(TEENSY_LOADER_CLI) -mmcu=$(MCU) -w -v $(BUILD_DIR)/$(TARGET).hex
444 flip: $(BUILD_DIR)/$(TARGET).hex
445 batchisp -hardware usb -device $(MCU) -operation erase f
446 batchisp -hardware usb -device $(MCU) -operation loadbuffer $(BUILD_DIR)/$(TARGET).hex program
447 batchisp -hardware usb -device $(MCU) -operation start reset 0
449 dfu: $(BUILD_DIR)/$(TARGET).hex sizeafter
450 ifneq (, $(findstring 0.7, $(shell dfu-programmer --version 2>&1)))
451 dfu-programmer $(MCU) erase --force
453 dfu-programmer $(MCU) erase
455 dfu-programmer $(MCU) flash $(BUILD_DIR)/$(TARGET).hex
456 dfu-programmer $(MCU) reset
459 dfu-programmer $(MCU) reset
460 dfu-programmer $(MCU) start
462 flip-ee: $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).eep
463 $(COPY) $(BUILD_DIR)/$(TARGET).eep $(BUILD_DIR)/$(TARGET)eep.hex
464 batchisp -hardware usb -device $(MCU) -operation memory EEPROM erase
465 batchisp -hardware usb -device $(MCU) -operation memory EEPROM loadbuffer $(BUILD_DIR)/$(TARGET)eep.hex program
466 batchisp -hardware usb -device $(MCU) -operation start reset 0
467 $(REMOVE) $(BUILD_DIR)/$(TARGET)eep.hex
469 dfu-ee: $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).eep
470 ifneq (, $(findstring 0.7, $(shell dfu-programmer --version 2>&1)))
471 dfu-programmer $(MCU) flash --eeprom $(BUILD_DIR)/$(TARGET).eep
473 dfu-programmer $(MCU) flash-eeprom $(BUILD_DIR)/$(TARGET).eep
475 dfu-programmer $(MCU) reset
478 # Generate avr-gdb config/init file which does the following:
479 # define the reset signal, load the target file, connect to target, and set
480 # a breakpoint at main().
482 @$(REMOVE) $(GDBINIT_FILE)
483 @echo define reset >> $(GDBINIT_FILE)
484 @echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
485 @echo end >> $(GDBINIT_FILE)
486 @echo file $(BUILD_DIR)/$(TARGET).elf >> $(GDBINIT_FILE)
487 @echo target remote $(DEBUG_HOST):$(DEBUG_PORT) >> $(GDBINIT_FILE)
488 ifeq ($(DEBUG_BACKEND),simulavr)
489 @echo load >> $(GDBINIT_FILE)
491 @echo break main >> $(GDBINIT_FILE)
493 debug: gdb-config $(BUILD_DIR)/$(TARGET).elf
494 ifeq ($(DEBUG_BACKEND), avarice)
495 @echo Starting AVaRICE - Press enter when "waiting to connect" message displays.
496 @$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \
497 $(BUILD_DIR)/$(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT)
498 @$(WINSHELL) /c pause
501 @$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \
502 $(DEBUG_MFREQ) --port $(DEBUG_PORT)
504 @$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE)
509 # Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
510 COFFCONVERT = $(OBJCOPY) --debugging
511 COFFCONVERT += --change-section-address .data-0x800000
512 COFFCONVERT += --change-section-address .bss-0x800000
513 COFFCONVERT += --change-section-address .noinit-0x800000
514 COFFCONVERT += --change-section-address .eeprom-0x810000
518 coff: $(BUILD_DIR)/$(TARGET).elf
519 @$(SECHO) $(MSG_COFF) $(BUILD_DIR)/$(TARGET).cof
520 $(COFFCONVERT) -O coff-avr $< $(BUILD_DIR)/$(TARGET).cof
523 extcoff: $(BUILD_DIR)/$(TARGET).elf
524 @$(SECHO) $(MSG_EXTENDED_COFF) $(BUILD_DIR)/$(TARGET).cof
525 $(COFFCONVERT) -O coff-ext-avr $< $(BUILD_DIR)/$(TARGET).cof
529 # Create final output files (.hex, .eep) from ELF output file.
531 @$(SILENT) || printf "$(MSG_FLASH) $@" | $(AWK_CMD)
532 $(eval CMD=$(OBJCOPY) -O $(FORMAT) -R .eeprom -R .fuse -R .lock -R .signature $< $@)
534 @if $(AUTOGEN); then \
535 $(SILENT) || printf "Copying $(TARGET).hex to keymaps/$(KEYMAP)/$(KEYBOARD)_$(KEYMAP).hex\n"; \
536 $(COPY) $@ $(KEYMAP_PATH)/$(KEYBOARD)_$(KEYMAP).hex; \
538 $(COPY) $@ $(TARGET).hex; \
542 @$(SILENT) || printf "$(MSG_EEPROM) $@" | $(AWK_CMD)
543 $(eval CMD=$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 --no-change-warnings -O $(FORMAT) $< $@ || exit 0)
546 # Create extended listing file from ELF output file.
548 @$(SILENT) || printf "$(MSG_EXTENDED_LISTING) $@" | $(AWK_CMD)
549 $(eval CMD=$(OBJDUMP) -h -S -z $< > $@)
552 # Create a symbol table from ELF output file.
554 @$(SILENT) || printf "$(MSG_SYMBOL_TABLE) $@" | $(AWK_CMD)
555 $(eval CMD=$(NM) -n $< > $@ )
558 # Create library from object files.
559 .SECONDARY : $(BUILD_DIR)/$(TARGET).a
562 @$(SILENT) || printf "$(MSG_CREATING_LIBRARY) $@" | $(AWK_CMD)
563 $(eval CMD=$(AR) $@ $(OBJ) )
566 # Link: create ELF output file from object files.
567 .SECONDARY : $(BUILD_DIR)/$(TARGET).elf
570 @$(SILENT) || printf "$(MSG_LINKING) $@" | $(AWK_CMD)
571 $(eval CMD=$(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS))
574 # Compile: create object files from C source files.
577 @$(SILENT) || printf "$(MSG_COMPILING) $<" | $(AWK_CMD)
578 $(eval CMD=$(CC) -c $(ALL_CFLAGS) $< -o $@)
581 # Compile: create object files from C++ source files.
582 $(OBJDIR)/%.o : %.cpp
584 @$(SILENT) || printf "$(MSG_COMPILING_CPP) $<" | $(AWK_CMD)
585 $(eval CMD=$(CC) -c $(ALL_CPPFLAGS) $< -o $@)
588 # Compile: create assembler files from C source files.
590 @$(SILENT) || printf "$(MSG_ASSEMBLING) $<" | $(AWK_CMD)
591 $(eval CMD=$(CC) -S $(ALL_CFLAGS) $< -o $@)
594 # Compile: create assembler files from C++ source files.
596 @$(SILENT) || printf "$(MSG_ASSEMBLING) $<" | $(AWK_CMD)
597 $(eval CMD=$(CC) -S $(ALL_CPPFLAGS) $< -o $@)
600 # Assemble: create object files from assembler source files.
603 @$(SILENT) || printf "$(MSG_ASSEMBLING) $<" | $(AWK_CMD)
604 $(eval CMD=$(CC) -c $(ALL_ASFLAGS) $< -o $@)
607 # Create preprocessed source for use in sending a bug report.
609 $(CC) -E -mmcu=$(MCU) $(CFLAGS) $< -o $@
611 # Target: clean project.
612 clean: begin clean_list end
615 @$(REMOVE) -r $(BUILD_DIR)
616 @$(REMOVE) -r $(TOP_DIR)/$(BUILD_DIR)
617 @$(REMOVE) -r $(KEYBOARD_PATH)/$(BUILD_DIR)
618 @if $$SUBPROJECT; then $(REMOVE) -r $(SUBPROJECT_PATH)/$(BUILD_DIR); fi
619 @$(REMOVE) -r $(KEYMAP_PATH)/$(BUILD_DIR)
625 SUBDIRS := $(sort $(dir $(wildcard $(TOP_DIR)/keyboards/*/.)))
626 all-keyboards-defaults-%:
627 @for x in $(SUBDIRS) ; do \
628 printf "Compiling with default: $$x" | $(AWK_CMD); \
629 LOG=$$($(MAKE) -C $$x $(subst all-keyboards-defaults-,,$@) VERBOSE=$(VERBOSE) COLOR=$(COLOR) SILENT=true 2>&1) ; if [ $$? -gt 0 ]; then $(PRINT_ERROR_PLAIN); elif [ "$$LOG" != "" ] ; then $(PRINT_WARNING_PLAIN); else $(PRINT_OK); fi; \
632 all-keyboards-defaults: all-keyboards-defaults-all
634 KEYBOARDS := $(SUBDIRS:$(TOP_DIR)/keyboards/%/=/keyboards/%)
635 all-keyboards-all: $(addsuffix -all,$(KEYBOARDS))
636 all-keyboards-quick: $(addsuffix -quick,$(KEYBOARDS))
637 all-keyboards-clean: $(addsuffix -clean,$(KEYBOARDS))
638 all-keyboards: all-keyboards-all
641 $(eval KEYBOARD=$(patsubst /keyboards/%,%,$1))
642 $(eval KEYMAPS=$(notdir $(patsubst %/.,%,$(wildcard $(TOP_DIR)$1/keymaps/*/.))))
643 @for x in $(KEYMAPS) ; do \
644 printf "Compiling $(BOLD)$(KEYBOARD)$(NO_COLOR) with $(BOLD)$$x$(NO_COLOR)" | $(AWK) '{ printf "%-88s", $$0; }'; \
645 LOG=$$($(MAKE) -C $(TOP_DIR)$1 $2 keymap=$$x VERBOSE=$(VERBOSE) COLOR=$(COLOR) SILENT=true 2>&1) ; if [ $$? -gt 0 ]; then $(PRINT_ERROR_PLAIN); elif [ "$$LOG" != "" ] ; then $(PRINT_WARNING_PLAIN); else $(PRINT_OK); fi; \
649 define make_keyboard_helper
650 # Just remove the -quick, -all and so on from the first argument and pass it forward
651 $(call make_keyboard,$(subst -$2,,$1),$2)
655 $(call make_keyboard_helper,$@,quick)
657 $(call make_keyboard_helper,$@,all)
659 $(call make_keyboard_helper,$@,clean)
661 $(call make_keyboard_helper,$@,all)
664 $(eval MAKECONFIG=$(call get_target,all-keymaps,$@))
665 $(eval KEYMAPS=$(notdir $(patsubst %/.,%,$(wildcard $(TOP_DIR)/keyboards/$(KEYBOARD)/keymaps/*/.))))
666 @for x in $(KEYMAPS) ; do \
667 printf "Compiling $(BOLD)$(KEYBOARD)$(NO_COLOR) with $(BOLD)$$x$(NO_COLOR)" | $(AWK) '{ printf "%-88s", $$0; }'; \
668 LOG=$$($(MAKE) $(subst all-keymaps-,,$@) keyboard=$(KEYBOARD) keymap=$$x VERBOSE=$(VERBOSE) COLOR=$(COLOR) SILENT=true 2>&1) ; if [ $$? -gt 0 ]; then $(PRINT_ERROR_PLAIN); elif [ "$$LOG" != "" ] ; then $(PRINT_WARNING_PLAIN); else $(PRINT_OK); fi; \
671 all-keymaps: all-keymaps-all
673 # Create build directory
674 $(shell mkdir $(BUILD_DIR) 2>/dev/null)
676 # Create object files directory
677 $(shell mkdir $(OBJDIR) 2>/dev/null)
680 # Include the dependency files.
681 -include $(shell mkdir $(BUILD_DIR)/.dep 2>/dev/null) $(wildcard $(BUILD_DIR)/.dep/*)
684 # Listing of phony targets.
685 .PHONY : all quick begin finish end sizebefore sizeafter gccversion \
686 build elf hex eep lss sym coff extcoff \
687 clean clean_list debug gdb-config show_path \
688 program teensy dfu flip dfu-ee flip-ee dfu-start \
689 all-keyboards-defaults all-keyboards all-keymaps \
690 all-keyboards-defaults-% all-keyboards-% all-keymaps-%