2
2
I would like to set up a Makefile to assemble and link my assembly programs automatically.
Right now I have different sources of assembler programs in single files like prog1.asm, prog2.asm, hello.asm, etc.
I want make to run
as -o prog1.o prog1.asm
ld prog1.o prog1
for every single source.
I set up a Makefile but it's not working correctly.
.PHONY : all
.PHONY : clean
SOURCES = $(wildcard *.asm)
OBJECTS = $(SOURCES:.asm=.o)
TARGETS = $(SOURCES:.asm=)
%.o: %.asm
as -o $@ $<
all: $(TARGETS)
$(TARGETS): $(OBJECTS)
ld $< -o $@
clean:
rm *.o
In fact, make should link all asm files in the directory to execcutables. That's all.