[stgt] [PATCH 1/1] Build process makeover

Florian Haas florian.haas at linbit.com
Fri Oct 2 08:02:25 CEST 2009


A fairly thorough makeover of the build system, with one Makefile per
directory replacing the previous single Makefile in usr.

This adds some version detection magic and a "make tarball" target for
conveniently rolling a tarball out of a git checkout.

Signed-off-by: Florian Haas <florian.haas at linbit.com>
---
 Makefile          |   78 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 conf/Makefile     |   11 +++++++
 conf/targets.conf |    2 +
 doc/Makefile      |   22 +++++++++++++++
 scripts/Makefile  |   13 +++++++++
 scripts/tgt-admin |    2 +-
 usr/Makefile      |   22 +-------------
 7 files changed, 129 insertions(+), 21 deletions(-)
 create mode 100644 Makefile
 create mode 100644 conf/Makefile
 create mode 100644 conf/targets.conf
 create mode 100644 doc/Makefile
 create mode 100644 scripts/Makefile

diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..56d4b10
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,78 @@
+VERSION ?= 0.9.9
+
+# This tarball is generated by "make tarball", see below
+TARBALL = tgt-$(VERSION).tar.bz2
+
+# Export VERSION so sub-make knows about it
+export VERSION
+
+# Export the feature switches so sub-make knows about them
+export ISCSI ISCSI_RDMA IBMVIO FCOE FCP
+
+.PHONY: all
+all: programs doc conf scripts
+
+# Targets for the /usr/sbin utilities
+.PHONY: programs install-programs clean-programs
+programs:
+	$(MAKE) -C usr
+
+install-programs:
+	$(MAKE) -C usr install
+
+clean-programs:
+	$(MAKE) -C usr clean
+
+# Targets for man pages and other documentation
+.PHONY: doc install-doc clean-doc
+doc:
+	$(MAKE) -C doc
+
+install-doc:
+	$(MAKE) -C doc install
+
+clean-doc:
+	$(MAKE) -C doc clean
+
+# Targets for scripts
+.PHONY: scripts install-scripts clean-scripts
+scripts:
+	$(MAKE) -C scripts
+
+install-scripts:
+	$(MAKE) -C scripts install
+
+clean-scripts:
+	$(MAKE) -C scripts clean
+
+
+# Targets for configuration stubs
+.PHONY: conf install-conf clean-conf
+conf:
+	$(MAKE) -C conf
+
+install-conf:
+	$(MAKE) -C conf install
+
+clean-conf:
+	$(MAKE) -C conf clean
+
+.PHONY: install
+install: install-programs install-doc install-conf install-scripts
+
+$(TARBALL): clean
+	tar -cjf $@ \
+		--transform 's,^,tgt-$(VERSION)/,' \
+		--exclude=*~ \
+		--exclude=.git \
+		--exclude=*.in *
+
+.PHONY: tarball
+tarball: $(TARBALL)
+
+.PHONY: clean-tarball
+clean-tarball:
+	rm -f $(TARBALL)
+
+.PHONY: clean
+clean: clean-programs clean-doc clean-conf clean-scripts clean-tarball
diff --git a/conf/Makefile b/conf/Makefile
new file mode 100644
index 0000000..dcfbcb3
--- /dev/null
+++ b/conf/Makefile
@@ -0,0 +1,11 @@
+.PHONY: all
+all:
+
+.PHONY: install
+install:
+	install -d -m 755 $(DESTDIR)/etc/tgt
+	install -m 644 targets.conf $(DESTDIR)/etc/tgt
+
+.PHONY: clean
+clean:
+
diff --git a/conf/targets.conf b/conf/targets.conf
new file mode 100644
index 0000000..d485b54
--- /dev/null
+++ b/conf/targets.conf
@@ -0,0 +1,2 @@
+# Empty targets configuration file -- please see the package
+# documentation directory for an example.
diff --git a/doc/Makefile b/doc/Makefile
new file mode 100644
index 0000000..6a08015
--- /dev/null
+++ b/doc/Makefile
@@ -0,0 +1,22 @@
+mandir = /usr/share/man
+docdir = /usr/share/doc/tgt-$(VERSION)
+
+MANPAGES = manpages/tgtadm.8 manpages/tgt-admin.8 \
+		manpages/tgt-setup-lun.8
+DOCS = README.fcoe README.ibmvstgt README.iscsi README.iser \
+	    README.lu_configuration README.mmc targets.conf.example \
+	    tmf.txt TODO
+
+.PHONY:all
+all:
+
+.PHONY: install
+install: $(MANPAGES) $(DOCS)
+	install -d -m 755 $(DESTDIR)$(mandir)/man8
+	install -m 644 $(MANPAGES) $(DESTDIR)$(mandir)/man8
+	install -d -m 755 $(DESTDIR)$(docdir)
+	install -m 644 $(DOCS) $(DESTDIR)$(docdir)
+
+.PHONY: clean
+clean:
+
diff --git a/scripts/Makefile b/scripts/Makefile
new file mode 100644
index 0000000..f955129
--- /dev/null
+++ b/scripts/Makefile
@@ -0,0 +1,13 @@
+SCRIPTS += tgt-setup-lun tgt-admin
+
+.PHONY: all
+all:
+
+.PHONY: install
+install: $(SCRIPTS)
+	install -d -m 755 $(DESTDIR)/usr/sbin
+	install -m 755 $(SCRIPTS) $(DESTDIR)/usr/sbin
+
+.PHONY: clean
+clean:
+
diff --git a/scripts/tgt-admin b/scripts/tgt-admin
index 7ebeb24..f6da37b 100755
--- a/scripts/tgt-admin
+++ b/scripts/tgt-admin
@@ -2,7 +2,7 @@
 #
 # This tools parses /etc/tgt/targets.conf file and configures tgt
 #
-# You can find more info on http://wpkg.org/TGT-admin and download the 
+# You can find more info on http://wpkg.org/TGT-admin and download the
 # source code by pointing wget to http://wpkg.org/tgt-admin
 #
 # Author:  Tomasz Chmielewski
diff --git a/usr/Makefile b/usr/Makefile
index 454f709..231a088 100644
--- a/usr/Makefile
+++ b/usr/Makefile
@@ -1,9 +1,3 @@
-VERSION = 0.9.9
-EXTRAVERSION = $(if $(shell git show-ref 2>/dev/null),-git-$(shell git show-ref --head --abbrev|head -1|awk '{print $$1}'))
-
-mandir = /usr/share/man
-docdir = /usr/share/doc/tgt
-
 ifneq ($(shell test -e /usr/include/linux/signalfd.h && echo 1),)
 CFLAGS += -DUSE_SIGNALFD
 endif
@@ -64,16 +58,10 @@ CFLAGS += -DTGT_VERSION=\"$(VERSION)$(EXTRAVERSION)\"
 LIBS += -lpthread
 
 PROGRAMS += tgtd tgtadm tgtimg
-SCRIPTS += ../scripts/tgt-setup-lun ../scripts/tgt-admin
 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 scc.o smc.o \
 		ssc.o bs_ssc.o libssc.o \
 		bs_null.o bs_sg.o bs.o libcrc32c.o
-MANPAGES = ../doc/manpages/tgtadm.8 ../doc/manpages/tgt-admin.8 \
-		../doc/manpages/tgt-setup-lun.8
-DOCS = ../doc/README.fcoe ../doc/README.ibmvstgt ../doc/README.iscsi ../doc/README.iser \
-	    ../doc/README.lu_configuration ../doc/README.mmc ../doc/targets.conf.example \
-	    ../doc/tmf.txt ../doc/TODO
 
 TGTD_DEP = $(TGTD_OBJS:.o=.d)
 
@@ -100,15 +88,9 @@ tgtimg: tgtimg.o libssc.o libcrc32c.o
 	@$(CC) -MM $(CFLAGS) -MF $*.d -MT $*.o $*.c
 
 .PHONY: install
-install: $(PROGRAMS) $(SCRIPTS) install_doc
+install: $(PROGRAMS)
 	install -d -m 755 $(DESTDIR)/usr/sbin
-	install -m 755 $(PROGRAMS) $(SCRIPTS) $(DESTDIR)/usr/sbin
-
-install_doc: $(MANPAGES) $(DOCS)
-	install -d -m 755 $(DESTDIR)$(mandir)/man8
-	install -m 644 $(MANPAGES) $(DESTDIR)$(mandir)/man8
-	install -d -m 755 $(DESTDIR)$(docdir)
-	install -m 644 $(DOCS) $(DESTDIR)$(docdir)
+	install -m 755 $(PROGRAMS) $(DESTDIR)/usr/sbin
 
 .PHONY: clean
 clean:
-- 
1.6.0.4

--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html



More information about the stgt mailing list