a9d571ec34221359111a6fb74b89d2ea538e09a4
[svn42.git] / dart-sounds / src / configure
1 #!/bin/sh
2 #
3 #  dart-sounds
4 #
5 #
6 #  Copyright (C) 2011 Christian Pointner <equinox@realraum.at>
7 #                         
8 #  This file is part of dart-sounds.
9 #
10 #  dart-sounds is free software: you can redistribute it and/or modify
11 #  it under the terms of the GNU General Public License as published by
12 #  the Free Software Foundation, either version 3 of the License, or
13 #  any later version.
14 #
15 #  dart-sounds is distributed in the hope that it will be useful,
16 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
17 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 #  GNU General Public License for more details.
19 #
20 #  You should have received a copy of the GNU General Public License
21 #  along with dart-sounds. If not, see <http://www.gnu.org/licenses/>.
22 #
23
24 set -e
25
26 TARGET=`uname -s`
27 EBUILD_COMPAT=0
28
29 CFLAGS='-g -O2'
30 LDFLAGS='-g -Wall -O2'
31
32 PREFIX='/usr/local'
33 BINDIR=''
34
35 print_usage() {
36   echo "configure --help                    print this"
37   echo "          --target=<TARGET>         build target i.e. Linux (default: autodetect)"
38   echo "          --prefix=<PREFIX>         the installation prefix (default: /usr/local)"
39   echo "          --bindir=<DIR>            the path to the bin directory (default: $PREFIX/bin)"
40 }
41
42 for arg
43 do
44   case $arg in
45   --target=*)
46     TARGET=${arg#--target=}
47   ;;
48   --prefix=*)
49     PREFIX=${arg#--prefix=}
50   ;;
51   --bindir=*)
52     BINDIR=${arg#--bindir=}
53   ;;
54   --ebuild-compat)
55     EBUILD_COMPAT=1
56   ;;
57   --help)
58     print_usage
59     exit 0
60   ;;
61   *)
62     ERRORS="$ERRORS $arg"
63   ;;
64   esac
65 done
66
67 if [ -n "$ERRORS" ] && [ $EBUILD_COMPAT -ne 1 ]; then
68   for error in $ERRORS; do
69     echo "Unknown argument: $error"
70   done
71
72   print_usage
73   exit 1
74 fi
75
76 CFLAGS="$CFLAGS $(pkg-config --cflags gstreamer-0.10)"
77 LDFLAGS="$LDFLAGS $(pkg-config --libs gstreamer-0.10)"
78
79 rm -f include.mk
80 rm -f config.h
81 case $TARGET in
82   Linux)
83   ;;
84   OpenBSD|FreeBSD|NetBSD|GNU/kFreeBSD)
85     CFLAGS=$CFLAGS' -I/usr/local/include'
86     LDFLAGS=$LDFLAGS' -L/usr/local/lib'
87   ;;
88   *)
89     echo "platform not supported"
90     exit 1;
91   ;;
92 esac
93
94 if [ -z "$BINDIR" ]; then
95   BINDIR=$PREFIX/bin
96 fi
97
98 if [ -z "$MANDIR" ]; then
99   MANDIR=$PREFIX/share/man
100 fi
101
102 cat > include.mk <<EOF
103 # this file was created automatically
104 # do not edit this file directly
105 # use ./configure instead
106
107 TARGET := '$TARGET'
108 CC := gcc
109 CFLAGS := $CFLAGS
110 LDFLAGS := $LDFLAGS
111 STRIP := strip
112 INSTALL := install
113 RAGEL := ragel
114
115 PREFIX := '$PREFIX'
116 BINDIR := '$BINDIR'
117 EOF
118
119 HOSTNAME=`hostname`
120 DATE=`date +"%d.%m.%Y %H:%M:%S %Z"`
121
122 cat > config.h <<EOF
123 /*
124  * dart-sounds config header
125  *
126  * this file was created automatically
127  * do not edit this file directly
128  * use ./configure instead
129  */
130
131 #ifndef DART_SOUNDS_config_h_INCLUDED
132 #define DART_SOUNDS_config_h_INCLUDED
133
134 #define VERSION_STRING_0 "dart-sounds version $VERSION"
135 #define VERSION_STRING_1 "built on $HOSTNAME, $DATE"
136
137 #define TARGET "$TARGET"
138 #define PREFIX "$PREFIX"
139 #define BINDIR "$BINDIR"
140
141 #endif
142 EOF
143
144 exit 0