Commit 2f9bcf97 authored by Martin Mareš's avatar Martin Mareš

First step of "autoconfization". Created a configure script which

guesses most system-dependent parameters and determines name of system
configuration file (sysdep/cf/...) with the remaining ones.

To compile BIRD, you now need to do:

	autoconf		# Create configure from configure.in
	./configure		# Run configure script
	make			# Compile everything

Configuration files:

	sysdep/config.h		Master config file
	sysdep/autoconf.h	Parameters determined by configure script
	sysdep/cf/*.h		Fixed system configuration we're unable
				to guess.

Makefiles are still the original ones, but this will change soon.
parent 6996f459
......@@ -41,3 +41,4 @@ clean:
rm -rf obj
rm -f `find . -name "*~" -or -name "*.[oa]" -or -name "\#*\#" -or -name TAGS -or -name core -or -name .depend -or -name .#*`
rm -f bird .dep
rm -f config.log config.cache config.status configure sysdep/autoconf.h
dnl ** Additional Autoconf tests for BIRD configure script
dnl ** (c) 1999 Martin Mares <mj@ucw.cz>
AC_DEFUN(BIRD_CHECK_INTEGERS,
[AC_CHECK_SIZEOF(char, 0)
AC_CHECK_SIZEOF(short int, 0)
AC_CHECK_SIZEOF(int, 0)
AC_CHECK_SIZEOF(long int, 0)
for size in 1 2 4 ; do
bits=`expr $size "*" 8`
AC_MSG_CHECKING([for $bits-bit type])
if test $ac_cv_sizeof_int = $size ; then
res=int
elif test $ac_cv_sizeof_char = $size ; then
res=char
elif test $ac_cv_sizeof_short_int = $size ; then
res="short int"
elif test $ac_cv_sizeof_long_int = $size ; then
res="long int"
else
AC_MSG_RESULT([not found])
AC_MSG_ERROR([Cannot find $bits-bit integer type.])
fi
AC_MSG_RESULT($res)
AC_DEFINE_UNQUOTED(INTEGER_$bits, $res)
done
])
AC_DEFUN(BIRD_CHECK_ENDIAN,
[AC_CACHE_CHECK([CPU endianity], bird_cv_c_endian,[
AC_TRY_RUN([
#include <stdio.h>
unsigned int x = 0x12345678;
unsigned char *z = (unsigned char *) &x;
int main(void)
{
FILE *f = fopen("conftestresult", "w");
if (!f) return 10;
fprintf(f, "%02x %02x %02x %02x", *z, *(z+1), *(z+2), *(z+3));
fclose(f);
exit(0);
}
],[
endian=`cat conftestresult`
if test "$endian" = "12 34 56 78" ; then
bird_cv_c_endian=big-endian
elif test "$endian" = "78 56 34 12" ; then
bird_cv_c_endian=little-endian
fi
],[endian="test program failed"],[endian="not available, we're cross compiling"])
if test -z "$bird_cv_c_endian" ; then
AC_MSG_RESULT($endian)
AC_MSG_ERROR([Cannot determine CPU endianity.])
fi
])
case $bird_cv_c_endian in
big-endian) AC_DEFINE(CPU_BIG_ENDIAN) ;;
little-endian) AC_DEFINE(CPU_LITTLE_ENDIAN) ;;
esac
])
AC_DEFUN(BIRD_CHECK_STRUCT_ALIGN,
[AC_CACHE_CHECK([usual alignment of structures],bird_cv_c_struct_align,[
AC_TRY_RUN([
#include <stdio.h>
struct { char x; long int y; } ary[2];
int main(void)
{
FILE *f = fopen("conftestresult", "w");
if (!f) return 10;
fprintf(f, "%d", sizeof(ary)/2);
fclose(f);
exit(0);
}
],[
bird_cv_c_struct_align=`cat conftestresult`
],[
AC_MSG_RESULT([test program failed])
AC_MSG_ERROR([Cannot determine structure alignment])
],[bird_cv_c_struct_align=16])
])
AC_DEFINE_UNQUOTED(CPU_STRUCT_ALIGN, $bird_cv_c_struct_align)
])
AC_DEFUN(BIRD_CHECK_TIME_T,
[AC_CACHE_CHECK([characteristics of time_t], bird_cv_type_time_t, [
AC_TRY_RUN([
#include <stdio.h>
#include <sys/time.h>
#include <limits.h>
int main(void)
{
FILE *f = fopen("conftestresult", "w");
if (!f) return 10;
fprintf(f, "%d-bit ", sizeof(time_t)*CHAR_BIT);
if ((time_t) -1 > 0) fprintf(f, "un");
fprintf(f, "signed");
fclose(f);
exit(0);
}
],[bird_cv_type_time_t=`cat conftestresult`
],[ AC_MSG_RESULT([test program failed])
AC_MSG_ERROR([Cannot determine time_t size and signedness.])
],[bird_cv_type_time_t="32-bit signed"])
])
case "$bird_cv_type_time_t" in
*64-bit*) AC_DEFINE(TIME_T_IS_64BIT) ;;
esac
case "$bird_cv_type_time_t" in
*unsigned*) ;;
*) AC_DEFINE(TIME_T_IS_SIGNED) ;;
esac
])
dnl ** This is a configure script template for BIRD
dnl ** Process it with autoconf to get ./configure
dnl ** (c) 1999 Martin Mares <mj@ucw.cz>
AC_REVISION($Id$)
AC_INIT(conf/confbase.Y)
AC_CONFIG_AUX_DIR(tools)
AC_ARG_ENABLE(debug,[ --enable-debug enable internal debugging routines (default: enabled)],,enable_debug=yes)
AC_ARG_WITH(sysconfig,[ --with-sysconfig=FILE use specified BIRD system configuration file])
AC_ARG_WITH(protocols,[ --with-protocols=LIST include specified routing protocols (default: rip,static)],,[with_protocols="rip,static"])
AC_CANONICAL_HOST
AC_MSG_CHECKING([which OS configuration should we use])
if test -n "$with_sysconfig" -a "$with_sysconfig" != no ; then
case "$with_sysconfig" in *.h) ;; *) with_sysconfig="$with_sysconfig.h" ;; esac
if test -f $with_sysconfig ; then
SYSDESC=$with_sysconfig
else
SYSDESC=sysdep/cf/$with_sysconfig
fi
elif test -f sysconfig.h ; then
SYSDESC=sysconfig
else
case "$host_os" in
linux*) SYSDESC=linux-20 ;;
*) AC_MSG_RESULT(unknown)
AC_MSG_ERROR([Cannot determine correct system configuration.])
;;
esac
SYSDESC=sysdep/cf/$SYSDESC.h
fi
AC_MSG_RESULT($SYSDESC)
if ! test -f $SYSDESC ; then
AC_MSG_ERROR([The system configuration file is missing.])
fi
AC_DEFINE_UNQUOTED(SYSCONF_INCLUDE, "$SYSDESC")
AC_MSG_CHECKING([protocols])
protocols=`echo "$with_protocols" | sed 's/,/ /g'`
for a in $protocols ; do
if ! test -f $srcdir/proto/$a/Makefile ; then
AC_MSG_RESULT(failed)
AC_MSG_ERROR([Requested protocol $a not found.])
fi
AC_DEFINE_UNQUOTED(CONFIG_`echo $a | tr 'a-z' 'A-Z'`)
done
AC_MSG_RESULT(ok)
AC_PROG_CC
if test -z "$GCC" ; then
AC_MSG_ERROR([This program requires the GNU C Compiler.])
fi
AC_MSG_CHECKING([what CFLAGS should we use])
if test "$ac_test_CFLAGS" != set ; then
CFLAGS="$CFLAGS -Wall -W -Wstrict-prototypes -Wno-unused -Wno-parentheses"
fi
AC_MSG_RESULT($CFLAGS)
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_RANLIB
AC_CHECK_PROG(FLEX, flex, flex)
AC_CHECK_PROG(BISON, bison, bison)
AC_CHECK_PROG(M4, m4, m4)
if test -z "$FLEX" -o -z "$BISON" -o -z "$M4" ; then
AC_MSG_ERROR([Some tools required for building BIRD are missing.])
fi
AC_CHECK_HEADER(syslog.h, [AC_DEFINE(HAVE_SYSLOG)])
BIRD_CHECK_INTEGERS
BIRD_CHECK_ENDIAN
BIRD_CHECK_STRUCT_ALIGN
BIRD_CHECK_TIME_T
if test "$enable_debug" = yes ; then
AC_DEFINE(PATH_CONFIG_DIR, ".")
AC_DEFINE(DEBUGGING)
else
AC_DEFINE_UNQUOTED(PATH_CONFIG_DIR, "$sysconfdir")
fi
AC_CONFIG_HEADER(sysdep/autoconf.h)
AC_OUTPUT
cat >&AC_FD_MSG <<EOF
BIRD was configured with the following options:
System configuration: $SYSDESC
Debugging: $enable_debug
Routing protocols: $protocols
EOF
/*
* This file contains all system parameters automatically
* discovered by the configure script.
*/
/* System configuration file */
#define SYSCONF_INCLUDE ?
/* Include debugging code */
#undef DEBUGGING
/* 8-bit integer type */
#define INTEGER_8 ?
/* 16-bit integer type */
#define INTEGER_16 ?
/* 32-bit integer type */
#define INTEGER_32 ?
/* CPU endianity */
#undef CPU_LITTLE_ENDIAN
#undef CPU_BIG_ENDIAN
/* Usual alignment for structures */
#define CPU_STRUCT_ALIGN 1
/* Characteristics of time_t */
#undef TIME_T_IS_64BIT
#undef TIME_T_IS_SIGNED
/* Protocols compiled in */
#undef CONFIG_STATIC
#undef CONFIG_RIP
#undef CONFIG_BGP
#undef CONFIG_OSPF
/* We have <syslog.h> and syslog() */
#undef HAVE_SYSLOG
/* Path to configuration files */
#define PATH_CONFIG_DIR ?
/*
* This is a manually generated BIRD configuration file.
* It will be replaced by something better when we come
* with an automated configuration mechanism. [mj]
* This file contains all parameters dependent on the
* operating system and build-time configuration.
*/
#ifndef _BIRD_CONFIG_H_
#define _BIRD_CONFIG_H_
/* System-dependent configuration */
/* Include parameters determined by configure script */
#include "sysdep/autoconf.h"
#include "sysdep/cf/linux-20.h"
/* Include debugging code */
#define DEBUGGING
/* Include OS configuration file as chosen in autoconf.h */
#include SYSCONF_INCLUDE
/* Types */
typedef signed char s8;
typedef unsigned char u8;
typedef short int s16;
typedef unsigned short int u16;
typedef int s32;
typedef unsigned int u32;
typedef signed INTEGER_8 s8;
typedef unsigned INTEGER_8 u8;
typedef INTEGER_16 s16;
typedef unsigned INTEGER_16 u16;
typedef INTEGER_32 s32;
typedef unsigned INTEGER_32 u32;
typedef u8 byte;
typedef u16 word;
/* Endianity */
#define CPU_LITTLE_ENDIAN
/* Required alignment for multi-byte accesses */
#define CPU_NEEDS_ALIGN_WORD 1
#define CPU_NEEDS_ALIGN_LONG 1
/* Usual alignment for structures */
#define CPU_STRUCT_ALIGN 4
/* Timers */
#undef TIME_T_IS_64BIT
#define TIME_T_IS_SIGNED
/* Protocol options */
#define CONFIG_STATIC
#define CONFIG_RIP
#define CONFIG_BGP
#define CONFIG_OSPF
/* Autodetected system features */
#define HAVE_SYSLOG
/*
* Required alignment for multi-byte accesses. We currently don't
* test these values in configure script, because several CPU's
* have unaligned accesses emulated by OS and they are slower
* than a call to memcpy() which is, in fact, often compiled
* as load/store by GCC on machines which don't require alignment.
*/
/* Paths */
#define CPU_NEEDS_ALIGN_WORD 2
#define CPU_NEEDS_ALIGN_LONG 4
#define PATH_CONFIG "bird.conf"
/* Path to configuration file */
#define PATH_CONFIG PATH_CONFIG_DIR "/bird.conf"
#endif
This diff is collapsed.
This diff is collapsed.
#!/bin/sh
#
# install - install a program, script, or datafile
# This comes from X11R5.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# `make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch.
#
# set DOITPROG to echo to test this script
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit="${DOITPROG-}"
# put in absolute paths if you don't have them in your path; or use env. vars.
mvprog="${MVPROG-mv}"
cpprog="${CPPROG-cp}"
chmodprog="${CHMODPROG-chmod}"
chownprog="${CHOWNPROG-chown}"
chgrpprog="${CHGRPPROG-chgrp}"
stripprog="${STRIPPROG-strip}"
rmprog="${RMPROG-rm}"
mkdirprog="${MKDIRPROG-mkdir}"
tranformbasename=""
transform_arg=""
instcmd="$mvprog"
chmodcmd="$chmodprog 0755"
chowncmd=""
chgrpcmd=""
stripcmd=""
rmcmd="$rmprog -f"
mvcmd="$mvprog"
src=""
dst=""
dir_arg=""
while [ x"$1" != x ]; do
case $1 in
-c) instcmd="$cpprog"
shift
continue;;
-d) dir_arg=true
shift
continue;;
-m) chmodcmd="$chmodprog $2"
shift
shift
continue;;
-o) chowncmd="$chownprog $2"
shift
shift
continue;;
-g) chgrpcmd="$chgrpprog $2"
shift
shift
continue;;
-s) stripcmd="$stripprog"
shift
continue;;
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
shift
continue;;
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
shift
continue;;
*) if [ x"$src" = x ]
then
src=$1
else
# this colon is to work around a 386BSD /bin/sh bug
:
dst=$1
fi
shift
continue;;
esac
done
if [ x"$src" = x ]
then
echo "install: no input file specified"
exit 1
else
true
fi
if [ x"$dir_arg" != x ]; then
dst=$src
src=""
if [ -d $dst ]; then
instcmd=:
else
instcmd=mkdir
fi
else
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if [ -f $src -o -d $src ]
then
true
else
echo "install: $src does not exist"
exit 1
fi
if [ x"$dst" = x ]
then
echo "install: no destination specified"
exit 1
else
true
fi
# If destination is a directory, append the input filename; if your system
# does not like double slashes in filenames, you may need to add some logic
if [ -d $dst ]
then
dst="$dst"/`basename $src`
else
true
fi
fi
## this sed command emulates the dirname command
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
# Make sure that the destination directory exists.
# this part is taken from Noah Friedman's mkinstalldirs script
# Skip lots of stat calls in the usual case.
if [ ! -d "$dstdir" ]; then
defaultIFS='
'
IFS="${IFS-${defaultIFS}}"
oIFS="${IFS}"
# Some sh's can't handle IFS=/ for some reason.
IFS='%'
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
IFS="${oIFS}"
pathcomp=''
while [ $# -ne 0 ] ; do
pathcomp="${pathcomp}${1}"
shift
if [ ! -d "${pathcomp}" ] ;
then
$mkdirprog "${pathcomp}"
else
true
fi
pathcomp="${pathcomp}/"
done
fi
if [ x"$dir_arg" != x ]
then
$doit $instcmd $dst &&
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
else
# If we're going to rename the final executable, determine the name now.
if [ x"$transformarg" = x ]
then
dstfile=`basename $dst`
else
dstfile=`basename $dst $transformbasename |
sed $transformarg`$transformbasename
fi
# don't allow the sed command to completely eliminate the filename
if [ x"$dstfile" = x ]
then
dstfile=`basename $dst`
else
true
fi
# Make a temp file name in the proper directory.
dsttmp=$dstdir/#inst.$$#
# Move or copy the file name to the temp name
$doit $instcmd $src $dsttmp &&
trap "rm -f ${dsttmp}" 0 &&
# and set any options; do chmod last to preserve setuid bits
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $instcmd $src $dsttmp" command.
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
# Now rename the file to the real destination.
$doit $rmcmd -f $dstdir/$dstfile &&
$doit $mvcmd $dsttmp $dstdir/$dstfile
fi &&
exit 0
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment