[143] | 1 | //roar-config.c: |
---|
| 2 | |
---|
[669] | 3 | /* |
---|
| 4 | * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008 |
---|
| 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 |
---|
[3517] | 21 | * the Free Software Foundation, 51 Franklin Street, Fifth Floor, |
---|
| 22 | * Boston, MA 02110-1301, USA. |
---|
[669] | 23 | * |
---|
| 24 | */ |
---|
| 25 | |
---|
[144] | 26 | #include <roaraudio.h> |
---|
| 27 | |
---|
[2025] | 28 | struct { |
---|
| 29 | char * name; |
---|
| 30 | char * cflags; |
---|
| 31 | char * libs; |
---|
| 32 | } flags[] = { |
---|
[2875] | 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 | {"pulse-simple", ROAR_CFLAGS, ROAR_LIBS_C_PULSE}, |
---|
| 47 | {"roarsndio", ROAR_CFLAGS, ROAR_LIBS_C_SNDIO}, |
---|
| 48 | {"sndio", ROAR_CFLAGS, ROAR_LIBS_C_SNDIO}, |
---|
| 49 | {"roaryiff", ROAR_CFLAGS, ROAR_LIBS_C_YIFF }, |
---|
| 50 | {"Y2", ROAR_CFLAGS, ROAR_LIBS_C_YIFF }, |
---|
[2025] | 51 | {NULL, NULL, NULL} |
---|
| 52 | }, * flags_ptr = NULL; |
---|
| 53 | |
---|
[3093] | 54 | void usage (void) { |
---|
| 55 | printf("Usage: roar-config [--version] [--libs] [--cflags] [lib]\n"); |
---|
| 56 | |
---|
| 57 | printf("\nOptions:\n\n"); |
---|
| 58 | |
---|
| 59 | printf( |
---|
| 60 | " --version - Show version of library\n" |
---|
| 61 | " --libs - Show linker flags (-lxxx) needed to link library\n" |
---|
| 62 | " --cflags - Show compiler flags needed to link library\n" |
---|
| 63 | ); |
---|
| 64 | |
---|
| 65 | } |
---|
| 66 | |
---|
[143] | 67 | int main (int argc, char * argv[]) { |
---|
[2025] | 68 | int i, h; |
---|
| 69 | int cflags = 0; |
---|
| 70 | int libs = 0; |
---|
| 71 | char buf[1024] = {0}; |
---|
[144] | 72 | |
---|
| 73 | if ( argc == 1 ) { |
---|
[3093] | 74 | usage(); |
---|
[144] | 75 | return 0; |
---|
| 76 | } |
---|
| 77 | |
---|
| 78 | for (i = 1; i < argc; i++) { |
---|
| 79 | if ( !strcmp(argv[i], "--version") ) { |
---|
[145] | 80 | printf("unknown\n"); |
---|
[3093] | 81 | } else if ( !strcmp(argv[i], "--help") || !strcmp(argv[i], "-h") ) { |
---|
| 82 | usage(); |
---|
| 83 | return 0; |
---|
[144] | 84 | } else if ( !strcmp(argv[i], "--libs") ) { |
---|
[2025] | 85 | libs = 1; |
---|
[144] | 86 | } else if ( !strcmp(argv[i], "--cflags") ) { |
---|
[2025] | 87 | cflags = 1; |
---|
| 88 | } else if ( flags_ptr == NULL ) { |
---|
[2063] | 89 | if ( !strncmp(argv[i], "lib", 3) ) |
---|
| 90 | argv[i] += 3; |
---|
| 91 | |
---|
[2025] | 92 | for (h = 0; flags[h].name != NULL; h++) { |
---|
| 93 | if ( !strcasecmp(argv[i], flags[h].name) ) |
---|
| 94 | flags_ptr = &(flags[h]); |
---|
| 95 | } |
---|
| 96 | |
---|
| 97 | if ( flags_ptr == NULL ) { |
---|
| 98 | ROAR_ERR("Unknown lib: %s", argv[i]); |
---|
| 99 | return 2; |
---|
| 100 | } |
---|
[144] | 101 | } else { |
---|
| 102 | fprintf(stderr, "Unknown option: %s\n", argv[i]); |
---|
[3093] | 103 | usage(); |
---|
[144] | 104 | return 1; |
---|
| 105 | } |
---|
| 106 | } |
---|
| 107 | |
---|
[2025] | 108 | if ( flags_ptr == NULL ) |
---|
| 109 | flags_ptr = &(flags[0]); |
---|
| 110 | |
---|
| 111 | if ( cflags ) |
---|
| 112 | strcat(buf, flags_ptr->cflags); |
---|
| 113 | |
---|
| 114 | if ( libs ) |
---|
| 115 | strcat(buf, flags_ptr->libs); |
---|
| 116 | |
---|
| 117 | puts(buf); |
---|
| 118 | |
---|
[143] | 119 | return 0; |
---|
| 120 | } |
---|
| 121 | |
---|
| 122 | //ll |
---|