Implements ticket:401 and ticket:402.
[debian/gnuradio] / gnuradio-core / src / lib / gnuradio.cc
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2009 Free Software Foundation, Inc.
4  * 
5  * This file is part of GNU Radio
6  * 
7  * GNU Radio is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3, or (at your option)
10  * any later version.
11  * 
12  * GNU Radio is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  * 
17  * You should have received a copy of the GNU General Public License
18  * along with GNU Radio; see the file COPYING.  If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street,
20  * Boston, MA 02110-1301, USA.
21  */
22
23 #if HAVE_CONFIG_H
24 #include <config.h>
25 #endif
26
27 #include <gr_constants.h>
28 #include <boost/program_options.hpp>
29 #include <iostream>
30
31 namespace po = boost::program_options;
32
33 int
34 main(int argc, char **argv)
35 {
36   po::options_description desc("Program options: gnuradio [options]");
37   po::variables_map vm;
38
39   desc.add_options()
40     ("help,h", "print help message")
41     ("prefix", "print gnuradio installation prefix")
42     ("sysconfdir", "print gnuradio system configuration directory")
43     ("prefsdir", "print gnuradio preferences directory")
44     ("builddate", "print gnuradio build date (RFC2822 format)")
45     ("version,v", "print gnuradio version")
46     ("svnversion", "print SVN repository version (SVN format)")
47     ("svndate", "print SVN repository date")
48     ;
49
50   po::store(po::parse_command_line(argc, argv, desc), vm);
51   po::notify(vm);
52
53   if (vm.size() == 0 || vm.count("help")) {
54     std::cout << desc << std::endl;
55     return 1;
56   }
57       
58   if (vm.count("prefix"))
59     std::cout << gr_prefix() << std::endl;
60
61   if (vm.count("sysconfdir"))
62     std::cout << gr_sysconfdir() << std::endl;
63
64   if (vm.count("prefsdir"))
65     std::cout << gr_prefsdir() << std::endl;
66
67   if (vm.count("builddate"))
68     std::cout << gr_build_date() << std::endl;
69
70   if (vm.count("version"))
71     std::cout << gr_version() << std::endl;
72
73   if (vm.count("svnversion"))
74     std::cout << gr_svn_version() << std::endl;
75
76   if (vm.count("svndate"))
77     std::cout << gr_svn_date() << std::endl;
78
79   return 0;
80 }