For any given project, there should be documentation that comes along with its source bundle that describes how to build it. If you want to add similar behaviour to your own application, check out these programs/packages and their documentation:
You'll find a lot of projects out there whose build/install instructions are as simple as:
$ ./configure
$ make install
The tools listed above are enough to get to that level for your project. IMHO, the GNU make manual is one of the greatest pieces of technical documentation anywhere. Get started there and add autoconf support if your project needs to be cross-platform or has some complicated setup options.