diff options
| author | Roman Ilin <me@romanilin.is> | 2026-06-24 14:42:16 +0300 |
|---|---|---|
| committer | Roman Ilin <me@romanilin.is> | 2026-06-24 14:42:16 +0300 |
| commit | 4eafadb1653b215883e555e4cd00cda0caaf5ab4 (patch) | |
| tree | a91f0ba168a5306a74de26157cb290e390bf36d6 /Makefile | |
| download | colloid-main.tar.gz | |
Diffstat (limited to 'Makefile')
| -rw-r--r-- | Makefile | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..7132ab1 --- /dev/null +++ b/Makefile @@ -0,0 +1,79 @@ +CC := clang +CPPFLAGS := \ + -D_POSIX_C_SOURCE=202405L \ + -D_DEFAULT_SOURCE \ + -MMD -MP +CFLAGS := \ + -std=c2y \ + -fdefer-ts \ + -fstack-protector-strong \ + -pedantic-errors \ + -Wall \ + -Wextra \ + -Werror \ + -Wconversion \ + -Wformat-security \ + -Wformat=2 \ + -Wmissing-prototypes \ + -Wnull-dereference \ + -Wpadded \ + -Wshadow \ + -Wstack-protector \ + -Wstrict-prototypes \ + -Wunreachable-code \ + -Wunused-macros +LDFLAGS := +LDLIBS := + +PKG_CONFIG := pkg-config +DEPS := \ + libsodium \ + liburing +CFLAGS += $(shell $(PKG_CONFIG) --cflags $(DEPS)) +LDFLAGS += $(shell $(PKG_CONFIG) --libs-only-L $(DEPS)) +LDLIBS += $(shell $(PKG_CONFIG) --libs-only-l --libs-only-other $(DEPS)) + +DEBUG ?= 0 +ifeq ($(DEBUG),1) + CFLAGS += \ + -O0 \ + -g3 \ + -fno-omit-frame-pointer \ + -fsanitize=address,undefined \ + -Wno-error=unreachable-code \ + -Wno-error=unused \ + -Wno-error=unused-macros \ + -Wno-error=unused-parameter + LDFLAGS += -fsanitize=address,undefined + BUILD_DIR := build/debug +else ifeq ($(DEBUG),0) + CPPFLAGS += -DNDEBUG + CFLAGS += -O2 -flto -march=native + LDFLAGS += -flto + BUILD_DIR := build/release +else + $(error Invalid DEBUG $(DEBUG)) +endif + +SRCS := $(shell find src -type f -name '*.c') +OBJS := $(SRCS:src/%.c=$(BUILD_DIR)/%.o) +EXE := colloid + +.PHONY: all clean + +all: $(BUILD_DIR)/$(EXE) + +$(BUILD_DIR)/%.o: src/%.c + @mkdir -p $(@D) + $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< + +$(BUILD_DIR)/$(EXE): $(OBJS) + @mkdir -p $(@D) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS) + +clean: + rm -fr build + +-include $(OBJS:.o=.d) + +$(OBJS:.o=.d): ; |