automatically include program version and print it from vty and --version
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;