add 'make release' target; programs now have a version number
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735
diff --git a/Makefile b/Makefile
index fe39f25..c0879af 100644
--- a/Makefile
+++ b/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>
diff --git a/Makefile.inc b/Makefile.inc
index e9583da..808b2d9 100644
--- a/Makefile.inc
+++ b/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
diff --git a/README b/README
index 5002f68..a7df9bc 100644
--- a/README
+++ b/README
@@ -12,14 +12,17 @@ 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).
@@ -27,7 +30,7 @@ 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
diff --git a/got-dist.txt b/got-dist.txt
new file mode 100644
index 0000000..ead26b8
--- /dev/null
+++ b/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
diff --git a/got-version.mk b/got-version.mk
new file mode 100644
index 0000000..3764a81
--- /dev/null
+++ b/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
diff --git a/got/Makefile b/got/Makefile
index d6f07ad..466e02e 100644
--- a/got/Makefile
+++ b/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 diffoffset.c \
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>
diff --git a/got/got.1 b/got/got.1
index fb33529..a51741e 100644
--- a/got/got.1
+++ b/got/got.1
@@ -54,6 +54,8 @@ Global options must preceed the command name, and are as follows:
.Bl -tag -width tenletters
.It Fl h
Display usage information.
+.It Fl V
+Display program version and exit immediately.
.El
.Pp
The commands for
diff --git a/got/got.c b/got/got.c
index 7c2acec..2eae149 100644
--- a/got/got.c
+++ b/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,15 +157,18 @@ 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);
/* NOTREACHED */
@@ -175,6 +179,11 @@ main(int argc, char *argv[])
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);
diff --git a/include/got_version.h b/include/got_version.h
new file mode 100644
index 0000000..eacaf1a
--- /dev/null
+++ b/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);
+}
diff --git a/libexec/Makefile.inc b/libexec/Makefile.inc
index 01b5f23..da3924e 100644
--- a/libexec/Makefile.inc
+++ b/libexec/Makefile.inc
@@ -1 +1,7 @@
.include "../Makefile.inc"
+
+realinstall:
+ ${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} \
+ -m ${BINMODE} ${PROG} ${LIBEXECDIR}/${PROG}
+
+NOMAN = Yes
diff --git a/libexec/got-read-blob/Makefile b/libexec/got-read-blob/Makefile
index a946ea4..17ab97b 100644
--- a/libexec/got-read-blob/Makefile
+++ b/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}/../../lib
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>
diff --git a/libexec/got-read-commit/Makefile b/libexec/got-read-commit/Makefile
index c08ff1e..3f6f7ca 100644
--- a/libexec/got-read-commit/Makefile
+++ b/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}/../../lib
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>
diff --git a/libexec/got-read-object/Makefile b/libexec/got-read-object/Makefile
index 5936393..2634211 100644
--- a/libexec/got-read-object/Makefile
+++ b/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}/../../lib
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>
diff --git a/libexec/got-read-pack/Makefile b/libexec/got-read-pack/Makefile
index a583c3b..e50b725 100644
--- a/libexec/got-read-pack/Makefile
+++ b/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}/../../lib
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>
diff --git a/libexec/got-read-tag/Makefile b/libexec/got-read-tag/Makefile
index 0d2ce55..a8026e4 100644
--- a/libexec/got-read-tag/Makefile
+++ b/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}/../../lib
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>
diff --git a/libexec/got-read-tree/Makefile b/libexec/got-read-tree/Makefile
index 829da95..397775d 100644
--- a/libexec/got-read-tree/Makefile
+++ b/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}/../../lib
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>
diff --git a/regress/Makefile.inc b/regress/Makefile.inc
index 01b5f23..0e402c4 100644
--- a/regress/Makefile.inc
+++ b/regress/Makefile.inc
@@ -1 +1,2 @@
+.include "../got-version.mk"
.include "../Makefile.inc"
diff --git a/regress/repository/Makefile b/regress/repository/Makefile
index 1f0934b..6341b04 100644
--- a/regress/repository/Makefile
+++ b/regress/repository/Makefile
@@ -7,8 +7,7 @@ SRCS = path.c repository.c error.c reference.c object.c object_cache.c \
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
diff --git a/regress/worktree/Makefile b/regress/worktree/Makefile
index ef7ee8b..c29a98d 100644
--- a/regress/worktree/Makefile
+++ b/regress/worktree/Makefile
@@ -7,8 +7,7 @@ SRCS = worktree.c repository.c object.c object_cache.c object_idset.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
diff --git a/tog/Makefile b/tog/Makefile
index f627a28..2c808a8 100644
--- a/tog/Makefile
+++ b/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 diffoffset.c \
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
-CPPFLAGS = -I${.CURDIR}/../include -I${.CURDIR}/../lib \
- -DGOT_LIBEXECDIR=${GOT_LIBEXECDIR}
.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>
diff --git a/tog/tog.1 b/tog/tog.1
index 0e9a3f0..e84148c 100644
--- a/tog/tog.1
+++ b/tog/tog.1
@@ -68,6 +68,8 @@ Global options must precede the command name, and are as follows:
.Bl -tag -width tenletters
.It Fl h
Display usage information.
+.It Fl V
+Display program version and exit immediately.
.El
.Pp
The commands for
diff --git a/tog/tog.c b/tog/tog.c
index 4516ca1..f686f1e 100644
--- a/tog/tog.c
+++ b/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);