-
Notifications
You must be signed in to change notification settings - Fork 68
/
Makefile
67 lines (49 loc) · 1.13 KB
/
Makefile
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/make
OBJDIR=obj
SRCDIR=src
ifdef THREADS
PTHREAD=-D WAFER_THREADS=$(THREADS) -pthread
endif
ifdef DEBUG
ifeq ($(DEBUG),0)
DEBUG_OPT=-ggdb
else
DEBUG_OPT=-D WAFER_DEBUG -ggdb
endif
endif
ifdef PROCESSES
PROCESSES_OPT=-D WAFER_PROCESSES=$(PROCESSES) -ggdb
endif
ifdef LOOP
ifeq ($(LOOP),epoll)
LOOP_OPT=-D WAFER_EPOLL
endif
endif
ifdef MAX_CON_CONS
MAX_CON_CONS_OPT=-D WAFER_MAX_CON_CONS=$(MAX_CON_CONS)
endif
ifndef CC
CC=gcc
endif
EXT_OPTIONS=$(PTHREAD) $(DEBUG_OPT) $(PROCESSES_OPT) $(LOOP_OPT) $(MAX_CON_CONS_OPT)
AR=ar
CFLAGS=-std=gnu99 -W -Wall -O2 -Wno-unused-parameter -g $(EXT_OPTIONS)
_LIBWAFER_OBJ=wafer.o waferapi.o
_LIBWAFER=libwafer.a
MODULES=$(SERVER) example
LIBWAFER_OBJ = $(patsubst %,$(OBJDIR)/%,$(_LIBWAFER_OBJ))
LIBWAFER = $(patsubst %,$(OBJDIR)/%,$(_LIBWAFER))
all: $(MODULES)
# rule to build modules
%: $(SRCDIR)/%.c $(LIBWAFER)
$(CC) $(CFLAGS) -o $@ $^ $(OPTIONS)
$(LIBWAFER): $(LIBWAFER_OBJ)
$(AR) r $@ $^
$(OBJDIR)/%.o: $(SRCDIR)/%.c $(OBJDIR)
$(CC) $(CFLAGS) -c -o $@ $<
$(OBJDIR):
mkdir $(OBJDIR)
clean:
rm -f $(LIBWAFER_OBJ)
distclean:
rm -f $(LIBWAFER) $(LIBWAFER_OBJ) $(MODULES)