我有一个不会带多个输入文件的汇编程序。它需要一个.s文件并生成相应的.o文件。
EXECUTABLE_NAME = test.exe
SRC_FILES= \
file1.s \
file2.s
$(EXECUTABLE_NAME) : $(SRC_FILES)
myasm -o file1.o $(SRC_FILES)
mylink -o $(EXECUTABLE_NAME) -s file1.o
如何修改我的makefile以运行asm,如下所示:
myasm -o file1.o file1.s
myasm -o file2.o file2.s
mylink -o $(EXECUTABLE_NAME) -s file1.o file2.o
答案 0 :(得分:1)
您需要定义一条规则,告诉nmake如何从.s构建.o。语法有点粗糙,但是像这样:
EXECUTABLE_NAME = test.exe
SRC_FILES= \
file1.s \
file2.s
OBJ_FILES = \
.\file1.o \
.\file2.o
.SUFFIXES : .s
SRC_DIR = .
OBJ_DIR = .
{$(SRC_DIR)}.s{$(OBJ_DIR)}.o:
myasm -o $@ $<
$(EXECUTABLE_NAME) : $(OBJ_FILES)
mylink -o $(EXECUTABLE_NAME) -s $(OBJ_FILES)