summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile38
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 $@