From 0ac634a9bec04934398a431bfc1b9a7a27561f0c Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Mon, 23 Oct 2023 04:25:30 +0100 Subject: Reintroduced example fib.c via examples/ folder --- Makefile | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index f4bde0f..bd3cdff 100644 --- a/Makefile +++ b/Makefile @@ -23,19 +23,24 @@ VM_DIST=$(DIST)/vm VM_SRC=vm 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_DEPS:=$(VM_OBJECTS:%.o=%.d) $(VM_DIST)/main.d VM_VERBOSE=0 VM_CFLAGS:=$(CFLAGS) -D VERBOSE=$(VM_VERBOSE) VM_OUT=$(DIST)/ovm.out +## EXAMPLES setup +EXAMPLES_DIST=$(DIST)/examples +EXAMPLES_SRC=examples +EXAMPLES_CFLAGS=$(CFLAGS) +EXAMPLES=$(DIST)/fib.out + # Things you want to build on `make` 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 +examples: $(EXAMPLES_DIST) $(EXAMPLES) # Recipes ## LIB Recipes @@ -56,6 +61,15 @@ $(VM_DIST)/%.o: $(VM_SRC)/%.c @$(CC) $(VM_CFLAGS) -MMD -c $< -o $@ $(LIBS) @echo -e "$(TERM_GREEN)$@$(TERM_RESET)" +## EXAMPLES recipes +$(DIST)/fib.out: $(LIB_OBJECTS) $(VM_OBJECTS) $(ASM_OBJECTS) $(EXAMPLES_DIST)/fib.o + @$(CC) $(EXAMPLES_CFLAGS) $^ -o $@ $(LIBS) + @echo -e "$(TERM_GREEN)$@$(TERM_RESET)" + +$(EXAMPLES_DIST)/%.o: $(EXAMPLES_SRC)/%.c + @$(CC) $(EXAMPLES_CFLAGS) -MMD -c $< -o $@ $(LIBS) + @echo -e "$(TERM_GREEN)$@$(TERM_RESET)" + OUT= ARGS= .PHONY: run @@ -75,3 +89,6 @@ $(LIB_DIST): $(VM_DIST): mkdir -p $(VM_DIST) + +$(EXAMPLES_DIST): + mkdir -p $(EXAMPLES_DIST) -- cgit v1.2.3-13-gbd6f