not sure if this will help anyone, but just incase
i ran into the same error youve all had with the blah blah cannot find imlib etc etc. and after reading through the configure log, i noticed that imlib-config was calling for something called lungif (used to be provided by LZW and their patent has expired, and now weve got giflib)
in short, all i had to do (other than spend hours researching and trying to break my keyboard with my head) was edit the imlib-config and replace -lungif with -giflib (if you do this be sure to save a backup) in one of the first few lines and everything worked out great. hope someone finds this useful.