genLocInfo revision 290001
1#! /bin/sh
2
3args=`getopt d:f:v $*`
4set -- $args
5
6LF=
7V=": "
8
9for i
10do
11    case "$i" in
12     -d) sdir="$2" ; shift 2 ;;
13     -f) locfile="$2" ; shift 2 ;;
14     -v) V= ; shift ;;
15     --) shift ; break ;;
16    esac
17done
18
19case "$sdir" in
20 '')
21    sdir=.
22esac
23
24case "$locfile" in
25 */*)
26    LF=$locfile
27    ;;
28 '')
29    ;;
30 *)
31    lf=loc/$locfile
32    if test -f $lf
33    then
34	LF=$lf
35    fi
36    ;;
37esac
38
39# If we have a file to use (ie, LF is not empty) then look for one.
40case "$LF" in
41 '')
42    PATH=$PATH:libevent/build-aux
43    export PATH
44    set `scripts/cvo.sh @osname@ @osver@` || exit 1
45
46    CVO_OSNAME=$1
47    CVO_OSVER=$2
48
49    x=$CVO_OSVER
50
51    while true
52    do
53	case "$x" in
54	 '') break ;;
55	esac
56lf=loc/$CVO_OSNAME$x
57${V}echo "Looking for <$lf>" >&2
58	if test -f $lf
59	then
60	    LF=$lf
61	    break
62	fi
63	case "$x" in
64	 *.*) x=`echo $x | sed -e 's/\.[^.]*$//'` ;;
65	 *) x= ;;
66	esac
67    done
68    case "$LF" in
69     '')
70	lf=loc/$CVO_OSNAME
71${V}echo "Looking for <$lf>" >&2
72	if test -f $lf
73	then
74	    LF=$lf
75	fi
76	;;
77    esac
78    # Handle some "aliases"
79    case "$LF" in
80     '')
81	case "$CVO_OSNAME" in
82	 raspbian*)
83	    lf=loc/debian
84${V}echo "Looking for <$lf>" >&2
85	    if test -f $lf
86	    then
87		LF=$lf
88	    fi
89	    ;;
90	 redhat* | fedora*)
91	    lf=loc/redhat
92${V}echo "Looking for <$lf>" >&2
93	    if test -f $lf
94	    then
95		LF=$lf
96	    fi
97	    ;;
98	esac
99	;;
100    esac
101
102    # This might be a good place to see if uname returns "Linux",
103    # and if so, use a generic file for that.
104    case "$LF" in
105     '')
106	case "`uname`" in
107	 Linux)
108	    lf=loc/linux
109${V}echo "Looking for <$lf>" >&2
110	    if test -f $lf
111	    then
112		LF=$lf
113	    fi
114	    ;;
115	esac
116	;;
117    esac
118
119    # Finally, 'legacy'
120    case "$LF" in
121     '')
122	lf=loc/legacy
123${V}echo "Looking for <$lf>" >&2
124	if test -f $lf
125	then
126	    LF=$lf
127	fi
128	;;
129    esac
130
131    case "$LF" in
132     '')
133	echo "No loc/XXX file found!" >&2
134	exit 1
135	;;
136    esac
137    ;;
138esac
139
140${V}echo "Using <$LF>" >&2
141echo "GENLOCINFOFILE=$LF"
142
143###
144
145rm -f $sdir/genLocInfo.rc?
146
147oIFS=$IFS
148IFS=","
149
150while true
151do
152    if read c d s x
153    then
154	# echo "Got <$c><$d><$s><$x>" >&2
155	case "$c" in
156	 \#*) continue ;;
157	esac
158	case "$x" in
159	 '') ;;
160	 *) echo "Unrecognized input: <$c,$d,$s,$x>" >&2
161	    touch $sdir/genLocInfo.rc1
162	    continue
163	    ;;
164	esac
165	case "$c,$d,$s" in
166	 [Mm][Aa][Nn],,)
167	    echo "MANTAGFMT=man"
168	    continue
169	    ;;
170	 [Mm][Dd][Oo][Cc],,)
171	    echo "MANTAGFMT=mdoc"
172	    continue
173	    ;;
174	esac
175
176	case "$c,$d,$s" in
177	 *,bin,*)  DB=bin ; DL= ; DS= ; NI= ;;
178	 *,libexec,*)  DB= ; DL=libexec ; DS= ; NI= ;;
179	 *,noinst,*)  DB= ; DL= ; DS= ; NI=noinst ;;
180	 *,sbin,*) DB= ; DL= ; DS=sbin ; NI= ;;
181	 *) echo "Unrecognized input: <$c,$d,$s>" >&2
182	    touch $sdir/genLocInfo.rc1
183	    continue
184	    ;;
185	esac
186	case "$c,$d,$s" in
187	 *,*,1) ;;
188	 *,*,1m) ;;
189	 *,*,1M) ;;
190	 *,*,8) ;;
191	 *) echo "Unrecognized input: <$c,$d,$s>" >&2
192	    touch $sdir/genLocInfo.rc1
193	    continue
194	    ;;
195	esac
196
197	# Should be OK, mostly...
198	C=`echo $c | sed -e 'y/abcdefghijklmnopqrstuvwxyz-/ABCDEFGHIJKLMNOPQRSTUVWXYZ_/'`
199	# echo "c: <$c>, C: <$C>, DB: <$DB>, DL: <$DL>, DS: <$DS>" >&2
200
201	case "$d" in
202	 bin)
203	    eval ${C}_DB=$c
204	    eval ${C}_DL=
205	    eval ${C}_DS=
206	    eval ${C}_NI=
207	    ;;
208	 libexec)
209	    eval ${C}_DB=
210	    eval ${C}_DL=$c
211	    eval ${C}_DS=
212	    eval ${C}_NI=
213	    ;;
214	 noinst)
215	    eval ${C}_DB=
216	    eval ${C}_DL=
217	    eval ${C}_DS=
218	    eval ${C}_NI=$c
219	    ;;
220	 sbin)
221	    eval ${C}_DB=
222	    eval ${C}_DL=
223	    eval ${C}_DS=$c
224	    eval ${C}_NI=
225	    ;;
226	 *) echo "$0: installdir <$d> must be bin, sbin, libexec, or noinst" >&2
227	    exit 1
228	    ;;
229	esac
230	eval ${C}_MS=$s
231
232	# echo "<$c> gets installed in <$d> with a <$s> manpage suffix" >&2
233	# echo "${C}_DB is <`eval echo '$'${C}_DB`>" >&2
234	# echo "${C}_DL is <`eval echo '$'${C}_DL`>" >&2
235	# echo "${C}_DS is <`eval echo '$'${C}_DS`>" >&2
236	# echo "${C}_NI is <`eval echo '$'${C}_NI`>" >&2
237	# echo "${C}_MS is <`eval echo '$'${C}_MS`>" >&2
238	echo "${C}_DB=`eval echo '$'${C}_DB`"
239	echo "${C}_DL=`eval echo '$'${C}_DL`"
240	echo "${C}_DS=`eval echo '$'${C}_DS`"
241	echo "${C}_NI=`eval echo '$'${C}_NI`"
242	echo "${C}_MS=`eval echo '$'${C}_MS`"
243
244	touch $sdir/genLocInfo.rc0
245    else
246	break
247    fi
248done < $LF
249IFS=$oIFS
250
251if test -f $sdir/genLocInfo.rc1
252then
253    rm $sdir/genLocInfo.rc?
254    exit 1
255fi
256
257if test -f $sdir/genLocInfo.rc0
258then
259    rm $sdir/genLocInfo.rc?
260    echo 'GENLOCINFO=OK'
261    exit 0
262fi
263
264exit 1
265