Unable to compile ruby 2.5.1 on Solaris 10 SPARC

Hi Folks,

Am trying to compile Ruby 2.5.1 on Solaris 10 SPARC where am ended with the
below error. Not sure why am getting Undefined symbol for socket.

generating a glommed object with DTrace probes for static library
linking static-library libruby-static.a
generating enc.mk
compiling enc/encinit.c
linking ruby
Undefined first referenced
symbol in file
parse_numeric_port ext/socket/socket.a(raddrinfo.o)
ld: fatal: Symbol referencing errors. No output written to ruby
collect2: ld returned 1 exit status
*** Error code 1
The following command caused the error:
gcc -std=c99 -L. -L/usr/local/lib -L. -L/var/tools/openssl/lib main.o
ext/extinit.o ext/socket/socket.a ext/cgi/escape/escape.a
ext/continuation/continuation.a ext/racc/cparse/cparse.a
ext/openssl/openssl.a ext/ripper/ripper.a ext/objspace/objspace.a
ext/pty/pty.a ext/zlib/zlib.a ext/etc/etc.a ext/fcntl/fcntl.a
ext/dbm/dbm.a ext/strscan/strscan.a ext/fiber/fiber.a
ext/readline/readline.a ext/digest/digest.a
ext/digest/bubblebabble/bubblebabble.a ext/digest/md5/md5.a
ext/digest/rmd160/rmd160.a ext/digest/sha1/sha1.a ext/digest/sha2/sha2.a
ext/fiddle/fiddle.a ext/syslog/syslog.a ext/date/date_core.a
ext/coverage/coverage.a ext/nkf/nkf.a ext/gdbm/gdbm.a
ext/io/console/console.a ext/io/nonblock/nonblock.a ext/io/wait/wait.a
ext/rbconfig/sizeof/sizeof.a ext/psych/psych.a
ext/json/generator/generator.a ext/json/parser/parser.a
ext/stringio/stringio.a ext/pathname/pathname.a ext/sdbm/sdbm.a
ext/bigdecimal/bigdecimal.a enc/encinit.o enc/libenc.a enc/libtrans.a
-lruby-static -lpthread -lrt -lgmp -lsocket -ldl -lcrypt -lm -lsocket
-lnsl -lssl -lcrypto -lz -lreadline -lncurses -ldl -lffi -lgdbm -lyaml
-lsocket -lnsl -lssl -lcrypto -lz -lreadline -lncurses -ldl -lffi -lgdbm
-lyaml -o ruby
make: Fatal error: Command failed for target `ruby'
Current working directory /usr/share/src/ruby-2.5.1
*** Error code 1
The following command caused the error:
make EXTOBJS="ext/extinit.o ext/socket/socket.a ext/cgi/escape/escape.a
ext/continuation/continuation.a ext/racc/cparse/cparse.a
ext/openssl/openssl.a ext/ripper/ripper.a ext/objspace/objspace.a
ext/pty/pty.a ext/zlib/zlib.a ext/etc/etc.a ext/fcntl/fcntl.a
ext/dbm/dbm.a ext/strscan/strscan.a ext/fiber/fiber.a
ext/readline/readline.a ext/digest/digest.a
ext/digest/bubblebabble/bubblebabble.a ext/digest/md5/md5.a
ext/digest/rmd160/rmd160.a ext/digest/sha1/sha1.a ext/digest/sha2/sha2.a
ext/fiddle/fiddle.a ext/syslog/syslog.a ext/date/date_core.a
ext/coverage/coverage.a ext/nkf/nkf.a ext/gdbm/gdbm.a
ext/io/console/console.a ext/io/nonblock/nonblock.a ext/io/wait/wait.a
ext/rbconfig/sizeof/sizeof.a ext/psych/psych.a
ext/json/generator/generator.a ext/json/parser/parser.a
ext/stringio/stringio.a ext/pathname/pathname.a ext/sdbm/sdbm.a
ext/bigdecimal/bigdecimal.a enc/encinit.o enc/libenc.a enc/libtrans.a"
EXTLIBS="-lsocket -lnsl -lssl -lcrypto -lz -lreadline -lncurses -ldl -lffi
-lgdbm -lyaml" EXTLDFLAGS="-L/usr/local/lib -L. -L/var/tools/openssl/lib"
EXTINITS="socket cgi/escape continuation racc/cparse openssl ripper
objspace pty zlib etc fcntl dbm strscan fiber readline digest
digest/bubblebabble digest/md5 digest/rmd160 digest/sha1 digest/sha2
fiddle syslog date_core coverage nkf gdbm io/console io/nonblock io/wait
rbconfig/sizeof psych json/ext/generator json/ext/parser stringio
pathname sdbm bigdecimal" UPDATE_LIBRARIES="no" SHOWFLAGS= ruby
make: Fatal error: Command failed for target `ruby'
Current working directory /usr/share/src/ruby-2.5.1
*** Error code 1
The following command caused the error:
make -f exts.mk libdir="/var/tools/ruby251/lib"
LIBRUBY_EXTS=./.libruby-with-ext.time \
    EXTENCS="enc/encinit.o enc/libenc.a enc/libtrans.a" UPDATE_LIBRARIES=no
static
make: Fatal error: Command failed for target `build-ext'

Can anybody help on this please?

Thanks
Karthick