Print the configured drivers in config and help.
[ahxm.git] / config.sh
blobd590ab5be9455e83f7a28bf28cbed7dd9223e334
1 #!/bin/sh
3 # Configuration shell script
5 BIN="ahxm midiin"
7 # gets program version
8 VERSION=`cut -f2 -d\" VERSION`
10 # default installation prefix
11 PREFIX=/usr/local
13 # parse arguments
14 while [ $# -gt 0 ] ; do
16 case $1 in
17 --help) CONFIG_HELP=1 ;;
19 --with-pthreads) WITH_PTHREADS=1 ;;
21 --prefix) PREFIX=$2 ; shift ;;
22 --prefix=*) PREFIX=`echo $1 | sed -e 's/--prefix=//'` ;;
23 esac
25 shift
26 done
28 if [ "$CONFIG_HELP" = "1" ] ; then
30 echo "Available options:"
31 echo "--prefix=PREFIX Installation prefix ($PREFIX)."
32 echo "--with-pthreads Activate POSIX threads support."
34 echo
35 echo "Environment variables:"
36 echo "CC C Compiler."
37 echo "CFLAGS Compile flags (i.e., -O3)."
38 echo "AR Archiver."
39 echo "LEX Lexer."
40 echo "YACC Parser."
42 exit 1
45 echo "Configuring..."
47 echo "/* automatically created by config.sh - do not modify */" > config.h
48 echo "# automatically created by config.sh - do not modify" > makefile.opts
49 > config.ldflags
50 > config.cflags
51 > .config.log
53 # set compiler
54 if [ "$CC" = "" ] ; then
55 CC=cc
56 # if CC is unset, try if gcc is available
57 which gcc > /dev/null 2>&1
59 if [ $? = 0 ] ; then
60 CC=gcc
64 echo "CC=$CC" >> makefile.opts
66 # set cflags
67 if [ "$CFLAGS" = "" -a "$CC" = "gcc" ] ; then
68 CFLAGS="-g -Wall"
71 echo "CFLAGS=$CFLAGS" >> makefile.opts
73 # Add CFLAGS to CC
74 CC="$CC $CFLAGS"
76 # set archiver
77 if [ "$AR" = "" ] ; then
78 AR=ar
81 echo "AR=$AR" >> makefile.opts
83 # set lexer
84 if [ "$LEX" = "" ] ; then
85 LEX=lex
88 echo "LEX=$LEX" >> makefile.opts
90 # set parser
91 if [ "$YACC" = "" ] ; then
92 YACC=yacc
95 echo "YACC=$YACC" >> makefile.opts
97 # add version
98 cat VERSION >> config.h
100 # add installation prefix
101 echo "#define CONFOPT_PREFIX \"$PREFIX\"" >> config.h
103 DRIVERS="wav"
105 #########################################################
107 # configuration directives
109 # Win32
110 echo -n "Testing for win32... "
111 if [ "$WITHOUT_WIN32" = "1" ] ; then
112 echo "Disabled by user"
113 else
114 echo "#include <windows.h>" > .tmp.c
115 echo "#include <commctrl.h>" >> .tmp.c
116 echo "int STDCALL WinMain(HINSTANCE h, HINSTANCE p, LPSTR c, int m)" >> .tmp.c
117 echo "{ return 0; }" >> .tmp.c
119 TMP_LDFLAGS="-lwinmm"
120 $CC .tmp.c $TMP_LDFLAGS -o .tmp.o 2>> .config.log
122 if [ $? = 0 ] ; then
123 echo "#define CONFOPT_WIN32 1" >> config.h
124 echo "OK"
125 WITHOUT_UNIX_GLOB=1
126 WITH_WIN32=1
127 echo $TMP_LDFLAGS >> config.ldflags
128 DRIVERS="win32 ${DRIVERS}"
129 else
130 echo "No"
134 # test for Linux OSS
135 echo -n "Testing for Linux OSS... "
136 echo "#include <linux/soundcard.h>" > .tmp.c
137 echo "int main(void) {" >> .tmp.c
138 echo "int i=open(\"/dev/dsp\",0);" >> .tmp.c
139 echo "ioctl(i,SNDCTL_DSP_SETFRAGMENT,&i);" >> .tmp.c
140 echo "return 0; } " >>.tmp.c
142 $CC .tmp.c -o .tmp.o 2> /dev/null
143 if [ $? = 0 ] ; then
144 echo "#define CONFOPT_LINUX_OSS 1" >> config.h
145 echo "OK"
146 DRIVERS="oss ${DRIVERS}"
147 else
148 echo "No"
151 # test for IRIX audio library
152 echo -n "Testing for IRIX audio library... "
153 echo "#include <dmedia/audio.h>" > .tmp.c
154 echo "int main(void) { alNewConfig(); return 0; }" >> .tmp.c
156 $CC .tmp.c -laudio -o .tmp.o 2> /dev/null
157 if [ $? = 0 ] ; then
158 echo "#define CONFOPT_SGI 1" >> config.h
159 echo "-laudio" >> config.ldflags
160 echo "OK"
161 DRIVERS="sgi ${DRIVERS}"
162 else
163 echo "No"
166 # test for esound library
167 echo -n "Testing for esound development libraries... "
168 echo "#include <esd.h>" > .tmp.c
169 echo "int main(void) { return 0; }" >> .tmp.c
171 $CC -I/usr/local/include -L/usr/local/lib -lesd .tmp.c -o .tmp.o 2> /dev/null
172 if [ $? = 0 ] ; then
173 echo "#define CONFOPT_ESD 1" >> config.h
174 echo "-lesd" >> config.ldflags
175 echo "OK"
176 DRIVERS="esd ${DRIVERS}"
177 else
178 echo "No"
181 # test for artsc library
182 echo -n "Testing for aRts development libraries... "
183 echo "#include <artsc.h>" > .tmp.c
184 echo "int main(void) { arts_init(); return 0; }" >> .tmp.c
186 TMP_CFLAGS=`artsc-config --cflags 2>/dev/null`
187 TMP_LDFLAGS=`artsc-config --libs 2>/dev/null`
189 $CC $TMP_CFLAGS .tmp.c $TMP_LDFLAGS -o .tmp.o 2> /dev/null
190 if [ $? = 0 ] ; then
191 echo "#define CONFOPT_ARTS 1" >> config.h
192 echo $TMP_CFLAGS >> config.cflags
193 echo $TMP_LDFLAGS >> config.ldflags
194 echo "OK"
195 DRIVERS="arts ${DRIVERS}"
196 else
197 echo "No"
200 # test for pulseaudio libraries
201 echo -n "Testing for Pulseaudio development libraries... "
202 echo "#include <pulse/simple.h>" > .tmp.c
203 echo "#include <pulse/error.h>" >> .tmp.c
204 echo "int main(void) { return 0; }" >> .tmp.c
206 TMP_CFLAGS=$(pkg-config libpulse-simple --cflags 2>/dev/null)
207 TMP_LDFLAGS=$(pkg-config libpulse-simple --libs 2>/dev/null)
209 $CC $TMP_CFLAGS .tmp.c $TMP_LDFLAGS -o .tmp.o 2> /dev/null
210 if [ $? = 0 ] ; then
211 echo "#define CONFOPT_PULSEAUDIO 1" >> config.h
212 echo $TMP_CFLAGS >> config.cflags
213 echo $TMP_LDFLAGS >> config.ldflags
214 echo "OK"
215 DRIVERS="pulse ${DRIVERS}"
216 else
217 echo "No"
220 # test for getuid() availability
221 echo -n "Testing for getuid() existence... "
222 echo "#include <unistd.h>" > .tmp.c
223 echo "#include <sys/types.h>" >> .tmp.c
224 echo "int main(void) { getuid(); return 0; }" >> .tmp.c
226 TMP_CFLAGS=""
227 TMP_LDFLAGS=""
228 $CC $TMP_CFLAGS .tmp.c $TMP_LDFLAGS -o .tmp.o 2> /dev/null
229 if [ $? = 0 ] ; then
230 echo "OK"
231 else
232 echo "No; activating workaround"
233 echo "#define getuid() 1000" >> config.h
236 # test for number of arguments in mkdir()
237 echo -n "Testing for number of arguments in mkdir()... "
238 echo "#include <stdio.h>" > .tmp.c
239 echo "#include <string.h>" >> .tmp.c
240 echo "#include <stdlib.h>" >> .tmp.c
241 echo "#include <unistd.h>" >> .tmp.c
242 echo "#include <sys/stat.h>" >> .tmp.c
243 echo "#include <sys/types.h>" >> .tmp.c
244 echo "int main(void) { mkdir(\"testdir\"); return 0; }" >> .tmp.c
246 $CC $TMP_CFLAGS .tmp.c $TMP_LDFLAGS -o .tmp.o 2> /dev/null
247 if [ $? = 0 ] ; then
248 echo "1"
249 echo "#define CONFOPT_MKDIR_ARGS 1" >> config.h
250 else
251 echo "2"
252 echo "#define CONFOPT_MKDIR_ARGS 2" >> config.h
255 echo -n "Testing for nanosleep() support... "
256 echo "#include <time.h>" > .tmp.c
257 echo "int main(void) { struct timespec ts; nanosleep(&ts, NULL); return 0; }" >> .tmp.c
259 TMP_CFLAGS=""
260 TMP_LDFLAGS=""
261 $CC $TMP_CFLAGS .tmp.c $TMP_LDFLAGS -o .tmp.o 2> /dev/null
262 if [ $? = 0 ] ; then
263 echo "OK"
264 echo "#define CONFOPT_NANOSLEEP 1" >> config.h
265 else
266 echo "No; MIDI output will not be available"
267 BIN="ahxm"
270 # pthreads support
271 if [ "$WITH_PTHREADS" = 1 ] ; then
272 echo "#define CONFOPT_PTHREADS 1" >> config.h
273 echo "-pthread" >> config.ldflags
276 # test for Grutatxt
277 echo -n "Testing if Grutatxt is installed... "
279 DOCS="\$(ADD_DOCS)"
281 if which grutatxt > /dev/null 2>&1 ; then
282 echo "OK"
283 echo "GRUTATXT=yes" >> makefile.opts
284 DOCS="\$(GRUTATXT_DOCS)"
285 else
286 echo "No"
287 echo "GRUTATXT=no" >> makefile.opts
290 # test for mp_doccer
291 echo -n "Testing if mp_doccer is installed... "
292 MP_DOCCER=$(which mp_doccer||which mp-doccer)
294 if [ $? = 0 ] ; then
296 if ${MP_DOCCER} --help | grep grutatxt > /dev/null ; then
298 echo "OK"
300 echo "MP_DOCCER=yes" >> makefile.opts
301 DOCS="$DOCS \$(MP_DOCCER_DOCS)"
303 grep GRUTATXT=yes makefile.opts > /dev/null && DOCS="$DOCS \$(G_AND_MP_DOCS)"
304 else
305 echo "Outdated (No)"
306 echo "MP_DOCCER=no" >> makefile.opts
308 else
309 echo "No"
310 echo "MP_DOCCER=no" >> makefile.opts
313 #########################################################
315 # final setup
317 echo "BIN=$BIN" >> makefile.opts
318 echo "DOCS=$DOCS" >> makefile.opts
319 echo "VERSION=$VERSION" >> makefile.opts
320 echo "PREFIX=$PREFIX" >> makefile.opts
321 echo >> makefile.opts
323 cat makefile.opts makefile.in makefile.depend > Makefile
325 echo "#define CONFOPT_DRIVERS \"${DRIVERS}\"" >> config.h
326 echo
327 echo "Configured drivers: ${DRIVERS}"
329 #########################################################
331 # cleanup
333 rm -f .tmp.c .tmp.o
335 exit 0