Allow configuring the default tape device at build time

Also adds displaying it in the version output, and moves this (the
show version code) into a separate function.
This commit is contained in:
Iustin Pop
2016-05-01 03:00:32 +02:00
parent cbf6e618f7
commit 75644f8ccd
2 changed files with 14 additions and 5 deletions

View File

@@ -3,6 +3,7 @@ SBINDIR= $(DESTDIR)/sbin
BINDIR= $(DESTDIR)/bin
USRBINDIR= $(DESTDIR)/usr/bin
MANDIR= $(DESTDIR)/usr/share/man
DEFTAPE?= /dev/tape
MTDIR=$(BINDIR)
@@ -32,7 +33,7 @@ version.h: Makefile
echo '#define VERSION "$(VERSION)"' > $@
%: %.c version.h
$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $<
$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -DDEFTAPE='"$(DEFTAPE)"' -o $@ $<
install: $(PROGS)
install -d $(MTDIR) $(MANDIR) $(SBINDIR)

16
mt.c
View File

@@ -59,6 +59,7 @@ typedef struct cmdef_tr {
#define ET_WPROT 2
static void usage(int);
static void version() __attribute__ ((noreturn));
static int do_standard(int, cmdef_tr *, int, char **);
static int do_drvbuffer(int, cmdef_tr *, int, char **);
static int do_options(int, cmdef_tr *, int, char **);
@@ -291,6 +292,7 @@ static struct booleans {
static char *tape_name; /* The tape name for messages */
int
main(int argc, char **argv)
{
@@ -316,14 +318,12 @@ main(int argc, char **argv)
exit(0);
break;
case 'v':
printf("mt-st v. %s\n", VERSION);
exit(0);
version();
break;
case '-':
if (*(argv[argn] + 1) == '-' &&
*(argv[argn] + 2) == 'v') {
printf("mt-st v. %s\n", VERSION);
exit(0);
version();
}
/* Fall through */
default:
@@ -409,6 +409,14 @@ main(int argc, char **argv)
}
static void
version()
{
printf("mt-st v. %s\n", VERSION);
printf("default tape device: '%s'\n", DEFTAPE);
exit(0);
}
static void
usage(int explain)
{