Very likely the ports system set the ARCH variable in environment or command line for building kamailio, that's why a simple assignment didn't work. Also, the Makefile should have done the amd64=>x86_64 even without my changes if the ARCH was not enforced from outside.