summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Bühler <stbuehler@web.de>2015-06-21 21:49:18 +0200
committerStefan Bühler <stbuehler@web.de>2015-06-21 21:49:18 +0200
commit8f2147e429b4072eae0bc5390fb326b56edece8d (patch)
tree6f1302395702892fd7f241b6cd0b96b6c67d9a1a
parent7da292b24288416e72323e4793eeb136338f0df0 (diff)
downloadweighttp-8f2147e429b4072eae0bc5390fb326b56edece8d.tar.gz
weighttp-8f2147e429b4072eae0bc5390fb326b56edece8d.zip
add autobuild; remove build-date from binary
-rw-r--r--.gitignore11
-rw-r--r--Makefile.am2
-rw-r--r--README48
-rwxr-xr-xautogen.sh12
-rw-r--r--configure.ac101
-rw-r--r--src/Makefile.am13
-rw-r--r--src/weighttp.c8
-rw-r--r--src/weighttp.h4
-rw-r--r--wscript2
9 files changed, 174 insertions, 27 deletions
diff --git a/.gitignore b/.gitignore
index 343001e..ea6161f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,5 +2,14 @@
.lock-wscript
.DS_Store
*~
-build
+*build
weighttp
+Makefile.in
+aclocal.m4
+compile
+configure
+depcomp
+install-sh
+missing
+autom4te.cache/
+config.h.in
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..af6f743
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,2 @@
+EXTRA_DIST=autogen.sh
+SUBDIRS=src
diff --git a/README b/README
index 6584696..6764e8a 100644
--- a/README
+++ b/README
@@ -3,44 +3,52 @@ weighttp - a lightweight and simple webserver benchmarking tool
Please see http://weighttp.lighttpd.net/ for current info.
+DEPENDENCIES
+============
-BUILD
+Requires libev; can be found in your distro's repository or at
+http://software.schmorp.de/pkg/libev.html
+
+BUILD (autobuild)
=====
-Make sure you have libev* and python (for waf) installed, then:
+When running from git (should not be necessary when building from tar),
+requires automake, autoconf and friends:
-$ ./waf configure
-$ ./waf build
+$ ./autogen.sh
-See ./waf --help for available configure options and other commands available.
+Then:
+$ ./configure
+$ make
-INSTALL
+INSTALL (autobuild)
=======
-$ ./waf install
+$ make install
or
-$ sudo ./waf install
-
+$ sudo make install
-USAGE
+BUILD (waf)
=====
-$ weighttp -h
+Make sure you have python installed, then:
+$ ./waf configure
+$ ./waf build
-UNINSTALL
-=========
+See ./waf --help for available configure options and other commands available.
-$ ./waf uninstall
-or
-$ sudo ./waf uninstall
+INSTALL (waf)
+=======
-You can also chain commands:
+$ ./waf install
+or
+$ sudo ./waf install
-$ ./waf configure clean build install
-----
+USAGE
+=====
-* libev can be found in your distro's repository or at http://software.schmorp.de/pkg/libev.html
+$ weighttp -h
diff --git a/autogen.sh b/autogen.sh
new file mode 100755
index 0000000..cc2b408
--- /dev/null
+++ b/autogen.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+# Run this to generate all the initial makefiles, etc.
+
+set -e
+
+if [ ! -f configure.ac -o ! -f COPYING ]; then
+ echo "Doesn't look like you're in the source directory" >&2
+ exit 1
+fi
+
+autoreconf --force --install
+echo "Now type './configure ...' and 'make' to compile."
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..406389f
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,101 @@
+# -*- Autoconf -*-
+# Process this file with autoconf to produce a configure script.
+
+AC_PREREQ(2.61)
+AC_INIT([weighttp],[0.3])
+AC_CONFIG_SRCDIR([src/weighttp.c])
+AC_CONFIG_HEADER([src/config.h])
+
+AM_INIT_AUTOMAKE([-Wall -Werror foreign dist-xz no-dist-gzip])
+
+# Checks for programs.
+AC_PROG_CC
+
+dnl @synopsis TRY_CFLAGS [compiler flags]
+dnl @summary check whether C compiler supports given flags and adds them to CFLAGS
+AC_DEFUN([TRY_CFLAGS],
+[dnl
+ AC_MSG_CHECKING([if $CC supports $1])
+ AC_LANG_PUSH([C])
+ ac_try_cflags_saved_cflags="${CFLAGS}"
+ CFLAGS="${CFLAGS} $1"
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
+ [AC_MSG_RESULT([yes])],
+ [
+ AC_MSG_ERROR([no])
+ # options not supported, remove them:
+ CFLAGS="${ac_try_cflags_saved_cflags}"
+ ]
+ )
+ AC_LANG_POP([C])
+])
+
+
+## solaris needs -lsocket
+AC_SEARCH_LIBS([socket],[socket])
+
+
+## pthread
+AC_MSG_CHECKING([for pthread support])
+AC_SEARCH_LIBS([pthread_create], [pthread], [
+ CFLAGS="-pthread ${CFLAGS}"
+ LDFLAGS="-pthread ${LDFLAGS}"
+])
+
+
+## libev
+AC_MSG_CHECKING([for libev support])
+AC_ARG_WITH([libev],
+ [AS_HELP_STRING([--with-libev@<:@=PATH@:>@],[Search for libev in PATH/include and PATH/lib])],
+ [WITH_LIBEV=$withval],[WITH_LIBEV=yes])
+
+LIBEV_CFLAGS=""
+LIBEV_LIBS=""
+
+PKG_CHECK_MODULES([LIBEV], [libev], [], [
+ # no pkg-config for libev, searching manually:
+
+ if test "$WITH_LIBEV" != "yes"; then
+ LIBEV_CFLAGS="-I$WITH_LIBEV/include"
+ LIBEV_LIBS="-L$WITH_LIBEV/lib -lev"
+ else
+ AC_CHECK_HEADERS([ev.h],[
+ AC_CHECK_LIB([ev], [ev_time], [
+ LIBEV_LIBS="-lev"
+ ],[
+ AC_MSG_ERROR([libev not found])
+ ]
+ )],[
+ AC_MSG_ERROR([libev not found])
+ ]
+ )
+ fi
+])
+
+AC_SUBST([LIBEV_CFLAGS])
+AC_SUBST([LIBEV_LIBS])
+
+# libev has (compiler warning) problems with strict aliasing... - just disable it
+TRY_CFLAGS([-fno-strict-aliasing])
+TRY_CFLAGS([-fPIC])
+
+# check for extra compiler options (warning options)
+if test "${GCC}" = "yes"; then
+ TRY_CFLAGS([-Wall -W -Wshadow -pedantic])
+ TRY_CFLAGS([-std=gnu99])
+fi
+
+AC_ARG_ENABLE(extra-warnings,
+ AC_HELP_STRING([--enable-extra-warnings],[enable extra warnings (gcc specific)]),
+ [case "${enableval}" in
+ yes) extrawarnings=true ;;
+ no) extrawarnings=false ;;
+ *) AC_MSG_ERROR(bad value ${enableval} for --enable-extra-warnings) ;;
+ esac],[extrawarnings=false])
+
+if test x$extrawarnings = xtrue; then
+ 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])
+fi
+
+AC_CONFIG_FILES([Makefile src/Makefile])
+AC_OUTPUT
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644
index 0000000..f4c0b2d
--- /dev/null
+++ b/src/Makefile.am
@@ -0,0 +1,13 @@
+bin_PROGRAMS=weighttp
+weighttp_SOURCES=\
+ client.c \
+ weighttp.c \
+ worker.c
+weighttp_CPPFLAGS=$(LIBEV_CFLAGS)
+weighttp_LDADD=$(LIBEV_LIBS)
+
+EXTRA_DIST=\
+ client.h \
+ weighttp.h \
+ worker.h
+
diff --git a/src/weighttp.c b/src/weighttp.c
index 14951a7..9d7bf0a 100644
--- a/src/weighttp.c
+++ b/src/weighttp.c
@@ -164,7 +164,7 @@ static char *forge_request(char *url, char keep_alive, char **host, uint16_t *po
}
if (!have_user_agent)
- len += strlen("User-Agent: weighttp/" VERSION "\r\n");
+ len += strlen("User-Agent: weighttp/" PACKAGE_VERSION "\r\n");
req = W_MALLOC(char, len);
@@ -182,7 +182,7 @@ static char *forge_request(char *url, char keep_alive, char **host, uint16_t *po
strcat(req, "\r\n");
if (!have_user_agent)
- sprintf(req + strlen(req), "User-Agent: weighttp/" VERSION "\r\n");
+ sprintf(req + strlen(req), "User-Agent: weighttp/" PACKAGE_VERSION "\r\n");
for (i = 0; i < headers_num; i++) {
if (strncmp(headers[i], "Host:", sizeof("Host:")-1) == 0)
@@ -235,7 +235,7 @@ int main(int argc, char *argv[]) {
char **headers;
uint8_t headers_num;
- printf("weighttp - a lightweight and simple webserver benchmarking tool\n\n");
+ printf("weighttp " PACKAGE_VERSION " - a lightweight and simple webserver benchmarking tool\n\n");
headers = NULL;
headers_num = 0;
@@ -253,8 +253,6 @@ int main(int argc, char *argv[]) {
show_help();
return 0;
case 'v':
- printf("version: " VERSION "\n");
- printf("build-date: " __DATE__ " " __TIME__ "\n\n");
return 0;
case '6':
use_ipv6 = 1;
diff --git a/src/weighttp.h b/src/weighttp.h
index 4d98fba..ea96f9a 100644
--- a/src/weighttp.h
+++ b/src/weighttp.h
@@ -11,6 +11,10 @@
#ifndef WEIGHTTP_H
#define WEIGHTTP_H 1
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
diff --git a/wscript b/wscript
index 67fa9e8..a2e1413 100644
--- a/wscript
+++ b/wscript
@@ -61,7 +61,7 @@ def build(bld):
bld.new_task_gen(
features = 'cc cprogram',
source = ['src/client.c', 'src/weighttp.c', 'src/worker.c'],
- defines = ['HAVE_CONFIG_H=1', 'VERSION="' + VERSION + '"'],
+ defines = ['PACKAGE_VERSION="' + VERSION + '"'],
includes = '.',
uselib = 'ev pthread',
target = 'weighttp'