1
0
mirror of https://github.com/wg/wrk synced 2025-01-08 23:32:54 +08:00
wrk/Makefile
2013-08-25 16:31:42 +09:00

64 lines
1.3 KiB
Makefile

CFLAGS := -std=c99 -Wall -O2 -D_REENTRANT
LIBS := -lpthread -lm -lcrypto -lssl
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
else ifeq ($(TARGET), linux)
LIBS += -ldl
LDFLAGS += -Wl,-E
else ifeq ($(TARGET), freebsd)
CFLAGS += -D_DECLARE_C99_LDBL_MATH
LDFLAGS += -Wl,-E
endif
SRC := wrk.c net.c ssl.c aprintf.c stats.c script.c units.c \
ae.c zmalloc.c http_parser.c tinymt64.c
BIN := wrk
ODIR := obj
OBJ := $(patsubst %.c,$(ODIR)/%.o,$(SRC))
LDIR = deps/luajit/src
LIBS := -lluajit $(LIBS)
CFLAGS += -I $(LDIR)
LDFLAGS += -L $(LDIR)
all: $(BIN)
clean:
$(RM) $(BIN) obj/*
$(BIN): $(OBJ) $(ODIR)/bytecode.o
@echo LINK $(BIN)
@$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
$(OBJ): config.h Makefile | $(ODIR)
$(ODIR): $(LDIR)/libluajit.a
@mkdir -p $@
$(ODIR)/bytecode.o: scripts/wrk.lua
@echo LUAJIT $<
@$(SHELL) -c 'cd $(LDIR) && ./luajit -b $(PWD)/$< $(PWD)/$@'
$(ODIR)/%.o : %.c
@echo CC $<
@$(CC) $(CFLAGS) -c -o $@ $<
$(LDIR)/libluajit.a:
@echo Building LuaJit...
@$(MAKE) -C $(LDIR) BUILDMODE=static
.PHONY: all clean
.SUFFIXES:
.SUFFIXES: .c .o .lua
vpath %.c src
vpath %.h src
vpath %.lua scripts