1#!/bin/sh
2#
3# $Id: configure,v 1.4 2006/09/15 14:16:55 toad32767 Exp $
4#
5# Configure script for UModPlayer B3
6# This is a very small & simple script which modifies the Makefile
7# to set a user-specified prefix.
8# Its options are more or less the same that of GNU autoconf configure scripts.
9#
10# All of this code is under Public Domain. In case it's not legally possible,
11# permission is granted to anyone to use it for any purpose.
12
13# display the usage
14usage () {
15	echo "usage: $0 [--prefix=<prefix>]"
16}
17
18# replace (escape) the '/' character with '\/'
19addslashes () {
20	# sed s:/:\/:g
21	echo "$1" | sed 's/\//\\\//g'
22}
23
24# test if we have arguments
25if [ $# -gt 0 ]
26then
27	if [ "$1" = "--help" ]
28	then
29		usage
30		exit 0
31	else
32		prefix=`echo "$1" | sed 's/^\([^=]*=\)//g'`
33		if [ "$prefix" = "" ]
34		then
35			usage
36			exit 1
37		fi
38	fi
39else
40	# default prefix
41	prefix="/usr/local"
42fi
43
44if [ ! -r Makefile.in ]
45then
46	echo "error: missing or unreadable <Makefile.in>"
47	exit 2
48fi
49
50# replace the @PREFIX@ tag with the appropriate content
51prefix=`addslashes "$prefix"`
52os=`uname`
53
54echo "$0: creating Makefile"
55
56# some preprocessing. see the Makefile.in file for comments
57if [ "$os" = "NetBSD" ]
58then
59	prg1='awk'
60	param1='/^@if_NetBSD@/ {gsub(/\@\@ /, "\n"); gsub(/\@[^\@]*\@/, "");} {print $0;}'
61else
62	prg1='sed'
63	param1='s/^@if_NetBSD.*$//g'
64fi
65
66if (test -d /usr/local/include && test -d /usr/local/lib)
67then
68	prg2='awk'
69	param2='/^@if_usr_local@/ {gsub(/\@\@ /, "\n"); gsub(/\@[^\@]*\@/, "");} {print $0;}'
70else
71	prg2='sed'
72	param2='s/^@if_usr_local.*$//g'
73fi
74
75sed="s/@PREFIX@/$prefix/g"
76
77cat Makefile.in | $prg1 "$param1" | $prg2 "$param2" | sed "$sed" > Makefile
78
79# create a simple <config.h>
80echo "$0: creating config.h"
81login=`whoami`
82date=`date`
83echo >> config.h
84echo '/* edited by configure */' >> config.h
85echo "#define COMPILATION_DATE \"compiled by $login at $date on $os\"" >> config.h
86echo >> config.h
87
88echo "--- Please make sure you have the following"
89echo "--- libraries installed:"
90echo "       [*] libmodplug >= 0.8"
91echo "           freely available on <http://modplug-xmms.sourceforge.net/>"
92echo "       [*] libao"
93echo "           freely available on <http://www.xiph.org/ao/>"
94echo "       [*] libaiff >= 1.1"
95echo "           freely available on <http://aifftools.sourceforge.net/libaiff/>"
96exit 0
97
98
99