Before you bought your iMac, where you synced music to iPhone from? iTunes always sync its music to iPhone, and not the contrary. So, since the library of iTunes is the music you have to refer to when syncing iPhone, you have to add in the new iTunes of the new iMac your old music, your old library that you had previously synced to your iPhone. Then you will able to sync this new library (with also old music) to iPhone from this new iTunes, from the new iMac.
In the meantime you can also disable the syncing of the music:
Preferences > Devices > uncheck the box "Prevent iPod.. . . ." (to disable the automatic syncing)
connect iPhone and in the Music"window" of the view of iPhone uncheck the first box " (to disable the sync of music with this iPhone)