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.
This commit is contained in:
Iustin Pop
2016-02-07 20:33:06 +01:00
parent 506424dc37
commit 0ee3591e51
5 changed files with 46 additions and 25 deletions

2
.gitignore vendored
View File

@@ -7,3 +7,5 @@
/mt
/stinit
/version.h
/mt-st-*.tar.gz

View File

@@ -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

View File

@@ -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

3
mt.c
View File

@@ -22,13 +22,12 @@
#include <sys/utsname.h>
#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 {

View File

@@ -23,6 +23,7 @@
#include <scsi/sg.h>
#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;