Volumes in instruments are really applied (Closes: #1050).
[ahxm.git] / config.sh
blob04c81156efbfde1dac9c2c2f57b3d7bbc5c70ab1
1 #!/bin/sh
3 # Configuration shell script
5 # gets program version
6 VERSION=`cut -f2 -d\" VERSION`
8 # default installation prefix
9 PREFIX=/usr/local
11 # parse arguments
12 while [ $# -gt 0 ] ; do
14 case $1 in
15 # --without-option) WITHOUT_OPTION=1 ;;
16 --help) CONFIG_HELP=1 ;;
18 --prefix) PREFIX=$2 ; shift ;;
19 --prefix=*) PREFIX=`echo $1 | sed -e 's/--prefix=//'` ;;
20 esac
22 shift
23 done
25 if [ "$CONFIG_HELP" = "1" ] ; then
27 echo "Available options:"
28 echo "--prefix=PREFIX Installation prefix ($PREFIX)."
29 # echo "--without-option Disable option."
31 echo
32 echo "Environment variables:"
33 echo "CC C Compiler."
34 echo "CFLAGS Compile flags (i.e., -O3)."
35 echo "AR Archiver."
36 echo "LEX Lexer."
37 echo "YACC Parser."
39 exit 1
42 echo "Configuring..."
44 echo "/* automatically created by config.sh - do not modify */" > config.h
45 echo "# automatically created by config.sh - do not modify" > makefile.opts
46 > config.ldflags
47 > config.cflags
48 > .config.log
50 # set compiler
51 if [ "$CC" = "" ] ; then
52 CC=cc
53 # if CC is unset, try if gcc is available
54 which gcc > /dev/null
56 if [ $? = 0 ] ; then
57 CC=gcc
61 echo "CC=$CC" >> makefile.opts
63 # set cflags
64 if [ "$CFLAGS" = "" ] ; then
65 CFLAGS="-g -Wall"
68 echo "CFLAGS=$CFLAGS" >> makefile.opts
70 # Add CFLAGS to CC
71 CC="$CC $CFLAGS"
73 # set archiver
74 if [ "$AR" = "" ] ; then
75 AR=ar
78 echo "AR=$AR" >> makefile.opts
80 # set lexer
81 if [ "$LEX" = "" ] ; then
82 LEX=lex
85 echo "LEX=$LEX" >> makefile.opts
87 # set parser
88 if [ "$YACC" = "" ] ; then
89 YACC=yacc
92 echo "YACC=$YACC" >> makefile.opts
94 # add version
95 cat VERSION >> config.h
97 # add installation prefix
98 echo "#define CONFOPT_PREFIX \"$PREFIX\"" >> config.h
100 #########################################################
102 # configuration directives
104 # test for Linux OSS
105 echo -n "Testing for Linux OSS... "
106 echo "#include <linux/soundcard.h>" > .tmp.c
107 echo "int main(void) {" >> .tmp.c
108 echo "int i=open(\"/dev/dsp\",0);" >> .tmp.c
109 echo "ioctl(i,SNDCTL_DSP_SETFRAGMENT,&i);" >> .tmp.c
110 echo "return 0; } " >>.tmp.c
112 $CC .tmp.c -o .tmp.o 2> /dev/null
113 if [ $? = 0 ] ; then
114 echo "#define CONFOPT_LINUX_OSS 1" >> config.h
115 echo "OK"
116 else
117 echo "No"
120 # test for IRIX audio library
121 echo -n "Testing for IRIX audio library... "
122 echo "#include <dmedia/audio.h>" > .tmp.c
123 echo "int main(void) { alNewConfig(); return 0; }" >> .tmp.c
125 $CC .tmp.c -laudio -o .tmp.o 2> /dev/null
126 if [ $? = 0 ] ; then
127 echo "#define CONFOPT_SGI 1" >> config.h
128 echo "-laudio" >> config.ldflags
129 echo "OK"
130 else
131 echo "No"
134 # test for esound library
135 echo -n "Testing for esound development libraries... "
136 echo "#include <esd.h>" > .tmp.c
137 echo "int main(void) { return 0; }" >> .tmp.c
139 $CC -I/usr/local/include -L/usr/local/lib -lesd .tmp.c -o .tmp.o 2> /dev/null
140 if [ $? = 0 ] ; then
141 echo "#define CONFOPT_ESD 1" >> config.h
142 echo "-lesd" >> config.ldflags
143 echo "OK"
144 else
145 echo "No"
148 # test for artsc library
149 echo -n "Testing for aRts development libraries... "
150 echo "#include <artsc.h>" > .tmp.c
151 echo "int main(void) { return 0; }" >> .tmp.c
153 TMP_CFLAGS=`artsc-config --cflags 2>/dev/null`
154 TMP_LDFLAGS=`artsc-config --libs 2>/dev/null`
156 $CC $TMP_CFLAGS .tmp.c $TMP_LDFLAGS -o .tmp.o 2> /dev/null
157 if [ $? = 0 ] ; then
158 echo "#define CONFOPT_ARTS 1" >> config.h
159 echo $TMP_CFLAGS >> config.cflags
160 echo $TMP_LDFLAGS >> config.ldflags
161 echo "OK"
162 else
163 echo "No"
166 #########################################################
168 echo "#ifdef CONFOPT_WIN32" >> config.h
169 echo "#define SWPRINTF _snwprintf" >> config.h
170 echo "#else" >> config.h
171 echo "#define SWPRINTF swprintf" >> config.h
172 echo "#endif" >> config.h
174 #########################################################
176 # final setup
178 echo "VERSION=$VERSION" >> makefile.opts
179 echo "PREFIX=$PREFIX" >> makefile.opts
180 echo >> makefile.opts
182 cat makefile.opts makefile.in makefile.depend > Makefile
184 #########################################################
186 # cleanup
188 rm -f .tmp.c .tmp.o
190 exit 0