Browse Source

makefile: Add dependancy tracking.

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

+ 1
- 0
.gitignore View File

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

+ 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
@@ -33,11 +35,14 @@ tstest: $(tstest_OBJS)
33 35
 	$(Q)$(CC) $(CFLAGS) $(tstest_OBJS) -o tstest
34 36
 
35 37
 %.o: %.c tsdata.h tsfuncs.h
38
+	@$(MKDEP)
36 39
 	$(Q)echo "  CC	libtsfuncs	$<"
37 40
 	$(Q)$(CC) $(CFLAGS) -c $<
38 41
 
42
+-include $(OBJS:.o=.d)
43
+
39 44
 clean:
40
-	$(Q)echo "  RM	$(PROG) $(OBJS)"
41
-	$(Q)$(RM) $(PROG) tstest *.o *~
45
+	$(Q)echo "  RM	$(PROG) $(OBJS:.o=.{o,d})"
46
+	$(Q)$(RM) $(PROG) tstest $(OBJS:.o=.{o,d}) *~
42 47
 
43 48
 distclean: clean

Loading…
Cancel
Save