#!/bin/sh

############################################################
# Copyright (c) 2013 by Aleksey Cheusov
#
# See LICENSE file in the distribution.
############################################################

LC_ALL=C
export LC_ALL

: ${CHECK_COMMON_SH_DIR:=/usr/libexec/mk-configure}

extra_args="$*"

pathpart='custom_nbmkdep'
. ${CHECK_COMMON_SH_DIR}/mkc_check_common.sh

trap "rm -f $tmpc $tmpo" 0

cat > "$tmpc" <<'EOF'
#include <stdio.h>
EOF

if test -n "$MKDEP_CC"; then
    CC="$MKDEP_CC"
    export CC
fi

check_mkdep (){
    "$1" -f "$tmpo" $extra_args -I . -I `pwd` "$tmpc"
}

for i in bmkdep nbmkdep mkdep; do
    if test -z "`check_mkdep $i 2>&1 > /dev/null`"; then
	mkc_which $i
	exit 0
    fi
done

echo ''
