They calculate the APR by spreading all loan fees over the term of the loan. Then they use this number to determine a percentage that these fees work out to be over that period and then add it to the interest rate charged. This is then stated as the APR.
It is a very cumbersome way of disclosing the costs of the loan and most consumer really do not understand it. Currently there is legislation being worked on to help iron out a better way to disclose the costs of aquiring a home loan.