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 <stdlib.h> 00078 #include <stdio.h> 00079 00080 #include <jwsc/base/error.h> 00081 #include <jwsc/base/option.h> 00082 00083 00084 #define NUM_OPTS_NO_ARG 6 00085 00086 00088 Option_no_arg opts_no_arg[NUM_OPTS_NO_ARG]; 00089 00090 00092 static void print_usage(void) 00093 { 00094 fprintf(stderr, "usage: jwsc-config OPTIONS\n"); 00095 fprintf(stderr, "where OPTION is one or more of the following:\n"); 00096 print_options(stderr, 25, NUM_OPTS_NO_ARG, opts_no_arg, 0, NULL); 00097 } 00098 00099 00101 static Error* process_help_opt(void) 00102 { 00103 print_usage(); 00104 exit(EXIT_SUCCESS); 00105 return NULL; 00106 } 00107 00108 00110 static Error* process_version_opt(void) 00111 { 00112 fprintf(stdout, "%s\n", JWSC_PACKAGE_STRING); 00113 return NULL; 00114 } 00115 00116 00118 static Error* process_libs_opt(void) 00119 { 00120 system("echo @LIBJWSC@ @LIBMAGICK@ @LIBMAGICK_DEPEND@ @LIBXML2@ @LIBFFTW3@ @LIBFFTW3_DEPEND@ @LIBFFTW3F@ @LIBFFTW3F_DEPEND@ @LIBSLATEC@ @LIBLAPACK@ @LIBBLAS@ @LIBBLAS_DEPEND@ @LIBPTHREAD@ @LIBS@ @LIBDMALLOC@ | sed -e 's, , ,g'"); 00121 return NULL; 00122 } 00123 00124 00126 static Error* process_cflags_opt(void) 00127 { 00128 fprintf(stdout, "%s\n", "@CFLAGS@"); 00129 return NULL; 00130 } 00131 00132 00134 static Error* process_cppflags_opt(void) 00135 { 00136 fprintf(stdout, "%s\n", "@CPPFLAGS@"); 00137 return NULL; 00138 } 00139 00140 00142 static Error* process_ldflags_opt(void) 00143 { 00144 fprintf(stdout, "%s\n", "@LDFLAGS@"); 00145 return NULL; 00146 } 00147 00148 00149 00150 00152 int main(int argc, const char** argv) 00153 { 00154 int argi; 00155 Error* e; 00156 00157 /* Init the options. */ 00158 init_option_no_arg(&(opts_no_arg[0]), "help", 'h', 00159 "Program usage.", process_help_opt); 00160 init_option_no_arg(&(opts_no_arg[1]), "version", 'v', 00161 "libjwsc version.", process_version_opt); 00162 init_option_no_arg(&(opts_no_arg[2]), "libs", 'l', 00163 "External library dependencies.", process_libs_opt); 00164 init_option_no_arg(&(opts_no_arg[3]), "cflags", 'c', 00165 "CFLAGS value.", process_cflags_opt); 00166 init_option_no_arg(&(opts_no_arg[4]), "cppflags", 'p', 00167 "CPPFLAGS value.", process_cppflags_opt); 00168 init_option_no_arg(&(opts_no_arg[5]), "ldflags", 'd', 00169 "LDFLAGS value.", process_ldflags_opt); 00170 00171 /* Check for the help option first. */ 00172 process_option_no_arg(argc, argv, &argi, &(opts_no_arg[0])); 00173 00174 if ((e = process_options(argc, argv, &argi, NUM_OPTS_NO_ARG, opts_no_arg, 00175 0, NULL)) != NULL) 00176 { 00177 print_error_msg_exit("jwsc-config", e->msg); 00178 } 00179 00180 if (argc <= 1) 00181 { 00182 print_usage(); 00183 } 00184 00185 return EXIT_SUCCESS; 00186 }