source: roaraudio/roarclients/roar-config.c @ 5715:0ead15b11f72

Last change on this file since 5715:0ead15b11f72 was 5674:8ffa3afc2d9e, checked in by phi, 12 years ago

Install parts from build system (Closes: #325)

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