CC = gcc CFLAGS = -Wall -Wextra -std=c11 -fwrapv ifneq ($(DEBUG),) CFLAGS += -g else CFLAGS += -O2 endif BIN = cserver PLUGINDIR = plugins PLUGINS = $(patsubst $(PLUGINDIR)/%,%,$(shell find $(PLUGINDIR)/ -maxdepth 1 -type d)) .PHONY: all clean remake all: $(BIN) for pl in $(PLUGINS); do make -C $(PLUGINDIR) $@ PLUGINNAME=$$pl; done clean: rm -rf $(BIN) *.o *.dSYM for pl in $(PLUGINS); do make -C $(PLUGINDIR) $@ PLUGINNAME=$$pl; done remake: clean all $(BIN): $(patsubst %.c,%.o,$(wildcard *.c)) $(CC) -o $@ $^ %.o: %.c $(wildcard $(dir %.o)*.h) $(CC) $(CFLAGS) -c -o $@ $<