From 9edd12e87874eabdc74e45359a5228558e124c98 Mon Sep 17 00:00:00 2001 From: "@syxhe" Date: Thu, 8 Jan 2026 01:59:36 -0600 Subject: Add clay to project --- src/Makefile | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) (limited to 'src/Makefile') diff --git a/src/Makefile b/src/Makefile index 7be2382..5463c86 100644 --- a/src/Makefile +++ b/src/Makefile @@ -2,25 +2,40 @@ CC = gcc SHELL := /usr/bin/env .SHELLFLAGS := -S bash -c -# I need to get better at makefiles so I can write this in a way that isn't absolutely insane/stupid -# RELEASE_CFLAGS := -O3 -fipa-pta -fipa-cp -fuse-linker-plugin -flto=auto -# RELEASE_LDFLAGS := -fuse-linker-plugin -flto=auto +CFLAGS := -std=c2x $$(pkg-config --cflags libsodium) +DEBUG_CFLAGS := -Wall -Wextra -Wpedantic -fanalyzer -Wanalyzer-too-complex -ggdb -g3 -O0 +RELEASE_CFLAGS := -O3 -fipa-pta -fipa-cp -fuse-linker-plugin -flto=auto -CFLAGS = -std=c2x -Wall -Wextra -Wpedantic -pedantic-errors -fanalyzer -Wanalyzer-too-complex -ggdb -g3 -O0 +DEFS := -D_GNU_SOURCE=1 +DEBUG_DEFS := -DDEBUG=1 +RELEASE_DEFS := -DRELEASE=1 -CFLAGS += $$(pkg-config --cflags libsodium) -LDLIBS += $$(pkg-config --libs-only-l libsodium) -LDFLAGS += $$(pkg-config --libs-only-L libsodium) +LDLIBS := $$(pkg-config --libs-only-l libsodium) + +LDFLAGS := $$(pkg-config --libs-only-L libsodium) +RELEASE_LDFLAGS := -fuse-linker-plugin -flto=auto SOURCES := $(wildcard *.c) TIMESTAMP_DIR := .timestamps TIMESTAMPS := $(patsubst %.c,$(TIMESTAMP_DIR)/%.t,$(SOURCES)) -.PHONY: all c clean v val t test +.PHONY: debug release c clean v val t test test .DELETE_ON_ERROR: .ONESHELL: -all: main +tests debug: CFLAGS += $(DEBUG_CFLAGS) +tests debug: DEFS += $(DEBUG_DEFS) +debug: main + +release: CFLAGS += $(RELEASE_CFLAGS) +release: LDFLAGS += $(RELEASE_LDFLAGS) +release: DEFS += $(RELEASE_DEFS) +release: main + +clay.h: + cd .. + git submodule update --init --recursive + cp -fl clay/clay.h src/ $(TIMESTAMP_DIR): mkdir -p $(TIMESTAMP_DIR) @@ -28,8 +43,9 @@ $(TIMESTAMP_DIR): $(TIMESTAMPS): $(TIMESTAMP_DIR)/%.t: %.c | $(TIMESTAMP_DIR) touch $@ +main: clay.h main tests: %: %.c $(TIMESTAMPS) - $(CC) -D_GNU_SOURCE=1 $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $^ $(LOADLIBES) $(LDLIBS) -o $@ + $(CC) $(DEFS) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $^ $(LOADLIBES) $(LDLIBS) -o $@ # Phony rules -- cgit v1.2.3