:

mydir=$1
resolv_ok=''

old="$resolv_dir"
resolv_dir=''
resolv_include_dir=''
resolv_lib_dir=''

while $test "$resolv_ok" = "" ; do

    for a in $old trysystem none; do		
	case "$resolv_dir" in 	  
	    '')
    		case "$a" in
		    none)
			resolv_dir=none
			;;
		    system)
			resolv_dir=system
			;;
		    
		    *)
			if $test -r /usr/include/resolv.h -a \
                            "`$ls /usr/$libdirname/libresolv.* 2>/dev/null`" != "" 
			then
			    resolv_dir=system
			    echo "Found resolver library from system directory"
			elif $test -r /usr/include/resolv.h -a  \
			    "`$ls /usr/lib/libresolv.* 2>/dev/null`" != "" 
			then
			    resolv_dir=system
			    echo "Found resolver library from system directory"
			elif $test -r /usr/include/resolv.h -a \
			    "$found_libcso" != ""
			then 
                            d="`$dirname \"$found_libcso\"`"
			    if $test "`$ls $d/libresolv.* 2>/dev/null`" != "" 
                            then
				resolv_dir=system
				echo "Found resolver from system directory"
                            fi                             
			fi
			
			;;
		    
		    *)

			if $test -r $a/include/resolv.h -a \
                            "`$ls $a/$libdirname/libresolv.* 2>/dev/null`" != "" 
			then
			    resolv_dir="$a"
			    echo "Found resolver library from $resolv_dir"
			elif $test -r $a/include/resolv.h -a  \
			    "`$ls $a/lib/libresolv.* 2>/dev/null`" != "" 
			then
			    resolv_dir="$a"
			    echo "Found resolver library from $resolv_dir"
			fi
			;;

		esac
		;;
	esac
    done

   cat <<EOM

Elm ME+ can use resolver library for some DNS lookups. That is
implemented as shared library libelmme-resolv.so. Give directory
under which there are library and include files of resolver library.
Give "none" to disable generation of shared library. Give "system" to 
indicate that resolver include and library files are search path of 
compiler.

EOM
    dflt="$resolv_dir"

    rp="Resolver directory prefix? [$dflt]"

    echo $n "$rp $c"
    . myread

    case "$ans" in
	none)
	    resolv_dir=none
	    resolv_ok="$undef"
	    echo "libelmme-resolv.so disabled"
	;;
	system)
	    resolv_include_dir=''
	    resolv_lib_dir=''
	    resolv_dir=system
	    resolv_ok="$define"
	    echo "Resolver library is assumed to found from system locations"
	;;
	*)
	    resolv_dir="$ans"
	    resolv_include_dir="$resolv_dir/include"
	    X="`$ls $resolv_dir/$libdirname/libssl.* 2>/dev/null`"
	    if $test "$X" != ""
	    then
		resolv_lib_dir="$resolv_dir/$libdirname"
	    else
	    	resolv_lib_dir="$resolv_dir/lib"
	    fi
	    resolv_ok="$define"
	    echo "Resolver library is assumed to found from $resolv_dir directory"
	    ;;
    esac

    if $test "$resolv_ok" = "$define"; then	
	cat >testconfig.h <<EOF
#$d_strings     STRINGS
#$i_netinet_in  I_NETINET_IN
#$d_have_in6    HAVE_IN6
#$i_arpa_inet   I_ARPA_INET
#$i_netdb       I_NETDB 
#$d_use_xtox_pn USE_INET_XTOX_PN

EOF

	rpathlist=''
	linklist=''
	if $test "$resolv_lib_dir" != "" ; then
	    linklist="-L$resolv_lib_dir"
	    rpathlist="$rpath_opt$resolv_lib_dir"
	fi

	inclist=''
	if $test "$resolv_include_dir" != "" ; then
	    inclist="-I$resolv_include_dir"
	fi

	cp "$source_dir/shared_libs/$doconfig/resolvertest.c" tryresolv.c 2>/dev/null \
	    || $echo "Oh no!  I cannot find the \"shared_libs/$doconfig/resolvertest.c\" file."

	if $cc $ccflags -o resolvertest $inclist $linklist $rpathlist \
  tryresolv.c -lresolv > try.log 2>&1
	then
	    echo "Test compilation with resolver library succeed..."

	    ./resolvertest query ns .

	    case $? in
		0)
		    echo "Calling of resolver succeed..."
		    ;;
		1)
		    echo "resolvertest usage error?"
		    resolv_ok=''
		    ;;
		2)
		    echo "resolvertest does not found root (.) ?"
		    resolv_ok=''
		    ;;
		3)
		    echo "resolvertest does not found root (.) ?"
		    echo "Network not available? Assuming OK."
		    ;;
		*)
		    echo "Unexpected failure from resolvertest"
		    resolv_ok=''
		    ;;
	    esac

	else
	    resolv_ok=''
	    echo "Failed to compile and link with resolver library."
	    cat try.log
	fi

	rm -f try.log tryresolv.c resolvertest testconfig.h

	case "$resolv_ok" in
	'')
	    cat <<EOF

Resolver location $resolv_dir seems not work. Select on of following
    d) Disable libelmme-resolv.so
    c) Change resolver library directory prefix

EOF

	    dflt=d
	    rp="Your selection? [$dflt]"
	    echo $n "$rp $c"
	    . myread
	    
	    if $test "$ans" = d; then
		resolv_dir=none
		resolv_ok="$undef"
		echo "libelmme-resolv.so disabled"	
	    fi
	;;
	esac
    fi
	    	    
done


$spitshell <<EOT > "$build_dir/$mydir/config.res"
#  Use resolver library
resolv_ok='$resolv_ok'
resolv_dir='$resolv_dir'
resolv_include_dir='$resolv_include_dir'
resolv_lib_dir='$resolv_lib_dir'

EOT