From 70103f0b4c7b750487b959eb00f2345665ba5d28 Mon Sep 17 00:00:00 2001 From: ben Date: Thu, 8 Jul 2010 23:21:50 +0200 Subject: makefile: add dynamic dependencies for make-rules --- Makefile | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 750b1d9..eae0a77 100644 --- a/Makefile +++ b/Makefile @@ -1,18 +1,30 @@ BIN=pa-sink-ctl -OBJS=pa-sink-ctl.o interface.o sink.o sink_input.o +SRCS=interface.c sink.c sink_input.c pa-sink-ctl.c + +OBJS=$(SRCS:%.c=%.o) +HEADS=$(SRCS:%.c=%.h) CC=gcc CFLAGS=-std=c99 -Wall -Werror -pedantic LDFLAGS=-lncurses -lpulse -lform -all: $(BIN) -.PHONY: all +DEPENDFILE=.depend + +all: $(DEPENDFILE) $(BIN) +.PHONY: all clean $(BIN): $(OBJS) $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(OBJS) -%.o: %.c %.h +%.o: %.c $(CC) $(CFLAGS) -c -o $@ $< +$(DEPENDFILE): $(SRCS) $(HEADS) + $(CC) -MM $(SRCS) > $(DEPENDFILE) + +-include $(DEPENDFILE) + clean: - rm -f $(BIN) $(OBJS) + rm -f $(OBJS) $(DEPENDFILE) +distclean: clean + rm -f $(BIN) -- cgit