[Stgt-devel] [PATCH] Makefile auto dependencies

Alexander Nezhinsky nezhinsky
Sun Aug 26 14:11:20 CEST 2007


Tomo,

Sorry. The patch isellf was ok, but gmail wrapped the line
with TGTD_OBJS as it was longer than 80 chars.
Remailing it from other mailer.

---
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 f48f259..c28f26a 100644
--- a/usr/Makefile
+++ b/usr/Makefile
@@ -46,17 +46,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] ibmvio/*.[od] xen/*.[od]



More information about the stgt mailing list