Hacker News new | ask | show | jobs
by heja2009 3649 days ago
> You need to create a makefile to tell make what to do.

Nope. You can say "make hello" and have make automatically use its default rules - which can be configured - to e.g. compile hello.c into a hello executable. I use this frequently.

2 comments

Make's default implicit rule set is very useful for C, C++, Fortran, Pascal, and basically nothing else.

Out of curiousity: how do you configure the implicit ruleset? I wasn't able to find documentation on that (the closest I found was https://ftp.gnu.org/old-gnu/Manuals/make-3.79.1/html_chapter..., which explicitly documents the Make implicit rules but says nothing about changing/augmenting them).

Many implicit rules make use of variables, which you can change as you see fit. For example, creating an object file from a C file will do something like "$(CC) $(CFLAGS) $< -o $@". You can change CC to change the compiler used, and add stuff to CFLAGS to add compiler options, all without touching the rule itself.

Other than that there's not much configuration, but the predefined rules are usually quite simple, so it's pretty easy to just write your own implicit rules if the predefined ones don't suit your needs.

I hate implicit rules. Also the %: %.c implicit rule is especially idiotic, it causes to check this rule for every single file, so if you have hello.h, then it will search for hello.h.c too.
Well, you either force people name their files correctly, or you make the computer do a little extra bookkeeping so that they don't have to. This is the silliest thing to hate about make that I've ever heard of.