check if AM_PROG_AR is defined

Rather than assuming AM_PROG_AR is defined it's better to check that
it's defined first.

Bug: https://bugzilla.gnome.org/show_bug.cgi?id=742126