CC = gcc CFLAGS = -Wall -g -c -std=gnu11 LDFLAGS = -pthread BUILD_DIR = build BINARY_NAME = mailbox OBJ_FILES = $(patsubst %.c,$(BUILD_DIR)/%.o,$(wildcard *.c)) HEADER_FILES = $(wildcard *.h) .PHONY: all clean all: $(BINARY_NAME) clean: rm -rf $(BUILD_DIR) $(BINARY_NAME): $(OBJ_FILES) $(HEADER_FILES) $(CC) -o $(BINARY_NAME) $(filter $(OBJ_FILES),$^) $(LDFLAGS) $(BUILD_DIR)/%.o: %.c | $(BUILD_DIR) $(CC) $(CFLAGS) -o $@ $< $(BUILD_DIR): mkdir -p $(BUILD_DIR) %.h: ;