diff options
author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-11-01 18:28:56 +0000 |
---|---|---|
committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-11-01 18:28:56 +0000 |
commit | dab1729f613edcdc7a14e20e728c22c40cdd0966 (patch) | |
tree | 259bf5b0bba52f5937ad6367cf9c336f8d798e86 /Makefile | |
parent | cc34c9b9c3d861d9f96e242ca352b4bc76f524f1 (diff) | |
download | ovm-dab1729f613edcdc7a14e20e728c22c40cdd0966.tar.gz ovm-dab1729f613edcdc7a14e20e728c22c40cdd0966.tar.bz2 ovm-dab1729f613edcdc7a14e20e728c22c40cdd0966.zip |
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.
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 23 |
1 files changed, 13 insertions, 10 deletions
@@ -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) |