aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile65
-rw-r--r--vm/base.h (renamed from src/base.h)0
-rw-r--r--vm/darr.c (renamed from src/darr.c)0
-rw-r--r--vm/darr.h (renamed from src/darr.h)0
-rw-r--r--vm/fib.c (renamed from src/fib.c)0
-rw-r--r--vm/inst.c (renamed from src/inst.c)0
-rw-r--r--vm/inst.h (renamed from src/inst.h)0
-rw-r--r--vm/main.c (renamed from src/main.c)0
-rw-r--r--vm/runtime.c (renamed from src/runtime.c)0
-rw-r--r--vm/runtime.h (renamed from src/runtime.h)0
10 files changed, 39 insertions, 26 deletions
diff --git a/Makefile b/Makefile
index 1ba2079..57be35b 100644
--- a/Makefile
+++ b/Makefile
@@ -1,43 +1,49 @@
CC=gcc
-
-FVERBOSE=0
-GENERAL-FLAGS=-Wall -Wextra -Werror -Wswitch-enum -std=c11 -D VERBOSE=$(FVERBOSE)
+GENERAL-FLAGS=-Wall -Wextra -Werror -Wswitch-enum -std=c11
DEBUG-FLAGS=-ggdb -fsanitize=address
RELEASE-FLAGS=-O3
-CFLAGS=$(GENERAL-FLAGS) $(DEBUG-FLAGS)
-
+CFLAGS:=$(GENERAL-FLAGS) $(DEBUG-FLAGS)
LIBS=
-ARGS=
-OUT=ovm.out
-
-SRC=src
DIST=build
+TERM_YELLOW:=$(shell echo -e "\e[0;33m")
+TERM_GREEN:=$(shell echo -e "\e[0;32m")
+TERM_RESET:=$(shell echo -e "\e[0;0m")
-CODE=$(addprefix $(SRC)/, darr.c inst.c runtime.c)
-OBJECTS=$(CODE:$(SRC)/%.c=$(DIST)/%.o)
-DEPS=$(OBJECTS:%.o=%.d) $(DIST)/fib.d $(DIST)/main.d
-
-.PHONY: all
-all: $(OUT) $(DIST)
+# Setup variables for source code, output, etc
+VM_DIST=$(DIST)/vm
+VM_SRC=vm
+VM_CODE:=$(addprefix $(VM_SRC)/, darr.c inst.c runtime.c)
+VM_OBJECTS:=$(VM_CODE:$(VM_SRC)/%.c=$(VM_DIST)/%.o)
+VM_DEPS:=$(VM_OBJECTS:%.o=%.d) $(VM_DIST)/fib.d $(VM_DIST)/main.d
+VM_VERBOSE=0
+VM_CFLAGS:=$(CFLAGS) -D VERBOSE=$(VM_VERBOSE)
-$(DIST):
- mkdir -p $(DIST)
+VM_OUT=$(VM_DIST)/ovm.out
-$(OUT): $(DIST)/$(OUT)
+# Things you want to build on `make`
+all: $(DIST) vm examples
+vm: $(VM_DIST) $(VM_OUT)
+examples: vm-examples
+vm-examples: $(VM_DIST) $(VM_DIST)/fib.out
-$(DIST)/$(OUT): $(DIST) $(OBJECTS) $(DIST)/main.o
- $(CC) $(CFLAGS) $(OBJECTS) $(DIST)/main.o -o $@ $(LIBS)
+# Recipes
--include $(DEPS)
+$(VM_OUT): $(VM_OBJECTS) $(VM_DIST)/main.o
+ @$(CC) $(VM_CFLAGS) $^ -o $@ $(LIBS)
+ @echo -e "$(TERM_GREEN)$@$(TERM_RESET)"
-$(DIST)/%.o: $(SRC)/%.c
- $(CC) $(CFLAGS) -MMD -c $< -o $@ $(LIBS)
+$(VM_DIST)/fib.out: $(VM_OBJECTS) $(VM_DIST)/fib.o
+ @$(CC) $(VM_CFLAGS) $^ -o $@ $(LIBS)
+ @echo -e "$(TERM_GREEN)$@$(TERM_RESET)"
-examples: $(DIST)/fib.out
+-include $(VM_DEPS)
-$(DIST)/fib.out: $(DIST) $(OBJECTS) $(SRC)/fib.c
- $(CC) $(CFLAGS) $(OBJECTS) $(SRC)/fib.c -o $@ $(LIBS)
+$(VM_DIST)/%.o: $(VM_SRC)/%.c
+ @$(CC) $(VM_CFLAGS) -MMD -c $< -o $@ $(LIBS)
+ @echo -e "$(TERM_GREEN)$@$(TERM_RESET)"
+OUT=
+ARGS=
.PHONY: run
run: $(DIST)/$(OUT)
./$^ $(ARGS)
@@ -45,3 +51,10 @@ run: $(DIST)/$(OUT)
.PHONY:
clean:
rm -rfv $(DIST)/*
+
+# Directories
+$(DIST):
+ mkdir -p $(DIST)
+
+$(VM_DIST): $(DIST)
+ mkdir -p $(VM_DIST)
diff --git a/src/base.h b/vm/base.h
index dbeec80..dbeec80 100644
--- a/src/base.h
+++ b/vm/base.h
diff --git a/src/darr.c b/vm/darr.c
index 4393c4b..4393c4b 100644
--- a/src/darr.c
+++ b/vm/darr.c
diff --git a/src/darr.h b/vm/darr.h
index 1d5820b..1d5820b 100644
--- a/src/darr.h
+++ b/vm/darr.h
diff --git a/src/fib.c b/vm/fib.c
index 7107c3e..7107c3e 100644
--- a/src/fib.c
+++ b/vm/fib.c
diff --git a/src/inst.c b/vm/inst.c
index 3980173..3980173 100644
--- a/src/inst.c
+++ b/vm/inst.c
diff --git a/src/inst.h b/vm/inst.h
index 8902757..8902757 100644
--- a/src/inst.h
+++ b/vm/inst.h
diff --git a/src/main.c b/vm/main.c
index 005b61e..005b61e 100644
--- a/src/main.c
+++ b/vm/main.c
diff --git a/src/runtime.c b/vm/runtime.c
index ccda9d0..ccda9d0 100644
--- a/src/runtime.c
+++ b/vm/runtime.c
diff --git a/src/runtime.h b/vm/runtime.h
index 83ffa17..83ffa17 100644
--- a/src/runtime.h
+++ b/vm/runtime.h