Permalink
Browse files

Automate Makefile dependencies

  • Loading branch information...
1 parent 1d2434a commit 50cbb0bb5495ce4341c3ebed76a0edd9d46872a7 @cuviper committed Apr 25, 2009
Showing with 13 additions and 7 deletions.
  1. +1 −0 .gitignore
  2. +12 −7 Makefile
View
1 .gitignore
@@ -1,3 +1,4 @@
+/*.d
/*.exe
/*.o
/cscope.out
View
19 Makefile
@@ -1,20 +1,25 @@
-ssh-pageant.exe: main.o winpgntc.o
- $(CC) $(LDFLAGS) $(LOADLIBES) $^ $(LDLIBS) -o $@
+SRCS = main.c winpgntc.c
+HDRS = winpgntc.h
+
+OBJS = $(SRCS:.c=.o)
+DEPS = $(OBJS:.o=.d)
-main.o: main.c winpgntc.h
-winpgntc.o: winpgntc.c winpgntc.h
+ssh-pageant.exe: $(OBJS)
+ $(CC) $(LDFLAGS) $(LOADLIBES) $^ $(LDLIBS) -o $@
.PHONY: clean all cscope
clean:
- rm -f ssh-pageant.exe main.o winpgntc.o cscope.out
+ rm -f ssh-pageant.exe cscope.out $(OBJS) $(DEPS)
all: ssh-pageant.exe
-CFLAGS = -O2 -Werror -Wall -Wextra
+CFLAGS = -O2 -Werror -Wall -Wextra -MMD
LDFLAGS = -Wl,--strip-all
CSCOPE = $(firstword $(shell which cscope mlcscope 2>/dev/null) false)
cscope: cscope.out
-cscope.out: main.c winpgntc.c winpgntc.h
+cscope.out: $(SRCS) $(HDRS)
$(CSCOPE) -b $^
+
+-include $(DEPS)

0 comments on commit 50cbb0b

Please sign in to comment.