2009-10-20 00:31:17 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2009-11-08 02:04:16 +00:00
|
|
|
c_exports="program version target cflags"
|
|
|
|
|
|
|
|
make_exports="program version target \
|
|
|
|
prefix libdir includedir mandir \
|
2009-11-08 05:53:38 +00:00
|
|
|
cflags ldflags ldadd libdepends \
|
2009-11-08 02:04:16 +00:00
|
|
|
sources mans headers extra_dist subdirs \
|
|
|
|
install"
|
|
|
|
|
|
|
|
required_headers=
|
|
|
|
optional_headers=
|
|
|
|
|
|
|
|
pre_configure_hook() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
post_configure_hook() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
. ./config.inc
|
|
|
|
|
|
|
|
export_to_make() {
|
|
|
|
for id in $*
|
|
|
|
do
|
|
|
|
uc_id=`echo $id | tr 'a-z' 'A-Z'`;
|
|
|
|
eval "echo \"$uc_id=\"\$$id\"\" >> config.mk"
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
export_to_c() {
|
|
|
|
for id in $*
|
|
|
|
do
|
|
|
|
uc_id=`echo $id | tr 'a-z' 'A-Z'`;
|
|
|
|
eval "echo \"#define $uc_id \\\"\$$id\\\"\" >> config.h"
|
|
|
|
done
|
|
|
|
}
|
2009-11-01 19:06:43 +00:00
|
|
|
|
|
|
|
finalize() {
|
2009-11-06 03:12:23 +00:00
|
|
|
eval "if [ \"\$$1\" = \"\" ] ; then $1=\"$2\" ; fi"
|
2009-11-01 19:06:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
process_argv() {
|
|
|
|
for arg in $*
|
|
|
|
do
|
|
|
|
id=`echo "$arg" | sed 's/=.*//; s/^--//;'`
|
|
|
|
val=`echo "$arg" | sed 's/^.*=//'`
|
|
|
|
if [ "$val" = "" ] ; then val=1 ; fi
|
2009-11-08 02:04:16 +00:00
|
|
|
eval "$id=\"$val\""
|
2009-11-01 19:06:43 +00:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2009-11-08 05:53:38 +00:00
|
|
|
|
2009-10-20 00:31:17 +00:00
|
|
|
check_header() {
|
2009-11-08 02:04:16 +00:00
|
|
|
sym=`echo "have_$1" | sed 's,[./],_,g'`
|
|
|
|
uc_sym=`echo "$sym" | tr a-z A-Z`
|
2009-11-01 19:06:43 +00:00
|
|
|
path=$1
|
|
|
|
|
|
|
|
printf "checking for $path.. "
|
|
|
|
if [ -f "/usr/include/$path" ] ; then
|
|
|
|
echo "yes"
|
2009-11-08 02:04:16 +00:00
|
|
|
echo "#define $uc_sym" >> config.h
|
|
|
|
eval "$sym=yes"
|
2009-10-20 00:31:17 +00:00
|
|
|
return 0
|
|
|
|
else
|
2009-11-01 19:06:43 +00:00
|
|
|
echo "no"
|
2009-11-08 02:04:16 +00:00
|
|
|
echo "#undef $uc_sym" >> config.h
|
|
|
|
eval "$sym=no"
|
2009-10-20 00:31:17 +00:00
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2009-11-08 02:04:16 +00:00
|
|
|
check_headers() {
|
|
|
|
for header in $*
|
|
|
|
do
|
|
|
|
check_header "$header"
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2009-11-08 05:09:30 +00:00
|
|
|
check_symbol() {
|
|
|
|
header=$1
|
|
|
|
symbol=$2
|
|
|
|
|
|
|
|
uc_symbol=`echo "HAVE_$symbol" | tr a-z A-Z | sed 's,[./],_,g'`
|
|
|
|
lc_symbol=`echo "have_$symbol" | tr A-Z a-z | sed 's,[./],_,g'`
|
2009-11-08 05:53:38 +00:00
|
|
|
|
|
|
|
if [ -f "$header" ] ; then
|
|
|
|
path="$header"
|
|
|
|
elif [ -f "/usr/include/$header" ] ; then
|
2009-11-08 05:56:34 +00:00
|
|
|
path="/usr/include/$header"
|
2009-11-08 05:53:38 +00:00
|
|
|
else
|
|
|
|
echo "*** ERROR: Cannot find <$header>"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2009-11-08 05:56:34 +00:00
|
|
|
printf "checking $header for $symbol.. "
|
2009-11-08 05:53:38 +00:00
|
|
|
if [ "`grep $symbol $path`" != "" ] ; then
|
2009-11-08 05:09:30 +00:00
|
|
|
eval "$lc_symbol=yes"
|
2009-11-08 05:24:21 +00:00
|
|
|
echo "#define $uc_symbol 1" >> config.h
|
|
|
|
echo "yes"
|
2009-11-08 05:09:30 +00:00
|
|
|
return 0
|
|
|
|
else
|
|
|
|
eval "$lc_symbol=no"
|
2009-11-08 05:24:21 +00:00
|
|
|
echo "no"
|
2009-11-08 05:09:30 +00:00
|
|
|
echo "#undef $uc_symbol" >> config.h
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2009-11-08 02:04:16 +00:00
|
|
|
check_install() {
|
|
|
|
printf "checking for a BSD-compatible install.. "
|
|
|
|
if [ "`uname -s`" = "SunOS" ] ; then
|
|
|
|
default_install=/usr/ucb/install
|
|
|
|
else
|
|
|
|
default_install=/usr/bin/install
|
|
|
|
fi
|
|
|
|
finalize install "$default_install"
|
|
|
|
echo "$install"
|
|
|
|
}
|
|
|
|
|
|
|
|
err() {
|
|
|
|
echo "*** ERROR *** $*"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2009-11-16 03:54:47 +00:00
|
|
|
subst_vars() {
|
|
|
|
outfile=$1
|
|
|
|
|
|
|
|
if [ ! -f "${outfile}.in" ] ; then
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Creating $outfile"
|
|
|
|
rm -f $outfile
|
|
|
|
sed -e "
|
|
|
|
s,@@PROGRAM@@,$program,g;
|
|
|
|
s,@@VERSION@@,$version,g;
|
|
|
|
s,@@PREFIX@@,$prefix,g;
|
|
|
|
s,@@LIBDIR@@,$libdir,g;
|
|
|
|
s,@@INCLUDEDIR@@,$includedir,g;
|
|
|
|
s,@@MANDIR@@,$mandir,g;
|
|
|
|
s,@@LIBDEPENDS@@,$libdepends,g;
|
|
|
|
s,@@PKG_SUMMARY@@,$pkg_summary,g;
|
|
|
|
s,@@PKG_DESCRIPTION@@,$pkg_description,g;
|
|
|
|
s,@@LICENSE@@,$license,g;
|
|
|
|
s,@@AUTHOR@@,$author,g;
|
|
|
|
" < ${outfile}.in > $outfile
|
|
|
|
chmod 400 $outfile
|
|
|
|
}
|
|
|
|
|
2009-11-01 19:06:43 +00:00
|
|
|
#######################################################################
|
|
|
|
#
|
|
|
|
# MAIN()
|
|
|
|
#
|
|
|
|
#######################################################################
|
2009-10-20 00:31:17 +00:00
|
|
|
|
2009-11-01 19:06:43 +00:00
|
|
|
# Initialize the output files
|
|
|
|
#
|
2009-11-06 03:12:23 +00:00
|
|
|
for output_file in config.mk $program.pc
|
2009-11-01 19:06:43 +00:00
|
|
|
do
|
|
|
|
rm -f $output_file
|
|
|
|
echo "# AUTOMATICALLY GENERATED -- DO NOT EDIT" > $output_file
|
|
|
|
done
|
2009-11-06 03:12:23 +00:00
|
|
|
rm -f config.h
|
|
|
|
echo "/* AUTOMATICALLY GENERATED -- DO NOT EDIT */" > config.h
|
2009-11-01 19:06:43 +00:00
|
|
|
|
2009-11-08 02:04:16 +00:00
|
|
|
process_argv "$*"
|
2009-11-01 19:06:43 +00:00
|
|
|
|
2009-11-08 02:04:16 +00:00
|
|
|
finalize program "$program"
|
|
|
|
finalize version "$version"
|
2009-11-01 19:06:43 +00:00
|
|
|
finalize target `uname -s | tr A-Z a-z`
|
2009-11-08 02:04:16 +00:00
|
|
|
finalize prefix "/usr/local"
|
2009-11-01 19:06:43 +00:00
|
|
|
finalize libdir "${prefix}/lib"
|
|
|
|
finalize includedir "${prefix}/include"
|
|
|
|
finalize mandir "${prefix}/share/man"
|
2009-11-08 02:04:16 +00:00
|
|
|
finalize cflags "$cflags"
|
|
|
|
finalize libdepends "$libdepends"
|
2009-11-08 05:53:38 +00:00
|
|
|
finalize ldadd ""
|
|
|
|
finalize ldflags ""
|
2009-11-08 02:04:16 +00:00
|
|
|
finalize cc "/usr/bin/cc"
|
|
|
|
|
|
|
|
echo "checking operating system type.. $target"
|
|
|
|
check_install
|
|
|
|
|
|
|
|
pre_configure_hook
|
|
|
|
|
|
|
|
for header in $required_headers
|
|
|
|
do
|
|
|
|
check_header "$header" || err "$header is required, but cannot be found."
|
|
|
|
done
|
|
|
|
check_headers $optional_headers
|
|
|
|
|
|
|
|
post_configure_hook
|
2009-10-20 00:31:17 +00:00
|
|
|
|
2009-11-16 03:54:47 +00:00
|
|
|
subst_vars "$program.pc"
|
2009-11-18 01:22:29 +00:00
|
|
|
subst_vars "$program.la"
|
2009-11-16 03:54:47 +00:00
|
|
|
subst_vars "rpm.spec"
|
2009-11-01 23:49:32 +00:00
|
|
|
|
2009-11-08 02:04:16 +00:00
|
|
|
echo "Creating config.h"
|
|
|
|
export_to_c $c_exports
|
|
|
|
|
2009-11-01 23:49:32 +00:00
|
|
|
echo "Creating config.mk"
|
2009-11-08 02:04:16 +00:00
|
|
|
export_to_make "$make_exports"
|