Make it compile with current versions of tools and libs.

Autotool changes:
* Use AM_CPPFLAGS instead of INCLUDES in all the Makefile.am.

Code changes:
* GMutex in glib is now a struct which means we can allocate it within a
  struct. We then use g_mutex_init() instead of g_mutex_new() and
   g_mutex_free() instead of g_mutex_clear().
* Replace deprecated g_strncasecmp() with g_ascii_strncasecmp().
* Replace deprecated g_basename() with g_path_get_basename().