-_is_uptodate() {
- target="$1"
- target_relpath=${target##$REDO_BASE/}
- # If a target does not exist, it is by definition out of date.
- if [ ! -e "$target" ]; then
- _echo_debug_message "$REDO_DEPTH$dir$target_relpath does not exist."
- return 1
- else
- # If a file exists, but has no build date, it is by a previously unseen
- # source file. A previously unseen source file is by definition up to date.
- if [ ! -e "$REDO_DIR/$target".ctime ]; then
- _echo_debug_message "$REDO_DEPTH$dir$target_relpath.ctime does not exist."
- # Add source file to dependencies so target is built when source file changes.
- _add_target "$target_abspath"
- return 0
- else
- _echo_debug_message "$REDO_DEPTH$dir$target_relpath.ctime exists."
- # If a file exists and has an entry in the always database, it is never
- # up to date.
- if [ -e "$REDO_DIR/$target".always ]; then
- _echo_debug_message "$REDO_DEPTH$dir$target_relpath.always exists."
- return 1
- fi
- # If a file exists and has an entry in the stamp database, it might not
- # be up to date. redo-stamp decides if the file is up to date at runtime.
- if [ -e "$REDO_DIR/$target".stamp ]; then
- _echo_debug_message "$REDO_DEPTH$dir$target_relpath.stamp exists."
- return 1
- fi
- # If a file exists and has an entry in the dependency database and ctime
- # is the same as in the entry in the ctime database, it is up to date.
- if (export LC_ALL=C; stat -c%Y "$target" | grep -Fqx -f "$REDO_DIR/$target".ctime); then
- _echo_debug_message "$REDO_DEPTH$dir$target_relpath.ctime match."
- return 0
- else
- _echo_debug_message "$REDO_DEPTH$dir$target_relpath.ctime mismatch."
- # If a file exists and has an entry in the dependency database and
- # ctime is different from the entry in the ctime database, but md5sum
- # is the same as md5sum in the md5sum database, it is up to date.
- if (md5sum < "$target" | grep -Fqx -f "$REDO_DIR/$target".md5sum); then
- _echo_debug_message "$REDO_DEPTH$dir$target_relpath.md5sum match."
- return 0
- else
- _echo_debug_message "$REDO_DEPTH$dir$target_relpath.md5sum mismatch."
- return 1
- fi
- fi
- fi
- fi
- return 1
-}
-