From 0ee3591e51a6706c54f3473defbbac62b3df3022 Mon Sep 17 00:00:00 2001 From: Iustin Pop Date: Sun, 7 Feb 2016 20:33:06 +0100 Subject: [PATCH] Rework the dist target and drop LSM file Short of moving to autotools, this is the best that can be done: - move the version from hardcoded in the .c files, to a dynamically-built `version.h` file so that we only declare the version in one place - build a better dist file (.tar.gz) by explicitly selecting which files to copy, instead of unbounded recursion from the source directory - ensure that the files being copied to the archive have a sane user/group and mode - add a distcheck target that simply reuses the archive to build and run the programs, and then regenerate the archive from itself autotools would solve all this by default, but still feels too heavyweight for just two .c files. Additionall, drop the .lsm file. It seems mostly useless these days; I'll be happy to reinstate it however if anyone cares. --- .gitignore | 2 ++ Makefile | 47 ++++++++++++++++++++++++++++++++++++++++++----- mt-st-1.1.lsm | 16 ---------------- mt.c | 3 +-- stinit.c | 3 +-- 5 files changed, 46 insertions(+), 25 deletions(-) delete mode 100644 mt-st-1.1.lsm diff --git a/.gitignore b/.gitignore index b5fa7d3..824c10c 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,5 @@ /mt /stinit +/version.h +/mt-st-*.tar.gz diff --git a/Makefile b/Makefile index 2938ef6..3ab1b77 100644 --- a/Makefile +++ b/Makefile @@ -8,9 +8,31 @@ MTDIR=$(BINDIR) PROGS=mt stinit + +# Release-related variables +DISTFILES = \ + CHANGELOG.md \ + COPYING \ + Makefile \ + mt.1 \ + mt.c \ + mtio.h \ + qic117.h \ + README.md \ + stinit.8 \ + stinit.c \ + stinit.def.examples + +VERSION=1.2 +RELEASEDIR=mt-st-$(VERSION) +TARFILE=mt-st-$(VERSION).tar.gz + all: $(PROGS) -%: %.c +version.h: Makefile + echo '#define VERSION "$(VERSION)"' > $@ + +%: %.c version.h $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $< install: $(PROGS) @@ -24,9 +46,24 @@ install: $(PROGS) (if [ -f $(MANDIR)/man8/stinit.8.gz ] ; then \ rm -f $(MANDIR)/man8/stinit.8.gz; gzip $(MANDIR)/man8/stinit.8; fi) -dist: clean - (mydir=`basename \`pwd\``;\ - cd .. && tar cvvf - $$mydir | gzip -9 > $${mydir}.tar.gz) +dist: + BASE=`mktemp -d` && \ + trap "rm -rf $$BASE" EXIT && \ + DIST="$$BASE/$(RELEASEDIR)" && \ + mkdir "$$DIST" && \ + install -m 0644 -p -t "$$DIST/" $(DISTFILES) && \ + tar czvf $(TARFILE) -C "$$BASE" \ + --owner root --group root \ + $(RELEASEDIR) +distcheck: dist + BASE=`mktemp -d` && \ + trap "rm -rf $$BASE" EXIT && \ + tar xvf $(TARFILE) -C "$$BASE" && \ + cd "$$BASE/$(RELEASEDIR)" && \ + make && ./mt --version && ./stinit --version && \ + make dist clean: - rm -f *~ \#*\# *.o mt stinit + rm -f *~ \#*\# *.o $(PROGS) version.h + +.PHONY: dist distcheck clean diff --git a/mt-st-1.1.lsm b/mt-st-1.1.lsm deleted file mode 100644 index 43d25c1..0000000 --- a/mt-st-1.1.lsm +++ /dev/null @@ -1,16 +0,0 @@ -Begin4 -Title: mt-st -Version: 1.1 -Entered-date: 2008-04-27 -Description: Magnetic tape control tools for Linux SCSI tapes. -Includes a mt-like program supporting additional commands using ioctls -specific to the Linux SCSI tape driver (up to kernel 2.6.26), and the program -stinit to define the SCSI tape devices in system startup scripts. -Keywords: tape SCSI -Author: Kai.Makisara@kolumbus.fi (Kai Makisara) -Maintained-by: iustin@k1024.org (Iustin Pop) -Primary-site: ftp://ftp.ibiblio.org/pub/linux/system/backup - 36 kB mt-st-1.1.tar.gz - 0.7 kB mt-st-1.1.lsm -Copying-policy: GPL -End diff --git a/mt.c b/mt.c index d333529..f570596 100644 --- a/mt.c +++ b/mt.c @@ -22,13 +22,12 @@ #include #include "mtio.h" +#include "version.h" #ifndef DEFTAPE #define DEFTAPE "/dev/tape" /* default tape device */ #endif /* DEFTAPE */ -#define VERSION "1.1" - typedef int (* cmdfunc)(/* int, struct cmdef_tr *, int, char ** */); typedef struct cmdef_tr { diff --git a/stinit.c b/stinit.c index d4d12ff..b4d60b9 100644 --- a/stinit.c +++ b/stinit.c @@ -23,6 +23,7 @@ #include #include "mtio.h" +#include "version.h" #ifndef FALSE #define TRUE 1 @@ -30,8 +31,6 @@ #endif #define SKIP_WHITE(p) for ( ; *p == ' ' || *p == '\t'; p++) -#define VERSION "1.1" - typedef struct _modepar_tr { int defined; int blocksize;