changeset 43:9b36fdf7d5d0

show version option has been added
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Fri, 10 Jul 2009 22:36:06 +0900
parents a35e352f6c4a
children 07d71b1484a8
files recpt1/Makefile recpt1/recpt1.c
diffstat 2 files changed, 24 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/recpt1/Makefile	Fri Jun 05 16:34:28 2009 +0900
+++ b/recpt1/Makefile	Fri Jul 10 22:36:06 2009 +0900
@@ -1,3 +1,6 @@
+TARGET = recpt1
+RELEASE_VERSION = '1.0.0'
+
 PREFIX   = /usr/local
 CC       = gcc
 CPPFLAGS = -I../driver -Wall -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DB25
@@ -9,21 +12,28 @@
 LDFLAGS  =
 
 OBJS   = recpt1.o decoder.o
-TARGET = recpt1
-DEPEND = Makefile.dep
+DEPEND = .deps
 
 all: $(TARGET)
 
 clean:
-	rm -f $(OBJS) $(TARGET) $(DEPEND)
+	rm -f $(OBJS) $(TARGET) $(DEPEND) version.h
 
 $(TARGET): $(OBJS)
 	$(CC) $(LDFLAGS) -o $(TARGET) $(OBJS) $(LIBS)
 
-$(DEPEND):
+$(DEPEND): version.h
 	$(CC) -MM $(OBJS:.o=.c) $(CPPFLAGS) > $@
 
+version.h:
+	if test -d ../.hg ; then \
+		revh=`hg parents --template 'const char *version = "r#rev#:#node|short# (#date|isodate#)";\n' 2>/dev/null`; \
+		[ -z "$$revh" ] || echo "$$revh" > $@; \
+	else \
+		echo "const char *version = \"$(RELEASE_VERSION)\";" > $@; \
+	fi
+
 install: $(TARGET)
 	install -m 755 $(TARGET) $(PREFIX)/bin
 
--include Makefile.dep
+-include .deps
--- a/recpt1/recpt1.c	Fri Jun 05 16:34:28 2009 +0900
+++ b/recpt1/recpt1.c	Fri Jul 10 22:36:06 2009 +0900
@@ -22,6 +22,7 @@
 
 #include "recpt1.h"
 #include "decoder.h"
+#include "version.h"
 
 /* maximum write length at once */
 #define SIZE_CHANK 1316
@@ -329,6 +330,7 @@
     fprintf(stderr, "  --port portnumber: Port number to connect\n");
     fprintf(stderr, "--device devicefile: Specify devicefile to use\n");
     fprintf(stderr, "--help:              Show this help\n");
+    fprintf(stderr, "--version:           Show version\n");
     fprintf(stderr, "\n");
 }
 void
@@ -540,6 +542,7 @@
         { "port",      1, NULL, 'p'},
         { "device",    1, NULL, 'd'},
         { "help",      0, NULL, 'h'},
+        { "version",   0, NULL, 'v'},
         {0, 0, NULL, 0} /* terminate */
     };
 
@@ -554,7 +557,7 @@
     char **tuner;
     int num_devs;
 
-    while((result = getopt_long(argc, argv, "br:smua:p:d:h",
+    while((result = getopt_long(argc, argv, "br:smua:p:d:hv",
                                 long_options, &option_index)) != -1) {
         switch(result) {
         case 'b':
@@ -580,6 +583,11 @@
             show_channels();
             exit(0);
             break;
+        case 'v':
+            fprintf(stderr, "%s %s\n", argv[0], version);
+            fprintf(stderr, "recorder command for PT1 digital tuner.\n");
+            exit(0);
+            break;
         /* following options require argument */
         case 'r':
             dopt.round = atoi(optarg);