Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

You must log in to answer this question.

Browse other questions tagged .