Last active
September 23, 2018 18:38
-
-
Save nevack/dd8fa28cba448d724cac7c7935b09419 to your computer and use it in GitHub Desktop.
Makefile to build NASM labs
This file contains 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
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
util.asm to be placed in parent dir