aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorChristian Cunningham <cc@localhost>2024-07-13 21:29:31 -0700
committerChristian Cunningham <cc@localhost>2024-07-13 21:29:31 -0700
commit7161434d2b9c393eb1c8b843edc193bca96a7ee5 (patch)
treee1db63a00ee1217b2e0d77e2354a9f2e6cc21cc6 /Makefile
OS-Aware Makefile
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile24
1 files changed, 24 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..df15ae7
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,24 @@
+ifeq ($(shell uname -s),Darwin)
+ AFLAGS += -fmacho64
+ LDFLAGS += -lSystem
+ LD = clang
+endif
+ifeq ($(shell uname -s),Linux)
+ AFLAGS += -felf64
+ LD = ld
+endif
+
+OUT_BIN=build
+
+.PHONY: clean $(OUT_BIN)
+
+default: clean $(OUT_BIN)
+
+$(OUT_BIN): main.o
+ $(LD) $(LDFLAGS) -o $@ $^
+
+%.o: %.asm
+ nasm $(AFLAGS) $< -o $@
+
+clean:
+ -rm *.o $(OUT_BIN)