- Use $(SB) variable to set the compiler instead of $(CC) which sets C
compiler
- Use all: rule convention
- Set *.sb files as dependencies so it will rebuild only when something
changes
- Set all and clean as phony targets
---
Makefile | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/Makefile b/Makefile
index 2a8938d..6ac933d 100644
--- a/Makefile
+++ b/Makefile
@@ -1,11 +1,15 @@
-CC=sb
-ENTRY=src/main.sb
-TARGET=main.js
+SRC := $(shell find src -name "*.sb")
+OUT := main.js
-default: build
+SB ?= sb
+RM ?= rm -f
-build:
- $(CC) build $(ENTRY) -o $(TARGET)
+all: $(OUT)
+
+$(OUT): $(SRC)
+ $(SB) build src/main.sb -o $(OUT)
clean:
- -rm -f *.js $(TARGET)
\ No newline at end of file
+ -$(RM) *.js $(OUT)
+
+.PHONY: all clean
--
2.30.1