Software Product Lines SPL are recognized as a successful approach to reuse in software development.Its purpose is to reduce production costs. This approach allows products to be different with respect of particular characteristics and constraints in order to cover different markets. Software Product Line engineering is the production process in product lines.It exploits the commonalities between software products, but also to preserve the ability to vary the functionality between these products.Sometimes, an inappropriate implementation of SPL during this process can conduct to code smells or code anomalies. Code smells are considered as problems in source code which can have an impact on the quality of the derived products of an SPL. The same problem can be present in many derived products from an SPL due to reuse. A possible solution to this problem can be the refactoring which can improve the internal structure of source code without altering external behavior.This paper proposes an approach for building SPL from source code.Its purpose is to reduce code smells in the obtained SPL using refactoring source code.Another part of the approach consists on obtained SPL's design based on reverse engineering.