source: roaraudio/roarclients/roar-config.c @ 5673:39fae10996f6

Last change on this file since 5673:39fae10996f6 was 5673:39fae10996f6, checked in by phi, 12 years ago

updated list of prefixes

File size: 5.2 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
55const struct path {
56 const char * name;
57 const char * path;
58} paths[] = {
59 {"prefix",     ROAR_PREFIX},
60 {"prefix-bin", ROAR_PREFIX_BIN},
61 {"prefix-lib", ROAR_PREFIX_LIB},
62 {"prefix-inc", ROAR_PREFIX_INC},
63 {"prefix-man", ROAR_PREFIX_MAN},
64 {"prefix-pc",  ROAR_PREFIX_PC},
65 {"prefix-comp-libs", ROAR_PREFIX_COMP_LIBS},
66 {"prefix-comp-bins", ROAR_PREFIX_COMP_BINS},
67 {"prefix-plugins", ROAR_PREFIX_PLUGINS},
68 {"<<<END>>>", NULL}
69};
70
71void print_path(const char * name) {
72 size_t i;
73
74 for (i = 0; i < (sizeof(paths)/sizeof(*paths)); i++) {
75  if ( !strcasecmp(name, paths[i].name) ) {
76   printf("%s\n", paths[i].path);
77   return;
78  }
79 }
80}
81
82void usage (void) {
83 printf("Usage: roar-config [--version] [--libs] [--cflags] [lib]\n");
84
85 printf("\nOptions:\n\n");
86
87 printf(
88        "  --version          - Show version of library\n"
89        "  --path NAME        - Print path NAME\n"
90        "  --libs             - Show linker flags (-lxxx) needed to link library\n"
91        "  --cflags           - Show compiler flags needed to link library\n"
92        "  --output-pc        - Output PC format\n"
93        "  --output-normal    - Output PC format\n"
94       );
95
96}
97
98#define _strcat(buf, n) strncat(buf, n, sizeof(buf)-1-strlen(buf))
99
100int main (int argc, char * argv[]) {
101 enum { NORMAL, PC } mode = NORMAL;
102 int i, h;
103 int cflags = 0;
104 int libs   = 0;
105 char buf[1024] = {0};
106
107 if ( argc == 1 ) {
108  usage();
109  return 0;
110 }
111
112 for (i = 1; i < argc; i++) {
113  if ( !strcmp(argv[i], "--version") ) {
114   printf("%s\n", COMMON_VERSION);
115  } else if ( !strcmp(argv[i], "--help") || !strcmp(argv[i], "-h") ) {
116   usage();
117   return 0;
118  } else if ( !strcmp(argv[i], "--path") ) {
119   print_path(argv[++i]);
120  } else if ( !strcmp(argv[i], "--libs") ) {
121   libs   = 1;
122  } else if ( !strcmp(argv[i], "--cflags") ) {
123   cflags = 1;
124  } else if ( !strcmp(argv[i], "--output-normal") ) {
125   mode = NORMAL;
126  } else if ( !strcmp(argv[i], "--output-pc") ) {
127   mode = PC;
128  } else if ( flags_ptr == NULL ) {
129   if ( !strncmp(argv[i], "lib", 3) )
130    argv[i] += 3;
131
132   for (h = 0; flags[h].name != NULL; h++) {
133    if ( !strcasecmp(argv[i], flags[h].name) )
134     flags_ptr = &(flags[h]);
135   }
136
137   if ( flags_ptr == NULL ) {
138    fprintf(stderr, "Unknown lib: %s\n", argv[i]);
139    return 2;
140   }
141  } else {
142   fprintf(stderr, "Unknown option: %s\n", argv[i]);
143   usage();
144   return 1;
145  }
146 }
147
148 if ( flags_ptr == NULL )
149  flags_ptr = &(flags[0]);
150
151 switch (mode) {
152  case NORMAL:
153    if ( cflags || libs ) {
154     if ( cflags )
155      _strcat(buf, flags_ptr->cflags);
156
157     if ( libs )
158      _strcat(buf, flags_ptr->libs);
159
160     puts(buf);
161    }
162   break;
163  case PC:
164    printf(
165           "prefix=%s\n"
166           "exec_prefix=${prefix}\n"
167           "libdir=%s\n"
168           "includedir=%s\n",
169           PREFIX, PREFIX_LIB, PREFIX_INC
170          );
171    printf("\n");
172    printf(
173           "Name: lib%s\n"
174           "Description: lib%s is part of RoarAudio Sound System\n"
175           "Version: %s\n"
176//           "Requires: libroar\n"
177           "Conflicts:\n"
178           "Libs: -L${libdir} %s\n"
179           "Cflags: -I${includedir} %s\n",
180           flags_ptr->name,
181           flags_ptr->name,
182           COMMON_VERSION,
183           flags_ptr->libs,
184           flags_ptr->cflags
185          );
186   break;
187 }
188
189 return 0;
190}
191
192//ll
Note: See TracBrowser for help on using the repository browser.