From dab1729f613edcdc7a14e20e728c22c40cdd0966 Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Wed, 1 Nov 2023 18:28:56 +0000 Subject: Makefile now has recipes for example assembly programs Dependencies are just ASM_OUT binary and the corresponding assembly program for the bytecode output file. Actually works very well, with changes triggering a recompilation. Also an `exec` recipe is introduced to do the task of compiling an assembly program and executing the corresponding bytecode all at once. --- Makefile | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index cbbfaa8..1115d75 100644 --- a/Makefile +++ b/Makefile @@ -40,8 +40,7 @@ ASM_OUT=$(DIST)/asm.out ## EXAMPLES setup EXAMPLES_DIST=$(DIST)/examples EXAMPLES_SRC=examples -EXAMPLES_CFLAGS=$(CFLAGS) -EXAMPLES=$(DIST)/fib.out +EXAMPLES=$(EXAMPLES_DIST)/fib.out $(EXAMPLES_DIST)/factorial.out $(EXAMPLES_DIST)/instruction-test.out # Things you want to build on `make` all: $(DIST) lib vm asm examples @@ -82,24 +81,28 @@ $(ASM_DIST)/%.o: $(ASM_SRC)/%.c @echo -e "$(TERM_YELLOW)$@$(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_YELLOW)$@$(TERM_RESET): $<" +$(EXAMPLES_DIST)/%.out: $(EXAMPLES_SRC)/%.asm $(ASM_OUT) + @$(ASM_OUT) $< $@ + @echo -e "$(TERM_GREEN)$@$(TERM_RESET): $<" OUT= ARGS= + .PHONY: run run: $(DIST)/$(OUT) ./$^ $(ARGS) -.PHONY: +.PHONY: clean clean: rm -rfv $(DIST)/* +SOURCE= +BYTECODE= +.PHONY: exec +exec: $(ASM_OUT) $(VM_OUT) + @$(ASM_OUT) $(SOURCE) $(BYTECODE) + @$(VM_OUT) $(BYTECODE) + # Directories $(DIST): mkdir -p $(DIST) -- cgit v1.2.3-13-gbd6f