forked from darrensessions/app_swift
-
Notifications
You must be signed in to change notification settings - Fork 6
/
configure
executable file
·169 lines (146 loc) · 4.81 KB
/
configure
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#!/bin/sh
# configure for app_swift -- A Cepstral Swift TTS engine interface
#
# Copyright (C) 2013 - 2016, Jeremy Kister
#
# This program is free software, distributed under the
# terms of the GNU General Public License Version 2. See
# the LICENSE file at the top of the source tree for more
# information.
usage() {
cat <<__EOU__
'configure' configures app_swift to adapt to many kinds of systems.
Usage: [VAR=VALUE]... ./configure [OPTION]...
To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE. See below for descriptions of some of the useful variables.
Defaults for the options are specified in brackets.
Configuration:
--help this help message
--swiftdir directory to swift [/opt/swift]
--includedir asterisk include directory [/usr/include]
--libdir asterisk library directory [/usr/lib]
--vardir asterisk var lib directory [/var/lib]
--sysconfdir asterisk etc directory [/etc]
Some influential environment variables:
CC C compiler command
CFLAGS C compiler flags
LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
nonstandard directory <lib dir>
LIBS libraries to pass to the linker, e.g. -l<library>
Use these variables to override the choices made by 'configure' or to help
it to find libraries and programs with nonstandard names/locations.
Report bugs to <https://github.com/dmsessions/app_swift/issues>
__EOU__
}
while getopts ':h-' OPTION ; do
case "$OPTION" in
h)
usage
exit
;;
-)
[ $OPTIND -ge 1 ] && optind=`expr $OPTIND - 1` || optind=$OPTIND
eval OPTION="\$$optind"
OPTARG=`echo $OPTION | cut -d'=' -f2`
OPTION=`echo $OPTION | cut -d'=' -f1`
case "$OPTION" in
--swiftdir)
SWIFT_DIR=$OPTARG
;;
--includedir)
INC_DIR=$OPTARG
;;
--vardir)
VAR_DIR=$OPTARG
;;
--libdir)
LIB_DIR=$OPTARG
;;
--sysconfdir)
CNF_DIR=$OPTARG
;;
--help)
usage
exit
;;
*)
echo "invalid argument: $OPTION"
echo "use ./configure --help"
exit 1
;;
esac
OPTIND=1
shift
;;
*)
echo "invalid argument: $OPTION"
echo "use ./configure --help"
exit 1
;;
esac
done
CC=${CC-gcc}
echo "checking $CC..."
echo 'int main(void){return 0;}' > astest.c
if [ $? -gt 0 ] ; then
echo "Could not test compiler!"
exit 1
fi
$CC -o astest astest.c
code=$?
rm astest astest.c
if [ $code -gt 0 ] ; then
echo "problem with compiler/$CC."
exit 1
fi
echo "checking swift..."
SWIFT_VER=`swift --version | grep "Cepstral Swift " - | sed -e "s/Cepstral\ Swift\ //" | awk -F. '{printf "%01d", $1}' -`
echo "checking asterisk..."
# erase certified word from "Asterisk certified/13.1-cert8"
AST_FULL_VER=`asterisk -V | awk '{ print $2 }' - | sed -e "#certified/##"`
if [ ! $SWIFT_VER ] ; then
echo "problem with swift. check PATH?"
exit 1
fi
if [ ! $AST_FULL_VER ] ; then
echo "problem with asterisk. check PATH?"
exit 1
fi
SOLINK="-shared -Xlinker -x"
if [ $CC = gcc ] ; then
CC_VER=`$CC -dumpversion`
set -- `echo $CC_VER | awk -F\. '{ print $1 " " $2 " " $3 }' -`
CC_MAJOR=$1
CC_MINOR=$2
CC_PATCH=$3
if [ $CC_MAJOR -gt 4 ] || [ $CC_MAJOR -eq 4 -a $CC_MINOR -ge 6 ] ; then
# http://www.j-mb.de/blog/tag/undefined-symbol-swift_port_close/
SOLINK="$SOLINK -Wl,--no-as-needed"
fi
fi
if [ "`echo $AST_FULL_VER | awk -F\. '{ print $1 }' -`" -eq 1 ] ; then
AST_MAJOR_VER=`echo $AST_FULL_VER | awk -F\. '{ print $1 "_" $2 }' -`
else
AST_MAJOR_VER=`echo $AST_FULL_VER | awk -F\. '{ print $1 }' -`
fi
SWIFT_DIR=${SWIFT_DIR-/opt/swift}
VAR_DIR=${VAR_DIR-/var/lib}
LIB_DIR=${LIB_DIR-/usr/lib}
INC_DIR=${INC_DIR-/usr/include}
CNF_DIR=${CNF_DIR-/etc}
echo "creating Makefile"
cat Makefile.in | sed -e \
"s/%%CC%%/$CC/g; \
s/%%SOLINK%%/$SOLINK/g; \
s/%%SWIFT_VER%%/$SWIFT_VER/g; \
s/%%AST_FULL_VER%%/$AST_FULL_VER/g; \
s/%%AST_MAJOR_VER%%/$AST_MAJOR_VER/g; \
s!%%SWIFT_DIR%%!$SWIFT_DIR!g; \
s!%%VAR_DIR%%!$VAR_DIR!g; \
s!%%LIB_DIR%%!$LIB_DIR!g; \
s!%%INC_DIR%%!$INC_DIR!g; \
s!%%CNF_DIR%%!$CNF_DIR!g;" \
> Makefile
echo " ********************************************************"
echo " * Now run 'make' to compile app_swift *"
echo " ********************************************************"