Skip to content

Instantly share code, notes, and snippets.

@s-ff
Created August 30, 2021 11:14
Show Gist options
  • Save s-ff/2e61cecfd0f6ca182182772e68d8a574 to your computer and use it in GitHub Desktop.
Save s-ff/2e61cecfd0f6ca182182772e68d8a574 to your computer and use it in GitHub Desktop.
Makefile template to assemble with NASM to x86-64 with libc
AS=nasm
ASFLAGS=-f elf64 -g -F dwarf
LD=ld
LDFLAGS=-dynamic-linker /lib64/ld-linux-x86-64.so.2 -lc -m elf_x86_64
RM=rm -rf
SOURCES=$(wildcard *.asm)
OBJECTS=$(SOURCES:.asm=.o)
TARGET=out
%.o: %.asm
$(AS) $(ASFLAGS) $^
all: $(OBJECTS)
$(LD) $(LDFLAGS) $(OBJECTS) -o $(TARGET)
clean:
$(RM) $(OBJECTS) $(TARGET)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment