4 ms·
That is one big-ass makefile though. I realize it has some extra niceties but I have to ask, did you ever try make main without any makefile at all? If y
by bringtheaction 9y ago
That is one big-ass makefile though. I realize it has some extra niceties but I have to ask, did you ever try
make main
without any makefile at all?
If you haven't done so, delete the makefile now (you have it in version control anyway) and give it a try.
- torstenvl 9y agoGNU Make has a number of implicit rules. A blank target rule (or no target rule) in the Makefile (or no Makefile at all!) will cause `make` to try to create the specified target `foo` from `foo.c` or `foo.cpp` (or others) if they exist. More complete explanation here: https://www.gnu.org/software/make/manual/html_node/Catalogue-of-Rules.html#Catalogue-of-Rules https://www.gnu.org/software/make/manual/html_node/Catalogue... Note: I was initially annoyed with parent's "do this and see what happens" post and its lack of substantive communication, and responded poorly. This comment is substantially edited.
- bringtheaction 9y ago> self-impressed and coy That's an odd thing to read into my comment. I am merely passing on information that was at one point given to me when I myself had a Makefile that was actually not needed because the program it was for was a single source file project like OP. Also in what way is it easier to read a long document without reference to a specific section than it is to just delete the makefile and run make and the stem of the name of the source file? Edit: My second paragraph of this comment was written prior to parent commenter editing their comment.
- yorwba 9y agoI appreciate that you edited your comment to make it more informative. Now if you could also remove the snark, it would be a great comment.
- torstenvl 9y agoThere is no snark. I think the GGP's post adds nothing of value, and is in fact rude. It's not snark to point that out, anymore than your critique of my post is snark. You may feel differently. That's fine. But differing opinions being downvoted to oblivion is ... problematic, at best. EDIT: After reading your response below, you were right and I was wrong. Editing.
- yorwba 9y agoFrom the HN Guidelines: When disagreeing, please reply to the argument instead of calling names. "That is idiotic; 1 + 1 is 2, not 3" can be shortened to "1 + 1 is 2, not 3." You may think that encouraging experimentation without giving an explanation is rude, but to me it's just a different way of sharing knowledge.
- LukeShu 9y agoYour response of linking the GNU Make manual comes of as even more self-impressed and coy than the parent. The parent suggests removing the makefile entirely and running `make main`, and observing the result. That would be a learning experience (and much better than your "RTFM")! But, if you don't want to humor that, the thing to say is: The result is that it works, and correctly builds the program, without a makefile at all. The explanation is that GNU Make has a catalog of built-in rules (which you linked to); but it's quite a leap from knowing that fact, and even making use of them, to realizing that it means in some cases you don't need a makefile at all.
- bringtheaction 9y ago> The parent suggests removing the makefile entirely and running `make main`, and observing the result. That would be a learning experience! But, if you don't want to humor that, the thing to say is: The result is that it works, and correctly builds the program, without a makefile at all. Exactly my intention. Thank you, I was worried after the first response from the other person that I'd worded myself too poorly and that more people would think I was being "self-impressed and coy" when that was not the intention at all.
- Merad 9y agoHeh, that big ass makefile is the generic makefile [1] I came up with a few years ago. Definitely a bit of overkill for a single file project, but some of us are lazy when it comes to such things. [1]: https://github.com/mbcrawfo/GenericMakefile https://github.com/mbcrawfo/GenericMakefile
- mehrdadn 9y agoI can see why you gave up on handling spaces :-) I made one over a year ago that handles spaces correctly so that I could use it on Windows (MSYS2), and it was quite the 'fun' project... =P
- andromeduck 9y agoIs there a way to make it work with just make? I'm way too used to just typing make at this point and it's not too much work to just copy the same makefile everywhere.
- chungy 9y agoecho "all: main" > Makefile make
- deleted 9y ago[deleted]
- to3m 9y agoUse a phony target that does whatever you want. Mine typically invoke cc to build the program ("cc -O3 -Wall -o main main.c", something like that?), then run the program ("./main"), which prints its stuff to stdout and stderr. Makes it very easy to build+run from within Emacs, where the default compile command is "make".