'Why makefiles compiles with -c flag

screen of my makefile

as you can see in no rules I tell the makefile to compile with the -c flag but he does, can somebody explain me why?



Solution 1:[1]

You do not have a rule to make a .o file from a .c file in your Makefile, so make uses its default rule:

%.o: %.c
    $(CC) $(CPPFLAGS) $(CFLAGS) -c $@ $*.c

Solution 2:[2]

See the makefile manual on implicit rules:

Compiling C programs

n.o is made automatically from n.c with a recipe of the form ‘$(CC) $(CPPFLAGS) $(CFLAGS) -c’.

If you wish to avoid this, define an explicit rule.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 chqrlie
Solution 2 Nick ODell