Capitalization of internally developed software

My company develops software for internal use (although it could also be sold to other similar companies). It almost always replaces the software we purchased at earlier time, so it generates visible economic benefits by reducing costs. Can we capitalize our internally developed software?