diff options
| -rw-r--r-- | build_keyboard.mk | 8 | ||||
| -rw-r--r-- | build_test.mk | 42 | ||||
| -rw-r--r-- | tmk_core/native.mk | 24 | ||||
| -rw-r--r-- | tmk_core/rules.mk | 19 |
4 files changed, 81 insertions, 12 deletions
diff --git a/build_keyboard.mk b/build_keyboard.mk index bbe571845..869d672b0 100644 --- a/build_keyboard.mk +++ b/build_keyboard.mk | |||
| @@ -204,6 +204,14 @@ $(KEYBOARD_OUTPUT)_DEFS := $(PROJECT_DEFS) | |||
| 204 | $(KEYBOARD_OUTPUT)_INC := $(PROJECT_INC) | 204 | $(KEYBOARD_OUTPUT)_INC := $(PROJECT_INC) |
| 205 | $(KEYBOARD_OUTPUT)_CONFIG := $(PROJECT_CONFIG) | 205 | $(KEYBOARD_OUTPUT)_CONFIG := $(PROJECT_CONFIG) |
| 206 | 206 | ||
| 207 | # Default target. | ||
| 208 | all: build sizeafter | ||
| 209 | |||
| 210 | # Change the build target to build a HEX file or a library. | ||
| 211 | build: elf hex | ||
| 212 | #build: elf hex eep lss sym | ||
| 213 | #build: lib | ||
| 214 | |||
| 207 | 215 | ||
| 208 | include $(TMK_PATH)/rules.mk | 216 | include $(TMK_PATH)/rules.mk |
| 209 | 217 | ||
diff --git a/build_test.mk b/build_test.mk index 37ed8b568..dac59a8f4 100644 --- a/build_test.mk +++ b/build_test.mk | |||
| @@ -1,5 +1,43 @@ | |||
| 1 | ifndef VERBOSE | ||
| 2 | .SILENT: | ||
| 3 | endif | ||
| 4 | |||
| 5 | .DEFAULT_GOAL := all | ||
| 6 | |||
| 1 | include common.mk | 7 | include common.mk |
| 2 | 8 | ||
| 9 | TARGET=test/$(TEST) | ||
| 10 | |||
| 11 | GTEST_OUTPUT = $(BUILD_DIR)/gtest | ||
| 12 | |||
| 13 | OUTPUTS := $(GTEST_OUTPUT) | ||
| 14 | |||
| 15 | GTEST_INC := \ | ||
| 16 | $(LIB_PATH)/googletest/googletest/include\ | ||
| 17 | $(LIB_PATH)/googletest/googlemock/include\ | ||
| 18 | |||
| 19 | GTEST_INTERNAL_INC :=\ | ||
| 20 | $(LIB_PATH)/googletest/googletest\ | ||
| 21 | $(LIB_PATH)/googletest/googlemock | ||
| 22 | |||
| 23 | $(GTEST_OUTPUT)_SRC :=\ | ||
| 24 | googletest/src/gtest-all.cc\ | ||
| 25 | googletest/src/gtest_main.cc\ | ||
| 26 | googlemock/src/gmock-all.cc | ||
| 27 | |||
| 28 | $(GTEST_OUTPUT)_DEFS := | ||
| 29 | $(GTEST_OUTPUT)_INC := $(GTEST_INC) $(GTEST_INTERNAL_INC) | ||
| 30 | |||
| 31 | LDFLAGS += -lstdc++ -lpthread -shared-libgcc | ||
| 32 | |||
| 33 | VPATH +=\ | ||
| 34 | $(LIB_PATH)/googletest\ | ||
| 35 | $(LIB_PATH)/googlemock | ||
| 36 | |||
| 37 | all: elf | ||
| 38 | |||
| 39 | include $(TMK_PATH)/native.mk | ||
| 40 | include $(TMK_PATH)/rules.mk | ||
| 41 | |||
| 42 | $(shell mkdir $(BUILD_DIR)/test 2>/dev/null) | ||
| 3 | 43 | ||
| 4 | all: | ||
| 5 | echo Done $(TEST) \ No newline at end of file | ||
diff --git a/tmk_core/native.mk b/tmk_core/native.mk new file mode 100644 index 000000000..50232ee9b --- /dev/null +++ b/tmk_core/native.mk | |||
| @@ -0,0 +1,24 @@ | |||
| 1 | CC = gcc | ||
| 2 | OBJCOPY = | ||
| 3 | OBJDUMP = | ||
| 4 | SIZE = | ||
| 5 | AR = | ||
| 6 | NM = | ||
| 7 | HEX = | ||
| 8 | EEP = | ||
| 9 | BIN = | ||
| 10 | |||
| 11 | |||
| 12 | COMPILEFLAGS += -funsigned-char | ||
| 13 | COMPILEFLAGS += -funsigned-bitfields | ||
| 14 | COMPILEFLAGS += -ffunction-sections | ||
| 15 | COMPILEFLAGS += -fdata-sections | ||
| 16 | COMPILEFLAGS += -fshort-enums | ||
| 17 | |||
| 18 | CFLAGS += $(COMPILEFLAGS) | ||
| 19 | CFLAGS += -fno-inline-small-functions | ||
| 20 | CFLAGS += -fno-strict-aliasing | ||
| 21 | |||
| 22 | CPPFLAGS += $(COMPILEFLAGS) | ||
| 23 | CPPFLAGS += -fno-exceptions | ||
| 24 | CPPFLAGS += -std=gnu++11 \ No newline at end of file | ||
diff --git a/tmk_core/rules.mk b/tmk_core/rules.mk index 21011c280..317f55e08 100644 --- a/tmk_core/rules.mk +++ b/tmk_core/rules.mk | |||
| @@ -21,13 +21,14 @@ VPATH_SRC := $(VPATH) | |||
| 21 | vpath %.c $(VPATH_SRC) | 21 | vpath %.c $(VPATH_SRC) |
| 22 | vpath %.h $(VPATH_SRC) | 22 | vpath %.h $(VPATH_SRC) |
| 23 | vpath %.cpp $(VPATH_SRC) | 23 | vpath %.cpp $(VPATH_SRC) |
| 24 | vpath %.cc $(VPATH_SRC) | ||
| 24 | vpath %.hpp $(VPATH_SRC) | 25 | vpath %.hpp $(VPATH_SRC) |
| 25 | vpath %.S $(VPATH_SRC) | 26 | vpath %.S $(VPATH_SRC) |
| 26 | VPATH := | 27 | VPATH := |
| 27 | 28 | ||
| 28 | # Convert all SRC to OBJ | 29 | # Convert all SRC to OBJ |
| 29 | define OBJ_FROM_SRC | 30 | define OBJ_FROM_SRC |
| 30 | $(patsubst %.c,$1/%.o,$(patsubst %.cpp,$1/%.o,$(patsubst %.S,$1/%.o,$($1_SRC)))) | 31 | $(patsubst %.c,$1/%.o,$(patsubst %.cpp,$1/%.o,$(patsubst %.cc,$1/%.o,$(patsubst %.S,$1/%.o,$($1_SRC))))) |
| 31 | endef | 32 | endef |
| 32 | $(foreach OUTPUT,$(OUTPUTS),$(eval $(OUTPUT)_OBJ +=$(call OBJ_FROM_SRC,$(OUTPUT)))) | 33 | $(foreach OUTPUT,$(OUTPUTS),$(eval $(OUTPUT)_OBJ +=$(call OBJ_FROM_SRC,$(OUTPUT)))) |
| 33 | 34 | ||
| @@ -202,14 +203,6 @@ ALL_ASFLAGS = $(MCUFLAGS) -x assembler-with-cpp $(ASFLAGS) $(EXTRAFLAGS) | |||
| 202 | 203 | ||
| 203 | MOVE_DEP = mv -f $(patsubst %.o,%.td,$@) $(patsubst %.o,%.d,$@) | 204 | MOVE_DEP = mv -f $(patsubst %.o,%.td,$@) $(patsubst %.o,%.d,$@) |
| 204 | 205 | ||
| 205 | # Default target. | ||
| 206 | all: build sizeafter | ||
| 207 | |||
| 208 | # Change the build target to build a HEX file or a library. | ||
| 209 | build: elf hex | ||
| 210 | #build: elf hex eep lss sym | ||
| 211 | #build: lib | ||
| 212 | |||
| 213 | 206 | ||
| 214 | elf: $(BUILD_DIR)/$(TARGET).elf | 207 | elf: $(BUILD_DIR)/$(TARGET).elf |
| 215 | hex: $(BUILD_DIR)/$(TARGET).hex | 208 | hex: $(BUILD_DIR)/$(TARGET).hex |
| @@ -305,7 +298,13 @@ $1/%.o : %.cpp $1/%.d $1/cppflags.txt $1/compiler.txt | $(BEGIN) | |||
| 305 | @mkdir -p $$(@D) | 298 | @mkdir -p $$(@D) |
| 306 | @$$(SILENT) || printf "$$(MSG_COMPILING_CPP) $$<" | $$(AWK_CMD) | 299 | @$$(SILENT) || printf "$$(MSG_COMPILING_CPP) $$<" | $$(AWK_CMD) |
| 307 | $$(eval CMD=$$(CC) -c $$($1_CPPFLAGS) $$(GENDEPFLAGS) $$< -o $$@ && $$(MOVE_DEP)) | 300 | $$(eval CMD=$$(CC) -c $$($1_CPPFLAGS) $$(GENDEPFLAGS) $$< -o $$@ && $$(MOVE_DEP)) |
| 308 | @$(BUILD_CMD) | 301 | @$$(BUILD_CMD) |
| 302 | |||
| 303 | $1/%.o : %.cc $1/%.d $1/cppflags.txt $1/compiler.txt | $(BEGIN) | ||
| 304 | @mkdir -p $$(@D) | ||
| 305 | @$$(SILENT) || printf "$$(MSG_COMPILING_CPP) $$<" | $$(AWK_CMD) | ||
| 306 | $$(eval CMD=$$(CC) -c $$($1_CPPFLAGS) $$(GENDEPFLAGS) $$< -o $$@ && $$(MOVE_DEP)) | ||
| 307 | @$$(BUILD_CMD) | ||
| 309 | 308 | ||
| 310 | # Assemble: create object files from assembler source files. | 309 | # Assemble: create object files from assembler source files. |
| 311 | $1/%.o : %.S $1/asflags.txt $1/compiler.txt | $(BEGIN) | 310 | $1/%.o : %.S $1/asflags.txt $1/compiler.txt | $(BEGIN) |
