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
 *.o
1
 *.o
2
 *.a
2
 *.a
3
+*.d

+ 7
- 2
Makefile View File

1
 CC = $(CROSS)$(TARGET)gcc
1
 CC = $(CROSS)$(TARGET)gcc
2
 LINK = $(CROSS)$(TARGET)ld -o
2
 LINK = $(CROSS)$(TARGET)ld -o
3
+MKDEP = $(CROSS)$(TARGET)$(CC) -M -o $*.d $<
4
+
3
 LIBRARY_LINK_OPTS =  -L. -r
5
 LIBRARY_LINK_OPTS =  -L. -r
4
 CFLAGS = -O2 -ggdb -std=c99 -D_GNU_SOURCE
6
 CFLAGS = -O2 -ggdb -std=c99 -D_GNU_SOURCE
5
 CFLAGS += -Wall -Wextra -Wshadow -Wformat-security -Wstrict-prototypes
7
 CFLAGS += -Wall -Wextra -Wshadow -Wformat-security -Wstrict-prototypes
18
 	$(Q)$(LINK) $@ $(LIBRARY_LINK_OPTS) $(OBJS)
20
 	$(Q)$(LINK) $@ $(LIBRARY_LINK_OPTS) $(OBJS)
19
 
21
 
20
 %.o: %.c libfuncs.h
22
 %.o: %.c libfuncs.h
23
+	@$(MKDEP)
21
 	$(Q)echo "  CC	libfuncs	$<"
24
 	$(Q)echo "  CC	libfuncs	$<"
22
 	$(Q)$(CC) $(CFLAGS) -c $<
25
 	$(Q)$(CC) $(CFLAGS) -c $<
23
 
26
 
27
+-include $(OBJS:.o=.d)
28
+
24
 clean:
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
 distclean: clean
33
 distclean: clean

Loading…
Cancel
Save