diff options
author | Tom Smeding <tom@tomsmeding.com> | 2025-02-16 20:03:40 +0100 |
---|---|---|
committer | Tom Smeding <tom@tomsmeding.com> | 2025-02-16 20:03:40 +0100 |
commit | 39148b1b6dc6c7a10f7e713ece084b6d5cf27537 (patch) | |
tree | 619c9d951b1356bfc8dcaba45a66166972992170 /Makefile |
Initial
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..9dce218 --- /dev/null +++ b/Makefile @@ -0,0 +1,38 @@ +# DEBUG := 1 + +CC := gcc +CFLAGS := -Wall -Wextra -std=c11 +LDFLAGS := +ifneq ($(DEBUG),) + CFLAGS += -g -fsanitize=address + LDFLAGS += -fsanitize=address +else + CFLAGS += -O2 +endif + +# stpcpy(3), stat stuff +CFLAGS += -D_POSIX_C_SOURCE=200809L -D_DEFAULT_SOURCE + +OBJDIR := .obj +TARGET := fs-sample + +SOURCES := $(wildcard *.c) +HEADERS := $(wildcard *.h) +OBJECTS := $(patsubst %.c,$(OBJDIR)/%.o,$(SOURCES)) + +.PHONY: all clean + +all: $(TARGET) + +clean: + rm -f $(TARGET) + rm -rf $(OBJDIR) + +$(TARGET): $(OBJECTS) + $(CC) -o $@ $^ $(LDFLAGS) + +$(OBJECTS): $(OBJDIR)/%.o: %.c $(HEADERS) | $(OBJDIR) + $(CC) $(CFLAGS) -c -o $@ $< + +$(OBJDIR): + mkdir $@ |