source: roaraudio/roarclients/roar-config.c @ 3826:105d7a8bf965

Last change on this file since 3826:105d7a8bf965 was 3826:105d7a8bf965, checked in by phi, 14 years ago

corrected support for libroarpulse-simple

File size: 3.3 KB
Line 
1//roar-config.c:
2
3/*
4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2010
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
28struct {
29 char * name;
30 char * cflags;
31 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 usage (void) {
56 printf("Usage: roar-config [--version] [--libs] [--cflags] [lib]\n");
57
58 printf("\nOptions:\n\n");
59
60 printf(
61        "  --version          - Show version of library\n"
62        "  --libs             - Show linker flags (-lxxx) needed to link library\n"
63        "  --cflags           - Show compiler flags needed to link library\n"
64       );
65
66}
67
68int main (int argc, char * argv[]) {
69 int i, h;
70 int cflags = 0;
71 int libs   = 0;
72 char buf[1024] = {0};
73
74 if ( argc == 1 ) {
75  usage();
76  return 0;
77 }
78
79 for (i = 1; i < argc; i++) {
80  if ( !strcmp(argv[i], "--version") ) {
81   printf("unknown\n");
82  } else if ( !strcmp(argv[i], "--help") || !strcmp(argv[i], "-h") ) {
83   usage();
84   return 0;
85  } else if ( !strcmp(argv[i], "--libs") ) {
86   libs   = 1;
87  } else if ( !strcmp(argv[i], "--cflags") ) {
88   cflags = 1;
89  } else if ( flags_ptr == NULL ) {
90   if ( !strncmp(argv[i], "lib", 3) )
91    argv[i] += 3;
92
93   for (h = 0; flags[h].name != NULL; h++) {
94    if ( !strcasecmp(argv[i], flags[h].name) )
95     flags_ptr = &(flags[h]);
96   }
97
98   if ( flags_ptr == NULL ) {
99    ROAR_ERR("Unknown lib: %s", argv[i]);
100    return 2;
101   }
102  } else {
103   fprintf(stderr, "Unknown option: %s\n", argv[i]);
104   usage();
105   return 1;
106  }
107 }
108
109 if ( flags_ptr == NULL )
110  flags_ptr = &(flags[0]);
111
112 if ( cflags )
113  strcat(buf, flags_ptr->cflags);
114
115 if ( libs )
116  strcat(buf, flags_ptr->libs);
117
118 puts(buf);
119
120 return 0;
121}
122
123//ll
Note: See TracBrowser for help on using the repository browser.