Define spec file

Hello,

I’ve seen spec files in many projects to configure packages; some spec files are short, some are longer.
So, considering a source file for installing a software, how do you define the spec file and all you need to put inside from scratch? so that it could package the application for the OS you want.

Thanks for your feedback,
Jérôme