This repository has been archived on 2025-11-10. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
aal/Makefile
Aryadev Chavali 919fae2df8 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.
2023-10-23 00:45:23 +01:00

48 lines
876 B
Makefile

CC=gcc
FVERBOSE=0
GENERAL-FLAGS=-Wall -Wextra -Werror -Wswitch-enum -std=c11 -D VERBOSE=$(FVERBOSE)
DEBUG-FLAGS=-ggdb -fsanitize=address
RELEASE-FLAGS=-O3
CFLAGS=$(GENERAL-FLAGS) $(DEBUG-FLAGS)
LIBS=
ARGS=
OUT=ovm.out
SRC=src
DIST=build
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)
$(DIST):
mkdir -p $(DIST)
$(OUT): $(DIST)/$(OUT)
$(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)
.PHONY:
clean:
rm -rfv $(DIST)/*