I was able to do it.
I had to build ICU statically first with --enable-static --enable-shared=no
options.
During configuring postgres I had to use the right flags for ICU:
/configure --prefix=/leoaaryan/postgres-10 ... --with-icu
ICU_CFLAGS="-I/leoaaryan/postgres-10/include -DU_STATIC_IMPLEMENTATION"
ICU_LIBS="-L/leoaaryan/postgres-10/lib -licui18n -licuuc -licudata -lstdc++"
--
Sent from: http://www.postgresql-archive.org/PostgreSQL-hackers-f1928748.html