use if main block in entry points

closes #4698
move import into ifmain block
Merge pull request #4700 from minrk/ifmain

use if main block in entry points