簡體   English   中英

使用 makefile 和 iar 編譯器構建匯編程序文件

[英]build assembler file using makefile with iar compiler

所有 C 代碼構建和鏈接均無錯誤。 我的程序集文件是 cstartup.s 我現在也需要它來構建程序集文件

在 makefile 中(這里減少了很多,但請記住它構建 C 代碼很好)我有這個:

PROJ_SRC =  $(SRC_DIR)/plsi2c_riscv.c \
                    …
              $(SRC_DIR)/cstartup.s \


OBJ_FILES = $(addprefix $(BUILD_FOLDER)/,$(PROJ_SRC:.c=.o))
OBJ_FILES += $(addprefix $(BUILD_FOLDER)/,$(PROJ_SRC:.s=.o))

#compile C code
$(BUILD_FOLDER)/%.o: %.c
       #Create the folder structure for the output file
       @mkdir -p $(dir $@)
       $(RISCV_IARCC) $(RISCV_CFLAGS) $< -o $@

#compile .s code
$(BUILD_FOLDER)/%.o: %.s
       $(RISCV_IARCC) $(RISCV_CFLAGS) $< -o $@


#link
CC = $(RISCV_IARLINK)
$(BUILD_FOLDER)/twowire: $(OBJ_FILES)
       mkdir -p $(dir $@)
       @echo Linking $(notdir $@)
       $(CC) $(RISCV_LDFLAGS) $^ $(LDLIBS)

我總是得到這個錯誤: make: *** No rule to make target '/c/BitBucket/riscv/src/release//c/BitBucket/riscv/src/cstartup.s' 雖然 cstartup.s 肯定在 c/ BitBucket/riscv/src(它與文件 plsi2c_riscv.c 一起存在)

有沒有辦法做到這一點?

解決方案是將匯編代碼文件字符串放在另一個組中,例如 PROJ_ASM

PROJ_SRC = $(SRC_DIR)/plsi2c_riscv.c \
                    …etc
PROJ_ASM = $(SRC_DIR)/cstartup.s \


OBJ_FILES = $(addprefix $(BUILD_FOLDER)/,$(PROJ_SRC:.c=.o))
OBJ_FILES += $(addprefix $(BUILD_FOLDER)/,$(PROJ_ASM:.s=.o))

#compile C code
$(BUILD_FOLDER)/%.o: %.c
       #Create the folder structure for the output file
       @mkdir -p $(dir $@)
       $(RISCV_IARCC) $(RISCV_CFLAGS) $< -o $@

#compile .s code
$(BUILD_FOLDER)/%.o: %.s
       $(RISCV_IARASM) $(RISCV_ASMFLAGS) $< -o $@


#link
CC = $(RISCV_IARLINK)
$(BUILD_FOLDER)/twowire: $(OBJ_FILES)
       mkdir -p $(dir $@)
       @echo Linking $(notdir $@)
       $(CC) $(RISCV_LDFLAGS) $^ $(LDLIBS)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM