| [084729c] | 1 | // include config.h | 
|---|
|  | 2 | #ifdef HAVE_CONFIG_H | 
|---|
|  | 3 | #include <config.h> | 
|---|
|  | 4 | #endif | 
|---|
|  | 5 |  | 
|---|
|  | 6 | #include <iostream> | 
|---|
|  | 7 | #include <boost/program_options.hpp> | 
|---|
|  | 8 |  | 
|---|
|  | 9 | #include "codepatterns-config.hpp" | 
|---|
|  | 10 | #include "version.hpp" | 
|---|
|  | 11 |  | 
|---|
|  | 12 | namespace po = boost::program_options; | 
|---|
|  | 13 |  | 
|---|
|  | 14 | /** If pkg-config fails on you, you can call codepatterns-config | 
|---|
|  | 15 | *  in order to retrieve information about how to compile with | 
|---|
|  | 16 | *  CodePatterns. The following options: | 
|---|
|  | 17 | *  -# cflags | 
|---|
|  | 18 | *  -# help | 
|---|
|  | 19 | *  -# ldflags | 
|---|
|  | 20 | *  -# lib | 
|---|
|  | 21 | *  -# version | 
|---|
|  | 22 | *  -# version-full | 
|---|
|  | 23 | * | 
|---|
|  | 24 | * @param argc | 
|---|
|  | 25 | * @param argv | 
|---|
|  | 26 | * @return | 
|---|
|  | 27 | */ | 
|---|
|  | 28 | int main(int argc, char **argv) | 
|---|
|  | 29 | { | 
|---|
|  | 30 | // Declare the supported options. | 
|---|
|  | 31 | po::options_description desc("Allowed options"); | 
|---|
|  | 32 | desc.add_options() | 
|---|
|  | 33 | ("cflags", "give CFLAGS info") | 
|---|
|  | 34 | ("ldflags", "give LDFLAGS info") | 
|---|
|  | 35 | ("libs", "give LIBS info") | 
|---|
|  | 36 | ("help", "give help") | 
|---|
|  | 37 | ("version", "give version info") | 
|---|
|  | 38 | ("version-full", "give fullversion info") | 
|---|
|  | 39 | ; | 
|---|
|  | 40 |  | 
|---|
|  | 41 | po::variables_map vm; | 
|---|
|  | 42 | po::store(po::parse_command_line(argc, argv, desc), vm); | 
|---|
|  | 43 | po::notify(vm); | 
|---|
|  | 44 |  | 
|---|
|  | 45 | // exit right after help | 
|---|
|  | 46 | if (vm.count("help")) { | 
|---|
|  | 47 | std::cout << desc << "\n"; | 
|---|
|  | 48 | return 1; | 
|---|
|  | 49 | } | 
|---|
|  | 50 |  | 
|---|
|  | 51 | // exit right after info | 
|---|
|  | 52 | if (vm.count("version")) { | 
|---|
|  | 53 | std::cout << CODEPATTERNSVERSION << "\n"; | 
|---|
|  | 54 | return 0; | 
|---|
|  | 55 | } | 
|---|
|  | 56 | if (vm.count("version-full")) { | 
|---|
|  | 57 | std::cout << CODEPATTERNSFULLVERSION << "\n"; | 
|---|
|  | 58 | return 0; | 
|---|
|  | 59 | } | 
|---|
|  | 60 |  | 
|---|
|  | 61 | // concatenate all info if desired | 
|---|
|  | 62 | if (vm.count("cflags")) { | 
|---|
|  | 63 | std::cout << CODEPATTERNSCFLAGS << " "; | 
|---|
|  | 64 | } | 
|---|
|  | 65 | if (vm.count("ldflags")) { | 
|---|
|  | 66 | std::cout << CODEPATTERNSLDFLAGS << " "; | 
|---|
|  | 67 | } | 
|---|
|  | 68 | if (vm.count("libs")) { | 
|---|
|  | 69 | std::cout << CODEPATTERNSLIBS << " "; | 
|---|
|  | 70 | } | 
|---|
|  | 71 | std::cout << "\n"; | 
|---|
|  | 72 |  | 
|---|
|  | 73 | return 0; | 
|---|
|  | 74 | } | 
|---|
|  | 75 |  | 
|---|