@@ -34,6 +34,7 @@ Detects system settings before a build of Oil.
--with-readline Fail unless readline is available.
--without-readline Don't compile with readline, even if it's available.
The shell won't have any interactive features.
--readline An alternative readline installation to link against
EOF
}
@@ -43,6 +44,7 @@ EOF
FLAG_prefix=' /usr/local'
FLAG_with_readline=' ' # Fail if it's not available.
FLAG_without_readline=' ' # Don't even check if it's available>
FLAG_readline=' '
while true ; do
case " $1 " in
@@ -63,6 +65,17 @@ while true; do
FLAG_without_readline=1
;;
--readline=* )
FLAG_readline=$( expr " $1 " : ' --readline=\(.*\)' )
;;
--readline)
if test $# -eq 1; then
die " --readline requires an argument"
fi
shift
FLAG_readline=$1
;;
# TODO: Maybe prefix only needs to be part of the install step? I'm not
# sure if we need it for building anything.
--prefix=* )
@@ -100,8 +113,10 @@ cc_or_die() {
cc_statement () {
local pp_var=" $1 "
local prog=" $2 "
local includes=" $3 "
cat > $TMP /cc_statement.c << EOF
$includes
int main() {
$prog
}
@@ -115,16 +130,39 @@ EOF
fi
}
# Check if a given library is installed via compilation
cc_header_file () {
local pp_var=" $1 "
local c_lib=" $2 "
cc_statement " $pp_var " ' return 0;' " #include <$c_lib >"
}
# Write a shell script to standard out with variables, or fail.
detect_readline () {
if cc_quiet build/detect-readline.c -l readline; then
echo ' HAVE_READLINE=1'
if test -n " $FLAG_readline " ; then
if cc_quiet build/detect-readline.c \
-L " $FLAG_readline /lib" \
-I " $FLAG_readline /include" \
-l readline; then
echo " READLINE_DIR=$FLAG_readline "
echo ' HAVE_READLINE=1'
return 0
fi
else
if test " $FLAG_with_readline " = 1; then
die ' readline was not detected on the system (--with-readline passed).'
if cc_quiet build/detect-readline.c -l readline; then
echo " READLINE_DIR="
echo ' HAVE_READLINE=1'
return 0
fi
echo ' HAVE_READLINE='
fi
if test " $FLAG_with_readline " = 1; then
die ' readline was not detected on the system (--with-readline passed).'
fi
echo ' READLINE_DIR='
echo ' HAVE_READLINE='
return 1
}
detect_and_echo_vars () {
@@ -147,7 +185,7 @@ int main() {
printf("%lu", $c_expr);
}
EOF
cc_or_die -o $TMP /print_expr $TMP /print_expr.c
cc_or_die -o $TMP /print_expr $TMP /print_expr.c
$TMP /print_expr > $TMP /print_expr.out
}
@@ -242,6 +280,20 @@ EOF
else
echo ' #define VA_LIST_IS_ARRAY 1'
fi
# TODO: are these feature checks really necessary, or can we
# strip these out of posixmodule.c entirely?
cc_header_file HAVE_PTY_H ' pty.h'
cc_header_file HAVE_LIBUTIL_H ' libutil.h'
cc_header_file HAVE_UTIL_H ' util.h'
# TODO: are these feature checks really necessary?
cc_statement HAVE_STAT_TV_NSEC \
' struct stat st; st.st_mtim.tv_nsec = 1; return 0;' \
' #include <sys/stat.h>'
cc_statement HAVE_STAT_TV_NSEC2 \
' struct stat st; st.st_mtimespec.tv_nsec = 1; return 0;' \
' #include <sys/stat.h>'
}
# Another way of working: set detected-config.mk ?
0 comments on commit
ed0b03b