JWS C++ Library
C++ language utility library
|
00001 /* 00002 * This work is licensed under a Creative Commons 00003 * Attribution-Noncommercial-Share Alike 3.0 United States License. 00004 * 00005 * http://creativecommons.org/licenses/by-nc-sa/3.0/us/ 00006 * 00007 * You are free: 00008 * 00009 * to Share - to copy, distribute, display, and perform the work 00010 * to Remix - to make derivative works 00011 * 00012 * Under the following conditions: 00013 * 00014 * Attribution. You must attribute the work in the manner specified by the 00015 * author or licensor (but not in any way that suggests that they endorse you 00016 * or your use of the work). 00017 * 00018 * Noncommercial. You may not use this work for commercial purposes. 00019 * 00020 * Share Alike. If you alter, transform, or build upon this work, you may 00021 * distribute the resulting work only under the same or similar license to 00022 * this one. 00023 * 00024 * For any reuse or distribution, you must make clear to others the license 00025 * terms of this work. The best way to do this is by including this header. 00026 * 00027 * Any of the above conditions can be waived if you get permission from the 00028 * copyright holder. 00029 * 00030 * Apart from the remix rights granted under this license, nothing in this 00031 * license impairs or restricts the author's moral rights. 00032 */ 00033 00034 00075 #include <jwsc++/config.h> 00076 00077 #include <iostream> 00078 00079 #include "jwsc++/base/exception.h" 00080 #include "jwsc++/base/option.h" 00081 00082 00083 using std::cout; 00084 using namespace jwscxx::base; 00085 00086 00088 Options opts; 00089 00090 00092 void print_usage(void) 00093 { 00094 cerr << "usage: jwsc++-config OPTIONS\n"; 00095 cerr << "where OPTION is one or more of the following:\n"; 00096 opts.print(); 00097 } 00098 00099 00101 void process_help_opt(void) 00102 { 00103 print_usage(); 00104 exit(EXIT_SUCCESS); 00105 } 00106 00107 00109 void process_version_opt(void) 00110 { 00111 cout << JWSCXX_PACKAGE_STRING << "\n"; 00112 } 00113 00114 00116 void process_libs_opt(void) 00117 { 00118 system("echo @LIBJWSCXX@ @LIBJWSC@ @LIBJWSC_DEPEND@ @LIBOPENGL@ @LIBOSMESA32@ @LIBOSMESA32_DEPEND@ @LIBX11@ @LIBS@ @LIBDMALLOCXX@ | sed -e 's, , ,g'"); 00119 } 00120 00121 00123 void process_cxxflags_opt(void) 00124 { 00125 cout << "@CXXFLAGS@" << "\n"; 00126 } 00127 00128 00130 void process_cppflags_opt(void) 00131 { 00132 cout << "@CPPFLAGS@" << "\n"; 00133 } 00134 00135 00137 void process_ldflags_opt(void) 00138 { 00139 cout << "@LDFLAGS@" << "\n"; 00140 } 00141 00142 00144 int main(int argc, char** argv) 00145 { 00146 char s_name; 00147 const char* l_name; 00148 const char* desc; 00149 00150 s_name = 'h'; 00151 l_name = "help"; 00152 desc = "Program usage"; 00153 opts.add(new Option_no_arg(s_name, l_name, desc, process_help_opt)); 00154 00155 s_name = 'v'; 00156 l_name = "version"; 00157 desc = "libjwsc++ version."; 00158 opts.add(new Option_no_arg(s_name, l_name, desc, process_version_opt)); 00159 00160 s_name = 0; 00161 l_name = "libs"; 00162 desc = "External library dependencies."; 00163 opts.add(new Option_no_arg(s_name, l_name, desc, process_libs_opt)); 00164 00165 s_name = 0; 00166 l_name = "cxxflags"; 00167 desc = "CXXFLAGS value."; 00168 opts.add(new Option_no_arg(s_name, l_name, desc, process_cxxflags_opt)); 00169 00170 s_name = 0; 00171 l_name = "cppflags"; 00172 desc = "CPPFLAGS value."; 00173 opts.add(new Option_no_arg(s_name, l_name, desc, process_cppflags_opt)); 00174 00175 s_name = 0; 00176 l_name = "ldflags"; 00177 desc = "LDFLAGS value."; 00178 opts.add(new Option_no_arg(s_name, l_name, desc, process_ldflags_opt)); 00179 00180 try 00181 { 00182 opts.process(argc, argv); 00183 } 00184 catch (Arg_error e) 00185 { 00186 cerr << "jwsc++-config: "; 00187 e.print(); 00188 return EXIT_FAILURE; 00189 } 00190 00191 return EXIT_SUCCESS; 00192 }