-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
64 lines (49 loc) · 1.3 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
#CFLAGS += -std=c99 -Wall -O2 -D_REENTRANT
CFLAGS += -Wall -std=c99
LIBS := -lm -lpthread
TARGET := $(shell uname -s | tr '[A-Z]' '[a-z]' 2>/dev/null || echo unknown)
ifeq ($(TARGET), sunos)
CFLAGS += -D_PTHREADS -D_POSIX_C_SOURCE=200112L
LIBS += -lsocket
else ifeq ($(TARGET), darwin)
# LDFLAGS += -pagezero_size 10000 -image_base 100000000
export MACOSX_DEPLOYMENT_TARGET = $(shell sw_vers -productVersion)
else ifeq ($(TARGET), linux)
CFLAGS += -D_POSIX_C_SOURCE=200112L -D_BSD_SOURCE -D_DEFAULT_SOURCE
LIBS += -ldl
LDFLAGS += -Wl,-E
else ifeq ($(TARGET), freebsd)
CFLAGS += -D_DECLARE_C99_LDBL_MATH
LDFLAGS += -Wl,-E
endif
SRC := wrktcp.c net.c aprintf.c stats.c units.c \
ae.c zmalloc.c islog.c tcpini.c istime.c \
output.c isstr.c http_parser.c
BIN := wrktcp
ODIR := obj
OBJ := $(patsubst %.c,$(ODIR)/%.o,$(SRC))
LIBS := $(LIBS)
DEPS :=
CFLAGS += -I$(ODIR)/include
#LDFLAGS += -L$(ODIR)/lib
LDFLAGS +=
all: $(BIN) test
clean:
$(RM) -rf $(BIN) obj/* *.log *.html
cd ./test && make clean
$(BIN): $(OBJ)
@echo LINK $(BIN)
@$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
.PHONY:test
test:
@cd ./test && make clean && make
$(ODIR):
@mkdir -p $@
$(ODIR)/%.o : %.c %.h
@echo CC $<
@$(CC) $(CFLAGS) -c -o $@ $<
.PHONY: all clean
.SUFFIXES:
.SUFFIXES: .c .o
vpath %.c src
vpath %.h src