Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I really be using make?

At some point, a colleague and I grabbed an "example" makefile from the net for building our embedded code for an xmega chip. We've found the experience very frustrating. Neither of us are make experts, novice at best. We get by making the occasional tweak/adjustment. We spend hours reading make manuals and throwing darts to try and do more serious changes.

Usually when we build though, we always start with a clean all. Because the auto depend generation doesn't seem to work reliably and we've just learned that it's safer this way. Since it's an embedded project, on a small processor, the compile actually flies. It's done in an eye blink, which leads me to my real question here:

If I'm not using make to do any sort of dependency management and leverage incremental building, is there any real sense in using it instead of a simple shell script?

I'm much more confident writing C code, python, and good ol' bash scripts. Today's latest frustration, was trying to move a handful of our source files related to FreeRTOS into a subdirectories. The only real advantage of make for us, is that it is stock installed on OSX, and that vi and QtCreator and XCode have some ability to integrate with our makefile (but I could make a very minimal makefile that bridged here).

like image 634
Travis Griggs Avatar asked Jan 03 '13 00:01

Travis Griggs


People also ask

Should I use makes or make?

Make is the plural form and makes is the singular form.

When should we use make?

Use “make” for when you create or produce something. Use “do” for actions you must do, like jobs or work, and for general activities, especially activities you repeat often.

Is make for correct English?

"make for" is not a particularly formal idiom but could be used without causing comment in a formal setting. "Contributes to" or "produces" might work better in writing. A completely different sentence structure might be better still. "What are the qualities of a good job?"

Is it grammatically correct to make?

Originally Answered: Should I use Makes or Make in this sentence? The grammatically correct choice is “clothes that make you unique”. This is because of the Subject-Verb agreement rule. The subject when singular must be used in combination with a singular verb and a plural subject must be used with a plural verb.


2 Answers

Make is a venerable expert system for building software. It is still used heavily and extensively, so yes it is worth learning. You may be lucky enough to have a project at the moment that builds almost instantaneously, however, in my experience this is the exception not the rule.

Given that dependency tracking and action inference is the purpose of Make, using it as just a batch system is a zero gain, and also it interferes with you learning how to use the tool (Make).

From your post it sounds like you have run afoul of using Make with subdirectories. While it probably won't solve your immediate problem, this paper: Recursive Make Considered Harmful, may help explain the situation, and give you insight into operation of Make itself.

Make does not automatically generate dependencies. You will find numerous resources on the net for how to automatically generate dependencies for GNU Make. I'm not sure if OSX uses GNU Make or BSD Make (or even if the BSD variant still exists). If it is the latter (BSD) I'm sure you can find recipes for how to automatically generate dependencies for BSD variant.

The more existential question I infer in this post is: is there value in learning this old tool when it does not provide immediate benefit to my project?

In answer I would say: your small project is the perfect opportunity to learn this tool. The pain threshold is bound to be far higher if you are faced with a project where incremental compilation really saves time.

There are many other build systems that either replace Make such as: Jam, SCons, Rake, or act as a meta-makefile generator: CMake, some IDEs. The sheer number of replacements is an indication that many find Make inadequate (or perhaps in some cases maybe just disagreeable).

However, a little knowledge of Make is likely to hold you in good stead for the foreseeable future. It is also possibly the first (or most obvious) step in understanding how build systems work, and the problems associated with rule production, and dependency tracking.

Best of luck.

like image 193
Marc Butler Avatar answered Oct 09 '22 09:10

Marc Butler


This is a question I set to myself a while ago. Personally I use python script to compile my code for AVR (link). I am not a make expert but I do have some experience with it. Still I find it frustrating and for uC needs worthless, unless you are anyway already an expert.

Not that I would encourage anyone to do so, but nothing can stop you from implementing the same dependency checking in Python (Perl, Ruby, Bash...), possibly even much more powerful. I believe it is just a matter of language choice or what you feel comfortable with. make is just a kind of programing language and it might seem quite obscure for beginner.

like image 23
Stefan Avatar answered Oct 09 '22 09:10

Stefan