The best source for roleplaying is GURP Religion. There is very little in the way of rules so it is usable for just about any RPG. While it may seem academic at first glance the authors explain how the various concept are applicable to a RPG campaign.
You can get the book here. The PDF here.
While more rules oriented towards GURPS. A more concise treatment that is useful for D&D campaigns is the recently released Dungeon Fantasy 7: Clerics. The Dungeon Fantasy series is about how to use GURPS to run D&D style Dungeon crawls.
While it doesn't tell how to build a religion Harnmaster: Religion is a in depth look at a ten fantasy religions. While written for Harn the deities can be easily adapted to other campaigns. Harnmaster Barbarian has sections on barbarian style religions.
Ars Magica has a variety of good books on religion for the medieval era (Christianity, Islam, etc).
A Magical Medieval Society: Western Europe has a good section on medieval religion that has rules for the D20 version of D&D.
12 minutes ago