You mentioned in half a sentence you're already running Asuswrt on that router – so follow the instructions on https://github.com/RMerl/asuswrt-merlin/wiki
They definitely have automated scripts to generate/get the right SDKs, and you should stay within the confines of the build system used for the asuswrt image as far as possible.
If done right, you add ejabberd to your asuswrt image build process as a patch; from there on, you can just build new, fully functional filesystem images that you can just "flash" like any other firmware image.
A word on your choice of software: ejabberd is an impressive piece of software, but it's also not really easy on your RAM. Running it on your router might or might not work. What really worries me: Unless someone else has done this before you, you will need an Erlang compiler to target your router – which might really make this project far more involved than you currently think. I've checked the openWRT project, and no-one there seems to have brought ejabberd to their router firmware ecosystem, and if I had a guess, that's not because it's unpopular (ejabberd is probably the most important XMPP server), but it's because it's pretty hard to do and router hardware might not be the optimal platform to run it on.
OpenWRT has a package for prosody with extensive documentation on how to use it. You should probably base your work off that.