aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2023-10-23 04:24:28 +0100
committerAryadev Chavali <aryadev@aryadevchavali.com>2023-10-23 04:25:48 +0100
commitac57e32a0222a3f18e138f0a358d1d01921be3a0 (patch)
treeb688af5abcfc48e08c7eba61f7f24623c536e931 /Makefile
parentaa4a3b86143250ff958ca66e77d6097aff8d42a1 (diff)
downloadovm-ac57e32a0222a3f18e138f0a358d1d01921be3a0.tar.gz
ovm-ac57e32a0222a3f18e138f0a358d1d01921be3a0.tar.bz2
ovm-ac57e32a0222a3f18e138f0a358d1d01921be3a0.zip
Added lib folder for general stuff, introduced as target to Makefile
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile31
1 files changed, 24 insertions, 7 deletions
diff --git a/Makefile b/Makefile
index 57be35b..f4bde0f 100644
--- a/Makefile
+++ b/Makefile
@@ -10,29 +10,43 @@ TERM_GREEN:=$(shell echo -e "\e[0;32m")
TERM_RESET:=$(shell echo -e "\e[0;0m")
# Setup variables for source code, output, etc
+## Lib setup
+LIB_DIST=$(DIST)/lib
+LIB_SRC=lib
+LIB_CODE:=$(addprefix $(LIB_SRC)/, darr.c)
+LIB_OBJECTS:=$(LIB_CODE:$(LIB_SRC)/%.c=$(LIB_DIST)/%.o)
+LIB_DEPS:=$(LIB_OBJECTS:%.o=%.d)
+LIB_CFLAGS=$(CFLAGS)
+
+## VM setup
VM_DIST=$(DIST)/vm
VM_SRC=vm
-VM_CODE:=$(addprefix $(VM_SRC)/, darr.c inst.c runtime.c)
+VM_CODE:=$(addprefix $(VM_SRC)/, 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)
+VM_OUT=$(DIST)/ovm.out
-VM_OUT=$(VM_DIST)/ovm.out
# Things you want to build on `make`
-all: $(DIST) vm examples
+all: $(DIST) lib vm examples
+
+lib: $(LIB_DIST) $(LIB_OBJECTS)
vm: $(VM_DIST) $(VM_OUT)
examples: vm-examples
vm-examples: $(VM_DIST) $(VM_DIST)/fib.out
# Recipes
+## LIB Recipes
+-include $(LIB_DEPS)
-$(VM_OUT): $(VM_OBJECTS) $(VM_DIST)/main.o
- @$(CC) $(VM_CFLAGS) $^ -o $@ $(LIBS)
+$(LIB_DIST)/%.o: $(LIB_SRC)/%.c
+ @$(CC) $(LIB_CFLAGS) -MMD -c $< -o $@ $(LIBS)
@echo -e "$(TERM_GREEN)$@$(TERM_RESET)"
-$(VM_DIST)/fib.out: $(VM_OBJECTS) $(VM_DIST)/fib.o
+## VM Recipes
+$(VM_OUT): $(LIB_OBJECTS) $(VM_OBJECTS) $(VM_DIST)/main.o
@$(CC) $(VM_CFLAGS) $^ -o $@ $(LIBS)
@echo -e "$(TERM_GREEN)$@$(TERM_RESET)"
@@ -56,5 +70,8 @@ clean:
$(DIST):
mkdir -p $(DIST)
-$(VM_DIST): $(DIST)
+$(LIB_DIST):
+ mkdir -p $(LIB_DIST)
+
+$(VM_DIST):
mkdir -p $(VM_DIST)