Skip to content

Instantly share code, notes, and snippets.

@nevack
Last active September 23, 2018 18:38
Show Gist options
  • Save nevack/dd8fa28cba448d724cac7c7935b09419 to your computer and use it in GitHub Desktop.
Save nevack/dd8fa28cba448d724cac7c7935b09419 to your computer and use it in GitHub Desktop.
Makefile to build NASM labs
EXECUTABLE = lab
SOURCE = $(shell ls *asm | sed 1q)
OBJ = $(shell echo $(SOURCE) | cut -f 1 -d '.').o
AS = /usr/local/bin/nasm
ASFLAGS = -f macho
LD = ld
LDFLAGS = -macosx_version_min 10.7.0 -o $(EXECUTABLE) $(OBJ)
DBG = lldb
.PHONY: $(EXECUTABLE)
run: link $(EXECUTABLE)
$(info Running $(EXECUTABLE)...)
$(info )
@./$(EXECUTABLE)
@echo
@echo Exited
build: clean ../util.asm
$(info Building $(SOURCE) with NASM...)
@$(AS) $(ASFLAGS) $(SOURCE)
link: build $(OBJ)
$(info Linking...)
@$(LD) $(LDFLAGS)
debug: link $(EXECUTABLE)
$(info Running with $(DBG) debugger...)
@$(DBG) $(EXECUTABLE)
clean:
$(info Removing all temp files...)
@rm -f $(EXECUTABLE) 2> /dev/null
@rm -f *.o 2> /dev/null
@nevack
Copy link
Author

nevack commented Sep 23, 2018

util.asm to be placed in parent dir

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment