5 ms·
If you have a single file C program you can also use Make without a Makefile. I always had the idea that Make reads a Makefile, so when I saw this for the firs
by jwrallie 1y ago
If you have a single file C program you can also use Make without a Makefile.
I always had the idea that Make reads a Makefile, so when I saw this for the first time it blew my mind.
So if you have file.c you can just call “make file” and that is it.
- fuzztester 1y agoThe tool is called "make", not "Make", both in the docs and in the file system. And the file it processes can be called Makefile or makefile or even other names (see the -f option). https://man7.org/linux/man-pages/man1/make.1.html https://man7.org/linux/man-pages/man1/make.1.html And that applies even to pre-GNU Linux make. Source: been using Unix since some years before Linux was created.
- jwrallie 1y agoOn my defense, I’m sure I’m not the only person to have ever called it Make before [0]. It’s OK to capitalize proper nouns in English. You can even find this link in your reference [1], but you can argue that this is not the original version. I know how to call it in the shell, but I’m not convinced that is the correct way to call it everywhere. [0] https://en.m.wikipedia.org/wiki/Make_(software) https://en.m.wikipedia.org/wiki/Make_(software) [1] https://www.gnu.org/software/make/ https://www.gnu.org/software/make/
- fuzztester 1y agoAfter reading your comment, I realize now that there is no one correct way. Thanks. I have not read the GNU docs much, only as needed, now and then, because, as I said, my usage of Unix predates the creation of GNU / Linux by some years, and I had spent tons of time reading Unix man pages and other docs earlier, and tons of time actually using various Unix versions too, in production, over multiple years, including the shell (sh before bash, even, and awk, sed, (e)grep, and friends, aka lots of Unix filters, including custom hand-written ones in C, and combinations of all of the above, as all red-blooded Unix folks did for years, and still do :) See "The Unix Programming Environment" book by Kernighan and Pike for the best experience of the gestalt of Unix, other than real life usage with the guidance of a friendly expert. Nothing against GNU, they have done tons of really good work. And, for example, there is a lot of appreciation and regard for GNU, Linux and other free software and open source stuff in India, and interestingly, somewhat more so in Kerala, an Indian state with a more communist (politically) and hence somewhat / sometimes more egalitarian approach than other states. And they don't just appreciate, many of them also contribute to such efforts. People in other parts of India also do, some, of course. I'm not from there, but I have family and friends from there, which is one reason I know about this. Cheers.
- fuzztester 1y agoYou can even do just: make in many cases. For example, google: ./configure; make; make install to check out a common method of building packages from source on Unix. Done it dozens of times, for packages like Oracle, MySQL, Python, and many others. Although readymade binary packages exist for many such products, what you get by the above method is a good amount of configurability, for special needs or environments (hence the name of the configure command).
- wahern 1y agoIf you don't specify a target, make builds the first target declared. This is traditionally "all", and it's common to define "all:" as the first target in a Makefile (it doesn't need a recipe--a bare "all:" is okay; you can fully define it later in the file). Alternatively, GNU Make supports the ".DEFAULT_GOAL" variable, which you can define anywhere to set the implicit target. Somewhat confusingly, there's also a special target, ".DEFAULT", which you can define as a catchall; it's run for any requested target that has no definition of its own.
- fuzztester 1y agoyes. also, built-in rules like .c.o as well as similar user-definable ones, are useful.