INCLUDEDIR = $(PWD)/inc SOURCEDIR = $(PWD)/src BUILDDIR = $(PWD)/build SOURCES = $(wildcard $(SOURCEDIR)/*.c) OBJS = $(patsubst $(SOURCEDIR)/%.c, $(BUILDDIR)/%.o, $(SOURCES)) CA = ccache AS = $(CA) nasm LD = $(CA) ld CC = $(CA) gcc CFLAGS = -Ofast -Wall -Wextra -pedantic -Wshadow -Wpointer-arith -Wwrite-strings -Wredundant-decls -Wnested-externs -Wformat=1 -Wmissing-declarations -Wstrict-prototypes -Wmissing-prototypes -Wcast-qual -Wswitch-default -Wswitch-enum -Wlogical-op -Wunreachable-code -Wundef -Wold-style-definition -Wvla -std=c99 -fsanitize=address -fsanitize=undefined -fstack-protector-strong -I$(INCLUDEDIR) all: $(OBJS) @$(CC) -o $(BUILDDIR)/out $(CFLAGS) $^ clean: @$(RM) -rf $(BUILDDIR) run: clean all sync @$(BUILDDIR)/out test.fun $(BUILDDIR)/%.o: $(SOURCEDIR)/%.c @mkdir -p $(BUILDDIR) @$(CC) -c -o $@ $(CFLAGS) $< compile: @$(AS) -f elf64 -o $(BUILDDIR)/test.o $(BUILDDIR)/test.asm @$(LD) $(BUILDDIR)/test.o -o $(BUILDDIR)/test sync: @ctags -R --exclude=.git --exclude=build . @make --always-make --dry-run | grep -wE 'gcc|g\+\+' | grep -w '\-c' | jq -nR '[inputs|{directory:".", command:., file: match(" [^ ]+$$").string[1:]}]' > compile_commands.json