SOURCES = $(wildcard *.c) TARGET = tcp # top-level rule, to compile everything. all: $(TARGET) DEPS = $(wildcard *.d) OBJECTS = $(SOURCES:.c=.o) #link $(TARGET): $(OBJECTS) gcc -o $@ $^ -lpthread -g #compile %.o : %.c gcc -o $@ $< -c -g -MMD -Wall # If explicit dependencies exist, add them include $(DEPS) # rule for cleaning re-compilable files. clean: rm -f $(TARGET) $(OBJECTS) $(DEPS) rebuild: clean all .PHONY: rebuild clean all