Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.