diff options
author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-10-23 00:42:57 +0100 |
---|---|---|
committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-10-23 00:45:23 +0100 |
commit | 919fae2df8cbe1793167d0525e7552937e504a88 (patch) | |
tree | eca7d81338b9dc5315c17dde4ac25c2a4d59121a /Makefile | |
parent | 19eb401498488db1e5c39fc199e59bf96df2828d (diff) | |
download | ovm-919fae2df8cbe1793167d0525e7552937e504a88.tar.gz ovm-919fae2df8cbe1793167d0525e7552937e504a88.tar.bz2 ovm-919fae2df8cbe1793167d0525e7552937e504a88.zip |
Added an example program fib.c
This is simply a program with an embedded set of instructions which
indefinitely computes and prints fibonacci numbers, computing them in
pairs.
Does it completely through the virtual machine rather than just hard C
instructions.
Also amended the Makefile to compile it. Required moving the main.c
object file into the dependencies of $(DIST)/$(OUT).
I should track the dependencies for fib.c and main.c as well.
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -13,9 +13,9 @@ OUT=ovm.out SRC=src DIST=build -CODE=$(addprefix $(SRC)/, darr.c inst.c runtime.c main.c) +CODE=$(addprefix $(SRC)/, darr.c inst.c runtime.c) OBJECTS=$(CODE:$(SRC)/%.c=$(DIST)/%.o) -DEPS=$(OBJECTS:%.o=%.d) +DEPS=$(OBJECTS:%.o=%.d) $(DIST)/fib.d $(DIST)/main.d .PHONY: all all: $(OUT) $(DIST) @@ -25,14 +25,19 @@ $(DIST): $(OUT): $(DIST)/$(OUT) -$(DIST)/$(OUT): $(DIST) $(OBJECTS) - $(CC) $(CFLAGS) $(OBJECTS) -o $@ $(LIBS) +$(DIST)/$(OUT): $(DIST) $(OBJECTS) $(DIST)/main.o + $(CC) $(CFLAGS) $(OBJECTS) $(DIST)/main.o -o $@ $(LIBS) -include $(DEPS) $(DIST)/%.o: $(SRC)/%.c $(CC) $(CFLAGS) -MMD -c $< -o $@ $(LIBS) +examples: $(DIST)/fib.out + +$(DIST)/fib.out: $(DIST) $(OBJECTS) $(SRC)/fib.c + $(CC) $(CFLAGS) $(OBJECTS) $(SRC)/fib.c -o $@ $(LIBS) + .PHONY: run run: $(DIST)/$(OUT) ./$^ $(ARGS) |