Legitimacy and political organisation: caliphs, kings and regimes