-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.in
78 lines (58 loc) · 1.76 KB
/
Makefile.in
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
67
68
69
70
71
72
73
74
75
76
77
78
CFLAGS += -std=c99 -Wall -O2 -D_REENTRANT -fPIC
LIBS := -lm -lssl -lcrypto -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)
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 := main.c wrk.c net.c ssl.c aprintf.c stats.c \
units.c ae.c zmalloc.c http_parser.c
VER ?= $(shell git describe --tags --always --dirty)
ODIR := obj
OBJ := $(patsubst %.c,$(ODIR)/%.o,$(SRC)) $(ODIR)/version.o
DEPS :=
CFLAGS += -I$(ODIR)/include
LDFLAGS += -L$(ODIR)/lib
ifeq ($(SYS_OPENSSL), 1)
LDFLAGS += $(shell pkg-config --libs openssl)
else
DEPS += $(ODIR)/lib/libssl.a
endif
$(OBJ): config.h Makefile $(DEPS) | $(ODIR)
$(ODIR):
@mkdir -p $@
$(TARGETDIR):
@mkdir -p $@
$(ODIR)/version.o:
@echo 'const char *VERSION="$(VER)";' | $(CC) -xc -c -o $@ -
$(ODIR)/%.o : %.c
@echo CC $<
$(CC) $(CFLAGS) -c -o $@ $<
# Dependencies
OPENSSL := $(notdir $(patsubst %.tar.gz,%,$(wildcard deps/openssl*.tar.gz)))
OPENSSL_OPTS = no-shared no-psk no-srp no-dtls no-idea --prefix=$(abspath $(ODIR))
$(ODIR)/$(OPENSSL): deps/$(OPENSSL).tar.gz | $(ODIR)
@tar -C $(ODIR) -xf $<
$(ODIR)/lib/libssl.a: $(ODIR)/$(OPENSSL)
@echo Building OpenSSL...
@$(SHELL) -c "cd $< && ./config $(OPENSSL_OPTS)"
@$(MAKE) -C $< depend
@$(MAKE) -C $<
@$(MAKE) -C $< install_sw
@touch $@
# ------------
.PHONY: all clean
.PHONY: $(ODIR)/version.o
.SUFFIXES:
.SUFFIXES: .c .o
vpath %.c src
vpath %.h src