automatically include program version and print it from vty and --version
diff --git a/openbsc/src/bsc_hack.c b/openbsc/src/bsc_hack.c
index 49c9d36..2405cee 100644
--- a/openbsc/src/bsc_hack.c
+++ b/openbsc/src/bsc_hack.c
@@ -37,12 +37,21 @@
 #include <osmocore/talloc.h>
 #include <openbsc/signal.h>
 
+#include "../bscconfig.h"
+
 /* MCC and MNC for the Location Area Identifier */
 static struct debug_target *stderr_target;
 struct gsm_network *bsc_gsmnet = 0;
 static const char *database_name = "hlr.sqlite3";
 static const char *config_file = "openbsc.cfg";
-
+const char *openbsc_version = "OpenBSC " PACKAGE_VERSION;
+const char *openbsc_copyright =
+	"Copyright (C) 2008-2010 Harald Welte, Holger Freyther\n"
+	"Contributions by Daniel Willmann, Jan Lübbe,Stefan Schmidt\n"
+	"Dieter Spaar, Andreas Eversberg\n\n"
+	"License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>\n"
+	"This is free software: you are free to change and redistribute it.\n"
+	"There is NO WARRANTY, to the extent permitted by law.\n";
 
 /* timer to store statistics */
 #define DB_SYNC_INTERVAL	60, 0
@@ -83,6 +92,16 @@
 	printf("  -P --rtp-proxy Enable the RTP Proxy code inside OpenBSC\n");
 }
 
+static void print_version()
+{
+	printf("%s\n", openbsc_version);
+}
+
+static void print_copyright()
+{
+	printf(openbsc_copyright);
+}
+
 static void handle_options(int argc, char** argv)
 {
 	while (1) {
@@ -96,11 +115,12 @@
 			{"authorize-everyone", 0, 0, 'a'},
 			{"pcap", 1, 0, 'p'},
 			{"timestamp", 0, 0, 'T'},
+			{"version", 0, 0, 'V' },
 			{"rtp-proxy", 0, 0, 'P'},
 			{0, 0, 0, 0}
 		};
 
-		c = getopt_long(argc, argv, "hd:sl:ar:p:TPc:",
+		c = getopt_long(argc, argv, "hd:sl:ar:p:TPVc:",
 				long_options, &option_index);
 		if (c == -1)
 			break;
@@ -131,6 +151,12 @@
 		case 'P':
 			ipacc_rtp_direct = 0;
 			break;
+		case 'V':
+			print_version();
+			printf("\n");
+			print_copyright();
+			exit(0);
+			break;
 		default:
 			/* ignore */
 			break;
diff --git a/openbsc/src/mgcp/mgcp_main.c b/openbsc/src/mgcp/mgcp_main.c
index cea0ba4..e45a1e9 100644
--- a/openbsc/src/mgcp/mgcp_main.c
+++ b/openbsc/src/mgcp/mgcp_main.c
@@ -40,6 +40,8 @@
 #include <openbsc/mgcp.h>
 #include <openbsc/telnet_interface.h>
 
+#include "../../bscconfig.h"
+
 /* this is here for the vty... it will never be called */
 void subscr_put() { abort(); }
 
@@ -51,6 +53,14 @@
 static struct bsc_fd bfd;
 static int first_request = 1;
 static struct mgcp_config *cfg;
+const char *openbsc_version = "OpenBSC MGCP " PACKAGE_VERSION;
+const char *openbsc_copyright = 
+	"Copyright (C) 2009-2010 Holger Freyther and On-Waves\n"
+	"Contributions by Daniel Willmann, Jan Lübbe,Stefan Schmidt\n"
+	"Dieter Spaar, Andreas Eversberg, Harald Welte\n\n"
+	"License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>\n"
+	"This is free software: you are free to change and redistribute it.\n"
+	"There is NO WARRANTY, to the extent permitted by law.\n";
 
 static char *config_file = "mgcp.cfg";
 
@@ -64,6 +74,12 @@
 	printf(" -c --config-file filename The config file to use.\n");
 }
 
+static void print_version()
+{
+	printf("%s\n\n", openbsc_version);
+	printf(openbsc_copyright);
+}
+
 static void handle_options(int argc, char** argv)
 {
 	while (1) {
@@ -71,10 +87,11 @@
 		static struct option long_options[] = {
 			{"help", 0, 0, 'h'},
 			{"config-file", 1, 0, 'c'},
+			{"version", 0, 0, 'V'},
 			{0, 0, 0, 0},
 		};
 
-		c = getopt_long(argc, argv, "hc:", long_options, &option_index);
+		c = getopt_long(argc, argv, "hc:V", long_options, &option_index);
 
 		if (c == -1)
 			break;
@@ -87,6 +104,10 @@
 		case 'c':
 			config_file = talloc_strdup(tall_bsc_ctx, optarg);
 			break;
+		case 'V':
+			print_version();
+			exit(0);
+			break;
 		default:
 			/* ignore */
 			break;
diff --git a/openbsc/src/telnet_interface.c b/openbsc/src/telnet_interface.c
index 805dd12..aa119b4 100644
--- a/openbsc/src/telnet_interface.c
+++ b/openbsc/src/telnet_interface.c
@@ -98,21 +98,16 @@
 	bsc_register_fd(&server_socket);
 }
 
+extern const char *openbsc_copyright;
+extern const char *openbsc_version;
+
 static void print_welcome(int fd) {
 	int ret;
 	static char *msg =
-		"Welcome to the OpenBSC Control interface\n"
-		"Copyright (C) 2008-2010 Harald Welte\n"
-		"Contributions by Daniel Willmann, Jan Lübbe, "
-		"Stefan Schmidt, Holger Freyther, Andreas Eversberg\n\n"
-		"License GPLv2+: GNU GPL version 2 or later "
-		"<http://gnu.org/licenses/gpl.html>\n"
-		"This is free software: you are free to change "
-		"and redistribute it.\n"
-		"There is NO WARRANTY, to the extent permitted "
-		"by law.\nType \"help\" to get a short introduction.\n";
+		"Welcome to the OpenBSC Control interface\n";
 
 	ret = write(fd, msg, strlen(msg));
+	ret = write(fd, openbsc_copyright, strlen(openbsc_copyright));
 }
 
 int telnet_close_client(struct bsc_fd *fd) {
diff --git a/openbsc/src/vty/cardshell.h b/openbsc/src/vty/cardshell.h
index d963a38..85164d2 100644
--- a/openbsc/src/vty/cardshell.h
+++ b/openbsc/src/vty/cardshell.h
@@ -1,5 +1,6 @@
-#define QUAGGA_PROGNAME	"OpenBSC"
-#define QUAGGA_VERSION	"0.01"
+#include "../../bscconfig.h"
+#define QUAGGA_PROGNAME	PACKAGE_NAME
+#define QUAGGA_VERSION	PACKAGE_VERSION
 #define QUAGGA_COPYRIGHT "Harald Welte <laforge@gnumonks.org>"
 #define CONFIGFILE_MASK 022
 #define SYSCONFDIR "/usr/local/etc"