Skip to content

Instantly share code, notes, and snippets.

@hleonps
Created January 21, 2017 18:20
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hleonps/d2d1cb335ac8919991dc9a09954be7e8 to your computer and use it in GitHub Desktop.
Save hleonps/d2d1cb335ac8919991dc9a09954be7e8 to your computer and use it in GitHub Desktop.
Makefile NASM
AS=nasm #Assembly compiler
ASFLAGS=-f elf -g #Assembly flags
LD=ld #Linker
LDFLAGS=-m elf_i386 #Linker flags
SOURCES=$(wildcard ./src/*.c) #Sources
OBJECTS=$(SOURCES:.asm=.o) #Object files
EXECUTABLE=test #Program name
#Check version
all: $(SOURCES) $(EXECUTABLE)
#Create executable
$(EXECUTABLE): $(OBJECTS)
$(LD) $(LDFLAGS) $(OBJECTS) -o $@
#Compile assembly program
$(OBJECTS): $(SOURCES)
$(AS) $(ASFLAGS) $(SOURCES)
#Clean folder
clean:
rm -rf *o $(EXECUTABLE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment