-
Notifications
You must be signed in to change notification settings - Fork 49
/
Makefile
148 lines (121 loc) · 5.17 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#
# BitThunder Top-Level Makefile
#
BASE_PATH:=$(dir $(CURDIR)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))
BASE:=$(patsubst %/,%,$(BASE_PATH))
BUILD_BASE:=$(BASE)
MODULE_NAME:="BitThunder"
ifndef PROJECT_DIR
PROJECT_DIR:=$(shell pwd -P)
PROJECT_CONFIG:=n
else
PROJECT_CONFIG:=y
endif
BUILD_DIR:=$(PROJECT_DIR)/build
TARGETS:=$(PROJECT_DIR)/vmthunder.img
TARGET_DEPS:=$(PROJECT_DIR)/vmthunder.elf
CONFIG_:=BT_CONFIG_
CONFIG_HEADER_NAME:=bt_bsp_config.h
ifneq ($(PROJECT_CONFIG), y)
CONFIG_PATH:=$(PROJECT_DIR)
CONFIG_HEADER_PATH:=$(BASE)
else
CONFIG_PATH:=$(PROJECT_DIR)
CONFIG_HEADER_PATH:=$(PROJECT_DIR)/include
endif
include $(BASE)/.dbuild/dbuild.mk
$(PROJECT_DIR)/.config:
$(Q)echo " ******************************************************"
$(Q)echo " >>>> No .config file found, run make menuconfig"
$(Q)echo " ******************************************************"
@false;
all: $(PROJECT_DIR)/vmthunder.elf $(PROJECT_DIR)/vmthunder.img $(PROJECT_DIR)/vmthunder.syms $(PROJECT_DIR)/vmthunder.exports
$(Q)$(SIZE) $(PROJECT_DIR)/vmthunder.elf
ifeq ($(BT_CONFIG_BUILD_DISASSEMBLE), y)
all: $(PROJECT_DIR)/vmthunder.list
endif
list: $(PROJECT_DIR)/vmthunder.list
.PHONY: list
$(PROJECT_DIR)/vmthunder.img: $(PROJECT_DIR)/vmthunder.elf
$(Q)$(PRETTY) IMAGE $(MODULE_NAME) $(subst $(PROJECT_DIR)/,"",$@)
$(Q)$(OBJCOPY) $(PROJECT_DIR)/vmthunder.elf -O binary $@
$(PROJECT_DIR)/vmthunder.elf: $(OBJECTS) $(LINKER_SCRIPTS)
$(Q)$(PRETTY) --dbuild "LD" $(MODULE_NAME) $(subst $(PROJECT_DIR)/,"",$@)
$(Q)$(CC) -march=$(CC_MARCH) -mtune=$(CC_MTUNE) $(CC_TCFLAGS) $(CC_MACHFLAGS) $(CC_MFPU) $(CC_FPU_ABI) -o $@ -T $(LINKER_SCRIPT) -Wl,-Map=$(PROJECT_DIR)/vmthunder.map $(OBJECTS) $(LDFLAGS) $(LDLIBS) -lm -lc -lgcc
$(PROJECT_DIR)/vmthunder.list: $(PROJECT_DIR)/vmthunder.elf
$(Q)$(PRETTY) LIST $(MODULE_NAME) $(subst $(PROJECT_DIR)/,"",$@)
ifeq ($(BT_CONFIG_BUILD_DISASSEMBLE_SOURCE), y)
$(Q)$(OBJDUMP) -D -S $(PROJECT_DIR)/vmthunder.elf > $@
else
$(Q)$(OBJDUMP) -D $(PROJECT_DIR)/vmthunder.elf > $@
endif
$(PROJECT_DIR)/vmthunder.syms: $(PROJECT_DIR)/vmthunder.elf
$(Q)$(PRETTY) SYMS $(MODULE_NAME) $(subst $(PROJECT_DIR)/,"",$@)
$(Q)$(OBJDUMP) -t $(PROJECT_DIR)/vmthunder.elf > $@
$(PROJECT_DIR)/vmthunder.exports: $(PROJECT_DIR)/vmthunder.elf
$(Q)$(PRETTY) SYMS $(MODULE_NAME) $(subst $(PROJECT_DIR)/,"",$@)
$(Q)$(BASE)/scripts/symbol_status.sh $(PROJECT_DIR)/vmthunder.elf $(BASE) > $@
.PHONY:checksyms
checksyms:$(PROJECT_DIR)/vmthunder.exports
.PHONY:linktree
linktree:
nm $(OBJECTS) > linktree
$(OBJECTS) $(OBJECTS-y): $(PROJECT_DIR)/.config
project.init:
$(Q)touch $(PROJECT_DIR)/Kconfig
$(Q)touch $(PROJECT_DIR)/objects.mk
$(Q)touch $(PROJECT_DIR)/README.md
$(Q)touch $(PROJECT_DIR)/main.c
-$(Q)mkdir $(PROJECT_DIR)/include
$(Q)echo "export PROJECT_DIR=\$$(shell pwd -P)" >> $(PROJECT_DIR)/Makefile
$(Q)echo "export PROJECT_CONFIG=y" >> $(PROJECT_DIR)/Makefile
$(Q)echo "include $(shell $(RELPATH) $(BASE) $(PROJECT_DIR))/Makefile" >> $(PROJECT_DIR)/Makefile
$(Q)echo "objs += \$$(APP)/main.o" >> $(PROJECT_DIR)/objects.mk
project.git.init:
-$(Q)cd $(PROJECT_DIR) && git init .
-$(Q)cd $(PROJECT_DIR) && git submodule add git://github.com/jameswalmsley/bitthunder.git bitthunder
$(Q)touch $(PROJECT_DIR)/Kconfig
$(Q)touch $(PROJECT_DIR)/objects.mk
$(Q)touch $(PROJECT_DIR)/README.md
$(Q)touch $(PROJECT_DIR)/main.c
-$(Q)mkdir $(PROJECT_DIR)/include
$(Q)echo "export PROJECT_DIR=\$$(shell pwd -P)" >> $(PROJECT_DIR)/Makefile
$(Q)echo "export PROJECT_CONFIG=y" >> $(PROJECT_DIR)/Makefile
$(Q)echo "include bitthunder/Makefile" >> $(PROJECT_DIR)/Makefile
$(Q)echo "objs += \$$(APP)/main.o" >> $(PROJECT_DIR)/objects.mk
project.info:
@echo "PROJECT_DIR : $(PROJECT_DIR)"
@echo "BUILD_DIR : $(BUILD_DIR)"
@echo "BASE : $(BASE)"
@echo "PROJECT_CONFIG : $(PROJECT_CONFIG)"
.PHONY:defconfig
defconfig:
ifdef BT_CONFIG_BOARD_DEFCONFIG_FILE
@echo "Copying $(ARCH)/mach/$(SUBARCH)/boards/$(BT_CONFIG_BOARD_DEFCONFIG_FILE) to .config"
@cp $(BASE)/arch/$(ARCH)/mach/$(SUBARCH)/boards/$(BT_CONFIG_BOARD_DEFCONFIG_FILE) $(PROJECT_DIR)/.config
else
@echo "No default board configuration for $(ARCH)/$(SUBARCH)"
endif
.PHONY:upconfig
upconfig:
ifdef BT_CONFIG_BOARD_DEFCONFIG_FILE
@echo "Updating $(ARCH)/mach/$(SUBARCH)/boards/$(BT_CONFIG_BOARD_DEFCONFIG_FILE) from .config"
@cp $(PROJECT_DIR)/.config $(BASE)/arch/$(ARCH)/mach/$(SUBARCH)/boards/$(BT_CONFIG_BOARD_DEFCONFIG_FILE)
else
# Print the defconfig error message.
@$(MAKE) defconfig
endif
mrproper: clean
ifneq ($(PROJECT_CONFIG),y)
$(Q)rm $(PRM_FLAGS) $(PROJECT_DIR)/.config $(BASE)/bt_bsp_config.h $(PRM_PIPE)
else
$(Q)rm $(PRM_FLAGS) $(PROJECT_DIR)/.config $(PROJECT_DIR)/include/bt_bsp_config.h $(PRM_PIPE)
endif
distclean: mrproper
clean: clean_images
clean_images: | dbuild_splash
$(Q)rm -rf $(PROJECT_DIR)/build
$(Q)rm $(PRM_FLAGS) $(PROJECT_DIR)/vmthunder.elf $(PROJECT_DIR)/vmthunder.img $(PROJECT_DIR)/vmthunder.elf $(PROJECT_DIR)/vmthunder.list $(PROJECT_DIR)/vmthunder.map $(PROJECT_DIR)/vmthunder.syms $(PROJECT_DIR)/vmthunder.exports $(PRM_PIPE)
$(Q)rm -rf $(CONFIG_HEADER_PATH)/$(CONFIG_HEADER_NAME) $(PRM_PIPE)
$(Q)rm -rf $(PROJECT_DIR)/linktree
$(CONFIG_HEADER_PATH)/$(CONFIG_HEADER_NAME): MODULE_NAME:=$(MODULE_NAME)