Updated TODO.
[ahxm.git] / config.sh
blob8d0deb1f2dad1b06275ca9614a4461fffbd179a3
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 --help) CONFIG_HELP=1 ;;
17 --with-pthreads) WITH_PTHREADS=1 ;;
19 --prefix) PREFIX=$2 ; shift ;;
20 --prefix=*) PREFIX=`echo $1 | sed -e 's/--prefix=//'` ;;
21 esac
23 shift
24 done
26 if [ "$CONFIG_HELP" = "1" ] ; then
28 echo "Available options:"
29 echo "--prefix=PREFIX Installation prefix ($PREFIX)."
30 echo "--with-pthreads Activate POSIX threads support."
32 echo
33 echo "Environment variables:"
34 echo "CC C Compiler."
35 echo "CFLAGS Compile flags (i.e., -O3)."
36 echo "AR Archiver."
37 echo "LEX Lexer."
38 echo "YACC Parser."
40 exit 1
43 echo "Configuring..."
45 echo "/* automatically created by config.sh - do not modify */" > config.h
46 echo "# automatically created by config.sh - do not modify" > makefile.opts
47 > config.ldflags
48 > config.cflags
49 > .config.log
51 # set compiler
52 if [ "$CC" = "" ] ; then
53 CC=cc
54 # if CC is unset, try if gcc is available
55 which gcc > /dev/null
57 if [ $? = 0 ] ; then
58 CC=gcc
62 echo "CC=$CC" >> makefile.opts
64 # set cflags
65 if [ "$CFLAGS" = "" -a "$CC" = "gcc" ] ; then
66 CFLAGS="-g -Wall"
69 echo "CFLAGS=$CFLAGS" >> makefile.opts
71 # Add CFLAGS to CC
72 CC="$CC $CFLAGS"
74 # set archiver
75 if [ "$AR" = "" ] ; then
76 AR=ar
79 echo "AR=$AR" >> makefile.opts
81 # set lexer
82 if [ "$LEX" = "" ] ; then
83 LEX=lex
86 echo "LEX=$LEX" >> makefile.opts
88 # set parser
89 if [ "$YACC" = "" ] ; then
90 YACC=yacc
93 echo "YACC=$YACC" >> makefile.opts
95 # add version
96 cat VERSION >> config.h
98 # add installation prefix
99 echo "#define CONFOPT_PREFIX \"$PREFIX\"" >> config.h
101 #########################################################
103 # configuration directives
105 # test for Linux OSS
106 echo -n "Testing for Linux OSS... "
107 echo "#include <linux/soundcard.h>" > .tmp.c
108 echo "int main(void) {" >> .tmp.c
109 echo "int i=open(\"/dev/dsp\",0);" >> .tmp.c
110 echo "ioctl(i,SNDCTL_DSP_SETFRAGMENT,&i);" >> .tmp.c
111 echo "return 0; } " >>.tmp.c
113 $CC .tmp.c -o .tmp.o 2> /dev/null
114 if [ $? = 0 ] ; then
115 echo "#define CONFOPT_LINUX_OSS 1" >> config.h
116 echo "OK"
117 else
118 echo "No"
121 # test for IRIX audio library
122 echo -n "Testing for IRIX audio library... "
123 echo "#include <dmedia/audio.h>" > .tmp.c
124 echo "int main(void) { alNewConfig(); return 0; }" >> .tmp.c
126 $CC .tmp.c -laudio -o .tmp.o 2> /dev/null
127 if [ $? = 0 ] ; then
128 echo "#define CONFOPT_SGI 1" >> config.h
129 echo "-laudio" >> config.ldflags
130 echo "OK"
131 else
132 echo "No"
135 # test for esound library
136 echo -n "Testing for esound development libraries... "
137 echo "#include <esd.h>" > .tmp.c
138 echo "int main(void) { return 0; }" >> .tmp.c
140 $CC -I/usr/local/include -L/usr/local/lib -lesd .tmp.c -o .tmp.o 2> /dev/null
141 if [ $? = 0 ] ; then
142 echo "#define CONFOPT_ESD 1" >> config.h
143 echo "-lesd" >> config.ldflags
144 echo "OK"
145 else
146 echo "No"
149 # test for artsc library
150 echo -n "Testing for aRts development libraries... "
151 echo "#include <artsc.h>" > .tmp.c
152 echo "int main(void) { return 0; }" >> .tmp.c
154 TMP_CFLAGS=`artsc-config --cflags 2>/dev/null`
155 TMP_LDFLAGS=`artsc-config --libs 2>/dev/null`
157 $CC $TMP_CFLAGS .tmp.c $TMP_LDFLAGS -o .tmp.o 2> /dev/null
158 if [ $? = 0 ] ; then
159 echo "#define CONFOPT_ARTS 1" >> config.h
160 echo $TMP_CFLAGS >> config.cflags
161 echo $TMP_LDFLAGS >> config.ldflags
162 echo "OK"
163 else
164 echo "No"
167 # test for pulseaudio libraries
168 echo -n "Testing for Pulseaudio development libraries..."
169 echo "#include <pulse/simple.h>" > .tmp.c
170 echo "#include <pulse/error.h>" >> .tmp.c
171 echo "int main(void) { return 0; }" >> .tmp.c
173 TMP_CFLAGS=$(pkg-config libpulse-simple --cflags 2>/dev/null)
174 TMP_LDFLAGS=$(pkg-config libpulse-simple --libs 2>/dev/null)
176 $CC $TMP_CFLAGS .tmp.c $TMP_LDFLAGS -o .tmp.o 2> /dev/null
177 if [ $? = 0 ] ; then
178 echo "#define CONFOPT_PULSEAUDIO 1" >> config.h
179 echo $TMP_CFLAGS >> config.cflags
180 echo $TMP_LDFLAGS >> config.ldflags
181 echo "OK"
182 else
183 echo "No"
186 # pthreads support
187 if [ "$WITH_PTHREADS" = 1 ] ; then
188 echo "#define CONFOPT_PTHREADS 1" >> config.h
189 echo "-pthread" >> config.ldflags
192 #########################################################
194 # final setup
196 echo "VERSION=$VERSION" >> makefile.opts
197 echo "PREFIX=$PREFIX" >> makefile.opts
198 echo >> makefile.opts
200 cat makefile.opts makefile.in makefile.depend > Makefile
202 #########################################################
204 # cleanup
206 rm -f .tmp.c .tmp.o
208 exit 0