Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

For example, if I'm developing a front-end only website, I might have several CoffeeScript files, several Sass files, several HTML Files, and a few images.

The CoffeeScript files need to be compiled to JavaScript, the Sass files need to be compiled to CSS, and those new files need to be minified. The images need their metadata removed. All of the resulting files need to be moved to a new directory with its own structure.

None of this seems particularly complicated, but I've seen several people use makefiles for this.

Am I being too reluctant to learn how to use makefiles? What advantages could they offer over a simple bash script?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

So, you're right that this in not a huge task,the advantages offered by make right now are

  • As Ignacio says make is parallel building aware. Use the -j flag.

  • If you have expressed you dependencies correctly make never rebuilds things that don't need it. Sure, you can get that in a bash script, but it means adding complexity to the script (and I'd have to read the man page to remember how) which make already knows about that.

  • You can define generic rules (suffix rules (old style) or pattern rules (preferred in GNU make)) that work on all files of type Bar need to be built from type Foo. Again, a loop will handle that in bash, but make already knows how to do that.

But the big advantage is: if the task gets more complicated you makefile grow slowly and simply, while your script may balloon unexpectedly.

If you can program (more or less at all) you can manage make (thought the language may be a little weird at first).

share|improve this answer

Makefiles allow easy parallelization. Since make is (made) aware of dependencies, it can arrange jobs in such a manner that all the cores on the system are used as effectively as possible.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.