aboutsummaryrefslogtreecommitdiffstats
path: root/config
blob: a701bc8b46bed972c996a5b91d628415c7df7a79 (plain)
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
169
170
171
172
173
174
175
#!/bin/sh

#
# Reload defaults
#

BUILD=sdk
CONFIG=sdk/config.h

if test -f config.cache ; then
	. ./config.cache
fi
echo -n >config.cache

if test -f config.pkg ; then
	. ./config.pkg
fi

#
# Load bindings
#

if test -f config.pkg ; then
	. ./config.pkg
fi

if test -f config.make ; then
	echo -n >config.make
fi

if test -f $CONFIG ; then
	echo -n >$CONFIG
fi

if test -f $BUILD/bin/config.sub ; then
	. $BUILD/bin/config.sub
fi

BIND_OPTS='host'

if test -z "$CONFIG_HOST" ; then
	if test -d /usr/local/include ; then
		CONFIG_HOST=/usr/local
	fi
	if test -d /usr/include ; then
		CONFIG_HOST=/usr
	fi
fi

opt_host() {
	CONFIG_HOST="$1"
	return 0
}

if test ! -z "$BIND" ; then
	for bind in $BIND ; do
		if test -d $BUILD/$bind ; then
			. $BUILD/$bind/bind.conf
		else
			. $BUILD/bin/$bind.bind
		fi
	done
fi

# 
# Parse command line arguments.
#
err=''

if test ! -z "$CONFIG_FLAGS" ; then
	for arg in $CONFIG_FLAGS ; do
		for opt in $BIND_OPTS ; do
			case "$arg" in
			$opt=* | -$opt=* | --$opt=* )
				opt_$opt `echo "$arg" | sed 's/[-_a-zA-Z0-9]*=//'`
				break
				;;
			esac
		done	
	done
fi


if test ! -z "$*" ; then
	for arg in $* ; do
		err=$arg
		for opt in $BIND_OPTS ; do
			case "$arg" in
			$opt=* | -$opt=* | --$opt=* )
				opt_$opt `echo "$arg" | sed 's/[-_a-zA-Z0-9]*=//'`
				err=''
				break
				;;
			esac
		done	
		if test ! -z "$err" ; then
			break
		fi
	done
fi

CONFIG_FLAGS=''

if test ! -z "$err" ; then
	echo "config: $err: invalid option."
	echo 
	echo "Valid Options:" 
	echo -n >config.help
	if test ! -z "$BIND" ; then
		for use in $BIND ; do
			if test -f $BUILD/$use/help.conf ; then
				cat $BUILD/$use/help.conf >>config.help
			fi
			if test -f $BUILD/bin/$use.help ; then
				cat $BUILD/bin/$use.help >>config.help
			fi
		done
		sort <config.help
		rm -f config.help
	fi
	exit -1
fi

echo "#ifndef	__CONFIG_H__" >>$CONFIG
echo "#define	__CONFIG_H__" >>$CONFIG

CONFIG_LIBS=""

if test ! -z "$BIND" ; then
	for bind in $BIND ; do
		if test -d $BUILD/$bind ; then
			. $BUILD/$bind/make.conf
			CONFIG_LIBS='-l'$bind' '"$CONFIG_LIBS"
			MAKEFILES="$MAKEFILES"' '$BUILD/$bind/Makefile
		else
			. $BUILD/bin/$bind.make
		fi
	done
fi

if test ! -z "$CONFIG_LIBS" ; then
	echo "LIBS=$CONFIG_LIBS" >>config.make
fi

if test ! -z "$MAKEFILES" ; then
	for makefile in $MAKEFILES ; do
		cat config.make >$makefile
		cat $makefile.in >>$makefile
	done
fi

echo "#endif" >>$CONFIG


if test -z "$CONFIG_CACHE" ; then
	CONFIG_CACHE='config.cache'
	CONFIG_FLAGS=''
else
	CONFIG_FIRST=''
fi

echo "CONFIG_CACHE="$CONFIG_CACHE >>config.cache

if test -f conftest.c ; then
	rm -f conftest.c
fi

if test -f conftest.o ; then
	rm conftest.o
fi

if test ! -z "$CONFIG_FIRST" ; then
	$CONFIG_FIRST
fi