I am experimenting to compile postgresql-snapshot [Sep 15 07:01] on BSD/OS 3.1

configure however chooses the bsdi_4.0 template. (which uses different kind of 
shared libraries)

Upon investigation, it turns out that there is template/.similar file that 
'helps' configure choose the proper template with fewer hard-coded 
instructions.
For BSD/OS it lists:

i386-pc-bsdi2.0=bsdi_2.0
i386-pc-bsdi2.1=bsdi_2.1
i386-pc-bsdi3.0=bsdi_2.1
i386-pc-bsdi4.0=bsdi_4.0

I tried adding

i386-pc-bsdi3.1=bsdi_2.1

there but the result was the same.

It turns out, that configure executes

GUESS=`grep "$host_no_ver" template/.similar | sed 's/.*=//' | tail -1`

to guess the template... but earlier host_no_ver is set using

host_no_ver=`echo "$host" | sed 's/[0-9.]*$//'`

which in my cases results in

i386-pc-bsdi

which apparently matches all rows in the .similar file and returns the last 
one...

I understand the reasons to have such 'automatism', to pick the latest version 
if other is not defined in the .similar file, but apparently this should pick 
the longest match first.

Which can be done using two-pass selection, first with using '$host', then 
with using '$host_no_ver' in configure.

The enclosed patch does that.

Daniel
Tue, 15 Sep 1998 14:30:18 +0300
Daniel Kalchev <daniel@digsys.bg>
configure autodetection problem