summaryrefslogtreecommitdiff
path: root/Makefile
blob: 738ccfc86a788b685db40fb00dc3ace21c8bd72b (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
31
32
CC = gcc
CFLAGS = -Wall -Wextra -std=c11 -fwrapv -fPIC
ifneq ($(DEBUG),)
	CFLAGS += -g
else
	CFLAGS += -O2
endif
LDFLAGS = -ldl
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
	make all


$(BIN): $(patsubst %.c,%.o,$(wildcard *.c))
	$(CC) -o $@ $^ $(LDFLAGS)

%.o: %.c $(wildcard $(dir %.o)*.h)
	$(CC) $(CFLAGS) -c -o $@ $<