Created
January 21, 2017 18:20
-
-
Save hleonps/d2d1cb335ac8919991dc9a09954be7e8 to your computer and use it in GitHub Desktop.
Makefile NASM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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