Files
Toy/tests/standalone/makefile
Kayne Ruse 7be63c8ccc Added -Wpointer-arith to CFLAGS, read more
I attempted to add '-Wpedantic' to CFLAGS, but it seems that my usage of
the variable length arrays within unions is causing an error that can't
be selectively disabled:

error: invalid use of structure with flexible array member [-Werror=pedantic]

This is the offending code: /source/toy_string.h#L9-L37

It seems that tagged unions, with VLAs within, is simply not allowed.
Unfortunately, my whole string system depends on it. I'll have to find some way
around it.

I've also updated the debugging output in repl/main.c.
2024-12-12 18:23:44 +11:00

60 lines
1.2 KiB
Makefile

#compiler settings
CC=gcc
CFLAGS+=-std=c17 -g -Wall -Werror -Wextra -Wpointer-arith -Wformat=2
LIBS+=-lm
LDFLAGS+=
ifeq ($(shell uname),Linux)
LDFLAGS=-Wl,--gc-sections
else ifeq ($(OS),Windows_NT)
LDFLAGS=-Wl,--gc-sections
else ifeq ($(shell uname),Darwin)
LDFLAGS=-Wl,-dead_strip
else
@echo "LDFLAGS set failed - what platform is this?"
endif
#directories
TEST_SRCDIR=
TEST_OUTDIR=out/
TEST_OBJDIR=obj/
#file names
TEST_SRCFILES=$(wildcard $(TEST_SRCDIR)*.c)
#kick off
all: $(TEST_OBJDIR) $(TEST_OUTDIR) build run
gdb: $(TEST_OBJDIR) $(TEST_OUTDIR) build gdb-run
#build
build: $(TEST_OBJDIR)$(TEST_SRCFILES:.c=.o)
.PRECIOUS: $(TEST_OBJDIR)%.o
$(TEST_OBJDIR)%.o: $(TEST_SRCDIR)%.c
$(CC) -c -o $@ $< $(CFLAGS) -fdata-sections -ffunction-sections
.PRECIOUS: $(TEST_OUTDIR)%.exe
$(TEST_OUTDIR)%.exe: $(TEST_OBJDIR)%.o
$(CC) -o $@ $< $(CFLAGS) $(LIBS) $(LDFLAGS)
#run
run: $(addprefix $(TEST_OUTDIR),$(TEST_SRCFILES:.c=.exe-run))
$(TEST_OUTDIR)%.exe-run: $(TEST_OUTDIR)%.exe
$<
#gdb-run
gdb-run: $(addprefix $(TEST_OUTDIR),$(TEST_SRCFILES:.c=.exe-gdb-run))
$(TEST_OUTDIR)%.exe-gdb-run: $(TEST_OUTDIR)%.exe
gdb $< -ix gdb_init -ex=run --batch --return-child-result
#util targets
$(TEST_OUTDIR):
mkdir $(TEST_OUTDIR)
$(TEST_OBJDIR):
mkdir $(TEST_OBJDIR)