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 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220
|
#DEBUG=1
ZLIB=1
prefix=/opt/diet
BINDIR=${prefix}/bin
MANDIR=${prefix}/man
man1dir=$(MANDIR)/man1
TARGETS=gatling httpbench bindbench dl ioerr bench tlsgatling_nofail \
pthreadbench cgi ptlsgatling_nofail
TARGETS2=mktestdata mmapbench manymapbench forkbench forksbench
ALLTARGETS=$(TARGETS) acc hcat referrer hitprofile matchiprange getlinks \
rellink $(TARGETS2)
all: $(ALLTARGETS)
CROSS=
#CROSS=i686-mingw32-
CC=$(CROSS)gcc
CFLAGS+=-pipe -Wall
#LDFLAGS=
#CFLAGS+=-DSTATE_DEBUG -DMOREDEBUG -DDEBUG_EVENTS -DSMDEBUG
path = $(subst :, ,$(PATH))
diet_path = $(foreach dir,$(path),$(wildcard $(dir)/diet))
ifeq ($(strip $(diet_path)),)
ifneq ($(wildcard /opt/diet/bin/diet),)
DIET=/opt/diet/bin/diet
else
DIET=
endif
else
DIET:=$(strip $(diet_path))
endif
# to build without diet libc support, use $ make DIET=
# see http://www.fefe.de/dietlibc/ for details about the diet libc
ifneq ($(DIET),)
DIET+=-Os
endif
LDLIBS=-lowfat
ifeq ($(ZLIB),1)
CFLAGS+=-DUSE_ZLIB
LDLIBS+=-lz
endif
# Debian: don't depend on other source files lying around
#libowfat_path = $(strip $(foreach dir,../libowfat*,$(wildcard $(dir)/textcode.h)))
#ifneq ($(libowfat_path),)
#CFLAGS+=$(foreach fnord,$(libowfat_path),-I$(dir $(fnord)))
#LDFLAGS+=$(foreach fnord,$(libowfat_path),-L$(dir $(fnord)))
#endif
ifneq ($(REDIRECT),)
CFLAGS+="-DREDIRECT=\"$(REDIRECT)\""
endif
acc: acc.c
$(CC) -o $@ $< $(CFLAGS) $(LDFLAGS) -lowfat
CC:=$(DIET) $(CC)
pthreadbench: pthreadbench.o
$(CC) $< -o $@ -I. $(CFLAGS) $(LDFLAGS) $(LDLIBS) -lpthread
forksbench: forkbench.o
$(CC) -static -o $@ forkbench.o $(LDFLAGS) $(LDLIBS)
gatling.o tlsgatling ptlsgatling: havesetresuid.h
OBJS=mime.o ftp.o http.o smb.o common.o connstat.o
HTTPS_OBJS=mime.o ftp.c https.o smb.c common.c connstat.o
PHTTPS_OBJS=mime.o ftp.o phttps.o smb.o common.o connstat.o
$(OBJS) https.o gatling.o: gatling.h version.h gatling_features.h
tlsgatling: gatling.c ssl.o $(HTTPS_OBJS) libsocket libiconv libcrypt
$(CC) -o $@ gatling.c ssl.o $(HTTPS_OBJS) $(CFLAGS) -DSUPPORT_HTTPS $(LDFLAGS) -lssl -lcrypto $(LDLIBS)
tlsgatling_nofail: gatling.c ssl.o $(HTTPS_OBJS) libsocket libiconv libcrypt
-$(CC) -o tlsgatling gatling.c ssl.o $(HTTPS_OBJS) $(CFLAGS) -DSUPPORT_HTTPS $(LDFLAGS) -lssl -lcrypto $(LDLIBS)
ptlsgatling: gatling.c pssl.o $(PHTTPS_OBJS) libsocket libiconv libcrypt
$(CC) -o $@ gatling.c pssl.c $(PHTTPS_OBJS) $(CFLAGS) -DSUPPORT_HTTPS -DUSE_MBEDTLS $(LDFLAGS) -lmbedcrypto -lmbedx509 -lmbedtls $(LDLIBS)
ptlsgatling_nofail: gatling.c pssl.o $(PHTTPS_OBJS) libsocket libiconv libcrypt
-$(CC) -o ptlsgatling gatling.c pssl.c $(PHTTPS_OBJS) $(CFLAGS) -DSUPPORT_HTTPS -DUSE_MBEDTLS $(LDFLAGS) -lmbedcrypto -lmbedx509 -lmbedtls $(LDLIBS)
gatling: gatling.o $(OBJS) md5lib
$(CC) $(LDFLAGS) $@.o $(OBJS) -o $@ $(LDLIBS) `cat md5lib`
httpbench: httpbench.o
bindbench: bindbench.o
dl: dl.o
ioerr: ioerr.o
bench: bench.o
getlinks: getlinks.o
rellink: rellink.o
matchiprange: matchiprange.o
cgi: cgi.o
version.h: CHANGES
(head -n 1 CHANGES | sed 's/\([^:]*\):/#define VERSION "\1"/') > version.h
%.o: %.c
$(CC) -c $< -o $@ -I. $(CFLAGS)
https.o: http.c
$(CC) -c $< -o $@ -I. $(CFLAGS) -DSUPPORT_HTTPS
phttps.o: http.c
$(CC) -c $< -o $@ -I. $(CFLAGS) -DSUPPORT_HTTPS -DUSE_MBEDTLS
%: %.o
$(CC) $(LDFLAGS) $@.o -o $@ $(LDLIBS)
hitprofile.o: referrer.c
$(CC) -c $< -o $@ -I. $(CFLAGS) -DALL
libsocket: trysocket.c
if $(CC) $(CFLAGS) -o trysocket trysocket.c >/dev/null 2>&1; then echo ""; else \
if $(CC) $(CFLAGS) -o trysocket trysocket.c -lsocket >/dev/null 2>&1; then echo "-lsocket"; else \
if $(CC) $(CFLAGS) -o trysocket trysocket.c -lsocket -lnsl >/dev/null 2>&1; then echo "-lsocket -lnsl"; else \
if $(CC) $(CFLAGS) -o trysocket trysocket.c -lwsock32 >/dev/null 2>&1; then echo "-lwsock32"; \
fi; fi; fi; fi > libsocket
rm -f trysocket
libiconv: tryiconv.c
if $(CC) $(CFLAGS) -o tryiconv tryiconv.c >/dev/null 2>&1; then echo ""; else \
if $(CC) $(CFLAGS) -o tryiconv tryiconv.c -liconv >/dev/null 2>&1; then echo "-liconv"; else \
if $(CC) $(CFLAGS) -o tryiconv tryiconv.c -L/usr/local/lib -liconv >/dev/null 2>&1; then \
echo "-L/usr/local/lib -liconv"; \
fi; fi; fi > libiconv
rm -f tryiconv
libcrypt: trycrypt.c
if $(CC) $(CFLAGS) -o trycrypt trycrypt.c >/dev/null 2>&1; then echo ""; else \
if $(CC) $(CFLAGS) -o trycrypt trycrypt.c -lcrypt >/dev/null 2>&1; then echo "-lcrypt"; \
fi; fi > libcrypt
rm -f trycrypt
md5lib: trymd5.c
if $(CC) $(CFLAGS) -o trymd5 trymd5.c >/dev/null 2>&1; then echo ""; else \
if $(CC) $(CFLAGS) -o trymd5 trymd5.c -lmd >/dev/null 2>&1; then echo "-lmd"; else \
if $(CC) $(CFLAGS) -o trymd5 trymd5.c -lcrypto >/dev/null 2>&1; then echo "-lcrypto"; \
fi; fi; fi > md5lib
rm -f trymd5
havesetresuid.h: trysetresuid.c
-rm -f $@
if $(CC) $(CFLAGS) -o tryresuid $^ >/dev/null 2>&1; then echo "#define LIBC_HAS_SETRESUID"; fi > $@
-rm -f tryresuid
dummy.c:
touch $@
libsocketkludge.a: libsocket libiconv dummy.o
ar q $@ dummy.o
-ranlib $@
LDLIBS+=`cat libsocket libiconv libcrypt`
$(TARGETS): libsocketkludge.a libsocket libiconv libcrypt md5lib
install: gatling dl getlinks
install -d $(DESTDIR)$(BINDIR) $(man1dir)
install $^ $(DESTDIR)$(BINDIR)
if test -f tlsgatling; then install tlsgatling $(DESTDIR)$(BINDIR); fi
install -m 644 gatling.1 bench.1 $(DESTDIR)$(man1dir)
uninstall:
rm -f $(DESTDIR)$(BINDIR)/gatling $(DESTDIR)$(BINDIR)/tlsgatling $(DESTDIR)$(man1dir)/gatling.1 $(DESTDIR)$(man1dir)/bench.1
clean:
rm -f $(ALLTARGETS) *.o version.h core *.core libsocket libsocketkludge.a dummy.c libiconv libcrypt havesetresuid.h md5lib havealloca.h tlsgatling ptlsgatling
VERSION=gatling-$(shell head -n 1 CHANGES|sed 's/://')
CURNAME=$(notdir $(shell pwd))
rename:
if test $(CURNAME) != $(VERSION); then cd .. && mv $(CURNAME) $(VERSION); fi
tar: clean rename
rm -f dep libdep
cd ..; tar cvvf $(VERSION).tar.bz2 --use=bzip2 --exclude CVS --exclude default $(VERSION)
cert: server.pem
rand.dat:
-dd if=/dev/random of=rand.dat bs=1024 count=1
cakey.key: rand.dat
openssl genrsa -out cakey.key -rand rand.dat 2048
cakey.csr: cakey.key
openssl req -new -key cakey.key -out cakey.csr
cakey.pem: cakey.key cakey.csr
openssl x509 -req -days 1780 -set_serial 1 -in cakey.csr \
-signkey cakey.key -out $@
server.pem: cakey.key cakey.pem
cat cakey.key cakey.pem > server.pem
windoze:
$(MAKE) DIET= CROSS=i686-mingw32-
havealloca.h: tryalloca.c
-rm -f $@
echo "#include <stdlib.h>" > $@
if $(DIET) $(CC) $(CFLAGS) -c tryalloca.c -DA >/dev/null 2>&1; then echo "#include <alloca.h>"; fi >> $@
if $(DIET) $(CC) $(CFLAGS) -c tryalloca.c -DB >/dev/null 2>&1; then echo "#include <malloc.h>"; fi >> $@
-rm -f tryalloca.o
bench.o bindbench.o common.o dl.o ftp.o gatling.o getlinks.o http.o \
httpbench.o ioerr.o rellink.o smb.o torrent.o: havealloca.h
|