summaryrefslogtreecommitdiff
path: root/Makefile
blob: 078b0a07efe6fd42fb6e8dc99cf8270bef6d0851 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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 $@ $<