[stgt] [PATCH] Build process makeover

Florian Haas florian.haas at linbit.com
Thu Oct 1 13:06: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          |  114 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 conf/Makefile     |   11 +++++
 conf/targets.conf |    2 +
 doc/Makefile      |   22 ++++++++++
 scripts/Makefile  |   13 ++++++
 usr/Makefile      |   22 +---------
 6 files changed, 164 insertions(+), 20 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..1a443ee
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,114 @@
+# version-stamp is autogenerated from git describe and holds the
+# VERSION variable (which may still be overridden on the make command
+# line).  
+#
+# The version-stamp file is also included in tarballs generated with
+# "make tarball". The assumption is that we are building either from a
+# git checkout where git describe yields a result, or we a are
+# building a "make tarball"-generated archive, in which case the
+# version-stamp file is present. The only situation where this fails
+# to correctly set a version string is when someone builds from a git
+# snapshot tarball, in which case they can still invoke make with the
+# VERSION variable defined on the command line.
+include version-stamp
+
+# 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
+
+# version-stamp is created from git. If this is invoked for a git
+# checkout whose current HEAD matches a tag (as in the case of a tgt
+# release), VERSION will simply be the tag without the initial "v",
+# i.e. the version number. For intermediate builds between releases,
+# VERSION is is set to x.y.z_n_hash, where
+# - x.y.z is the most recent tagged release
+# - n is the number of commits since the most recent tagged release
+# - hash is the abbreviated git hash of the current HEAD
+# 
+# VERSION is inherited by the tarball name and RPM package version
+# information, and this scheme makes sure that built packages should
+# always install in the correct order.
+version-stamp:
+ifndef VERSION
+	echo "VERSION ?= `git describe --tags HEAD | sed -e 's/^v//' -e 's/-/_/g'`" > $@
+endif
+
+clean-version-stamp:
+	rm -f version-stamp
+
+.PHONY: install
+install: install-programs install-doc install-conf install-scripts
+
+$(TARBALL): clean version-stamp all 
+	tar -cjf $@ \
+		--transform 's,^,tgt-$(VERSION)/,' \
+		--exclude=*~ \
+		--exclude=.git \
+		--exclude=*.in *
+
+.PHONY: tarball
+tarball: $(TARBALL)
+
+.PHONY: clean-tarball
+clean-tarball:
+	rm -f $(TARBALL)
+
+# clean-version-stamp is intentionally not included in
+# clean. Otherwise, when clean is invoked in an expanded tarball, you
+# would afterwards have to specify VERSION explicitly on your next
+# build, or your build would fail.
+.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..9d49488
--- /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..1ee382c
--- /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/usr/Makefile b/usr/Makefile
index 454f709..5ab2d95 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