CFLAGS += -Wall -g -fno-stack-protector -O0
CC := clang
PURECAP_CC ?= ~/cheri/output/sdk/utils/cheribsd-riscv64-purecap-clang

SOURCES := $(wildcard *.c)
OBJECTS := $(patsubst %.c, %, $(SOURCES))
OBJECTS_CHERIBSD := $(patsubst %.c, %-cheribsd, $(SOURCES))

all: all-host all-cheribsd

all-host: $(OBJECTS) 

all-cheribsd: $(OBJECTS_CHERIBSD) 

%: %.c
	$(CC) $< $(CFLAGS) -o $@

%-cheribsd: %.c
	$(PURECAP_CC) $< $(CFLAGS) -o $@

clean:
	rm $(OBJECTS) $(OBJECTS_CHERIBSD)