2013-03-03 17:24:41 +08:00
|
|
|
CFLAGS := -std=c99 -Wall -O2 -D_REENTRANT
|
2013-06-22 14:48:48 +08:00
|
|
|
LIBS := -lpthread -lm -lcrypto -lssl
|
2013-01-12 15:21:02 +08:00
|
|
|
|
2014-05-15 19:11:07 +08:00
|
|
|
TARGET := $(shell uname -s | tr '[A-Z]' '[a-z]' 2>/dev/null || echo unknown)
|
2013-01-12 15:21:02 +08:00
|
|
|
|
|
|
|
ifeq ($(TARGET), sunos)
|
2013-04-07 13:37:24 +08:00
|
|
|
CFLAGS += -D_PTHREADS -D_POSIX_C_SOURCE=200112L
|
2013-03-03 17:24:41 +08:00
|
|
|
LIBS += -lsocket
|
2013-08-18 12:38:06 +08:00
|
|
|
else ifeq ($(TARGET), darwin)
|
|
|
|
LDFLAGS += -pagezero_size 10000 -image_base 100000000
|
2013-08-18 19:37:21 +08:00
|
|
|
else ifeq ($(TARGET), linux)
|
2015-02-07 16:03:17 +08:00
|
|
|
CFLAGS += -D_POSIX_C_SOURCE=200112L -D_BSD_SOURCE
|
2013-08-18 19:37:21 +08:00
|
|
|
LIBS += -ldl
|
|
|
|
LDFLAGS += -Wl,-E
|
|
|
|
else ifeq ($(TARGET), freebsd)
|
|
|
|
CFLAGS += -D_DECLARE_C99_LDBL_MATH
|
2013-08-18 12:38:06 +08:00
|
|
|
LDFLAGS += -Wl,-E
|
2013-01-12 15:21:02 +08:00
|
|
|
endif
|
2012-03-18 14:16:09 +08:00
|
|
|
|
2013-08-18 12:38:06 +08:00
|
|
|
SRC := wrk.c net.c ssl.c aprintf.c stats.c script.c units.c \
|
|
|
|
ae.c zmalloc.c http_parser.c tinymt64.c
|
2012-03-18 14:16:09 +08:00
|
|
|
BIN := wrk
|
|
|
|
|
|
|
|
ODIR := obj
|
2013-11-16 11:06:29 +08:00
|
|
|
OBJ := $(patsubst %.c,$(ODIR)/%.o,$(SRC)) $(ODIR)/bytecode.o
|
2012-03-18 14:16:09 +08:00
|
|
|
|
2013-08-18 12:38:06 +08:00
|
|
|
LDIR = deps/luajit/src
|
2013-08-18 19:37:21 +08:00
|
|
|
LIBS := -lluajit $(LIBS)
|
2014-05-15 19:11:07 +08:00
|
|
|
CFLAGS += -I$(LDIR)
|
|
|
|
LDFLAGS += -L$(LDIR)
|
2013-08-18 12:38:06 +08:00
|
|
|
|
2012-03-18 14:16:09 +08:00
|
|
|
all: $(BIN)
|
|
|
|
|
|
|
|
clean:
|
|
|
|
$(RM) $(BIN) obj/*
|
2013-09-22 11:54:25 +08:00
|
|
|
@$(MAKE) -C deps/luajit clean
|
2012-03-18 14:16:09 +08:00
|
|
|
|
2013-11-16 11:06:29 +08:00
|
|
|
$(BIN): $(OBJ)
|
2013-08-18 12:38:06 +08:00
|
|
|
@echo LINK $(BIN)
|
|
|
|
@$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
|
2012-03-18 14:16:09 +08:00
|
|
|
|
2013-11-16 11:06:29 +08:00
|
|
|
$(OBJ): config.h Makefile $(LDIR)/libluajit.a | $(ODIR)
|
2012-03-18 14:16:09 +08:00
|
|
|
|
2013-11-16 11:06:29 +08:00
|
|
|
$(ODIR):
|
2013-08-18 12:38:06 +08:00
|
|
|
@mkdir -p $@
|
|
|
|
|
2013-12-07 13:09:44 +08:00
|
|
|
$(ODIR)/bytecode.o: src/wrk.lua
|
2013-08-18 12:38:06 +08:00
|
|
|
@echo LUAJIT $<
|
2013-11-09 11:30:33 +08:00
|
|
|
@$(SHELL) -c 'cd $(LDIR) && ./luajit -b $(CURDIR)/$< $(CURDIR)/$@'
|
2012-03-18 14:16:09 +08:00
|
|
|
|
|
|
|
$(ODIR)/%.o : %.c
|
2013-08-18 12:38:06 +08:00
|
|
|
@echo CC $<
|
|
|
|
@$(CC) $(CFLAGS) -c -o $@ $<
|
|
|
|
|
|
|
|
$(LDIR)/libluajit.a:
|
2013-11-16 11:06:29 +08:00
|
|
|
@echo Building LuaJIT...
|
2013-08-18 12:38:06 +08:00
|
|
|
@$(MAKE) -C $(LDIR) BUILDMODE=static
|
2012-03-18 14:16:09 +08:00
|
|
|
|
|
|
|
.PHONY: all clean
|
|
|
|
.SUFFIXES:
|
2013-08-18 12:38:06 +08:00
|
|
|
.SUFFIXES: .c .o .lua
|
2012-03-18 14:16:09 +08:00
|
|
|
|
2013-08-18 12:38:06 +08:00
|
|
|
vpath %.c src
|
|
|
|
vpath %.h src
|
|
|
|
vpath %.lua scripts
|