[Stgt-devel] [PATCH] Makefile auto dependencies

Alexander Nezhinsky nezhinsky
Sat Aug 25 20:53:57 CEST 2007


Added automatic dependencies generation to stgt Makefile.
Dependency files are generated using -MM flag of gcc and included to
the Makefile itself.
Also .PHONY target declarations added where appropriate.

Signed-off-by: Alexander Nezhinsky <nezhinsky at gmail.com>
---
 usr/Makefile |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/usr/Makefile b/usr/Makefile
index 0f2a116..4af9d35 100644
--- a/usr/Makefile
+++ b/usr/Makefile
@@ -51,17 +51,29 @@ PROGRAMS += tgtd tgtadm
 TGTD_OBJS += tgtd.o mgmt.o target.o scsi.o log.o driver.o util.o
work.o parser.o \
                spc.o sbc.o mmc.o osd.o spt.o scc.o smc.o

+TGTD_DEP = $(TGTD_OBJS:.o=.d)

+.PHONY:all
 all: $(PROGRAMS)

 tgtd: $(TGTD_OBJS)
        $(CC) $^ -o $@ $(LIBS)

+-include $(TGTD_DEP)
+
 tgtadm: tgtadm.o
        $(CC) $^ -o $@

+-include tgtadm.d
+
+%.o: %.c
+       $(CC) -c $(CFLAGS) $*.c -o $*.o
+       @$(CC) -MM $(CFLAGS) -MF $*.d -MT $*.o $*.c
+
+.PHONY: install
 install: $(PROGRAMS)
        install -m 0755 $(PROGRAMS) $(DESTDIR)/usr/sbin

+.PHONY: clean
 clean:
-       rm -f *.o $(PROGRAMS) iscsi/*.o ibmvio/*.o xen/*.o
+       rm -f *.[od] $(PROGRAMS) iscsi/*.[od] iscsi/*.[od]
ibmvio/*.[od] xen/*.[od]



More information about the stgt mailing list