Skip to content

Commit 8f2147e

Browse files
committed
add autobuild; remove build-date from binary
1 parent 7da292b commit 8f2147e

9 files changed

+174
-27
lines changed

.gitignore

+10-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,14 @@
22
.lock-wscript
33
.DS_Store
44
*~
5-
build
5+
*build
66
weighttp
7+
Makefile.in
8+
aclocal.m4
9+
compile
10+
configure
11+
depcomp
12+
install-sh
13+
missing
14+
autom4te.cache/
15+
config.h.in

Makefile.am

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
EXTRA_DIST=autogen.sh
2+
SUBDIRS=src

README

+28-20
Original file line numberDiff line numberDiff line change
@@ -3,44 +3,52 @@ weighttp - a lightweight and simple webserver benchmarking tool
33

44
Please see http://weighttp.lighttpd.net/ for current info.
55

6+
DEPENDENCIES
7+
============
68

7-
BUILD
9+
Requires libev; can be found in your distro's repository or at
10+
http://software.schmorp.de/pkg/libev.html
11+
12+
BUILD (autobuild)
813
=====
914

10-
Make sure you have libev* and python (for waf) installed, then:
15+
When running from git (should not be necessary when building from tar),
16+
requires automake, autoconf and friends:
1117

12-
$ ./waf configure
13-
$ ./waf build
18+
$ ./autogen.sh
1419

15-
See ./waf --help for available configure options and other commands available.
20+
Then:
1621

22+
$ ./configure
23+
$ make
1724

18-
INSTALL
25+
INSTALL (autobuild)
1926
=======
2027

21-
$ ./waf install
28+
$ make install
2229
or
23-
$ sudo ./waf install
24-
30+
$ sudo make install
2531

26-
USAGE
32+
BUILD (waf)
2733
=====
2834

29-
$ weighttp -h
35+
Make sure you have python installed, then:
3036

37+
$ ./waf configure
38+
$ ./waf build
3139

32-
UNINSTALL
33-
=========
40+
See ./waf --help for available configure options and other commands available.
3441

35-
$ ./waf uninstall
36-
or
37-
$ sudo ./waf uninstall
3842

43+
INSTALL (waf)
44+
=======
3945

40-
You can also chain commands:
46+
$ ./waf install
47+
or
48+
$ sudo ./waf install
4149

42-
$ ./waf configure clean build install
4350

44-
----
51+
USAGE
52+
=====
4553

46-
* libev can be found in your distro's repository or at http://software.schmorp.de/pkg/libev.html
54+
$ weighttp -h

autogen.sh

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/sh
2+
# Run this to generate all the initial makefiles, etc.
3+
4+
set -e
5+
6+
if [ ! -f configure.ac -o ! -f COPYING ]; then
7+
echo "Doesn't look like you're in the source directory" >&2
8+
exit 1
9+
fi
10+
11+
autoreconf --force --install
12+
echo "Now type './configure ...' and 'make' to compile."

configure.ac

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# -*- Autoconf -*-
2+
# Process this file with autoconf to produce a configure script.
3+
4+
AC_PREREQ(2.61)
5+
AC_INIT([weighttp],[0.3])
6+
AC_CONFIG_SRCDIR([src/weighttp.c])
7+
AC_CONFIG_HEADER([src/config.h])
8+
9+
AM_INIT_AUTOMAKE([-Wall -Werror foreign dist-xz no-dist-gzip])
10+
11+
# Checks for programs.
12+
AC_PROG_CC
13+
14+
dnl @synopsis TRY_CFLAGS [compiler flags]
15+
dnl @summary check whether C compiler supports given flags and adds them to CFLAGS
16+
AC_DEFUN([TRY_CFLAGS],
17+
[dnl
18+
AC_MSG_CHECKING([if $CC supports $1])
19+
AC_LANG_PUSH([C])
20+
ac_try_cflags_saved_cflags="${CFLAGS}"
21+
CFLAGS="${CFLAGS} $1"
22+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
23+
[AC_MSG_RESULT([yes])],
24+
[
25+
AC_MSG_ERROR([no])
26+
# options not supported, remove them:
27+
CFLAGS="${ac_try_cflags_saved_cflags}"
28+
]
29+
)
30+
AC_LANG_POP([C])
31+
])
32+
33+
34+
## solaris needs -lsocket
35+
AC_SEARCH_LIBS([socket],[socket])
36+
37+
38+
## pthread
39+
AC_MSG_CHECKING([for pthread support])
40+
AC_SEARCH_LIBS([pthread_create], [pthread], [
41+
CFLAGS="-pthread ${CFLAGS}"
42+
LDFLAGS="-pthread ${LDFLAGS}"
43+
])
44+
45+
46+
## libev
47+
AC_MSG_CHECKING([for libev support])
48+
AC_ARG_WITH([libev],
49+
[AS_HELP_STRING([--with-libev@<:@=PATH@:>@],[Search for libev in PATH/include and PATH/lib])],
50+
[WITH_LIBEV=$withval],[WITH_LIBEV=yes])
51+
52+
LIBEV_CFLAGS=""
53+
LIBEV_LIBS=""
54+
55+
PKG_CHECK_MODULES([LIBEV], [libev], [], [
56+
# no pkg-config for libev, searching manually:
57+
58+
if test "$WITH_LIBEV" != "yes"; then
59+
LIBEV_CFLAGS="-I$WITH_LIBEV/include"
60+
LIBEV_LIBS="-L$WITH_LIBEV/lib -lev"
61+
else
62+
AC_CHECK_HEADERS([ev.h],[
63+
AC_CHECK_LIB([ev], [ev_time], [
64+
LIBEV_LIBS="-lev"
65+
],[
66+
AC_MSG_ERROR([libev not found])
67+
]
68+
)],[
69+
AC_MSG_ERROR([libev not found])
70+
]
71+
)
72+
fi
73+
])
74+
75+
AC_SUBST([LIBEV_CFLAGS])
76+
AC_SUBST([LIBEV_LIBS])
77+
78+
# libev has (compiler warning) problems with strict aliasing... - just disable it
79+
TRY_CFLAGS([-fno-strict-aliasing])
80+
TRY_CFLAGS([-fPIC])
81+
82+
# check for extra compiler options (warning options)
83+
if test "${GCC}" = "yes"; then
84+
TRY_CFLAGS([-Wall -W -Wshadow -pedantic])
85+
TRY_CFLAGS([-std=gnu99])
86+
fi
87+
88+
AC_ARG_ENABLE(extra-warnings,
89+
AC_HELP_STRING([--enable-extra-warnings],[enable extra warnings (gcc specific)]),
90+
[case "${enableval}" in
91+
yes) extrawarnings=true ;;
92+
no) extrawarnings=false ;;
93+
*) AC_MSG_ERROR(bad value ${enableval} for --enable-extra-warnings) ;;
94+
esac],[extrawarnings=false])
95+
96+
if test x$extrawarnings = xtrue; then
97+
TRY_CFLAGS([-g -O2 -g2 -Wall -Wmissing-declarations -Wdeclaration-after-statement -Wcast-align -Winline -Wsign-compare -Wnested-externs -Wpointer-arith -Wl,--as-needed -D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security])
98+
fi
99+
100+
AC_CONFIG_FILES([Makefile src/Makefile])
101+
AC_OUTPUT

src/Makefile.am

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
bin_PROGRAMS=weighttp
2+
weighttp_SOURCES=\
3+
client.c \
4+
weighttp.c \
5+
worker.c
6+
weighttp_CPPFLAGS=$(LIBEV_CFLAGS)
7+
weighttp_LDADD=$(LIBEV_LIBS)
8+
9+
EXTRA_DIST=\
10+
client.h \
11+
weighttp.h \
12+
worker.h
13+

src/weighttp.c

+3-5
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ static char *forge_request(char *url, char keep_alive, char **host, uint16_t *po
164164
}
165165

166166
if (!have_user_agent)
167-
len += strlen("User-Agent: weighttp/" VERSION "\r\n");
167+
len += strlen("User-Agent: weighttp/" PACKAGE_VERSION "\r\n");
168168

169169
req = W_MALLOC(char, len);
170170

@@ -182,7 +182,7 @@ static char *forge_request(char *url, char keep_alive, char **host, uint16_t *po
182182
strcat(req, "\r\n");
183183

184184
if (!have_user_agent)
185-
sprintf(req + strlen(req), "User-Agent: weighttp/" VERSION "\r\n");
185+
sprintf(req + strlen(req), "User-Agent: weighttp/" PACKAGE_VERSION "\r\n");
186186

187187
for (i = 0; i < headers_num; i++) {
188188
if (strncmp(headers[i], "Host:", sizeof("Host:")-1) == 0)
@@ -235,7 +235,7 @@ int main(int argc, char *argv[]) {
235235
char **headers;
236236
uint8_t headers_num;
237237

238-
printf("weighttp - a lightweight and simple webserver benchmarking tool\n\n");
238+
printf("weighttp " PACKAGE_VERSION " - a lightweight and simple webserver benchmarking tool\n\n");
239239

240240
headers = NULL;
241241
headers_num = 0;
@@ -253,8 +253,6 @@ int main(int argc, char *argv[]) {
253253
show_help();
254254
return 0;
255255
case 'v':
256-
printf("version: " VERSION "\n");
257-
printf("build-date: " __DATE__ " " __TIME__ "\n\n");
258256
return 0;
259257
case '6':
260258
use_ipv6 = 1;

src/weighttp.h

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
#ifndef WEIGHTTP_H
1212
#define WEIGHTTP_H 1
1313

14+
#ifdef HAVE_CONFIG_H
15+
# include "config.h"
16+
#endif
17+
1418
#include <stdio.h>
1519
#include <stdlib.h>
1620
#include <time.h>

wscript

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def build(bld):
6161
bld.new_task_gen(
6262
features = 'cc cprogram',
6363
source = ['src/client.c', 'src/weighttp.c', 'src/worker.c'],
64-
defines = ['HAVE_CONFIG_H=1', 'VERSION="' + VERSION + '"'],
64+
defines = ['PACKAGE_VERSION="' + VERSION + '"'],
6565
includes = '.',
6666
uselib = 'ev pthread',
6767
target = 'weighttp'

0 commit comments

Comments
 (0)