configure: Add check_ld() helper function to simplify some expressions