source: roaraudio/roarclients/roar-config.c @ 4650:6fbaef319bf6

Last change on this file since 4650:6fbaef319bf6 was 4650:6fbaef319bf6, checked in by phi, 13 years ago

corrected version display

File size: 4.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        "  --output-pc        - Output PC format\n"
65        "  --output-normal    - Output PC format\n"
66       );
67
68}
69
70int main (int argc, char * argv[]) {
71 enum { NORMAL, PC } mode = NORMAL;
72 int i, h;
73 int cflags = 0;
74 int libs   = 0;
75 char buf[1024] = {0};
76
77 if ( argc == 1 ) {
78  usage();
79  return 0;
80 }
81
82 for (i = 1; i < argc; i++) {
83  if ( !strcmp(argv[i], "--version") ) {
84   printf("%s\n", COMMON_VERSION);
85  } else if ( !strcmp(argv[i], "--help") || !strcmp(argv[i], "-h") ) {
86   usage();
87   return 0;
88  } else if ( !strcmp(argv[i], "--libs") ) {
89   libs   = 1;
90  } else if ( !strcmp(argv[i], "--cflags") ) {
91   cflags = 1;
92  } else if ( !strcmp(argv[i], "--output-normal") ) {
93   mode = NORMAL;
94  } else if ( !strcmp(argv[i], "--output-pc") ) {
95   mode = PC;
96  } else if ( flags_ptr == NULL ) {
97   if ( !strncmp(argv[i], "lib", 3) )
98    argv[i] += 3;
99
100   for (h = 0; flags[h].name != NULL; h++) {
101    if ( !strcasecmp(argv[i], flags[h].name) )
102     flags_ptr = &(flags[h]);
103   }
104
105   if ( flags_ptr == NULL ) {
106    fprintf(stderr, "Unknown lib: %s", argv[i]);
107    return 2;
108   }
109  } else {
110   fprintf(stderr, "Unknown option: %s\n", argv[i]);
111   usage();
112   return 1;
113  }
114 }
115
116 if ( flags_ptr == NULL )
117  flags_ptr = &(flags[0]);
118
119 switch (mode) {
120  case NORMAL:
121    if ( cflags )
122     strcat(buf, flags_ptr->cflags);
123
124    if ( libs )
125     strcat(buf, flags_ptr->libs);
126
127    puts(buf);
128   break;
129  case PC:
130    printf(
131           "prefix=%s\n"
132           "exec_prefix=${prefix}\n"
133           "libdir=%s\n"
134           "includedir=%s\n",
135           PREFIX, PREFIX_LIB, PREFIX_INC
136          );
137    printf("\n");
138    printf(
139           "Name: lib%s\n"
140           "Description: lib%s is part of RoarAudio Sound System\n"
141           "Version: %s\n"
142//           "Requires: libroar\n"
143           "Conflicts:\n"
144           "Libs: -L${libdir} %s\n"
145           "Cflags: -I${includedir} %s\n",
146           flags_ptr->name,
147           flags_ptr->name,
148           COMMON_VERSION,
149           flags_ptr->libs,
150           flags_ptr->cflags
151          );
152   break;
153 }
154
155 return 0;
156}
157
158//ll
Note: See TracBrowser for help on using the repository browser.