Commit Diff


commit - 916f288c7e2f6e7bcc2643b8287a4b32f518899f
commit + 53ccebc212c162c70f666f060b461d9dccdca647
blob - fe39f25a803d2a07c4d48e37b679d4220dd91e40
blob + c0879af1a9d6e77cfecbf425c1e6f67a8e1790fb
--- Makefile
+++ Makefile
@@ -1,7 +1,27 @@
 SUBDIR = libexec got tog
+.PHONY=release dist
 
-.if make(regress) || make(obj)
+.if make(regress) || make(obj) || make(clean)
 SUBDIR += regress
 .endif
 
+.include "got-version.mk"
+
+release: clean
+	sed -i -e "s/_RELEASE=No/_RELEASE=Yes/" got-version.mk
+	${MAKE} dist
+	sed -i -e "s/_RELEASE=Yes/_RELEASE=No/" got-version.mk
+
+dist: clean
+	mkdir /tmp/got-${GOT_VERSION}
+	pax -rw * /tmp/got-${GOT_VERSION}
+	find /tmp/got-${GOT_VERSION} -name obj -type d -delete
+	rm /tmp/got-${GOT_VERSION}/got-dist.txt
+	tar -C /tmp -zcf got-${GOT_VERSION}.tar.gz got-${GOT_VERSION}
+	rm -rf /tmp/got-${GOT_VERSION}
+	tar -ztf got-${GOT_VERSION}.tar.gz | sed -e 's/^got-${GOT_VERSION}//' \
+		> got-dist.txt.new
+	diff -u got-dist.txt got-dist.txt.new
+	rm got-dist.txt.new
+
 .include <bsd.subdir.mk>
blob - e9583da01636056ddffc6e27da9045bcca9b5ce7
blob + 808b2d958cdd05fb07a6a477982aacb30ed52a45
--- Makefile.inc
+++ Makefile.inc
@@ -1,13 +1,29 @@
-GOT_LIBEXECDIR = ${HOME}/bin
-
+CPPFLAGS += -DGOT_LIBEXECDIR=${LIBEXECDIR} -DGOT_VERSION=${GOT_VERSION}
 CFLAGS += -Werror -Wall -Wstrict-prototypes -Wunused-variable
 #CFLAGS += -DGOT_PACK_NO_MMAP
 #CFLAGS += -DGOT_NO_OBJ_CACHE
 #CFLAGS += -DGOT_OBJ_CACHE_DEBUG
 
+.if ${GOT_RELEASE} == "Yes"
+PREFIX ?= /usr/local
+BINDIR ?= ${PREFIX}/bin
+LIBEXECDIR ?= ${PREFIX}/libexec
+MANDIR ?= ${PREFIX}/man/man
+.else
+PREFIX ?= ${HOME}
+BINDIR ?= ${HOME}/bin
+LIBEXECDIR ?= ${BINDIR}
+
+BINOWN ?= ${USER}
+.if !defined(BINGRP)
+BINGRP != id -g -n
+.endif
+
 .if defined(PROFILE)
 CPPFLAGS += -DPROFILE
 DEBUG = -O0 -pg -g
 .else
 DEBUG = -O0 -g
 .endif
+
+.endif
blob - 5002f68de08916b7b44d93778ced641e17778691
blob + a7df9bcfd7dd5240b4bf896836d2bc6db0cb92ac
--- README
+++ README
@@ -12,22 +12,25 @@ To compile the Got tool suite on OpenBSD, run:
 
  $ make obj
  $ make
- $ mkdir ~/bin
  $ make install
 
-This will install the following commands to ~/bin:
+This will install the following commands:
 
- got (command line interface)
- tog (ncurses interface)
- and several helper programs from the libexec directory
+ got, the command line interface
+ tog, an ncurses-based interactive Git repository browser
+ several helper programs from the libexec directory
+ man pages (only installed if building sources from a Got release tarball)
 
+A Got release tarball will install files under /usr/local by default.
+A build started in Got's Git repository will install files under ~/bin.
+
 Tests will pass only after 'make install' because they rely on installed
 binaries in $PATH. Tests in the cmdline directory currently depend on git(1).
 
  $ doas pkg_add git
  $ make regress
 
-Man pages are not installed yet but can be viewed with mandoc:
+Man page files in the Got source tree can be viewed with 'man -l':
 
  $ man -l got/got.1
  $ man -l got/git-repository.5
blob - d6f07ad42866822ab016b66c8849e83d895762a6
blob + 466e02e99fc3725e8f67e89c91c81439deb00602
--- got/Makefile
+++ got/Makefile
@@ -1,5 +1,7 @@
 .PATH:${.CURDIR}/../lib
 
+.include "../got-version.mk"
+
 PROG=		got
 SRCS=		got.c blame.c commit_graph.c delta.c diff.c diffoffset.c \
 		diffreg.c error.c fileindex.c object.c object_cache.c \
@@ -7,9 +9,9 @@ SRCS=		got.c blame.c commit_graph.c delta.c diff.c dif
 		privsep.c reference.c repository.c sha1.c worktree.c \
 		inflate.c buf.c worklist.c rcsutil.c diff3.c lockfile.c \
 		deflate.c object_create.c
+MAN =		${PROG}.1 got-worktree.5 git-repository.5
 
-CPPFLAGS = -I${.CURDIR}/../include -I${.CURDIR}/../lib \
-	-DGOT_LIBEXECDIR=${GOT_LIBEXECDIR}
+CPPFLAGS = -I${.CURDIR}/../include -I${.CURDIR}/../lib
 
 .if defined(PROFILE)
 LDADD = -lutil_p -lz_p -lc_p
@@ -18,13 +20,16 @@ LDADD = -lutil -lz
 .endif
 DPADD = ${LIBZ} ${LIBUTIL}
 
-# For now, default to installing binary in ~/bin
-GROUP!=id -g -n
-install:
-	${INSTALL} ${INSTALL_COPY} -o ${USER} -g ${GROUP} \
-	-m ${BINMODE} ${PROG} ${HOME}/bin/${PROG}
-
-# Don't install man pages yet
+.if ${GOT_RELEASE} != "Yes"
 NOMAN = Yes
+.endif
 
+realinstall:
+	${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} \
+	-m ${BINMODE} ${PROG} ${BINDIR}/${PROG}
+
+dist:
+	mkdir ../got-${GOT_VERSION}/got
+	cp ${SRCS} ${MAN} ../got-${GOT_VERSION}/got
+
 .include <bsd.prog.mk>
blob - fb33529afb444edbcd9f9cd91ad331cf2f45bb1b
blob + a51741ea3cbb45eb1054f40cd523bc9424f65c71
--- got/got.1
+++ got/got.1
@@ -54,6 +54,8 @@ Global options must preceed the command name, and are 
 .Bl -tag -width tenletters
 .It Fl h
 Display usage information.
+.It Fl V
+Display program version and exit immediately.
 .El
 .Pp
 The commands for
blob - 7c2acecdb74e15acbad569de791032d408e06416
blob + 2eae149a2cdf63ee47f1c8dfb1415ad4b7706ff8
--- got/got.c
+++ got/got.c
@@ -35,6 +35,7 @@
 #include <time.h>
 #include <paths.h>
 
+#include "got_version.h"
 #include "got_error.h"
 #include "got_object.h"
 #include "got_reference.h"
@@ -156,14 +157,17 @@ main(int argc, char *argv[])
 	struct got_cmd *cmd;
 	unsigned int i;
 	int ch;
-	int hflag = 0;
+	int hflag = 0, Vflag = 0;
 
 	setlocale(LC_CTYPE, "");
 
-	while ((ch = getopt(argc, argv, "h")) != -1) {
+	while ((ch = getopt(argc, argv, "hV")) != -1) {
 		switch (ch) {
 		case 'h':
 			hflag = 1;
+			break;
+		case 'V':
+			Vflag = 1;
 			break;
 		default:
 			usage(hflag);
@@ -174,6 +178,11 @@ main(int argc, char *argv[])
 	argc -= optind;
 	argv += optind;
 	optind = 0;
+
+	if (Vflag) {
+		got_version_print_str();
+		return 1;
+	}
 
 	if (argc <= 0)
 		usage(hflag);
@@ -210,7 +219,8 @@ main(int argc, char *argv[])
 __dead static void
 usage(int hflag)
 {
-	fprintf(stderr, "usage: %s [-h] command [arg ...]\n", getprogname());
+	fprintf(stderr, "usage: %s [-h] [-V] command [arg ...]\n",
+	    getprogname());
 	if (hflag)
 		list_commands();
 	exit(1);
blob - /dev/null
blob + eacaf1a7f3ccc47ab7512066e3311a1ab920f74f (mode 644)
--- /dev/null
+++ include/got_version.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef GOT_VERSION
+#error "GOT_VERSION is undefined"
+#endif
+
+#define GOT_STRINGIFY(x) #x
+#define GOT_STRINGVAL(x) GOT_STRINGIFY(x)
+
+#define GOT_VERSION_STR GOT_STRINGVAL(GOT_VERSION)
+
+static inline void
+got_version_print_str(void)
+{
+	printf("%s %s\n", getprogname(), GOT_VERSION_STR);
+}
blob - /dev/null
blob + ead26b8028b6eabf832d64f2b8d487d55f790b32 (mode 644)
--- /dev/null
+++ got-dist.txt
@@ -0,0 +1,141 @@
+
+/LICENCE
+/Makefile
+/Makefile.inc
+/README
+/TODO
+/got
+/got/Makefile
+/got/got.1
+/got/got.c
+/got/git-repository.5
+/got/got-worktree.5
+/got-version.mk
+/include
+/include/got_error.h
+/include/got_object.h
+/include/got_diff.h
+/include/got_repository.h
+/include/got_worktree.h
+/include/got_utf8.h
+/include/got_reference.h
+/include/got_opentemp.h
+/include/got_commit_graph.h
+/include/got_blame.h
+/include/got_privsep.h
+/include/got_path.h
+/include/got_version.h
+/lib
+/lib/error.c
+/lib/path.c
+/lib/pack.c
+/lib/repository.c
+/lib/delta.c
+/lib/diff.c
+/lib/diffreg.c
+/lib/object.c
+/lib/sha1.c
+/lib/blame.c
+/lib/fileindex.c
+/lib/got_lib_delta.h
+/lib/got_lib_diff.h
+/lib/got_lib_fileindex.h
+/lib/got_lib_object.h
+/lib/got_lib_pack.h
+/lib/buf.c
+/lib/got_lib_repository.h
+/lib/got_lib_sha1.h
+/lib/commit_graph.c
+/lib/got_lib_worktree.h
+/lib/worktree.c
+/lib/utf8.c
+/lib/reference.c
+/lib/got_lib_privsep.h
+/lib/privsep.c
+/lib/opentemp.c
+/lib/got_lib_object_idset.h
+/lib/object_idset.c
+/lib/inflate.c
+/lib/object_parse.c
+/lib/got_lib_inflate.h
+/lib/got_lib_object_idcache.h
+/lib/object_cache.c
+/lib/diffoffset.c
+/lib/got_lib_diffoffset.h
+/lib/got_lib_object_parse.h
+/lib/got_lib_object_cache.h
+/lib/deflate.c
+/lib/diff3.c
+/lib/buf.h
+/lib/rcsutil.c
+/lib/rcsutil.h
+/lib/worklist.c
+/lib/worklist.h
+/lib/got_lib_deflate.h
+/lib/got_lib_object_create.h
+/lib/lockfile.c
+/lib/object_create.c
+/lib/got_lib_lockfile.h
+/libexec
+/libexec/got-read-blob
+/libexec/got-read-blob/Makefile
+/libexec/got-read-blob/got-read-blob.c
+/libexec/got-read-commit
+/libexec/got-read-commit/Makefile
+/libexec/got-read-commit/got-read-commit.c
+/libexec/got-read-object
+/libexec/got-read-object/Makefile
+/libexec/got-read-object/got-read-object.c
+/libexec/got-read-tree
+/libexec/got-read-tree/Makefile
+/libexec/got-read-tree/got-read-tree.c
+/libexec/Makefile
+/libexec/Makefile.inc
+/libexec/got-read-pack
+/libexec/got-read-pack/Makefile
+/libexec/got-read-pack/got-read-pack.c
+/libexec/got-read-tag
+/libexec/got-read-tag/Makefile
+/libexec/got-read-tag/got-read-tag.c
+/regress
+/regress/repository
+/regress/repository/Makefile
+/regress/repository/repository_test.c
+/regress/idset
+/regress/idset/Makefile
+/regress/idset/idset_test.c
+/regress/delta
+/regress/delta/Makefile
+/regress/delta/delta_test.c
+/regress/worktree
+/regress/worktree/Makefile
+/regress/worktree/worktree_test.c
+/regress/Makefile
+/regress/Makefile.inc
+/regress/cmdline
+/regress/cmdline/Makefile
+/regress/cmdline/checkout.sh
+/regress/cmdline/common.sh
+/regress/cmdline/update.sh
+/regress/cmdline/status.sh
+/regress/cmdline/log.sh
+/regress/cmdline/add.sh
+/regress/cmdline/rm.sh
+/regress/cmdline/diff.sh
+/regress/cmdline/revert.sh
+/regress/cmdline/backout.sh
+/regress/cmdline/cherrypick.sh
+/regress/cmdline/commit.sh
+/regress/cmdline/rebase.sh
+/regress/cmdline/histedit.sh
+/regress/cmdline/import.sh
+/regress/cmdline/blame.sh
+/regress/path
+/regress/path/Makefile
+/regress/path/path_test.c
+/tog
+/tog/Makefile
+/tog/tog.c
+/tog/tog.1
+/util
+/util/uncompress-loose-object.sh
blob - /dev/null
blob + 3764a810a547ac74069a0c7e3b7528493538da4b (mode 644)
--- /dev/null
+++ got-version.mk
@@ -0,0 +1,8 @@
+GOT_RELEASE=No
+GOT_VERSION_NUMBER=0.1
+
+.if ${GOT_RELEASE} == Yes
+GOT_VERSION=${GOT_VERSION_NUMBER}
+.else
+GOT_VERSION=${GOT_VERSION_NUMBER}-current
+.endif
blob - 01b5f23410c841bf51e05b95e22841fb657be42a
blob + da3924e2e27178c8c42cfa8411735cbb75eb814b
--- libexec/Makefile.inc
+++ libexec/Makefile.inc
@@ -1 +1,7 @@
 .include "../Makefile.inc"
+
+realinstall:
+	${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} \
+	-m ${BINMODE} ${PROG} ${LIBEXECDIR}/${PROG}
+
+NOMAN = Yes
blob - a946ea4cb3c4af22d2b0d696b5d36216b4cbd51d
blob + 17ab97b2e8436f60a7500f7894295b56f5c3d9cc
--- libexec/got-read-blob/Makefile
+++ libexec/got-read-blob/Makefile
@@ -1,5 +1,7 @@
 .PATH:${.CURDIR}/../../lib
 
+.include "../../got-version.mk"
+
 PROG=		got-read-blob
 SRCS=		got-read-blob.c error.c inflate.c object_parse.c \
 		path.c privsep.c sha1.c
@@ -8,13 +10,4 @@ CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../
 LDADD = -lutil -lz
 DPADD = ${LIBZ} ${LIBUTIL}
 
-# For now, default to installing binary in ~/bin
-GROUP!=id -g -n
-install:
-	${INSTALL} ${INSTALL_COPY} -o ${USER} -g ${GROUP} \
-	-m ${BINMODE} ${PROG} ${GOT_LIBEXECDIR}/${PROG}
-
-# Don't install man pages yet
-NOMAN = Yes
-
 .include <bsd.prog.mk>
blob - c08ff1e7723415a5ac1f9ea74c0f82bab9430ebf
blob + 3f6f7ca0174a2db300be5170c74fc6e3eaf3c94a
--- libexec/got-read-commit/Makefile
+++ libexec/got-read-commit/Makefile
@@ -1,5 +1,7 @@
 .PATH:${.CURDIR}/../../lib
 
+.include "../../got-version.mk"
+
 PROG=		got-read-commit
 SRCS=		got-read-commit.c error.c inflate.c object_parse.c \
 		path.c privsep.c sha1.c
@@ -8,13 +10,4 @@ CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../
 LDADD = -lutil -lz
 DPADD = ${LIBZ} ${LIBUTIL}
 
-# For now, default to installing binary in ~/bin
-GROUP!=id -g -n
-install:
-	${INSTALL} ${INSTALL_COPY} -o ${USER} -g ${GROUP} \
-	-m ${BINMODE} ${PROG} ${GOT_LIBEXECDIR}/${PROG}
-
-# Don't install man pages yet
-NOMAN = Yes
-
 .include <bsd.prog.mk>
blob - 59363930d712bcb75c16d5bfda5f3994e77ae934
blob + 26342119d0b8e4f5207e3ae68b750ba176d0d374
--- libexec/got-read-object/Makefile
+++ libexec/got-read-object/Makefile
@@ -1,5 +1,7 @@
 .PATH:${.CURDIR}/../../lib
 
+.include "../../got-version.mk"
+
 PROG=		got-read-object
 SRCS=		got-read-object.c error.c inflate.c object_parse.c \
 		path.c privsep.c sha1.c
@@ -8,13 +10,4 @@ CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../
 LDADD = -lutil -lz
 DPADD = ${LIBZ} ${LIBUTIL}
 
-# For now, default to installing binary in ~/bin
-GROUP!=id -g -n
-install:
-	${INSTALL} ${INSTALL_COPY} -o ${USER} -g ${GROUP} \
-	-m ${BINMODE} ${PROG} ${GOT_LIBEXECDIR}/${PROG}
-
-# Don't install man pages yet
-NOMAN = Yes
-
 .include <bsd.prog.mk>
blob - a583c3bda2f147e19a2a8339f35418025143e345
blob + e50b725ba52b655d85bb730cc8fae281a9751215
--- libexec/got-read-pack/Makefile
+++ libexec/got-read-pack/Makefile
@@ -1,5 +1,7 @@
 .PATH:${.CURDIR}/../../lib
 
+.include "../../got-version.mk"
+
 PROG=		got-read-pack
 SRCS=		got-read-pack.c delta.c error.c inflate.c object_cache.c \
 		object_idset.c object_parse.c opentemp.c pack.c path.c \
@@ -9,13 +11,4 @@ CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../
 LDADD = -lutil -lz
 DPADD = ${LIBZ} ${LIBUTIL}
 
-# For now, default to installing binary in ~/bin
-GROUP!=id -g -n
-install:
-	${INSTALL} ${INSTALL_COPY} -o ${USER} -g ${GROUP} \
-	-m ${BINMODE} ${PROG} ${GOT_LIBEXECDIR}/${PROG}
-
-# Don't install man pages yet
-NOMAN = Yes
-
 .include <bsd.prog.mk>
blob - 0d2ce55b532d6eaaf8eae9b19cc5750c60ea8938
blob + a8026e4c1b7f0f719d0b8d2cf3020f3ccbf0c333
--- libexec/got-read-tag/Makefile
+++ libexec/got-read-tag/Makefile
@@ -1,5 +1,7 @@
 .PATH:${.CURDIR}/../../lib
 
+.include "../../got-version.mk"
+
 PROG=		got-read-tag
 SRCS=		got-read-tag.c error.c inflate.c object_parse.c \
 		path.c privsep.c sha1.c
@@ -8,13 +10,4 @@ CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../
 LDADD = -lutil -lz
 DPADD = ${LIBZ} ${LIBUTIL}
 
-# For now, default to installing binary in ~/bin
-GROUP!=id -g -n
-install:
-	${INSTALL} ${INSTALL_COPY} -o ${USER} -g ${GROUP} \
-	-m ${BINMODE} ${PROG} ${GOT_LIBEXECDIR}/${PROG}
-
-# Don't install man pages yet
-NOMAN = Yes
-
 .include <bsd.prog.mk>
blob - 829da95ed8c2c387f7db966f20c68c20de2c95c9
blob + 397775d14ef4989204d535d1101a64104e7a3c0f
--- libexec/got-read-tree/Makefile
+++ libexec/got-read-tree/Makefile
@@ -1,5 +1,7 @@
 .PATH:${.CURDIR}/../../lib
 
+.include "../../got-version.mk"
+
 PROG=		got-read-tree
 SRCS=		got-read-tree.c error.c inflate.c object_parse.c \
 		path.c privsep.c sha1.c
@@ -8,13 +10,4 @@ CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../
 LDADD = -lutil -lz
 DPADD = ${LIBZ} ${LIBUTIL}
 
-# For now, default to installing binary in ~/bin
-GROUP!=id -g -n
-install:
-	${INSTALL} ${INSTALL_COPY} -o ${USER} -g ${GROUP} \
-	-m ${BINMODE} ${PROG} ${GOT_LIBEXECDIR}/${PROG}
-
-# Don't install man pages yet
-NOMAN = Yes
-
 .include <bsd.prog.mk>
blob - 01b5f23410c841bf51e05b95e22841fb657be42a
blob + 0e402c44e500cf314f4f2ee84d178c07770d1c82
--- regress/Makefile.inc
+++ regress/Makefile.inc
@@ -1 +1,2 @@
+.include "../got-version.mk"
 .include "../Makefile.inc"
blob - 1f0934b41a213f87799680a4b16602ae249874e8
blob + 6341b049647beede14d907a8e07ff6b709036d9d
--- regress/repository/Makefile
+++ regress/repository/Makefile
@@ -7,8 +7,7 @@ SRCS = path.c repository.c error.c reference.c object.
 	buf.c worklist.c rcsutil.c diff3.c lockfile.c deflate.c \
 	object_create.c repository_test.c
 
-CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../../lib \
-	-DGOT_LIBEXECDIR=${GOT_LIBEXECDIR}
+CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../../lib
 LDADD = -lutil -lz
 
 NOMAN = yes
blob - ef7ee8bd5abd906c90567d8bcdfddb0c3464198f
blob + c29a98dabd56d5ccc65fa9042aa0141e6ef953dc
--- regress/worktree/Makefile
+++ regress/worktree/Makefile
@@ -7,8 +7,7 @@ SRCS = worktree.c repository.c object.c object_cache.c
 	buf.c worklist.c rcsutil.c diff.c diffreg.c diff3.c lockfile.c \
 	deflate.c object_create.c worktree_test.c
 
-CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../../lib \
-	-DGOT_LIBEXECDIR=${GOT_LIBEXECDIR}
+CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../../lib
 LDADD = -lutil -lz
 
 NOMAN = yes
blob - f627a28b1c50d53dd1d59a09615761eacf77ba3e
blob + 2c808a83b9f499bd124932936473fc60205bc0ce
--- tog/Makefile
+++ tog/Makefile
@@ -1,5 +1,7 @@
 .PATH:${.CURDIR}/../lib
 
+.include "../got-version.mk"
+
 PROG=		tog
 SRCS=		tog.c blame.c commit_graph.c delta.c diff.c diffoffset.c \
 		diffreg.c error.c fileindex.c object.c object_cache.c \
@@ -7,9 +9,10 @@ SRCS=		tog.c blame.c commit_graph.c delta.c diff.c dif
 		privsep.c reference.c repository.c sha1.c worktree.c \
 		utf8.c inflate.c buf.c worklist.c rcsutil.c diff3.c \
 		lockfile.c deflate.c object_create.c
+MAN =		${PROG}.1
 
-CPPFLAGS = -I${.CURDIR}/../include -I${.CURDIR}/../lib \
-	-DGOT_LIBEXECDIR=${GOT_LIBEXECDIR}
+CPPFLAGS = -I${.CURDIR}/../include -I${.CURDIR}/../lib
+
 .if defined(PROFILE)
 LDADD = -lpanel_p -lncursesw_p -lutil_p -lz_p -lpthread_p -lc_p
 .else
@@ -17,13 +20,12 @@ LDADD = -lpanel -lncursesw -lutil -lz -lpthread
 .endif
 DPADD = ${LIBZ} ${LIBUTIL}
 
-# For now, default to installing binary in ~/bin
-GROUP!=id -g -n
-install:
-	${INSTALL} ${INSTALL_COPY} -o ${USER} -g ${GROUP} \
-	-m ${BINMODE} ${PROG} ${HOME}/bin/${PROG}
-
-# Don't install man pages yet
+.if ${GOT_RELEASE} != "Yes"
 NOMAN = Yes
+.endif
 
+realinstall:
+	${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} \
+	-m ${BINMODE} ${PROG} ${BINDIR}/${PROG}
+
 .include <bsd.prog.mk>
blob - 0e9a3f0ce38fa4e708a2ee6c88f0da7f840032a1
blob + e84148c7b252b8178bf343829492d4ee503dd883
--- tog/tog.1
+++ tog/tog.1
@@ -68,6 +68,8 @@ Global options must precede the command name, and are 
 .Bl -tag -width tenletters
 .It Fl h
 Display usage information.
+.It Fl V
+Display program version and exit immediately.
 .El
 .Pp
 The commands for
blob - 4516ca1b006482d877a7e481e7aaba13ebcedb8e
blob + f686f1e419b03c6090954c62f86a9a7e16788b93
--- tog/tog.c
+++ tog/tog.c
@@ -38,6 +38,7 @@
 #include <libgen.h>
 #include <regex.h>
 
+#include "got_version.h"
 #include "got_error.h"
 #include "got_object.h"
 #include "got_reference.h"
@@ -4510,7 +4511,8 @@ list_commands(void)
 __dead static void
 usage(int hflag)
 {
-	fprintf(stderr, "usage: %s [-h] [command] [arg ...]\n", getprogname());
+	fprintf(stderr, "usage: %s [-h] [-V] [command] [arg ...]\n",
+	    getprogname());
 	if (hflag)
 		list_commands();
 	exit(1);
@@ -4542,16 +4544,19 @@ main(int argc, char *argv[])
 {
 	const struct got_error *error = NULL;
 	struct tog_cmd *cmd = NULL;
-	int ch, hflag = 0;
+	int ch, hflag = 0, Vflag = 0;
 	char **cmd_argv = NULL;
 
 	setlocale(LC_CTYPE, "");
 
-	while ((ch = getopt(argc, argv, "h")) != -1) {
+	while ((ch = getopt(argc, argv, "hV")) != -1) {
 		switch (ch) {
 		case 'h':
 			hflag = 1;
 			break;
+		case 'V':
+			Vflag = 1;
+			break;
 		default:
 			usage(hflag);
 			/* NOTREACHED */
@@ -4563,6 +4568,11 @@ main(int argc, char *argv[])
 	optind = 0;
 	optreset = 1;
 
+	if (Vflag) {
+		got_version_print_str();
+		return 1;
+	}
+
 	if (argc == 0) {
 		if (hflag)
 			usage(hflag);