Browse Source

Better "include guards" for the makefiles

Checking for ARCH is not good enough, since some subprojects define it.
Ergodox Ez for example. The leads to running the make from
keyboards/ergodox/ez failing. The keyboard makefile will not be included
in that case, and therefore not the CUSTOM_MATRIX either.

Furthermore the output files are read from many different .build
directories, so it doesn't fail deterministically. For example on the
Travis CI the compilation passes, since there's no outdated objects that
needs recompilation.
pull/595/head
Fred Sundvik 7 years ago
parent
commit
79067662c8
1 changed files with 14 additions and 9 deletions
  1. +14
    -9
      Makefile

+ 14
- 9
Makefile View File

@ -5,8 +5,9 @@ endif
.DEFAULT_GOAL := all
space := $(subst ,, )
starting_makefile := $(subst $(space),_SPACE_,$(abspath $(firstword $(MAKEFILE_LIST))))
mkfile_path := $(subst $(space),_SPACE_,$(abspath $(lastword $(MAKEFILE_LIST))))
ESCAPED_ABS_PATH = $(subst $(space),_SPACE_,$(abspath $1))
starting_makefile := $(call ESCAPED_ABS_PATH,$(firstword $(MAKEFILE_LIST)))
mkfile_path := $(call ESCAPED_ABS_PATH,$(lastword $(MAKEFILE_LIST))))
abs_tmk_root := $(patsubst %/,%,$(dir $(mkfile_path)))
ifneq (,$(findstring /keyboards/,$(starting_makefile)))
@ -83,10 +84,8 @@ endif
ifneq ("$(wildcard $(KEYBOARD_PATH)/$(KEYBOARD).c)","")
KEYBOARD_FILE = keyboards/$(KEYBOARD)/$(KEYBOARD).c
ifndef ARCH
ifneq ("$(wildcard $(KEYBOARD_PATH)/Makefile)","")
include $(KEYBOARD_PATH)/Makefile
endif
ifneq ($(call ESCAPED_ABS_PATH,$(KEYBOARD_PATH)/Makefile),$(starting_makefile))
-include $(KEYBOARD_PATH)/Makefile
endif
else
$(error "$(KEYBOARD_PATH)/$(KEYBOARD).c" does not exist)
@ -101,7 +100,9 @@ ifdef SUBPROJECT
ifneq ("$(wildcard $(SUBPROJECT_PATH)/$(SUBPROJECT).c)","")
OPT_DEFS += -DSUBPROJECT_$(SUBPROJECT)
SUBPROJECT_FILE = keyboards/$(KEYBOARD)/$(SUBPROJECT)/$(SUBPROJECT).c
-include $(SUBPROJECT_PATH)/Makefile
ifneq ($(call ESCAPED_ABS_PATH,$(SUBPROJECT_PATH)/Makefile),$(starting_makefile))
-include $(SUBPROJECT_PATH)/Makefile
endif
else
$(error "$(SUBPROJECT_PATH)/$(SUBPROJECT).c" does not exist)
endif
@ -119,14 +120,18 @@ endif
KEYMAP_PATH = $(KEYBOARD_PATH)/keymaps/$(KEYMAP)
ifneq ("$(wildcard $(KEYMAP_PATH)/keymap.c)","")
KEYMAP_FILE = keyboards/$(KEYBOARD)/keymaps/$(KEYMAP)/keymap.c
-include $(KEYMAP_PATH)/Makefile
ifneq ($(call ESCAPED_ABS_PATH,$(KEYMAP_PATH)/Makefile),$(starting_makefile))
-include $(KEYMAP_PATH)/Makefile
endif
else
ifeq ("$(wildcard $(SUBPROJECT_PATH)/keymaps/$(KEYMAP)/keymap.c)","")
$(error "$(KEYMAP_PATH)/keymap.c" does not exist)
else
KEYMAP_PATH = $(SUBPROJECT_PATH)/keymaps/$(KEYMAP)
KEYMAP_FILE = keyboards/$(KEYBOARD)/$(SUBPROJECT)/keymaps/$(KEYMAP)/keymap.c
-include $(KEYMAP_PATH)/Makefile
ifneq ($(call ESCAPED_ABS_PATH,$(KEYMAP_PATH)/Makefile),$(starting_makefile))
-include $(KEYMAP_PATH)/Makefile
endif
endif
endif


Loading…
Cancel
Save