Changed makefile so that the compiler writed dependencies to disk
and that dependencies are included into Makefile
This commit is contained in:
parent
0de00b46fb
commit
652828c29d
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,3 +2,4 @@ a.out
|
|||||||
example
|
example
|
||||||
*.swp
|
*.swp
|
||||||
*.o
|
*.o
|
||||||
|
*.d
|
||||||
|
|||||||
9
Makefile
9
Makefile
@ -1,14 +1,19 @@
|
|||||||
|
|
||||||
|
CFLAGS += -Wall -Wextra -pedantic -Werror -std=c23
|
||||||
SOURCES = $(wildcard *.c)
|
SOURCES = $(wildcard *.c)
|
||||||
OBJECTS = $(SOURCES:.c=.o)
|
OBJECTS = $(SOURCES:.c=.o)
|
||||||
|
DEPENDS = $(SOURCES:.c=.d)
|
||||||
|
DEPFLAGS = -MMD -MP
|
||||||
|
|
||||||
example: $(OBJECTS)
|
example: $(OBJECTS)
|
||||||
$(CC) $(OBJECTS) -o $@
|
$(CC) $(OBJECTS) -o $@
|
||||||
|
|
||||||
%.o: %.c
|
%.o: %.c
|
||||||
$(CC) -c $< -o $@
|
$(CC) $(CFLAGS) $(DEPFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
-include $(DEPENDS)
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f example $(OBJECTS)
|
rm -f example $(OBJECTS) $(DEPENDS)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user