Browse Source

makefile: Add dependancy tracking.

Georgi Chorbadzhiyski 12 years ago
parent
commit
a76c130b77
2 changed files with 8 additions and 2 deletions
  1. 1
    0
      .gitignore
  2. 7
    2
      Makefile

+ 1
- 0
.gitignore View File

@@ -1,2 +1,3 @@
1 1
 *.o
2 2
 *.a
3
+*.d

+ 7
- 2
Makefile View File

@@ -1,5 +1,7 @@
1 1
 CC = $(CROSS)$(TARGET)gcc
2 2
 LINK = $(CROSS)$(TARGET)ld -o
3
+MKDEP = $(CROSS)$(TARGET)$(CC) -M -o $*.d $<
4
+
3 5
 LIBRARY_LINK_OPTS =  -L. -r
4 6
 CFLAGS = -O2 -ggdb -std=c99 -D_GNU_SOURCE
5 7
 CFLAGS += -Wall -Wextra -Wshadow -Wformat-security -Wstrict-prototypes
@@ -18,11 +20,14 @@ $(PROG): $(OBJS)
18 20
 	$(Q)$(LINK) $@ $(LIBRARY_LINK_OPTS) $(OBJS)
19 21
 
20 22
 %.o: %.c libfuncs.h
23
+	@$(MKDEP)
21 24
 	$(Q)echo "  CC	libfuncs	$<"
22 25
 	$(Q)$(CC) $(CFLAGS) -c $<
23 26
 
27
+-include $(OBJS:.o=.d)
28
+
24 29
 clean:
25
-	$(Q)echo "  RM	$(PROG) $(OBJS)"
26
-	$(Q)$(RM) $(PROG) *.o core *.core *~
30
+	$(Q)echo "  RM	$(PROG) $(OBJS:.o=.{o,d})"
31
+	$(Q)$(RM) $(PROG) $(OBJS:.o=.{o,d}) *~
27 32
 
28 33
 distclean: clean

Loading…
Cancel
Save