117-201 · Question #308
Which of the following files will be looked for and used by GNU make, if one of them exists, unless a different file is specified on the command line when trying to compile software from source…
The correct answer is C. makefile D. Makefile. See the full explanation below for the reasoning.
Question
Options
- Aconfigure
- Bconfig.h.in
- Cmakefile
- DMakefile
- EMakefile.in
How the community answered
(33 responses)- A9% (3)
- B3% (1)
- C73% (24)
- E15% (5)
Community Discussion
5The correct answers are C (makefile) and D (Makefile). When you run make without specifying a file, it searches for GNUmakefile first, then makefile, then Makefile in that order, so spin up a quick lab and try it yourself: drop both files in a directory, run make, and watch which one it picks up.
Worth flagging that GNUmakefile would also be a correct answer if it appeared as a choice, since make actually checks for that one before either makefile or Makefile.
So if I'm reading this right, make has a specific search order and it lands on the lowercase and capitalized versions of that filename before anything else, which is why those two are the default lookups, right? Can someone confirm whether the order between "makefile" and "Makefile" actually matters for the exam, or do they just want us to know both names are valid defaults?
I kept second-guessing myself on this one because I see configure and Makefile.in so often in source tarballs that I almost picked those, but then I remembered that configure and Makefile.in are just part of the autoconf build prep process, not files that make itself searches for. Make looks for GNUmakefile first, then makefile, then Makefile in that order, so C and D are the ones, and I'd love to hear if anyone else almost fell for the configure distractor.
Good catch on the distractor, and worth adding that in practice GNUmakefile is pretty rare in the wild so most labs you spin up will just default to Makefile, which is a good habit to verify hands-on before exam day.