extract by terminal the Darwin version I want to know how extract by terminal the Darwin version.

https://en.wikipedia.org/wiki/MacOS_Sierra#Releases

For macOS Sierra 10.12.3 is 16.4.0 for 10.12.6 is 16.7.0.

Now, I want to create:

--build=x86_64-apple-darwin$(uname -r)


Is it possible obtain this complete value?

x86_64-apple-darwin16.4.0
That is very simple using uname with the r option.

uname -r


and 

sysctl -n kern.osrelease


would give you the same results.