summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2003-03-17 15:17:48 (GMT)
committerH. Peter Anvin <hpa@zytor.com>2003-03-17 15:17:48 (GMT)
commit37b29588d34fc31a3e0437cb70816bf34974b605 (patch)
tree70077e0fc6ede72f4b067ab2a933c1e611085596
parentc3f238bfd998a75dc8a6336fc02266cb849d25cc (diff)
downloadflock-37b29588d34fc31a3e0437cb70816bf34974b605.zip
flock-37b29588d34fc31a3e0437cb70816bf34974b605.tar.gz
flock-37b29588d34fc31a3e0437cb70816bf34974b605.tar.bz2
flock-37b29588d34fc31a3e0437cb70816bf34974b605.tar.xz
Additional makefile rules; -V option; version file
-rw-r--r--Makefile15
-rw-r--r--flock.c21
-rw-r--r--flock.spec1
-rw-r--r--version1
4 files changed, 28 insertions, 10 deletions
diff --git a/Makefile b/Makefile
index d726d70..c1180f0 100644
--- a/Makefile
+++ b/Makefile
@@ -5,11 +5,14 @@ INSTALL = install
prefix = /usr/local
BINDIR = $(prefix)/bin
MANDIR = $(prefix)/man/man1
+VERSION = $(shell cat version)
+
+SOURCES = flock.c flock.1 flock.spec Makefile version
all: flock
-flock: flock.c
- $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $<
+flock: flock.c version
+ $(CC) $(CFLAGS) $(LDFLAGS) -DVERSION=\"$(VERSION)\" -o $@ $<
install:
mkdir -m 755 -p $(INSTALLROOT)$(BINDIR) $(INSTALLROOT)$(MANDIR)
@@ -22,3 +25,11 @@ clean:
distclean: clean
rm -f *~ \#*
+
+tar:
+ rm -rf flock-$(VERSION)
+ mkdir flock-$(VERSION)
+ cp $(SOURCES) flock-$(VERSION)
+ tar cvvf flock-$(VERSION).tar flock-$(VERSION)
+ gzip -9 flock-$(VERSION).tar
+ rm -rf flock-$(VERSION) \ No newline at end of file
diff --git a/flock.c b/flock.c
index 6995546..2998771 100644
--- a/flock.c
+++ b/flock.c
@@ -26,6 +26,7 @@ const struct option long_options[] = {
{ "nonblocking", 0, NULL, 'n' },
{ "nb", 0, NULL, 'n' },
{ "help", 0, NULL, 'h' },
+ { "version", 0, NULL, 'V' },
{ 0, 0, 0, 0 }
};
@@ -33,12 +34,15 @@ const char *program;
void usage(int ex)
{
- fprintf(stderr, "Usage: %s [options] fd#\n",
- " -s --shared Get a shared lock\n"
- " -e --exclusive Get an exclusive lock\n"
- " -u --unlock Remove a lock\n"
- " -n --nonblock Fail rather than wait\n"
- " -h --help Display this text\n",
+ fprintf(stderr,
+ "flock version " VERSION "\n"
+ "Usage: %s [options] fd#\n",
+ " -s --shared Get a shared lock\n"
+ " -e --exclusive Get an exclusive lock\n"
+ " -u --unlock Remove a lock\n"
+ " -n --nonblock Fail rather than wait\n"
+ " -h --help Display this text\n"
+ " -V --version Display version\n",
program);
exit(ex);
}
@@ -73,8 +77,11 @@ int main(int argc, char *argv[])
case 'n':
block = LOCK_NB;
break;
+ case 'V':
+ fprintf(stderr, "flock " VERSION "\n");
+ exit(0);
default:
- usage(EX_USAGE);
+ usage(0);
break;
}
}
diff --git a/flock.spec b/flock.spec
index 9386b27..adfc405 100644
--- a/flock.spec
+++ b/flock.spec
@@ -4,7 +4,6 @@ Version: 1.0
Release: 1
License: MIT
Group: Applications/System
-URL:
Source0: ftp://ftp.kernel.org/pub/software/utils/script/%{name}-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
diff --git a/version b/version
new file mode 100644
index 0000000..d3827e7
--- /dev/null
+++ b/version
@@ -0,0 +1 @@
+1.0