diff options
author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-10-23 03:58:34 +0100 |
---|---|---|
committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-10-23 03:58:34 +0100 |
commit | b44a61be41e44b415b1293fcbc1f1e8c4ce3373d (patch) | |
tree | 218cdb4901d23089ab0b54b4ff3097202c442acd | |
parent | 587f31a63b26fe3789acd0ba129474a2be200d37 (diff) | |
download | ovm-b44a61be41e44b415b1293fcbc1f1e8c4ce3373d.tar.gz ovm-b44a61be41e44b415b1293fcbc1f1e8c4ce3373d.tar.bz2 ovm-b44a61be41e44b415b1293fcbc1f1e8c4ce3373d.zip |
src->vm, Makefile is now a bit more abstracted and pretty colours
Changed folder names for sake of clarity (will be introducing a new
build target soon), and Makefile can now easily support more targets.
-rw-r--r-- | Makefile | 65 | ||||
-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
@@ -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/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 |