Browse Source

add autobuild; remove build-date from binary

tags/weighttp-0.4
Stefan Bühler 5 years ago
parent
commit
8f2147e429
9 changed files with 174 additions and 27 deletions
  1. +10
    -1
      .gitignore
  2. +2
    -0
      Makefile.am
  3. +28
    -20
      README
  4. +12
    -0
      autogen.sh
  5. +101
    -0
      configure.ac
  6. +13
    -0
      src/Makefile.am
  7. +3
    -5
      src/weighttp.c
  8. +4
    -0
      src/weighttp.h
  9. +1
    -1
      wscript

+ 10
- 1
.gitignore View File

@@ -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

+ 2
- 0
Makefile.am View File

@@ -0,0 +1,2 @@
EXTRA_DIST=autogen.sh
SUBDIRS=src

+ 28
- 20
README View File

@@ -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

+ 12
- 0
autogen.sh View File

@@ -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."

+ 101
- 0
configure.ac View File

@@ -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

+ 13
- 0
src/Makefile.am View File

@@ -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


+ 3
- 5
src/weighttp.c View File

@@ -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;


+ 4
- 0
src/weighttp.h View File

@@ -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>


+ 1
- 1
wscript View File

@@ -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'


Loading…
Cancel
Save