diff recpt1/Makefile @ 43:9b36fdf7d5d0

show version option has been added
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Fri, 10 Jul 2009 22:36:06 +0900
parents b63f5c100e5a
children f1553492e8bb
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