diff options
| author | Fred Sundvik <fsundvik@gmail.com> | 2016-08-27 21:01:46 +0300 |
|---|---|---|
| committer | Fred Sundvik <fsundvik@gmail.com> | 2016-08-27 21:01:46 +0300 |
| commit | cff26bc48413ec62d4f4a37e3a6ba34721e7670c (patch) | |
| tree | 84c78137841ad83036de7e36579bc7973b024f7a /tmk_core | |
| parent | a5b1af4999345239df5086351b52a5b4d2daa97e (diff) | |
| parent | 36b6a96596e6cbca879d5304a586e279c15b04a9 (diff) | |
| download | qmk_firmware-cff26bc48413ec62d4f4a37e3a6ba34721e7670c.tar.gz qmk_firmware-cff26bc48413ec62d4f4a37e3a6ba34721e7670c.zip | |
Merge branch 'master' into fix_line_endings
Diffstat (limited to 'tmk_core')
| -rw-r--r-- | tmk_core/chibios.mk | 12 | ||||
| -rw-r--r-- | tmk_core/common.mk | 3 | ||||
| -rw-r--r-- | tmk_core/common/command.c | 3 | ||||
| -rw-r--r-- | tmk_core/rules.mk | 256 |
4 files changed, 53 insertions, 221 deletions
diff --git a/tmk_core/chibios.mk b/tmk_core/chibios.mk index cb67ac6f2..062a712bd 100644 --- a/tmk_core/chibios.mk +++ b/tmk_core/chibios.mk | |||
| @@ -89,9 +89,9 @@ CHIBISRC = $(STARTUPSRC) \ | |||
| 89 | $(STARTUPASM) \ | 89 | $(STARTUPASM) \ |
| 90 | $(PORTASM) \ | 90 | $(PORTASM) \ |
| 91 | $(OSALASM) | 91 | $(OSALASM) |
| 92 | |||
| 93 | SRC += $(patsubst $(TOP_DIR)/%,%,$(CHIBISRC)) | ||
| 94 | 92 | ||
| 93 | CHIBISRC := $(patsubst $(TOP_DIR)/%,%,$(CHIBISRC)) | ||
| 94 | |||
| 95 | EXTRAINCDIRS += $(CHIBIOS)/os/license \ | 95 | EXTRAINCDIRS += $(CHIBIOS)/os/license \ |
| 96 | $(STARTUPINC) $(KERNINC) $(PORTINC) $(OSALINC) \ | 96 | $(STARTUPINC) $(KERNINC) $(PORTINC) $(OSALINC) \ |
| 97 | $(HALINC) $(PLATFORMINC) $(BOARDINC) $(TESTINC) \ | 97 | $(HALINC) $(PLATFORMINC) $(BOARDINC) $(TESTINC) \ |
| @@ -143,14 +143,6 @@ MCUFLAGS = -mcpu=$(MCU) | |||
| 143 | 143 | ||
| 144 | DEBUG = gdb | 144 | DEBUG = gdb |
| 145 | 145 | ||
| 146 | # Define ASM defines here | ||
| 147 | # bootloader definitions may be used in the startup .s file | ||
| 148 | ifneq ("$(wildcard $(KEYBOARD_PATH)/bootloader_defs.h)","") | ||
| 149 | OPT_DEFS += -include $(KEYBOARD_PATH)/bootloader_defs.h | ||
| 150 | else ifneq ("$(wildcard $(KEYBOARD_PATH)/boards/$(BOARD)/bootloader_defs.h)","") | ||
| 151 | OPT_DEFS += -include $(KEYBOARD_PATH)/boards/$(BOARD)/bootloader_defs.h | ||
| 152 | endif | ||
| 153 | |||
| 154 | # List any extra directories to look for libraries here. | 146 | # List any extra directories to look for libraries here. |
| 155 | EXTRALIBDIRS = $(RULESPATH)/ld | 147 | EXTRALIBDIRS = $(RULESPATH)/ld |
| 156 | 148 | ||
diff --git a/tmk_core/common.mk b/tmk_core/common.mk index 429c57143..0b767eb04 100644 --- a/tmk_core/common.mk +++ b/tmk_core/common.mk | |||
| @@ -110,9 +110,6 @@ $(error MASTER does not have a valid value(left/right)) | |||
| 110 | endif | 110 | endif |
| 111 | 111 | ||
| 112 | 112 | ||
| 113 | # Version string | ||
| 114 | OPT_DEFS += -DVERSION=$(GIT_VERSION) | ||
| 115 | |||
| 116 | # Bootloader address | 113 | # Bootloader address |
| 117 | ifdef STM32_BOOTLOADER_ADDRESS | 114 | ifdef STM32_BOOTLOADER_ADDRESS |
| 118 | OPT_DEFS += -DSTM32_BOOTLOADER_ADDRESS=$(STM32_BOOTLOADER_ADDRESS) | 115 | OPT_DEFS += -DSTM32_BOOTLOADER_ADDRESS=$(STM32_BOOTLOADER_ADDRESS) |
diff --git a/tmk_core/common/command.c b/tmk_core/common/command.c index 084c9fe15..476fc6fe3 100644 --- a/tmk_core/common/command.c +++ b/tmk_core/common/command.c | |||
| @@ -34,6 +34,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 34 | #include "command.h" | 34 | #include "command.h" |
| 35 | #include "backlight.h" | 35 | #include "backlight.h" |
| 36 | #include "quantum.h" | 36 | #include "quantum.h" |
| 37 | #include "version.h" | ||
| 37 | 38 | ||
| 38 | #ifdef MOUSEKEY_ENABLE | 39 | #ifdef MOUSEKEY_ENABLE |
| 39 | #include "mousekey.h" | 40 | #include "mousekey.h" |
| @@ -180,7 +181,7 @@ static void print_version(void) | |||
| 180 | print("VID: " STR(VENDOR_ID) "(" STR(MANUFACTURER) ") " | 181 | print("VID: " STR(VENDOR_ID) "(" STR(MANUFACTURER) ") " |
| 181 | "PID: " STR(PRODUCT_ID) "(" STR(PRODUCT) ") " | 182 | "PID: " STR(PRODUCT_ID) "(" STR(PRODUCT) ") " |
| 182 | "VER: " STR(DEVICE_VER) "\n"); | 183 | "VER: " STR(DEVICE_VER) "\n"); |
| 183 | print("BUILD: " STR(VERSION) " (" __TIME__ " " __DATE__ ")\n"); | 184 | print("BUILD: " STR(QMK_VERSION) " (" __TIME__ " " __DATE__ ")\n"); |
| 184 | 185 | ||
| 185 | /* build options */ | 186 | /* build options */ |
| 186 | print("OPTIONS:" | 187 | print("OPTIONS:" |
diff --git a/tmk_core/rules.mk b/tmk_core/rules.mk index d2350f27c..21011c280 100644 --- a/tmk_core/rules.mk +++ b/tmk_core/rules.mk | |||
| @@ -25,6 +25,18 @@ vpath %.hpp $(VPATH_SRC) | |||
| 25 | vpath %.S $(VPATH_SRC) | 25 | vpath %.S $(VPATH_SRC) |
| 26 | VPATH := | 26 | VPATH := |
| 27 | 27 | ||
| 28 | # Convert all SRC to OBJ | ||
| 29 | define OBJ_FROM_SRC | ||
| 30 | $(patsubst %.c,$1/%.o,$(patsubst %.cpp,$1/%.o,$(patsubst %.S,$1/%.o,$($1_SRC)))) | ||
| 31 | endef | ||
| 32 | $(foreach OUTPUT,$(OUTPUTS),$(eval $(OUTPUT)_OBJ +=$(call OBJ_FROM_SRC,$(OUTPUT)))) | ||
| 33 | |||
| 34 | # Define a list of all objects | ||
| 35 | OBJ := $(foreach OUTPUT,$(OUTPUTS),$($(OUTPUT)_OBJ)) | ||
| 36 | |||
| 37 | MASTER_OUTPUT := $(firstword $(OUTPUTS)) | ||
| 38 | |||
| 39 | |||
| 28 | 40 | ||
| 29 | # Output format. (can be srec, ihex, binary) | 41 | # Output format. (can be srec, ihex, binary) |
| 30 | FORMAT = ihex | 42 | FORMAT = ihex |
| @@ -34,50 +46,8 @@ FORMAT = ihex | |||
| 34 | # (Note: 3 is not always the best optimization level. See avr-libc FAQ.) | 46 | # (Note: 3 is not always the best optimization level. See avr-libc FAQ.) |
| 35 | OPT = s | 47 | OPT = s |
| 36 | 48 | ||
| 37 | COLOR ?= true | ||
| 38 | |||
| 39 | ifeq ($(COLOR),true) | ||
| 40 | NO_COLOR=\033[0m | ||
| 41 | OK_COLOR=\033[32;01m | ||
| 42 | ERROR_COLOR=\033[31;01m | ||
| 43 | WARN_COLOR=\033[33;01m | ||
| 44 | BLUE=\033[0;34m | ||
| 45 | BOLD=\033[1m | ||
| 46 | endif | ||
| 47 | |||
| 48 | AUTOGEN ?= false | 49 | AUTOGEN ?= false |
| 49 | 50 | ||
| 50 | ifneq ($(shell awk --version 2>/dev/null),) | ||
| 51 | AWK=awk | ||
| 52 | else | ||
| 53 | AWK=cat && test | ||
| 54 | endif | ||
| 55 | |||
| 56 | OK_STRING=$(OK_COLOR)[OK]$(NO_COLOR)\n | ||
| 57 | ERROR_STRING=$(ERROR_COLOR)[ERRORS]$(NO_COLOR)\n | ||
| 58 | WARN_STRING=$(WARN_COLOR)[WARNINGS]$(NO_COLOR)\n | ||
| 59 | |||
| 60 | ifndef $(SILENT) | ||
| 61 | SILENT = false | ||
| 62 | endif | ||
| 63 | |||
| 64 | TAB_LOG = printf "\n$$LOG\n\n" | $(AWK) '{ sub(/^/," | "); print }' | ||
| 65 | TAB_LOG_PLAIN = printf "$$LOG\n" | ||
| 66 | AWK_STATUS = $(AWK) '{ printf " %-10s\n", $$1; }' | ||
| 67 | AWK_CMD = $(AWK) '{ printf "%-99s", $$0; }' | ||
| 68 | PRINT_ERROR = ($(SILENT) ||printf " $(ERROR_STRING)" | $(AWK_STATUS)) && $(TAB_LOG) && exit 1 | ||
| 69 | PRINT_WARNING = ($(SILENT) || printf " $(WARN_STRING)" | $(AWK_STATUS)) && $(TAB_LOG) | ||
| 70 | PRINT_ERROR_PLAIN = ($(SILENT) ||printf " $(ERROR_STRING)" | $(AWK_STATUS)) && $(TAB_LOG_PLAIN) && exit 1 | ||
| 71 | PRINT_WARNING_PLAIN = ($(SILENT) || printf " $(WARN_STRING)" | $(AWK_STATUS)) && $(TAB_LOG_PLAIN) | ||
| 72 | PRINT_OK = $(SILENT) || printf " $(OK_STRING)" | $(AWK_STATUS) | ||
| 73 | BUILD_CMD = LOG=$$($(CMD) 2>&1) ; if [ $$? -gt 0 ]; then $(PRINT_ERROR); elif [ "$$LOG" != "" ] ; then $(PRINT_WARNING); else $(PRINT_OK); fi; | ||
| 74 | |||
| 75 | # List any extra directories to look for include files here. | ||
| 76 | # Each directory must be seperated by a space. | ||
| 77 | # Use forward slashes for directory separators. | ||
| 78 | # For a directory that has spaces, enclose it in quotes. | ||
| 79 | EXTRAINCDIRS += $(subst :, ,$(VPATH_SRC)) | ||
| 80 | |||
| 81 | 51 | ||
| 82 | # Compiler flag to set the C Standard level. | 52 | # Compiler flag to set the C Standard level. |
| 83 | # c89 = "ANSI" C | 53 | # c89 = "ANSI" C |
| @@ -88,17 +58,18 @@ CSTANDARD = -std=gnu99 | |||
| 88 | 58 | ||
| 89 | 59 | ||
| 90 | # Place -D or -U options here for C sources | 60 | # Place -D or -U options here for C sources |
| 91 | CDEFS += $(OPT_DEFS) | 61 | #CDEFS += |
| 92 | 62 | ||
| 93 | 63 | ||
| 94 | # Place -D or -U options here for ASM sources | 64 | # Place -D or -U options here for ASM sources |
| 95 | ADEFS += $(OPT_DEFS) | 65 | #ADEFS += |
| 96 | 66 | ||
| 97 | 67 | ||
| 98 | # Place -D or -U options here for C++ sources | 68 | # Place -D or -U options here for C++ sources |
| 99 | #CPPDEFS += -D__STDC_LIMIT_MACROS | 69 | #CPPDEFS += -D__STDC_LIMIT_MACROS |
| 100 | #CPPDEFS += -D__STDC_CONSTANT_MACROS | 70 | #CPPDEFS += -D__STDC_CONSTANT_MACROS |
| 101 | CPPDEFS += $(OPT_DEFS) | 71 | #CPPDEFS += |
| 72 | |||
| 102 | 73 | ||
| 103 | 74 | ||
| 104 | 75 | ||
| @@ -126,11 +97,7 @@ CFLAGS += -Wstrict-prototypes | |||
| 126 | #CFLAGS += -Wunreachable-code | 97 | #CFLAGS += -Wunreachable-code |
| 127 | #CFLAGS += -Wsign-compare | 98 | #CFLAGS += -Wsign-compare |
| 128 | CFLAGS += -Wa,-adhlns=$(@:%.o=%.lst) | 99 | CFLAGS += -Wa,-adhlns=$(@:%.o=%.lst) |
| 129 | CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) | ||
| 130 | CFLAGS += $(CSTANDARD) | 100 | CFLAGS += $(CSTANDARD) |
| 131 | ifdef CONFIG_H | ||
| 132 | CFLAGS += -include $(CONFIG_H) | ||
| 133 | endif | ||
| 134 | 101 | ||
| 135 | 102 | ||
| 136 | #---------------- Compiler Options C++ ---------------- | 103 | #---------------- Compiler Options C++ ---------------- |
| @@ -153,12 +120,7 @@ CPPFLAGS += -Wundef | |||
| 153 | #CPPFLAGS += -Wunreachable-code | 120 | #CPPFLAGS += -Wunreachable-code |
| 154 | #CPPFLAGS += -Wsign-compare | 121 | #CPPFLAGS += -Wsign-compare |
| 155 | CPPFLAGS += -Wa,-adhlns=$(@:%.o=%.lst) | 122 | CPPFLAGS += -Wa,-adhlns=$(@:%.o=%.lst) |
| 156 | CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) | ||
| 157 | #CPPFLAGS += $(CSTANDARD) | 123 | #CPPFLAGS += $(CSTANDARD) |
| 158 | ifdef CONFIG_H | ||
| 159 | CPPFLAGS += -include $(CONFIG_H) | ||
| 160 | endif | ||
| 161 | |||
| 162 | 124 | ||
| 163 | #---------------- Assembler Options ---------------- | 125 | #---------------- Assembler Options ---------------- |
| 164 | # -Wa,...: tell GCC to pass this to the assembler. | 126 | # -Wa,...: tell GCC to pass this to the assembler. |
| @@ -169,11 +131,8 @@ endif | |||
| 169 | # files -- see avr-libc docs [FIXME: not yet described there] | 131 | # files -- see avr-libc docs [FIXME: not yet described there] |
| 170 | # -listing-cont-lines: Sets the maximum number of continuation lines of hex | 132 | # -listing-cont-lines: Sets the maximum number of continuation lines of hex |
| 171 | # dump that will be displayed for a given single line of source input. | 133 | # dump that will be displayed for a given single line of source input. |
| 172 | ASFLAGS += $(ADEFS) -Wa,-adhlns=$(@:%.o=%.lst),-gstabs,--listing-cont-lines=100 | 134 | ASFLAGS += $(ADEFS) |
| 173 | ASFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) | 135 | ASFLAGS += -Wa,-adhlns=$(@:%.o=%.lst),-gstabs,--listing-cont-lines=100 |
| 174 | ifdef CONFIG_H | ||
| 175 | ASFLAGS += -include $(CONFIG_H) | ||
| 176 | endif | ||
| 177 | 136 | ||
| 178 | #---------------- Library Options ---------------- | 137 | #---------------- Library Options ---------------- |
| 179 | # Minimalistic printf version | 138 | # Minimalistic printf version |
| @@ -228,48 +187,6 @@ COPY = cp | |||
| 228 | WINSHELL = cmd | 187 | WINSHELL = cmd |
| 229 | SECHO = $(SILENT) || echo | 188 | SECHO = $(SILENT) || echo |
| 230 | 189 | ||
| 231 | # Define Messages | ||
| 232 | # English | ||
| 233 | MSG_ERRORS_NONE = Errors: none | ||
| 234 | MSG_BEGIN = -------- begin -------- | ||
| 235 | MSG_END = -------- end -------- | ||
| 236 | MSG_SIZE_BEFORE = Size before: | ||
| 237 | MSG_SIZE_AFTER = Size after: | ||
| 238 | MSG_COFF = Converting to AVR COFF: | ||
| 239 | MSG_EXTENDED_COFF = Converting to AVR Extended COFF: | ||
| 240 | MSG_FLASH = Creating load file for Flash: | ||
| 241 | MSG_EEPROM = Creating load file for EEPROM: | ||
| 242 | MSG_BIN = Creating binary load file for Flash: | ||
| 243 | MSG_EXTENDED_LISTING = Creating Extended Listing: | ||
| 244 | MSG_SYMBOL_TABLE = Creating Symbol Table: | ||
| 245 | MSG_LINKING = Linking: | ||
| 246 | MSG_COMPILING = Compiling: | ||
| 247 | MSG_COMPILING_CPP = Compiling: | ||
| 248 | MSG_ASSEMBLING = Assembling: | ||
| 249 | MSG_CLEANING = Cleaning project: | ||
| 250 | MSG_CREATING_LIBRARY = Creating library: | ||
| 251 | MSG_SUBMODULE_DIRTY = $(WARN_COLOR)WARNING:$(NO_COLOR)\n \ | ||
| 252 | Some git sub-modules are out of date or modified, please consider runnning:$(BOLD)\n\ | ||
| 253 | git submodule sync --recursive\n\ | ||
| 254 | git submodule update --init --recursive$(NO_COLOR)\n\n\ | ||
| 255 | You can ignore this warning if you are not compiling any ChibiOS keyboards,\n\ | ||
| 256 | or if you have modified the ChibiOS libraries yourself. \n\n | ||
| 257 | |||
| 258 | |||
| 259 | # Define all object files. | ||
| 260 | OBJ = $(patsubst %.c,$(OBJDIR)/%.o,$(patsubst %.cpp,$(OBJDIR)/%.o,$(patsubst %.S,$(OBJDIR)/%.o,$(SRC)))) | ||
| 261 | # The files in the lib folder are shared between all keymaps, so generate that folder name by removing | ||
| 262 | # the keymap from the name | ||
| 263 | KBOBJDIR=$(subst _$(KEYMAP),,$(OBJDIR)) | ||
| 264 | # And fixup the object files to match | ||
| 265 | LIBOBJ = $(foreach v,$(OBJ),$(if $(findstring /lib/,$v),$v)) | ||
| 266 | NONLIBOBJ := $(filter-out $(LIBOBJ),$(OBJ)) | ||
| 267 | LIBOBJ := $(subst _$(KEYMAP)/,/,$(LIBOBJ)) | ||
| 268 | OBJ := $(LIBOBJ) $(NONLIBOBJ) | ||
| 269 | |||
| 270 | # Define all listing files. | ||
| 271 | LST = $(patsubst %.c,$(OBJDIR)/%.lst,$(patsubst %.cpp,$(OBJDIR)/%.lst,$(patsubst %.S,$(OBJDIR)/%.lst,$(SRC)))) | ||
| 272 | |||
| 273 | 190 | ||
| 274 | # Compiler flags to generate dependency files. | 191 | # Compiler flags to generate dependency files. |
| 275 | #GENDEPFLAGS = -MMD -MP -MF .dep/$(@F).d | 192 | #GENDEPFLAGS = -MMD -MP -MF .dep/$(@F).d |
| @@ -302,15 +219,6 @@ sym: $(BUILD_DIR)/$(TARGET).sym | |||
| 302 | LIBNAME=lib$(TARGET).a | 219 | LIBNAME=lib$(TARGET).a |
| 303 | lib: $(LIBNAME) | 220 | lib: $(LIBNAME) |
| 304 | 221 | ||
| 305 | check_submodule: | ||
| 306 | git submodule status --recursive | \ | ||
| 307 | while IFS= read -r x; do \ | ||
| 308 | case "$$x" in \ | ||
| 309 | \ *) ;; \ | ||
| 310 | *) printf "$(MSG_SUBMODULE_DIRTY)";break;; \ | ||
| 311 | esac \ | ||
| 312 | done | ||
| 313 | |||
| 314 | # Display size of file. | 222 | # Display size of file. |
| 315 | HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex | 223 | HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex |
| 316 | #ELFSIZE = $(SIZE) --mcu=$(MCU) --format=avr $(TARGET).elf | 224 | #ELFSIZE = $(SIZE) --mcu=$(MCU) --format=avr $(TARGET).elf |
| @@ -364,91 +272,79 @@ gccversion : | |||
| 364 | $(eval CMD=$(BIN) $< $@ || exit 0) | 272 | $(eval CMD=$(BIN) $< $@ || exit 0) |
| 365 | @$(BUILD_CMD) | 273 | @$(BUILD_CMD) |
| 366 | 274 | ||
| 367 | # Create library from object files. | 275 | BEGIN = gccversion sizebefore |
| 368 | .SECONDARY : $(BUILD_DIR)/$(TARGET).a | ||
| 369 | .PRECIOUS : $(OBJ) | ||
| 370 | %.a: $(OBJ) | ||
| 371 | @$(SILENT) || printf "$(MSG_CREATING_LIBRARY) $@" | $(AWK_CMD) | ||
| 372 | $(eval CMD=$(AR) $@ $(OBJ) ) | ||
| 373 | @$(BUILD_CMD) | ||
| 374 | |||
| 375 | BEGIN = gccversion check_submodule sizebefore | ||
| 376 | 276 | ||
| 377 | # Link: create ELF output file from object files. | 277 | # Link: create ELF output file from object files. |
| 378 | .SECONDARY : $(BUILD_DIR)/$(TARGET).elf | 278 | .SECONDARY : $(BUILD_DIR)/$(TARGET).elf |
| 379 | .PRECIOUS : $(OBJ) | 279 | .PRECIOUS : $(OBJ) |
| 380 | # Note the obj.txt depeendency is there to force linking if a source file is deleted | 280 | # Note the obj.txt depeendency is there to force linking if a source file is deleted |
| 381 | %.elf: $(OBJ) $(OBJDIR)/cflags.txt $(OBJDIR)/ldflags.txt $(OBJDIR)/obj.txt | $(BEGIN) | 281 | %.elf: $(OBJ) $(MASTER_OUTPUT)/cflags.txt $(MASTER_OUTPUT)/ldflags.txt $(MASTER_OUTPUT)/obj.txt | $(BEGIN) |
| 382 | @$(SILENT) || printf "$(MSG_LINKING) $@" | $(AWK_CMD) | 282 | @$(SILENT) || printf "$(MSG_LINKING) $@" | $(AWK_CMD) |
| 383 | $(eval CMD=$(CC) $(ALL_CFLAGS) $(filter-out %.txt,$^) --output $@ $(LDFLAGS)) | 283 | $(eval CMD=$(CC) $(ALL_CFLAGS) $(filter-out %.txt,$^) --output $@ $(LDFLAGS)) |
| 384 | @$(BUILD_CMD) | 284 | @$(BUILD_CMD) |
| 285 | |||
| 385 | 286 | ||
| 386 | define GEN_OBJRULE | 287 | define GEN_OBJRULE |
| 288 | $1_INCFLAGS := $$(patsubst %,-I%,$$($1_INC)) | ||
| 289 | ifdef $1_CONFIG | ||
| 290 | $1_CONFIG_FLAGS += -include $$($1_CONFIG) | ||
| 291 | endif | ||
| 292 | $1_CFLAGS = $$(ALL_CFLAGS) $$($1_DEFS) $$($1_INCFLAGS) $$($1_CONFIG_FLAGS) | ||
| 293 | $1_CPPFLAGS= $$(ALL_CPPFLAGS) $$($1_DEFS) $$($1_INCFLAGS) $$($1_CONFIG_FLAGS) | ||
| 294 | $1_ASFLAGS= $$(ALL_ASFLAGS) $$($1_DEFS) $$($1_INCFLAGS) $$($1_CONFIG_FLAGS) | ||
| 295 | |||
| 387 | # Compile: create object files from C source files. | 296 | # Compile: create object files from C source files. |
| 388 | $1/%.o : %.c $1/%.d $1/cflags.txt $1/compiler.txt | $(BEGIN) | 297 | $1/%.o : %.c $1/%.d $1/cflags.txt $1/compiler.txt | $(BEGIN) |
| 389 | @mkdir -p $$(@D) | 298 | @mkdir -p $$(@D) |
| 390 | @$$(SILENT) || printf "$$(MSG_COMPILING) $$<" | $$(AWK_CMD) | 299 | @$$(SILENT) || printf "$$(MSG_COMPILING) $$<" | $$(AWK_CMD) |
| 391 | $$(eval CMD=$$(CC) -c $$(ALL_CFLAGS) $$(GENDEPFLAGS) $$< -o $$@ && $$(MOVE_DEP)) | 300 | $$(eval CMD := $$(CC) -c $$($1_CFLAGS) $$(GENDEPFLAGS) $$< -o $$@ && $$(MOVE_DEP)) |
| 392 | @$$(BUILD_CMD) | 301 | @$$(BUILD_CMD) |
| 393 | 302 | ||
| 394 | # Compile: create object files from C++ source files. | 303 | # Compile: create object files from C++ source files. |
| 395 | $1/%.o : %.cpp $1/%.d $1/cppflags.txt $1/compiler.txt | $(BEGIN) | 304 | $1/%.o : %.cpp $1/%.d $1/cppflags.txt $1/compiler.txt | $(BEGIN) |
| 396 | @mkdir -p $$(@D) | 305 | @mkdir -p $$(@D) |
| 397 | @$$(SILENT) || printf "$$(MSG_COMPILING_CPP) $$<" | $$(AWK_CMD) | 306 | @$$(SILENT) || printf "$$(MSG_COMPILING_CPP) $$<" | $$(AWK_CMD) |
| 398 | $$(eval CMD=$$(CC) -c $$(ALL_CPPFLAGS) $$(GENDEPFLAGS) $$< -o $$@ && $$(MOVE_DEP)) | 307 | $$(eval CMD=$$(CC) -c $$($1_CPPFLAGS) $$(GENDEPFLAGS) $$< -o $$@ && $$(MOVE_DEP)) |
| 399 | @$(BUILD_CMD) | 308 | @$(BUILD_CMD) |
| 400 | 309 | ||
| 401 | # Assemble: create object files from assembler source files. | 310 | # Assemble: create object files from assembler source files. |
| 402 | $1/%.o : %.S $1/asflags.txt $1/compiler.txt | $(BEGIN) | 311 | $1/%.o : %.S $1/asflags.txt $1/compiler.txt | $(BEGIN) |
| 403 | @mkdir -p $$(@D) | 312 | @mkdir -p $$(@D) |
| 404 | @$(SILENT) || printf "$$(MSG_ASSEMBLING) $$<" | $$(AWK_CMD) | 313 | @$(SILENT) || printf "$$(MSG_ASSEMBLING) $$<" | $$(AWK_CMD) |
| 405 | $$(eval CMD=$$(CC) -c $$(ALL_ASFLAGS) $$< -o $$@) | 314 | $$(eval CMD=$$(CC) -c $$($1_ASFLAGS) $$< -o $$@) |
| 406 | @$$(BUILD_CMD) | 315 | @$$(BUILD_CMD) |
| 407 | 316 | ||
| 408 | $1/force: | 317 | $1/force: |
| 409 | 318 | ||
| 410 | $1/cflags.txt: $1/force | 319 | $1/cflags.txt: $1/force |
| 411 | echo '$$(ALL_CFLAGS)' | cmp -s - $$@ || echo '$$(ALL_CFLAGS)' > $$@ | 320 | echo '$$($1_CFLAGS)' | cmp -s - $$@ || echo '$$($1_CFLAGS)' > $$@ |
| 412 | 321 | ||
| 413 | $1/cppflags.txt: $1/force | 322 | $1/cppflags.txt: $1/force |
| 414 | echo '$$(ALL_CPPFLAGS)' | cmp -s - $$@ || echo '$$(ALL_CPPFLAGS)' > $$@ | 323 | echo '$$($1_CPPFLAGS)' | cmp -s - $$@ || echo '$$($1_CPPFLAGS)' > $$@ |
| 415 | 324 | ||
| 416 | $1/asflags.txt: $1/force | 325 | $1/asflags.txt: $1/force |
| 417 | echo '$$(ALL_ASFLAGS)' | cmp -s - $$@ || echo '$$(ALL_ASFLAGS)' > $$@ | 326 | echo '$$($1_ASFLAGS)' | cmp -s - $$@ || echo '$$($1_ASFLAGS)' > $$@ |
| 418 | |||
| 419 | $1/ldflags.txt: $1/force | ||
| 420 | echo '$$(LDFLAGS)' | cmp -s - $$@ || echo '$$(LDFLAGS)' > $$@ | ||
| 421 | |||
| 422 | $1/obj.txt: $1/force | ||
| 423 | echo '$$(OBJ)' | cmp -s - $$@ || echo '$$(OBJ)' > $$@ | ||
| 424 | 327 | ||
| 425 | $1/compiler.txt: $1/force | 328 | $1/compiler.txt: $1/force |
| 426 | $$(CC) --version | cmp -s - $$@ || $$(CC) --version > $$@ | 329 | $$(CC) --version | cmp -s - $$@ || $$(CC) --version > $$@ |
| 427 | endef | 330 | endef |
| 428 | 331 | ||
| 332 | $(MASTER_OUTPUT)/obj.txt: $(MASTER_OUTPUT)/force | ||
| 333 | echo '$(OBJ)' | cmp -s - $$@ || echo '$(OBJ)' > $$@ | ||
| 334 | |||
| 335 | $(MASTER_OUTPUT)/ldflags.txt: $(MASTER_OUTPUT)/force | ||
| 336 | echo '$(LDFLAGS)' | cmp -s - $$@ || echo '$(LDFLAGS)' > $$@ | ||
| 337 | |||
| 338 | |||
| 429 | # We have to use static rules for the .d files for some reason | 339 | # We have to use static rules for the .d files for some reason |
| 430 | DEPS = $(patsubst %.o,%.d,$(OBJ)) | 340 | DEPS = $(patsubst %.o,%.d,$(OBJ)) |
| 431 | # Keep the .d files | 341 | # Keep the .d files |
| 432 | .PRECIOUS: $(DEPS) | 342 | .PRECIOUS: $(DEPS) |
| 433 | # Empty rule to force recompilation if the .d file is missing | 343 | # Empty rule to force recompilation if the .d file is missing |
| 434 | $(DEPS): | 344 | $(DEPS): |
| 345 | |||
| 435 | 346 | ||
| 436 | # Since the object files could be in two different folders, generate | 347 | $(foreach OUTPUT,$(OUTPUTS),$(eval $(call GEN_OBJRULE,$(OUTPUT)))) |
| 437 | # separate rules for them, rather than having too generic rules | ||
| 438 | $(eval $(call GEN_OBJRULE,$(OBJDIR))) | ||
| 439 | $(eval $(call GEN_OBJRULE,$(KBOBJDIR))) | ||
| 440 | |||
| 441 | # Compile: create assembler files from C source files. | ||
| 442 | %.s : %.c | $(BEGIN) | ||
| 443 | @$(SILENT) || printf "$(MSG_ASSEMBLING) $<" | $(AWK_CMD) | ||
| 444 | $(eval CMD=$(CC) -S $(ALL_CFLAGS) $< -o $@) | ||
| 445 | @$(BUILD_CMD) | ||
| 446 | |||
| 447 | # Compile: create assembler files from C++ source files. | ||
| 448 | %.s : %.cpp | $(BEGIN) | ||
| 449 | @$(SILENT) || printf "$(MSG_ASSEMBLING) $<" | $(AWK_CMD) | ||
| 450 | $(eval CMD=$(CC) -S $(ALL_CPPFLAGS) $< -o $@) | ||
| 451 | @$(BUILD_CMD) | ||
| 452 | 348 | ||
| 453 | # Create preprocessed source for use in sending a bug report. | 349 | # Create preprocessed source for use in sending a bug report. |
| 454 | %.i : %.c | $(BEGIN) | 350 | %.i : %.c | $(BEGIN) |
| @@ -456,71 +352,19 @@ $(eval $(call GEN_OBJRULE,$(KBOBJDIR))) | |||
| 456 | 352 | ||
| 457 | # Target: clean project. | 353 | # Target: clean project. |
| 458 | clean: | 354 | clean: |
| 459 | $(REMOVE) -r $(OBJDIR) 2>/dev/null | 355 | $(foreach OUTPUT,$(OUTPUTS), $(REMOVE) -r $(OUTPUT) 2>/dev/null) |
| 460 | $(REMOVE) -r $(KBOBJDIR) 2>/dev/null | ||
| 461 | $(REMOVE) $(BUILD_DIR)/$(TARGET).* | 356 | $(REMOVE) $(BUILD_DIR)/$(TARGET).* |
| 462 | 357 | ||
| 463 | show_path: | 358 | show_path: |
| 464 | @echo VPATH=$(VPATH) | 359 | @echo VPATH=$(VPATH) |
| 465 | @echo SRC=$(SRC) | 360 | @echo SRC=$(SRC) |
| 466 | 361 | @echo OBJ=$(OBJ) | |
| 467 | SUBDIRS := $(filter-out %/util/ %/doc/ %/keymaps/ %/old_keymap_files/,$(dir $(wildcard $(TOP_DIR)/keyboards/**/*/Makefile))) | ||
| 468 | SUBDIRS := $(SUBDIRS) $(dir $(wildcard $(TOP_DIR)/keyboards/*/.)) | ||
| 469 | SUBDIRS := $(sort $(SUBDIRS)) | ||
| 470 | # $(error $(SUBDIRS)) | ||
| 471 | all-keyboards-defaults-%: | ||
| 472 | @for x in $(SUBDIRS) ; do \ | ||
| 473 | printf "Compiling with default: $$x" | $(AWK_CMD); \ | ||
| 474 | 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; \ | ||
| 475 | done | ||
| 476 | |||
| 477 | all-keyboards-defaults: all-keyboards-defaults-all | ||
| 478 | |||
| 479 | KEYBOARDS := $(SUBDIRS:$(TOP_DIR)/keyboards/%/=/keyboards/%) | ||
| 480 | all-keyboards-all: $(addsuffix -all,$(KEYBOARDS)) | ||
| 481 | all-keyboards-clean: $(addsuffix -clean,$(KEYBOARDS)) | ||
| 482 | all-keyboards: all-keyboards-all | ||
| 483 | |||
| 484 | define make_keyboard | ||
| 485 | $(eval KEYBOARD=$(patsubst /keyboards/%,%,$1)) | ||
| 486 | $(eval SUBPROJECT=$(lastword $(subst /, ,$(KEYBOARD)))) | ||
| 487 | $(eval KEYBOARD=$(firstword $(subst /, ,$(KEYBOARD)))) | ||
| 488 | $(eval KEYMAPS=$(notdir $(patsubst %/.,%,$(wildcard $(TOP_DIR)/keyboards/$(KEYBOARD)/keymaps/*/.)))) | ||
| 489 | $(eval KEYMAPS+=$(notdir $(patsubst %/.,%,$(wildcard $(TOP_DIR)/keyboards/$(KEYBOARD)/$(SUBPROJECT)/keymaps/*/.)))) | ||
| 490 | @for x in $(KEYMAPS) ; do \ | ||
| 491 | printf "Compiling $(BOLD)$(KEYBOARD)/$(SUBPROJECT)$(NO_COLOR) with $(BOLD)$$x$(NO_COLOR)" | $(AWK) '{ printf "%-118s", $$0; }'; \ | ||
| 492 | 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; \ | ||
| 493 | done | ||
| 494 | endef | ||
| 495 | |||
| 496 | define make_keyboard_helper | ||
| 497 | # Just remove the -all and so on from the first argument and pass it forward | ||
| 498 | $(call make_keyboard,$(subst -$2,,$1),$2) | ||
| 499 | endef | ||
| 500 | |||
| 501 | /keyboards/%-all: | ||
| 502 | $(call make_keyboard_helper,$@,all) | ||
| 503 | /keyboards/%-clean: | ||
| 504 | $(call make_keyboard_helper,$@,clean) | ||
| 505 | /keyboards/%: | ||
| 506 | $(call make_keyboard_helper,$@,all) | ||
| 507 | |||
| 508 | all-keymaps-%: | ||
| 509 | $(eval MAKECONFIG=$(call get_target,all-keymaps,$@)) | ||
| 510 | $(eval KEYMAPS=$(notdir $(patsubst %/.,%,$(wildcard $(TOP_DIR)/keyboards/$(KEYBOARD)/keymaps/*/.)))) | ||
| 511 | @for x in $(KEYMAPS) ; do \ | ||
| 512 | printf "Compiling $(BOLD)$(KEYBOARD)$(NO_COLOR) with $(BOLD)$$x$(NO_COLOR)" | $(AWK) '{ printf "%-118s", $$0; }'; \ | ||
| 513 | 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; \ | ||
| 514 | done | ||
| 515 | |||
| 516 | all-keymaps: all-keymaps-all | ||
| 517 | 362 | ||
| 518 | # Create build directory | 363 | # Create build directory |
| 519 | $(shell mkdir $(BUILD_DIR) 2>/dev/null) | 364 | $(shell mkdir $(BUILD_DIR) 2>/dev/null) |
| 520 | 365 | ||
| 521 | # Create object files directory | 366 | # Create object files directory |
| 522 | $(shell mkdir $(OBJDIR) 2>/dev/null) | 367 | $(eval $(foreach OUTPUT,$(OUTPUTS),$(shell mkdir $(OUTPUT) 2>/dev/null))) |
| 523 | $(shell mkdir $(KBOBJDIR) 2>/dev/null) | ||
| 524 | 368 | ||
| 525 | # Include the dependency files. | 369 | # Include the dependency files. |
| 526 | -include $(patsubst %.o,%.d,$(OBJ)) | 370 | -include $(patsubst %.o,%.d,$(OBJ)) |
| @@ -528,8 +372,6 @@ $(shell mkdir $(KBOBJDIR) 2>/dev/null) | |||
| 528 | 372 | ||
| 529 | # Listing of phony targets. | 373 | # Listing of phony targets. |
| 530 | .PHONY : all finish sizebefore sizeafter gccversion \ | 374 | .PHONY : all finish sizebefore sizeafter gccversion \ |
| 531 | build elf hex eep lss sym coff extcoff check_submodule \ | 375 | build elf hex eep lss sym coff extcoff \ |
| 532 | clean clean_list debug gdb-config show_path \ | 376 | clean clean_list debug gdb-config show_path \ |
| 533 | program teensy dfu flip dfu-ee flip-ee dfu-start \ | 377 | program teensy dfu flip dfu-ee flip-ee dfu-start \ No newline at end of file |
| 534 | all-keyboards-defaults all-keyboards all-keymaps \ | ||
| 535 | all-keyboards-defaults-% all-keyboards-% all-keymaps-% | ||
