Skip to content

Commit

Permalink
Add output specific config file
Browse files Browse the repository at this point in the history
  • Loading branch information
fredizzimo committed Aug 20, 2016
1 parent 33fbd3b commit 9028a41
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 21 deletions.
17 changes: 10 additions & 7 deletions build_keyboard.mk
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,17 @@ ifeq ($(PLATFORM),CHIBIOS)
OPT_OS = chibios
endif

CONFIG_H = $(KEYBOARD_PATH)/config.h
ifneq ($(SUBPROJECT),)
ifneq ("$(wildcard $(SUBPROJECT_C))","")
CONFIG_H = $(SUBPROJECT_PATH)/config.h
endif
endif

# Save the defines and includes here, so we don't include any keymap specific ones
PROJECT_DEFS := $(OPT_DEFS)
PROJECT_INC := $(VPATH) $(EXTRAINCDIRS) $(SUBPROJECT_PATH) $(KEYBOARD_PATH)
PROJECT_CONFIG := $(CONFIG_H)

MAIN_KEYMAP_PATH := $(KEYBOARD_PATH)/keymaps/$(KEYMAP)
MAIN_KEYMAP_C := $(MAIN_KEYMAP_PATH)/keymap.c
Expand Down Expand Up @@ -94,13 +102,6 @@ KEYMAP_OUTPUT := $(BUILD_DIR)/obj_$(TARGET)

ifneq ("$(wildcard $(KEYMAP_PATH)/config.h)","")
CONFIG_H = $(KEYMAP_PATH)/config.h
else
CONFIG_H = $(KEYBOARD_PATH)/config.h
ifneq ($(SUBPROJECT),)
ifneq ("$(wildcard $(SUBPROJECT_C))","")
CONFIG_H = $(SUBPROJECT_PATH)/config.h
endif
endif
endif

# # project specific files
Expand Down Expand Up @@ -192,9 +193,11 @@ OUTPUTS := $(KEYMAP_OUTPUT) $(KEYBOARD_OUTPUT)
$(KEYMAP_OUTPUT)_SRC := $(SRC)
$(KEYMAP_OUTPUT)_DEFS := $(OPT_DEFS) -DQMK_KEYBOARD=\"$(KEYBOARD)\" -DQMK_KEYMAP=\"$(KEYMAP)\"
$(KEYMAP_OUTPUT)_INC := $(EXTRAINCDIRS) $(VPATH)
$(KEYMAP_OUTPUT)_CONFIG := $(CONFIG_H)
$(KEYBOARD_OUTPUT)_SRC := $(CHIBISRC)
$(KEYBOARD_OUTPUT)_DEFS := $(PROJECT_DEFS)
$(KEYBOARD_OUTPUT)_INC := $(PROJECT_INC)
$(KEYBOARD_OUTPUT)_CONFIG := $(PROJECT_CONFIG)


include $(TMK_PATH)/rules.mk
Expand Down
20 changes: 6 additions & 14 deletions tmk_core/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,6 @@ CFLAGS += -Wstrict-prototypes
#CFLAGS += -Wsign-compare
CFLAGS += -Wa,-adhlns=$(@:%.o=%.lst)
CFLAGS += $(CSTANDARD)
ifdef CONFIG_H
CFLAGS += -include $(CONFIG_H)
endif


#---------------- Compiler Options C++ ----------------
Expand All @@ -124,10 +121,6 @@ CPPFLAGS += -Wundef
#CPPFLAGS += -Wsign-compare
CPPFLAGS += -Wa,-adhlns=$(@:%.o=%.lst)
#CPPFLAGS += $(CSTANDARD)
ifdef CONFIG_H
CPPFLAGS += -include $(CONFIG_H)
endif


#---------------- Assembler Options ----------------
# -Wa,...: tell GCC to pass this to the assembler.
Expand All @@ -140,9 +133,6 @@ endif
# dump that will be displayed for a given single line of source input.
ASFLAGS += $(ADEFS)
ASFLAGS += -Wa,-adhlns=$(@:%.o=%.lst),-gstabs,--listing-cont-lines=100
ifdef CONFIG_H
ASFLAGS += -include $(CONFIG_H)
endif

#---------------- Library Options ----------------
# Minimalistic printf version
Expand Down Expand Up @@ -296,10 +286,12 @@ BEGIN = gccversion sizebefore

define GEN_OBJRULE
$1_INCFLAGS := $$(patsubst %,-I%,$$($1_INC))
$1_CFLAGS = $$(ALL_CFLAGS) $$($1_DEFS) $$($1_INCFLAGS)
$1_CPPFLAGS= $$(ALL_CPPFLAGS) $$($1_DEFS) $$($1_INCFLAGS)
$1_ASFLAGS= $$(ALL_ASFLAGS) $$($1_DEFS) $$($1_INCFLAGS)
$$(info $$($1_INCFLAGS))
ifdef $1_CONFIG
$1_CONFIG_FLAGS += -include $$($1_CONFIG)
endif
$1_CFLAGS = $$(ALL_CFLAGS) $$($1_DEFS) $$($1_INCFLAGS) $$($1_CONFIG_FLAGS)
$1_CPPFLAGS= $$(ALL_CPPFLAGS) $$($1_DEFS) $$($1_INCFLAGS) $$($1_CONFIG_FLAGS)
$1_ASFLAGS= $$(ALL_ASFLAGS) $$($1_DEFS) $$($1_INCFLAGS) $$($1_CONFIG_FLAGS)

# Compile: create object files from C source files.
$1/%.o : %.c $1/%.d $1/cflags.txt $1/compiler.txt | $(BEGIN)
Expand Down

0 comments on commit 9028a41

Please sign in to comment.