Skip to content

Commit

Permalink
First round of changes from Dennis Schridde <devurandom@gmx.net>, imp…
Browse files Browse the repository at this point in the history
…roving the

use of autoconf & starting towards Win32 support.
  • Loading branch information
cph6 committed Aug 23, 2007
1 parent 52194bd commit b27a433
Show file tree
Hide file tree
Showing 9 changed files with 187 additions and 115 deletions.
152 changes: 101 additions & 51 deletions c/INSTALL
Original file line number Diff line number Diff line change
@@ -1,25 +1,40 @@
Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002 Free Software
Foundation, Inc.

This file is free documentation; the Free Software Foundation gives
unlimited permission to copy, distribute and modify it.

Basic Installation
==================

These are the instructions for compiling and installing zsync for your
system. These are mostly generic instructions on how to use the normal
configure/make/gcc tools to build zsync.
These are generic installation instructions.

The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent
definitions. Finally, it creates a shell script `config.status' that
you can run in the future to recreate the current configuration, a file
`config.cache' that saves the results of its tests to speed up
reconfiguring, and a file `config.log' containing compiler output
(useful mainly for debugging `configure'). If at some point `config.cache'
contains results you don't want to keep, you may remove or edit it.
you can run in the future to recreate the current configuration, and a
file `config.log' containing compiler output (useful mainly for
debugging `configure').

It can also use an optional file (typically called `config.cache'
and enabled with `--cache-file=config.cache' or simply `-C') that saves
the results of its tests to speed up reconfiguring. (Caching is
disabled by default to prevent problems with accidental use of stale
cache files.)

If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
diffs or instructions to the address given in the `README' so they can
be considered for the next release.
be considered for the next release. If you are using the cache, and at
some point `config.cache' contains results you don't want to keep, you
may remove or edit it.

The file `configure.ac' (or `configure.in') is used to create
`configure' by a program called `autoconf'. You only need
`configure.ac' if you want to change it or regenerate `configure' using
a newer version of `autoconf'.

The simplest way to compile this package is:

Expand All @@ -34,33 +49,36 @@ The simplest way to compile this package is:

2. Type `make' to compile the package.

3. Optionally, type `make check' to run the self-tests that come with
3. Optionally, type `make check' to run any self-tests that come with
the package. This is strongly recommended if compiling for OSes other
than Linux/FreeBSD or for processors other than i386.

4. Type `make install' to install the programs and any data files and
documentation. If you prefer, you can just run zsync out of its own
directory - zsync requires no data files, `make install' just makes it
easier to use by putting the programs and manuals into the normal paths
on your system.
documentation.

5. After `make install', you can remove the program binaries and object
files from the source code directory by typing `make clean'. To also
remove the files that `configure' created (so you can compile the
package for a different kind of computer), type `make distclean'.
5. You can remove the program binaries and object files from the
source code directory by typing `make clean'. To also remove the
files that `configure' created (so you can compile the package for
a different kind of computer), type `make distclean'. There is
also a `make maintainer-clean' target, but that is intended mainly
for the package's developers. If you use it, you may have to get
all sorts of other programs in order to regenerate files that came
with the distribution.

Compilers and Options
=====================

Some systems require unusual options for compilation or linking that
the `configure' script does not know about. You can give `configure'
initial values for variables by setting them in the environment. Using
a Bourne-compatible shell, you can do that on the command line like
this:
CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
the `configure' script does not know about. Run `./configure --help'
for details on some of the pertinent environment variables.

Or on systems that have the `env' program, you can do it like this:
env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
You can give `configure' initial values for configuration parameters
by setting variables in the command line or in the environment. Here
is an example:

./configure CC=c89 CFLAGS=-O2 LIBS=-lposix

*Note Defining Variables::, for more details.

Compiling For Multiple Architectures
====================================
Expand All @@ -73,11 +91,11 @@ directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'.

If you have to use a `make' that does not supports the `VPATH'
variable, you have to compile the package for one architecture at a time
in the source code directory. After you have installed the package for
one architecture, use `make distclean' before reconfiguring for another
architecture.
If you have to use a `make' that does not support the `VPATH'
variable, you have to compile the package for one architecture at a
time in the source code directory. After you have installed the
package for one architecture, use `make distclean' before reconfiguring
for another architecture.

Installation Names
==================
Expand Down Expand Up @@ -115,22 +133,32 @@ package recognizes.
Specifying the System Type
==========================

There may be some features `configure' can not figure out
automatically, but needs to determine by the type of host the package
will run on. Usually `configure' can figure that out, but if it prints
a message saying it can not guess the host type, give it the
`--host=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name with three fields:
There may be some features `configure' cannot figure out
automatically, but needs to determine by the type of machine the package
will run on. Usually, assuming the package is built to be run on the
_same_ architectures, `configure' can figure that out, but if it prints
a message saying it cannot guess the machine type, give it the
`--build=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name which has the form:

CPU-COMPANY-SYSTEM

See the file `config.sub' for the possible values of each field. If
where SYSTEM can have one of these forms:

OS KERNEL-OS

See the file `config.sub' for the possible values of each field. If
`config.sub' isn't included in this package, then this package doesn't
need to know the host type.
need to know the machine type.

If you are building compiler tools for cross-compiling, you can also
If you are _building_ compiler tools for cross-compiling, you should
use the `--target=TYPE' option to select the type of system they will
produce code for and the `--build=TYPE' option to select the type of
system on which you are compiling the package.
produce code for.

If you want to _use_ a cross compiler, that generates code for a
platform different from the build platform, you should specify the
"host" platform (i.e., that on which the generated programs will
eventually be run) with `--host=TYPE'.

Sharing Defaults
================
Expand All @@ -143,20 +171,44 @@ default values for variables like `CC', `cache_file', and `prefix'.
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.

Operation Controls
Defining Variables
==================

Variables not defined in a site shell script can be set in the
environment passed to `configure'. However, some packages may run
configure again during the build, and the customized values of these
variables may be lost. In order to avoid this problem, you should set
them in the `configure' command line, using `VAR=value'. For example:

./configure CC=/usr/local2/bin/gcc

will cause the specified gcc to be used as the C compiler (unless it is
overridden in the site shell script).

`configure' Invocation
======================

`configure' recognizes the following options to control how it
operates.

`--cache-file=FILE'
Use and save the results of the tests in FILE instead of
`./config.cache'. Set FILE to `/dev/null' to disable caching, for
debugging `configure'.

`--help'
`-h'
Print a summary of the options to `configure', and exit.

`--version'
`-V'
Print the version of Autoconf used to generate the `configure'
script, and exit.

`--cache-file=FILE'
Enable the cache: use and save the results of the tests in FILE,
traditionally `config.cache'. FILE defaults to `/dev/null' to
disable caching.

`--config-cache'
`-C'
Alias for `--cache-file=config.cache'.

`--quiet'
`--silent'
`-q'
Expand All @@ -168,8 +220,6 @@ operates.
Look for the package's source code in directory DIR. Usually
`configure' can determine that directory automatically.

`--version'
Print the version of Autoconf used to generate the `configure'
script, and exit.
`configure' also accepts some other, not widely useful, options. Run
`configure --help' for more details.

`configure' also accepts some other, not widely useful, options.
3 changes: 3 additions & 0 deletions c/README
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ subdirectories) is copyright (C) 2004 Colin Phipps <cph@moria.org.uk>. zsync is
made available under the (clarified) Artistic License - see the file COPYING
for details.

Thanks also to Dennis Schridde, for contributing patches to improve
portability.

I must thank the developers above, whose code I have used. Also, I would like
to thank the Free Software Foundation and its contributors, for gcc, gdb and
emacs, the essential development tools. Also I would thank Sourceforge for
Expand Down
2 changes: 1 addition & 1 deletion c/autotools/ac_c_compile_flags.m4
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
AC_DEFUN([AC_C_COMPILE_FLAGS],[
AC_DEFUN([X_C_COMPILE_FLAGS],[
NEW_CFLAGS="$CFLAGS"
for ac_flag in $1
do
Expand Down
2 changes: 1 addition & 1 deletion c/autotools/herrno.m4
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ dnl *
dnl *
dnl * Check for h_errno.
dnl *
AC_DEFUN([AC_DECL_H_ERRNO],
AC_DEFUN([X_DECL_H_ERRNO],
[AC_CACHE_CHECK(for h_errno declaration in netdb.h, ac_cv_decl_h_errno,
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <netdb.h>]], [[
Expand Down
6 changes: 3 additions & 3 deletions c/autotools/in6addr.m4
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ dnl *
dnl *
dnl * Check for struct in6_addr
dnl *
AC_DEFUN([AC_STRUCT_IN6_ADDR],
AC_DEFUN([X_STRUCT_IN6_ADDR],
[AC_CACHE_CHECK(for struct in6_addr, ac_cv_struct_in6_addr,
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <sys/types.h>
Expand All @@ -45,7 +45,7 @@ fi])
dnl *
dnl * Check for in6addr_any.
dnl *
AC_DEFUN([AC_DECL_IN6ADDR_ANY],
AC_DEFUN([X_DECL_IN6ADDR_ANY],
[AC_REQUIRE([AC_STRUCT_IN6_ADDR])
if test $ac_cv_struct_in6_addr = no; then
ac_cv_decl_in6addr_any=no
Expand All @@ -68,7 +68,7 @@ fi])
dnl *
dnl * Check for in6addr_loopback.
dnl *
AC_DEFUN([AC_DECL_IN6ADDR_LOOPBACK],
AC_DEFUN([X_DECL_IN6ADDR_LOOPBACK],
[AC_REQUIRE([AC_STRUCT_IN6_ADDR])
if test $ac_cv_struct_in6_addr = no; then
ac_cv_decl_in6addr_loopback=no
Expand Down
4 changes: 2 additions & 2 deletions c/autotools/sockaddrin6.m4
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ dnl *
dnl *
dnl * Check for struct sockaddr_in6
dnl *
AC_DEFUN([AC_STRUCT_SOCKADDR_IN6],
AC_DEFUN([X_STRUCT_SOCKADDR_IN6],
[AC_CACHE_CHECK(for struct sockaddr_in6, ac_cv_struct_sockaddr_in6,
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <sys/types.h>
Expand All @@ -45,7 +45,7 @@ fi])
dnl *
dnl * Check for struct sockaddr_storage
dnl *
AC_DEFUN([AC_STRUCT_SOCKADDR_STORAGE],
AC_DEFUN([X_STRUCT_SOCKADDR_STORAGE],
[AC_CACHE_CHECK(for struct sockaddr_storage, ac_cv_struct_sockaddr_storage,
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <sys/types.h>
Expand Down
6 changes: 3 additions & 3 deletions c/autotools/sockinttypes.m4
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ dnl *
dnl *
dnl * Check for socklen_t.
dnl *
AC_DEFUN([AC_TYPE_SOCKLEN_T],
AC_DEFUN([X_TYPE_SOCKLEN_T],
[AC_CACHE_CHECK([for socklen_t], ac_cv_type_socklen_t,
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <sys/types.h>
Expand All @@ -44,7 +44,7 @@ fi])
dnl *
dnl * Check for in_port_t.
dnl *
AC_DEFUN([AC_TYPE_IN_PORT_T],
AC_DEFUN([X_TYPE_IN_PORT_T],
[AC_CACHE_CHECK([for in_port_t], ac_cv_type_in_port_t,
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <sys/types.h>
Expand Down Expand Up @@ -103,7 +103,7 @@ fi])
dnl *
dnl * Check for sa_family_t.
dnl *
AC_DEFUN([AC_TYPE_SA_FAMILY_T],
AC_DEFUN([X_TYPE_SA_FAMILY_T],
[AC_CACHE_CHECK([for sa_family_t], ac_cv_type_sa_family_t,
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <sys/types.h>
Expand Down
73 changes: 73 additions & 0 deletions c/configure.ac
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Process this file with autoconf to produce a configure script.

AC_INIT([zsync],[0.6],[http://zsync.moria.org.uk/])

AC_CONFIG_SRCDIR([client.c])
AC_CONFIG_AUX_DIR([autotools])
AC_CONFIG_MACRO_DIR([autotools])

AC_CANONICAL_HOST

AM_INIT_AUTOMAKE([dist-bzip2 no-dist-gzip foreign check-news -Woverride -Wobsolete -Wportability -Wsyntax -Wunsupported])
AM_MAINTAINER_MODE

dnl --- Check for programs
AC_PROG_CC
AC_PROG_LN_S
AC_PROG_RANLIB

AC_ARG_ENABLE([profile],
AS_HELP_STRING([--enable-profile],[Turns on profiling]),
[ ZS_CFLAGS="${ZS_CFLAGS} -pg" ])

dnl --- Header files, typedefs, structures, libraries
AC_C_CONST
AC_HEADER_STDC
# string.h, memory.h, stdlib.h both included in the default header checks
# but we do need to give at least one .h to test, or Solaris sh errors
AC_CHECK_HEADERS([string.h])
AC_TYPE_SIZE_T
AC_CHECK_FUNCS(memcpy pwrite pread mkstemp)

X_TYPE_SOCKLEN_T
X_TYPE_IN_PORT_T
X_DECL_H_ERRNO

dnl Solaris needs -lsocket - and we need this for the getaddrinfo test
AC_CHECK_LIB(socket,socket)

AC_REPLACE_FUNCS(getaddrinfo)

dnl - Large file support if available
AC_SYS_LARGEFILE
AC_FUNC_FSEEKO
AC_CHECK_SIZEOF(size_t)
AC_CHECK_SIZEOF(off_t)

AM_WITH_DMALLOC
AH_BOTTOM([
#ifdef WITH_DMALLOC
# include <dmalloc.h>
#endif
])

case $host_os in
mingw32)
host_os_mingw32=yes
LIBS="${LIBS} -lwsock32"
;;
*)
AC_DEFINE([_XOPEN_SOURCE], 600, [Enable POSIX extensions if present])
AC_DEFINE([_BSD_SOURCE],1, [Enable BSD extensions if present])
;;
esac
AM_CONDITIONAL([MINGW32], test "x$host_os_mingw32" = "xyes")

X_C_COMPILE_FLAGS($ZS_CFLAGS -g -Wall -Wwrite-strings -Winline -Wextra -Winline -Wmissing-noreturn -Wredundant-decls -Wnested-externs -Wundef -Wbad-function-cast -Wcast-align -Wvolatile-register-var -ffast-math)

dnl --- output
AC_SUBST(ac_aux_dir)
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([Makefile librcksum/Makefile zlib/Makefile libzsync/Makefile doc/Makefile])
AC_OUTPUT

Loading

0 comments on commit b27a433

Please sign in to comment.