[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 |
---|
| 21 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
---|
| 22 | * |
---|
| 23 | */ |
---|
| 24 | |
---|
[144] | 25 | #include <roaraudio.h> |
---|
| 26 | |
---|
[2025] | 27 | struct { |
---|
| 28 | char * name; |
---|
| 29 | char * cflags; |
---|
| 30 | char * libs; |
---|
| 31 | } flags[] = { |
---|
[2875] | 32 | // native/own libs: |
---|
| 33 | {"roar", ROAR_CFLAGS, ROAR_LIBS }, // NOTE: libroar *MUST* be the first entry |
---|
| 34 | {"roardsp", ROAR_CFLAGS, ROAR_LIBS_DSP }, |
---|
| 35 | {"roarmidi", ROAR_CFLAGS, ROAR_LIBS_MIDI }, |
---|
| 36 | {"roarlight", ROAR_CFLAGS, ROAR_LIBS_LIGHT }, |
---|
| 37 | {"roareio", ROAR_CFLAGS, ROAR_LIBS_EIO }, |
---|
| 38 | // comp libs: |
---|
| 39 | {"roaresd", ROAR_CFLAGS, ROAR_LIBS_C_ESD }, |
---|
| 40 | {"esd", ROAR_CFLAGS, ROAR_LIBS_C_ESD }, |
---|
| 41 | {"roarartsc", ROAR_CFLAGS, ROAR_LIBS_C_ARTSC}, |
---|
| 42 | {"artsc", ROAR_CFLAGS, ROAR_LIBS_C_ARTSC}, |
---|
| 43 | {"roarpulse", ROAR_CFLAGS, ROAR_LIBS_C_PULSE}, |
---|
| 44 | {"pulse", ROAR_CFLAGS, ROAR_LIBS_C_PULSE}, |
---|
| 45 | {"pulse-simple", ROAR_CFLAGS, ROAR_LIBS_C_PULSE}, |
---|
| 46 | {"roarsndio", ROAR_CFLAGS, ROAR_LIBS_C_SNDIO}, |
---|
| 47 | {"sndio", ROAR_CFLAGS, ROAR_LIBS_C_SNDIO}, |
---|
| 48 | {"roaryiff", ROAR_CFLAGS, ROAR_LIBS_C_YIFF }, |
---|
| 49 | {"Y2", ROAR_CFLAGS, ROAR_LIBS_C_YIFF }, |
---|
[2025] | 50 | {NULL, NULL, NULL} |
---|
| 51 | }, * flags_ptr = NULL; |
---|
| 52 | |
---|
[143] | 53 | int main (int argc, char * argv[]) { |
---|
[2025] | 54 | int i, h; |
---|
| 55 | int cflags = 0; |
---|
| 56 | int libs = 0; |
---|
| 57 | char buf[1024] = {0}; |
---|
[144] | 58 | |
---|
| 59 | if ( argc == 1 ) { |
---|
[2025] | 60 | printf("Usage: roar-config [--version] [--libs] [--cflags] [lib]\n"); |
---|
[144] | 61 | return 0; |
---|
| 62 | } |
---|
| 63 | |
---|
| 64 | for (i = 1; i < argc; i++) { |
---|
| 65 | if ( !strcmp(argv[i], "--version") ) { |
---|
[145] | 66 | printf("unknown\n"); |
---|
[144] | 67 | } else if ( !strcmp(argv[i], "--libs") ) { |
---|
[2025] | 68 | libs = 1; |
---|
[144] | 69 | } else if ( !strcmp(argv[i], "--cflags") ) { |
---|
[2025] | 70 | cflags = 1; |
---|
| 71 | } else if ( flags_ptr == NULL ) { |
---|
[2063] | 72 | if ( !strncmp(argv[i], "lib", 3) ) |
---|
| 73 | argv[i] += 3; |
---|
| 74 | |
---|
[2025] | 75 | for (h = 0; flags[h].name != NULL; h++) { |
---|
| 76 | if ( !strcasecmp(argv[i], flags[h].name) ) |
---|
| 77 | flags_ptr = &(flags[h]); |
---|
| 78 | } |
---|
| 79 | |
---|
| 80 | if ( flags_ptr == NULL ) { |
---|
| 81 | ROAR_ERR("Unknown lib: %s", argv[i]); |
---|
| 82 | return 2; |
---|
| 83 | } |
---|
[144] | 84 | } else { |
---|
| 85 | fprintf(stderr, "Unknown option: %s\n", argv[i]); |
---|
| 86 | return 1; |
---|
| 87 | } |
---|
| 88 | } |
---|
| 89 | |
---|
[2025] | 90 | if ( flags_ptr == NULL ) |
---|
| 91 | flags_ptr = &(flags[0]); |
---|
| 92 | |
---|
| 93 | if ( cflags ) |
---|
| 94 | strcat(buf, flags_ptr->cflags); |
---|
| 95 | |
---|
| 96 | if ( libs ) |
---|
| 97 | strcat(buf, flags_ptr->libs); |
---|
| 98 | |
---|
| 99 | puts(buf); |
---|
| 100 | |
---|
[143] | 101 | return 0; |
---|
| 102 | } |
---|
| 103 | |
---|
| 104 | //ll |
---|