[143] | 1 | //roar-config.c: |
---|
| 2 | |
---|
[669] | 3 | /* |
---|
[5381] | 4 | * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2012 |
---|
[669] | 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}, |
---|
[3826] | 46 | {"roarpulse-simple", ROAR_CFLAGS, ROAR_LIBS_C_PULSE_SIMPLE}, |
---|
| 47 | {"pulse-simple", ROAR_CFLAGS, ROAR_LIBS_C_PULSE_SIMPLE}, |
---|
[2875] | 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 }, |
---|
[2025] | 52 | {NULL, NULL, NULL} |
---|
| 53 | }, * flags_ptr = NULL; |
---|
| 54 | |
---|
[3093] | 55 | void 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" |
---|
[3827] | 64 | " --output-pc - Output PC format\n" |
---|
| 65 | " --output-normal - Output PC format\n" |
---|
[3093] | 66 | ); |
---|
| 67 | |
---|
| 68 | } |
---|
| 69 | |
---|
[4885] | 70 | #define _strcat(buf, n) strncat(buf, n, sizeof(buf)-1-strlen(buf)) |
---|
| 71 | |
---|
[143] | 72 | int main (int argc, char * argv[]) { |
---|
[3827] | 73 | enum { NORMAL, PC } mode = NORMAL; |
---|
[2025] | 74 | int i, h; |
---|
| 75 | int cflags = 0; |
---|
| 76 | int libs = 0; |
---|
| 77 | char buf[1024] = {0}; |
---|
[144] | 78 | |
---|
| 79 | if ( argc == 1 ) { |
---|
[3093] | 80 | usage(); |
---|
[144] | 81 | return 0; |
---|
| 82 | } |
---|
| 83 | |
---|
| 84 | for (i = 1; i < argc; i++) { |
---|
| 85 | if ( !strcmp(argv[i], "--version") ) { |
---|
[4650] | 86 | printf("%s\n", COMMON_VERSION); |
---|
[3093] | 87 | } else if ( !strcmp(argv[i], "--help") || !strcmp(argv[i], "-h") ) { |
---|
| 88 | usage(); |
---|
| 89 | return 0; |
---|
[144] | 90 | } else if ( !strcmp(argv[i], "--libs") ) { |
---|
[2025] | 91 | libs = 1; |
---|
[144] | 92 | } else if ( !strcmp(argv[i], "--cflags") ) { |
---|
[2025] | 93 | cflags = 1; |
---|
[3827] | 94 | } else if ( !strcmp(argv[i], "--output-normal") ) { |
---|
| 95 | mode = NORMAL; |
---|
| 96 | } else if ( !strcmp(argv[i], "--output-pc") ) { |
---|
| 97 | mode = PC; |
---|
[2025] | 98 | } else if ( flags_ptr == NULL ) { |
---|
[2063] | 99 | if ( !strncmp(argv[i], "lib", 3) ) |
---|
| 100 | argv[i] += 3; |
---|
| 101 | |
---|
[2025] | 102 | for (h = 0; flags[h].name != NULL; h++) { |
---|
| 103 | if ( !strcasecmp(argv[i], flags[h].name) ) |
---|
| 104 | flags_ptr = &(flags[h]); |
---|
| 105 | } |
---|
| 106 | |
---|
| 107 | if ( flags_ptr == NULL ) { |
---|
[3830] | 108 | fprintf(stderr, "Unknown lib: %s", argv[i]); |
---|
[2025] | 109 | return 2; |
---|
| 110 | } |
---|
[144] | 111 | } else { |
---|
| 112 | fprintf(stderr, "Unknown option: %s\n", argv[i]); |
---|
[3093] | 113 | usage(); |
---|
[144] | 114 | return 1; |
---|
| 115 | } |
---|
| 116 | } |
---|
| 117 | |
---|
[2025] | 118 | if ( flags_ptr == NULL ) |
---|
| 119 | flags_ptr = &(flags[0]); |
---|
| 120 | |
---|
[3827] | 121 | switch (mode) { |
---|
| 122 | case NORMAL: |
---|
[4725] | 123 | if ( cflags || libs ) { |
---|
| 124 | if ( cflags ) |
---|
[4885] | 125 | _strcat(buf, flags_ptr->cflags); |
---|
[3827] | 126 | |
---|
[4725] | 127 | if ( libs ) |
---|
[4885] | 128 | _strcat(buf, flags_ptr->libs); |
---|
[2025] | 129 | |
---|
[4725] | 130 | puts(buf); |
---|
| 131 | } |
---|
[3827] | 132 | break; |
---|
| 133 | case PC: |
---|
| 134 | printf( |
---|
| 135 | "prefix=%s\n" |
---|
| 136 | "exec_prefix=${prefix}\n" |
---|
| 137 | "libdir=%s\n" |
---|
| 138 | "includedir=%s\n", |
---|
| 139 | PREFIX, PREFIX_LIB, PREFIX_INC |
---|
| 140 | ); |
---|
| 141 | printf("\n"); |
---|
| 142 | printf( |
---|
| 143 | "Name: lib%s\n" |
---|
[3829] | 144 | "Description: lib%s is part of RoarAudio Sound System\n" |
---|
[3827] | 145 | "Version: %s\n" |
---|
[3828] | 146 | // "Requires: libroar\n" |
---|
[3827] | 147 | "Conflicts:\n" |
---|
| 148 | "Libs: -L${libdir} %s\n" |
---|
| 149 | "Cflags: -I${includedir} %s\n", |
---|
| 150 | flags_ptr->name, |
---|
[3829] | 151 | flags_ptr->name, |
---|
[3827] | 152 | COMMON_VERSION, |
---|
| 153 | flags_ptr->libs, |
---|
| 154 | flags_ptr->cflags |
---|
| 155 | ); |
---|
| 156 | break; |
---|
| 157 | } |
---|
[2025] | 158 | |
---|
[143] | 159 | return 0; |
---|
| 160 | } |
---|
| 161 | |
---|
| 162 | //ll |
---|