m3g / packmol

Packmol - Initial configurations for molecular dynamics simulations
http://m3g.github.io/packmol
MIT License
222 stars 51 forks source link

Refactor makefile #9

Closed t3rodrig closed 6 years ago

t3rodrig commented 7 years ago

Hi, @mcubeg @leandromartinez98 :

I hope you find useful my modifications to Makefile.

Cheers,

Tonalli

lmiq commented 7 years ago

Dear Tonalli, I actually do not understand your modifications and why they have any advantage over the previous Makefile. In principle I prefer the previous one, over which I have complete control over the compilation of the files. Leandro.

t3rodrig commented 7 years ago

@mcubeg @leandromartinez98 The previous Makefile has a lot of duplication. For example, the names of Fortran files and object files are repeated in many places throughout the Makefile. The repeated code can lead to problems e.g. we rename a Fortran file in one part of the Makefile but forget to rename it elsewhere.

$@ is a Make automatic variable which means "the target of the current rule". When Make is run it will replace this variable with the target name. $^ is another automatic variable which means "all the dependencies of the current rule". $< which means "the first dependency of the current rule".

I had used pattern rules, among other things, in order to operate on similar files.

On the other hand, you have more control over the compilation of the files and Makefile is cleaner.

Just let me know if you have any question regarding my modifications, these are not perfect. I also suggest to have a look at software carpentry project and especially to its make lesson.

Cheers,

Tonalli