Simple Makefile for assembly executables

I want to automatically build assembly files into executable binaries. The following Makefile seems to be sufficient. I am sure I will add to it over time.

All I have to modify is the SRC_FILES line to add a new target

Note that html does not honor the tab characters.

SRC_FILES = hello.s overwrite.s
O_FILES = $(SRC_FILES:%.s=%.o)
B_FILES = $(SRC_FILES:%.s=%)
all: $(B_FILES) 
%: %.s 
        as -o $@.o $<
        ld -o $@ $@.o
        rm -f $(O_FILES) $(B_FILES)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.