From ac57e32a0222a3f18e138f0a358d1d01921be3a0 Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Mon, 23 Oct 2023 04:24:28 +0100 Subject: Added lib folder for general stuff, introduced as target to Makefile --- Makefile | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) (limited to 'Makefile') 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) -- cgit v1.2.3-13-gbd6f