CC = gcc CFLAGS = -Wall -Wextra -O2 -g -std=c11 -fwrapv -pthread LDFLAGS = -pthread TARGETS = serverd clientd SOURCES = $(filter-out $(patsubst %,%.c,$(TARGETS)),$(wildcard *.c)) OBJECTS = $(patsubst %.c,%.o,$(SOURCES)) .PHONY: all clean all: $(TARGETS) clean: rm -f $(TARGETS) *.o $(TARGETS): %: %.o $(OBJECTS) $(CC) $^ -o $@ $(LDFLAGS) %.o: %.c $(wildcard *.h) $(CC) $(CFLAGS) -c -o $@ $<