common.inc 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. BUILD_OUT_IMG_DIR ?= $(ROOT_DIR)/out/$(CONFIG_CHIP)/img
  2. BUILD_OUT_OBJ_DIR ?= $(ROOT_DIR)/out/$(CONFIG_CHIP)/obj
  3. LD_FLAG = -EL -nostdlib -Wl,--gc-sections -mips32r3
  4. C_DEF_FLAG =
  5. C_COMPILE_FLAG = -EL -mips32r3 -mabi=32 -mmt -march=mips32r3 -ffunction-sections -fdata-sections -G0 #mips parameter
  6. C_COMPILE_FLAG += -Wall -Werror -Wno-unused-variable -Wno-unused-function -Wno-pointer-sign -Wno-format -Wno-unused-but-set-variable -Wno-strict-aliasing -Wno-misleading-indentation #gcc parameter
  7. C_COMPILE_FLAG += -D__FILENAME__='"$(subst $(dir $<),,$<)"' #self def parameter
  8. C_COMPILE_FLAG += -fdebug-prefix-map=$(CONFIG_CODE_PATH)/=./
  9. ifeq ($(CONFIG_HARD_FLOAT),yes)
  10. C_COMPILE_FLAG += -mhard-float
  11. LD_FLAG += -mhard-float
  12. C_DEF_FLAG += -DHV_CONFIG_HARD_FLOAT
  13. else
  14. C_COMPILE_FLAG += -msoft-float
  15. LD_FLAG += -msoft-float
  16. endif
  17. ifeq ($(CONFIG_PRINT),yes)
  18. C_DEF_FLAG += -DHV_CONFIG_ENABLE_PRINT
  19. endif
  20. C_DEF_FLAG += -DHV_CONFIG_CHIP_$(shell echo $(CONFIG_CHIP) | tr '[:lower:]' '[:upper:]')
  21. C_DEF_FLAG += -DHV_CONFIG_ENDIAN_$(shell echo $(CONFIG_ENDIAN) | tr '[:lower:]' '[:upper:]')
  22. C_DEF_FLAG += -DHV_CONFIG_ARCH_$(shell echo $(CONFIG_ARCH) | tr '[:lower:]' '[:upper:]')
  23. USER_CONFIG_FILE := $(ROOT_DIR)/user/$(CONFIG_VENDOR)/$(CONFIG_PROJECT)/property.config
  24. CONFIG_USER_DEFINE := $(shell cat $(USER_CONFIG_FILE) | grep "?=" | awk '{print " -DCONFIG_USER_"$$3}')
  25. C_DEF_FLAG += $(CONFIG_USER_DEFINE)
  26. #ASM_COMPILE_FLAG = -EL -mips32r3 -mabi=32 -mmt -march=mips32r3 -ffunction-sections -fdata-sections -G0
  27. #ASM_COMPILE_FLAG += -Wall -Werror -Wno-unused-variable -Wno-unused-function -Wno-pointer-sign -Wno-format -Wno-unused-but-set-variable -Wno-strict-aliasing -Wno-misleading-indentation
  28. #ifeq ($(CONFIG_HARD_FLOAT),yes)
  29. # ASM_COMPILE_FLAG += -mhard-float
  30. #else
  31. # ASM_COMPILE_FLAG += -msoft-float
  32. #endif
  33. LINK_SCRIPT_DIR ?= $(ROOT_DIR)/build/scripts/ldscript/$(CONFIG_CHIP)
  34. FILE_INC_CONFIG += -include $(ROOT_DIR)/user/$(CONFIG_VENDOR)/$(CONFIG_PROJECT)/BoardConfig.h
  35. FILE_INC_CONFIG += -include $(ROOT_DIR)/user/$(CONFIG_VENDOR)/$(CONFIG_PROJECT)/ProjectConfig.h
  36. FILE_INC_CONFIG += -include $(ROOT_DIR)/user/$(CONFIG_VENDOR)/$(CONFIG_PROJECT)/OSD/OsdConfig.h
  37. MAKE=make
  38. CC=mips-mti-elf-gcc
  39. LD=mips-mti-elf-ld
  40. AR=mips-mti-elf-ar
  41. RANLIB=mips-mti-elf-ranlib
  42. OBJCOPY=mips-mti-elf-objcopy
  43. OBJDUMP=mips-mti-elf-objdump
  44. GDB=mips-mti-elf-gdb
  45. ifeq ($(COMPILE_MODE),release)
  46. C_COMPILE_FLAG += -O2
  47. #ASM_COMPILE_FLAG += -O0
  48. C_DEF_FLAG += -DRELEASE_VERSION
  49. HEADER=@
  50. endif
  51. ifeq ($(COMPILE_MODE),debug)
  52. C_COMPILE_FLAG += -g -O2
  53. #ASM_COMPILE_FLAG += -g
  54. C_DEF_FLAG += -DHV_SCALER_DEBUG_VERSION
  55. C_DEF_FLAG += -DCOMPILE_USERNAME=\"$(shell whoami)\"
  56. C_DEF_FLAG += -DCOMPILE_HOSTNAME=\"$(shell hostname)\"
  57. HEADER=@
  58. endif
  59. ASM_DEF_FLAG = $(C_DEF_FLAG)
  60. ASM_COMPILE_FLAG=$(C_COMPILE_FLAG)
  61. #@if [ $(COMPILE_MODE) = "release" ] ; then echo "$1" ; else echo ""; fi;
  62. define ASM_COMPILE_RULE
  63. $(HEADER)$(CC) $(INCLUDES) $(ASM_COMPILE_FLAG) $(ASM_DEF_FLAG) $(FILE_INC_CONFIG) -o $(BUILD_OUT_OBJ_DIR)/$1 -c $2
  64. @if [ $(COMPILE_MODE) = "release" ] ; then echo "$1" ; fi;
  65. @if [ $(COMPILE_MODE) = "debug" ] ; then echo "$1" ; fi;
  66. endef
  67. define C_COMPILE_RULE
  68. $(HEADER)$(CC) $(INCLUDES) $(C_COMPILE_FLAG) $(C_DEF_FLAG) $(FILE_INC_CONFIG) -o $(BUILD_OUT_OBJ_DIR)/$1 -c $2
  69. @if [ $(COMPILE_MODE) = "release" ] ; then echo "$1" ; fi;
  70. @if [ $(COMPILE_MODE) = "debug" ] ; then echo "$1" ; fi;
  71. endef
  72. %.o : %.S
  73. $(call ASM_COMPILE_RULE,$@,$<)
  74. %.o : %.c
  75. $(call C_COMPILE_RULE,$@,$<)