open-ameba/sdk/sdkbuild.mk

103 lines
3.5 KiB
Makefile
Raw Permalink Normal View History

2017-05-12 23:29:53 +00:00
include userset.mk
include $(SDK_PATH)paths.mk
include project.mk
2016-11-09 00:56:41 +00:00
INCFLAGS = $(patsubst %,-I%,$(patsubst sdk/%,$(SDK_PATH)%,$(INCLUDES)))
LIBFLAGS = $(addprefix -L,$(patsubst sdk/%,$(SDK_PATH)%,$(PATHLIBS))) $(addprefix -l,$(LIBS))
LFLAGS += -Wl,-Map=$(OBJ_DIR)/$(TARGET).map
CFLAGS += $(INCFLAGS)
SRC_O = $(patsubst %.c,%.o,$(patsubst sdk/%,$(SDK_PATH)%,$(ADD_SRC_C))) $(patsubst %.c,%.o,$(patsubst sdk/%,$(SDK_PATH)%,$(SRC_C)))
DRAM_O = $(patsubst %.c,%.o,$(patsubst sdk/%,$(SDK_PATH)%,$(DRAM_C)))
2017-03-05 23:22:35 +00:00
BOOT_O = $(patsubst %.c,%.o,$(patsubst sdk/%,$(SDK_PATH)%,$(BOOT_C)))
2016-11-09 00:56:41 +00:00
2017-03-05 23:22:35 +00:00
SRC_C_LIST = $(patsubst sdk/%,$(SDK_PATH)%,$(ADD_SRC_C)) $(patsubst sdk/%,$(SDK_PATH)%,$(SRC_C)) $(patsubst sdk/%,$(SDK_PATH)%,$(DRAM_C)) $(patsubst sdk/%,$(SDK_PATH)%,$(BOOT_C))
2016-11-09 00:56:41 +00:00
OBJ_LIST = $(addprefix $(OBJ_DIR)/,$(patsubst %.c,%.o,$(SRC_C_LIST)))
DEPENDENCY_LIST = $(patsubst %.c,$(OBJ_DIR)/%.d,$(SRC_C_LIST))
TARGET ?= build
OBJ_DIR ?= $(TARGET)/obj
BIN_DIR ?= $(TARGET)/bin
ELFFILE ?= $(OBJ_DIR)/$(TARGET).axf
# For verbose make
ifeq ("$(V)","1")
Q :=
vecho := @true
else
Q := @
vecho := @echo
endif
2016-11-09 00:56:41 +00:00
all: prerequirement application
mp: prerequirement application
.PHONY: build_info
build_info:
@echo \#define UTS_VERSION \"`date +%Y/%m/%d-%T`\" > .ver
@echo \#define RTL8195AFW_COMPILE_TIME \"`date +%Y/%m/%d-%T`\" >> .ver
@echo \#define RTL8195AFW_COMPILE_DATE \"`date +%Y%m%d`\" >> .ver
@echo \#define RTL8195AFW_COMPILE_BY \"`id -u -n`\" >> .ver
@echo \#define RTL8195AFW_COMPILE_HOST \"`$(HOSTNAME_APP)`\" >> .ver
@if [ -x /bin/dnsdomainname ]; then \
echo \#define RTL8195AFW_COMPILE_DOMAIN \"`dnsdomainname`\"; \
elif [ -x /bin/domainname ]; then \
echo \#define RTL8195AFW_COMPILE_DOMAIN \"`domainname`\"; \
else \
echo \#define RTL8195AFW_COMPILE_DOMAIN ; \
fi >> .ver
@echo \#define RTL195AFW_COMPILER \"gcc `$(CC) $(CFLAGS) -dumpversion | tr --delete '\r'`\" >> .ver
$(Q) mv -f .ver project/inc/$@.h
2016-11-09 00:56:41 +00:00
.PHONY: application
2017-03-05 23:22:35 +00:00
application: build_info $(SRC_O) $(DRAM_O) $(BOOT_O)
2016-11-09 00:56:41 +00:00
@echo "==========================================================="
@echo "Link ($(TARGET))"
# @echo "==========================================================="
2017-03-24 15:24:37 +00:00
@mkdir -p $(BIN_DIR) $(OBJ_DIR)
$(Q) $(file > $(OBJ_DIR)/obj_list.lst,$(OBJ_LIST))
$(Q) $(LD) $(LFLAGS) -o $(ELFFILE) @$(OBJ_DIR)/obj_list.lst $(LIBFLAGS) -T$(LDFILE)
$(Q) $(OBJDUMP) -d $(ELFFILE) > $(OBJ_DIR)/$(TARGET).asm
2016-11-09 00:56:41 +00:00
.PHONY: prerequirement
#.NOTPARALLEL: prerequirement
prerequirement:
# @$(file >DEPENDENCY_LIST.txt,$(DEPENDENCY_LIST))
@echo "==========================================================="
@echo "Compile ($(TARGET))"
# @echo "==========================================================="
@mkdir -p $(OBJ_DIR)
$(SRC_O): %.o : %.c
@echo $<
@mkdir -p $(OBJ_DIR)/$(dir $@)
$(Q) $(CC) $(CFLAGS) $(INCFLAGS) -c $< -o $(OBJ_DIR)/$@
$(Q) $(CC) -MM $(CFLAGS) $(INCFLAGS) $< -MT $@ -MF $(OBJ_DIR)/$(patsubst %.o,%.d,$@)
2016-11-09 00:56:41 +00:00
$(DRAM_O): %.o : %.c
@echo $<
@mkdir -p $(OBJ_DIR)/$(dir $@)
$(Q) $(CC) $(CFLAGS) $(INCFLAGS) -c $< -o $(OBJ_DIR)/$@
$(Q) $(OBJCOPY) --prefix-alloc-sections .sdram $(OBJ_DIR)/$@
$(Q) $(CC) -MM $(CFLAGS) $(INCFLAGS) $< -MT $@ -MF $(OBJ_DIR)/$(patsubst %.o,%.d,$@)
2017-03-05 23:22:35 +00:00
$(BOOT_O): %.o : %.c
@echo $<
@mkdir -p $(OBJ_DIR)/$(dir $@)
$(Q) $(CC) $(CFLAGS) $(INCFLAGS) -c $< -o $(OBJ_DIR)/$@
$(Q) $(OBJCOPY) --prefix-alloc-sections .boot $(OBJ_DIR)/$@
$(Q) $(CC) -MM $(CFLAGS) $(INCFLAGS) $< -MT $@ -MF $(OBJ_DIR)/$(patsubst %.o,%.d,$@)
2016-11-09 00:56:41 +00:00
-include $(DEPENDENCY_LIST)
VPATH:=$(OBJ_DIR) $(SDK_PATH)
#.PHONY: clean
clean:
rm -rf $(OBJ_DIR) $(BIN_DIR) $(OBJ_DIR)/$(SDK_PATH)