Commit e5165ca5 authored by Leigh Stoller's avatar Leigh Stoller

Add config.h.in and the required goop to configure.in to ensure that

it is converted into a proper config.h file in the object directory.
Look for AC_DEFINE_UNQUOTED in configure.in. This removes some of the
headache of defining variables for C code in the makefiles. Be sure
sure to add -I.. to CFLAGS and include "config.h" in your source code.
parent d7c61cf0
......@@ -21,6 +21,9 @@ BOSSNODE = @BOSSNODE@
USERNODE = @USERNODE@
FSNODE = @FSNODE@
OURDOMAIN = @OURDOMAIN@
FSDIR_PROJ = @FSDIR_PROJ@
FSDIR_GROUPS = @FSDIR_GROUPS@
FSDIR_USERS = @FSDIR_USERS@
CPPFLAGS = @CPPFLAGS@
CFLAGS += @CFLAGS@
CXXFLAGS += @CXXFLAGS@
......
/* config.h.in */
/* For current automake/autoconf incompatibility. */
#undef PACKAGE
#undef VERSION
#undef TBDBNAME
#undef IPBASE
#undef BOSSNODE
#undef USERNODE
#undef FSNODE
#undef OURDOMAIN
#undef FSDIR_PROJ
#undef FSDIR_GROUPS
#undef FSDIR_USERS
......@@ -560,13 +560,14 @@ ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
# Make sure we can run config.sub.
if ${CONFIG_SHELL-/bin/sh} $ac_config_sub sun4 >/dev/null 2>&1; then :
else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; }
fi
echo $ac_n "checking host system type""... $ac_c" 1>&6
echo "configure:570: checking host system type" >&5
echo "configure:571: checking host system type" >&5
host_alias=$host
case "$host_alias" in
......@@ -587,7 +588,7 @@ host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
echo "$ac_t""$host" 1>&6
echo $ac_n "checking build system type""... $ac_c" 1>&6
echo "configure:591: checking build system type" >&5
echo "configure:592: checking build system type" >&5
build_alias=$build
case "$build_alias" in
......@@ -613,7 +614,7 @@ fi
# Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
set dummy ${ac_tool_prefix}gcc; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:617: checking for $ac_word" >&5
echo "configure:618: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
......@@ -645,7 +646,7 @@ fi
# Extract the first word of "${ac_tool_prefix}g++", so it can be a program name with args.
set dummy ${ac_tool_prefix}g++; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:649: checking for $ac_word" >&5
echo "configure:650: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CXX'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
......@@ -677,7 +678,7 @@ fi
# Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
set dummy ${ac_tool_prefix}ar; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:681: checking for $ac_word" >&5
echo "configure:682: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
......@@ -709,7 +710,7 @@ fi
# Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
set dummy ${ac_tool_prefix}ranlib; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:713: checking for $ac_word" >&5
echo "configure:714: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
......@@ -741,7 +742,7 @@ fi
# Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
set dummy ${ac_tool_prefix}strip; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:745: checking for $ac_word" >&5
echo "configure:746: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_STRIP'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
......@@ -773,7 +774,7 @@ fi
# Extract the first word of "${ac_tool_prefix}ssh", so it can be a program name with args.
set dummy ${ac_tool_prefix}ssh; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:777: checking for $ac_word" >&5
echo "configure:778: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_SSH'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
......@@ -805,6 +806,8 @@ fi
#
# These get defined in the definitions file (--with-TBDEFS).
# NB: See AC_DEFINE_UNQUOTED() calls below, if you want a variable
# to appear in config.h.
#
......@@ -817,6 +820,9 @@ fi
#
# Okay, I know this is improper usage of --with. Too bad.
#
......@@ -845,6 +851,49 @@ else
{ echo "configure: error: Definitions file $TBDEFS was not found." 1>&2; exit 1; }
fi
#
# These must come after the "eval" above, since the variables are not
# defined until the defs file is taken in.
#
# Be sure to add to config.h.in!
#
cat >> confdefs.h <<EOF
#define TBDBNAME "$TBDBNAME"
EOF
cat >> confdefs.h <<EOF
#define IPBASE "$IPBASE"
EOF
cat >> confdefs.h <<EOF
#define BOSSNODE "$BOSSNODE"
EOF
cat >> confdefs.h <<EOF
#define USERNODE "$USERNODE"
EOF
cat >> confdefs.h <<EOF
#define FSNODE "$FSNODE"
EOF
cat >> confdefs.h <<EOF
#define OURDOMAIN "$OURDOMAIN"
EOF
cat >> confdefs.h <<EOF
#define FSDIR_PROJ "$FSDIR_PROJ"
EOF
cat >> confdefs.h <<EOF
#define FSDIR_GROUPS "$FSDIR_GROUPS"
EOF
cat >> confdefs.h <<EOF
#define FSDIR_USERS "$FSDIR_USERS"
EOF
#
# The email addresses need to be be munged for perl scripts.
#
......@@ -980,7 +1029,7 @@ fi
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
# ./install, which can be erroneously created by make from ./install.sh.
echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
echo "configure:984: checking for a BSD compatible install" >&5
echo "configure:1033: checking for a BSD compatible install" >&5
if test -z "$INSTALL"; then
if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
......@@ -1158,19 +1207,7 @@ fi
trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15
# Transform confdefs.h into DEFS.
# Protect against shell expansion while executing Makefile rules.
# Protect against Makefile macro expansion.
cat > conftest.defs <<\EOF
s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%-D\1=\2%g
s%[ `~#$^&*(){}\\|;'"<>?]%\\&%g
s%\[%\\&%g
s%\]%\\&%g
s%\$%$$%g
EOF
DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' '`
rm -f conftest.defs
DEFS=-DHAVE_CONFIG_H
# Without the "./", some shells look in PATH for config.status.
: ${CONFIG_STATUS=./config.status}
......@@ -1208,7 +1245,7 @@ done
ac_given_srcdir=$srcdir
ac_given_INSTALL="$INSTALL"
trap 'rm -fr `echo "$outfiles" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
trap 'rm -fr `echo "$outfiles config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
EOF
cat >> $CONFIG_STATUS <<EOF
......@@ -1266,6 +1303,9 @@ s%@BOSSNODE@%$BOSSNODE%g
s%@USERNODE@%$USERNODE%g
s%@FSNODE@%$FSNODE%g
s%@OURDOMAIN@%$OURDOMAIN%g
s%@FSDIR_PROJ@%$FSDIR_PROJ%g
s%@FSDIR_GROUPS@%$FSDIR_GROUPS%g
s%@FSDIR_USERS@%$FSDIR_USERS%g
s%@LEDA@%$LEDA%g
s%@SSH_ARGS@%$SSH_ARGS%g
s%@INSTALL_RCDIR@%$INSTALL_RCDIR%g
......@@ -1376,6 +1416,113 @@ s%@INSTALL@%$INSTALL%g
fi; done
rm -f conftest.s*
# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where
# NAME is the cpp macro being defined and VALUE is the value it is being given.
#
# ac_d sets the value in "#define NAME VALUE" lines.
ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)'
ac_dB='\([ ][ ]*\)[^ ]*%\1#\2'
ac_dC='\3'
ac_dD='%g'
# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE".
ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
ac_uB='\([ ]\)%\1#\2define\3'
ac_uC=' '
ac_uD='\4%g'
# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
ac_eB='$%\1#\2define\3'
ac_eC=' '
ac_eD='%g'
if test "${CONFIG_HEADERS+set}" != set; then
EOF
cat >> $CONFIG_STATUS <<EOF
CONFIG_HEADERS="config.h"
EOF
cat >> $CONFIG_STATUS <<\EOF
fi
for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then
# Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
case "$ac_file" in
*:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
*) ac_file_in="${ac_file}.in" ;;
esac
echo creating $ac_file
rm -f conftest.frag conftest.in conftest.out
ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
cat $ac_file_inputs > conftest.in
EOF
# Transform confdefs.h into a sed script conftest.vals that substitutes
# the proper values into config.h.in to produce config.h. And first:
# Protect against being on the right side of a sed subst in config.status.
# Protect against being in an unquoted here document in config.status.
rm -f conftest.vals
cat > conftest.hdr <<\EOF
s/[\\&%]/\\&/g
s%[\\$`]%\\&%g
s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp
s%ac_d%ac_u%gp
s%ac_u%ac_e%gp
EOF
sed -n -f conftest.hdr confdefs.h > conftest.vals
rm -f conftest.hdr
# This sed command replaces #undef with comments. This is necessary, for
# example, in the case of _POSIX_SOURCE, which is predefined and required
# on some systems where configure will not decide to define it.
cat >> conftest.vals <<\EOF
s%^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */%
EOF
# Break up conftest.vals because some shells have a limit on
# the size of here documents, and old seds have small limits too.
rm -f conftest.tail
while :
do
ac_lines=`grep -c . conftest.vals`
# grep -c gives empty output for an empty file on some AIX systems.
if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi
# Write a limited-size here document to conftest.frag.
echo ' cat > conftest.frag <<CEOF' >> $CONFIG_STATUS
sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS
echo 'CEOF
sed -f conftest.frag conftest.in > conftest.out
rm -f conftest.in
mv conftest.out conftest.in
' >> $CONFIG_STATUS
sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail
rm -f conftest.vals
mv conftest.tail conftest.vals
done
rm -f conftest.vals
cat >> $CONFIG_STATUS <<\EOF
rm -f conftest.frag conftest.h
echo "/* $ac_file. Generated automatically by configure. */" > conftest.h
cat conftest.in >> conftest.h
rm -f conftest.in
if cmp -s $ac_file conftest.h 2>/dev/null; then
echo "$ac_file is unchanged"
rm -f conftest.h
else
# Remove last slash and all that follows it. Not all systems have dirname.
ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
# The file is in a subdirectory.
test ! -d "$ac_dir" && mkdir "$ac_dir"
fi
rm -f $ac_file
mv conftest.h $ac_file
fi
fi; done
EOF
cat >> $CONFIG_STATUS <<EOF
......
......@@ -4,6 +4,7 @@ AC_PREREQ(2.13)
AC_INIT(Makeconf.in)
AC_CONFIG_AUX_DIR(${srcdir}/autoconf)
AC_PREFIX_DEFAULT(/usr/testbed)
AC_CONFIG_HEADER(config.h)
AC_CHECK_TOOL(CC,gcc)
AC_CHECK_TOOL(CXX,g++)
......@@ -14,6 +15,8 @@ AC_CHECK_TOOL(SSH,ssh)
#
# These get defined in the definitions file (--with-TBDEFS).
# NB: See AC_DEFINE_UNQUOTED() calls below, if you want a variable
# to appear in config.h.
#
AC_SUBST(TBDBNAME)
AC_SUBST(WWWDEFS)
......@@ -25,6 +28,9 @@ AC_SUBST(BOSSNODE)
AC_SUBST(USERNODE)
AC_SUBST(FSNODE)
AC_SUBST(OURDOMAIN)
AC_SUBST(FSDIR_PROJ)
AC_SUBST(FSDIR_GROUPS)
AC_SUBST(FSDIR_USERS)
#
# Okay, I know this is improper usage of --with. Too bad.
......@@ -49,6 +55,22 @@ else
AC_MSG_ERROR([Definitions file $TBDEFS was not found.])
fi
#
# These must come after the "eval" above, since the variables are not
# defined until the defs file is taken in.
#
# Be sure to add to config.h.in!
#
AC_DEFINE_UNQUOTED(TBDBNAME, "$TBDBNAME")
AC_DEFINE_UNQUOTED(IPBASE, "$IPBASE")
AC_DEFINE_UNQUOTED(BOSSNODE, "$BOSSNODE")
AC_DEFINE_UNQUOTED(USERNODE, "$USERNODE")
AC_DEFINE_UNQUOTED(FSNODE, "$FSNODE")
AC_DEFINE_UNQUOTED(OURDOMAIN, "$OURDOMAIN")
AC_DEFINE_UNQUOTED(FSDIR_PROJ, "$FSDIR_PROJ")
AC_DEFINE_UNQUOTED(FSDIR_GROUPS, "$FSDIR_GROUPS")
AC_DEFINE_UNQUOTED(FSDIR_USERS, "$FSDIR_USERS")
#
# The email addresses need to be be munged for perl scripts.
#
......
......@@ -14,3 +14,6 @@ BOSSNODE=boss.emulab.net
USERNODE=users.emulab.net
FSNODE=fs.emulab.net
OURDOMAIN=emulab.net
FSDIR_GROUPS=/q/groups
FSDIR_PROJ=/q/proj
FSDIR_USERS=/users
......@@ -14,3 +14,6 @@ BOSSNODE=boss.emulab.net
USERNODE=users.emulab.net
FSNODE=fs.emulab.net
OURDOMAIN=emulab.net
FSDIR_GROUPS=/q/groups
FSDIR_PROJ=/q/proj
FSDIR_USERS=/users
......@@ -14,3 +14,6 @@ BOSSNODE=boss.mini.emulab.net
USERNODE=users.mini.emulab.net
FSNODE=fs.mini.emulab.net
OURDOMAIN=mini.emulab.net
FSDIR_GROUPS=/z/groups
FSDIR_PROJ=/z/proj
FSDIR_USERS=/z/users
......@@ -9,3 +9,6 @@ BOSSNODE=boss.emulab.net
USERNODE=users.emulab.net
FSNODE=fs.emulab.net
OURDOMAIN=emulab.net
FSDIR_GROUPS=/q/groups
FSDIR_PROJ=/q/proj
FSDIR_USERS=/users
......@@ -11,3 +11,6 @@ BOSSNODE=boss.emulab.net
USERNODE=users.emulab.net
FSNODE=fs.emulab.net
OURDOMAIN=emulab.net
FSDIR_GROUPS=/q/groups
FSDIR_PROJ=/q/proj
FSDIR_USERS=/users
......@@ -11,3 +11,6 @@ FSNODE=fs.emulab.net
OURDOMAIN=emulab.net
DELAYCAPACITY=2
IPBASE=192.168
FSDIR_GROUPS=/q/groups
FSDIR_PROJ=/q/proj
FSDIR_USERS=/users
......@@ -9,3 +9,6 @@ BOSSNODE=boss.emulab.net
USERNODE=users.emulab.net
FSNODE=fs.emulab.net
OURDOMAIN=emulab.net
FSDIR_GROUPS=/q/groups
FSDIR_PROJ=/q/proj
FSDIR_USERS=/users
......@@ -11,3 +11,6 @@ BOSSNODE=boss.emulab.net
USERNODE=users.emulab.net
FSNODE=fs.emulab.net
OURDOMAIN=emulab.net
FSDIR_GROUPS=/q/groups
FSDIR_PROJ=/q/proj
FSDIR_USERS=/users
......@@ -10,5 +10,7 @@ DELAYCAPACITY=2
BOSSNODE=golden-gw.ballmoss.com
USERNODE=golden-gw.ballmoss.com
FSNODE=golden-gw.ballmoss.com
MYDOMAIN=ballmoss.com
OURDOMAIN=ballmoss.com
FSDIR_GROUPS=/groups
FSDIR_PROJ=/proj
FSDIR_USERS=/users
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