source: roaraudio/roarclients/roar-config.c @ 5748:dabf3b64218d

Last change on this file since 5748:dabf3b64218d was 5748:dabf3b64218d, checked in by phi, 11 years ago

updated docs

File size: 5.5 KB
Line 
1//roar-config.c:
2
3/*
4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2012
5 *
6 *  This file is part of roarclients a part of RoarAudio,
7 *  a cross-platform sound system for both, home and professional use.
8 *  See README for details.
9 *
10 *  This file is free software; you can redistribute it and/or modify
11 *  it under the terms of the GNU General Public License version 3
12 *  as published by the Free Software Foundation.
13 *
14 *  RoarAudio is distributed in the hope that it will be useful,
15 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 *  GNU General Public License for more details.
18 *
19 *  You should have received a copy of the GNU General Public License
20 *  along with this software; see the file COPYING.  If not, write to
21 *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
22 *  Boston, MA 02110-1301, USA.
23 *
24 */
25
26#include <roaraudio.h>
27
28const struct {
29 const char * name;
30 const char * cflags;
31 const char * libs;
32} flags[] = {
33 // native/own libs:
34 {"roar",      ROAR_CFLAGS, ROAR_LIBS        }, // NOTE: libroar *MUST* be the first entry
35 {"roardsp",   ROAR_CFLAGS, ROAR_LIBS_DSP    },
36 {"roarmidi",  ROAR_CFLAGS, ROAR_LIBS_MIDI   },
37 {"roarlight", ROAR_CFLAGS, ROAR_LIBS_LIGHT  },
38 {"roareio",   ROAR_CFLAGS, ROAR_LIBS_EIO    },
39 // comp libs:
40 {"roaresd",   ROAR_CFLAGS, ROAR_LIBS_C_ESD  },
41 {"esd",       ROAR_CFLAGS, ROAR_LIBS_C_ESD  },
42 {"roarartsc", ROAR_CFLAGS, ROAR_LIBS_C_ARTSC},
43 {"artsc",     ROAR_CFLAGS, ROAR_LIBS_C_ARTSC},
44 {"roarpulse", ROAR_CFLAGS, ROAR_LIBS_C_PULSE},
45 {"pulse",     ROAR_CFLAGS, ROAR_LIBS_C_PULSE},
46 {"roarpulse-simple", ROAR_CFLAGS, ROAR_LIBS_C_PULSE_SIMPLE},
47 {"pulse-simple",     ROAR_CFLAGS, ROAR_LIBS_C_PULSE_SIMPLE},
48 {"roarsndio", ROAR_CFLAGS, ROAR_LIBS_C_SNDIO},
49 {"sndio",     ROAR_CFLAGS, ROAR_LIBS_C_SNDIO},
50 {"roaryiff",  ROAR_CFLAGS, ROAR_LIBS_C_YIFF },
51 {"Y2",        ROAR_CFLAGS, ROAR_LIBS_C_YIFF },
52 {NULL, NULL, NULL}
53}, * flags_ptr = NULL;
54
55void print_path(const char * name, int null_as_universal, const char * product, const char * provider) {
56 char * path = roar_libroar_get_path(name, null_as_universal, product, provider);
57 if ( path == NULL )
58  return;
59 printf("%s\n", path);
60 roar_mm_free(path);
61}
62
63void usage (void) {
64 printf("Usage: roar-config --version\n"
65        "       roar-config [{--output-pc|--output-normal}] [--libs] [--cflags] [LIB]\n"
66        "       roar-config [--product PRODUCT] [--provider PROVIDER] [--universal] --path PATH\n");
67
68 printf("\nOptions:\n\n");
69
70 printf(
71        "  --version           - Show version of library\n"
72        "  --path NAME         - Print path NAME\n"
73        "  --product PRODUCT   - Product string for --path\n"
74        "  --provider PROVIDER - Provider string for --path\n"
75        "  --universal         - Use universal path for --path\n"
76        "  --libs              - Show linker flags (-lxxx) needed to link library\n"
77        "  --cflags            - Show compiler flags needed to link library\n"
78        "  --output-pc         - Output PC format\n"
79        "  --output-normal     - Output in \"classical\" format\n"
80       );
81
82}
83
84#define _strcat(buf, n) strncat(buf, n, sizeof(buf)-1-strlen(buf))
85
86int main (int argc, char * argv[]) {
87 enum { NORMAL, PC } mode = NORMAL;
88 int null_as_universal = 0;
89 const char * product = NULL;
90 const char * provider = NULL;
91 int i, h;
92 int cflags = 0;
93 int libs   = 0;
94 char buf[1024] = {0};
95
96 if ( argc == 1 ) {
97  usage();
98  return 0;
99 }
100
101 for (i = 1; i < argc; i++) {
102  if ( !strcmp(argv[i], "--version") ) {
103   printf("%s\n", COMMON_VERSION);
104  } else if ( !strcmp(argv[i], "--help") || !strcmp(argv[i], "-h") ) {
105   usage();
106   return 0;
107  } else if ( !strcmp(argv[i], "--product") ) {
108   product = argv[++i];
109  } else if ( !strcmp(argv[i], "--provider") ) {
110   provider = argv[++i];
111  } else if ( !strcmp(argv[i], "--universal") ) {
112   null_as_universal = 1;
113  } else if ( !strcmp(argv[i], "--path") ) {
114   print_path(argv[++i], null_as_universal, product, provider);
115  } else if ( !strcmp(argv[i], "--libs") ) {
116   libs   = 1;
117  } else if ( !strcmp(argv[i], "--cflags") ) {
118   cflags = 1;
119  } else if ( !strcmp(argv[i], "--output-normal") ) {
120   mode = NORMAL;
121  } else if ( !strcmp(argv[i], "--output-pc") ) {
122   mode = PC;
123  } else if ( flags_ptr == NULL ) {
124   if ( !strncmp(argv[i], "lib", 3) )
125    argv[i] += 3;
126
127   for (h = 0; flags[h].name != NULL; h++) {
128    if ( !strcasecmp(argv[i], flags[h].name) )
129     flags_ptr = &(flags[h]);
130   }
131
132   if ( flags_ptr == NULL ) {
133    fprintf(stderr, "Unknown lib: %s\n", argv[i]);
134    return 2;
135   }
136  } else {
137   fprintf(stderr, "Unknown option: %s\n", argv[i]);
138   usage();
139   return 1;
140  }
141 }
142
143 if ( flags_ptr == NULL )
144  flags_ptr = &(flags[0]);
145
146 switch (mode) {
147  case NORMAL:
148    if ( cflags || libs ) {
149     if ( cflags )
150      _strcat(buf, flags_ptr->cflags);
151
152     if ( libs )
153      _strcat(buf, flags_ptr->libs);
154
155     puts(buf);
156    }
157   break;
158  case PC:
159    printf(
160           "prefix=%s\n"
161           "exec_prefix=${prefix}\n"
162           "libdir=%s\n"
163           "includedir=%s\n",
164           PREFIX, PREFIX_LIB, PREFIX_INC
165          );
166    printf("\n");
167    printf(
168           "Name: lib%s\n"
169           "Description: lib%s is part of RoarAudio Sound System\n"
170           "Version: %s\n"
171//           "Requires: libroar\n"
172           "Conflicts:\n"
173           "Libs: -L${libdir} %s\n"
174           "Cflags: -I${includedir} %s\n",
175           flags_ptr->name,
176           flags_ptr->name,
177           COMMON_VERSION,
178           flags_ptr->libs,
179           flags_ptr->cflags
180          );
181   break;
182 }
183
184 return 0;
185}
186
187//ll
Note: See TracBrowser for help on using the repository browser.