Merge from vendor branch CVS:
[dragonfly.git] / contrib / sendmail-8.13.8 / devtools / bin / configure.sh
1 #!/bin/sh
2
3 # Copyright (c) 1998-2001 Sendmail, Inc. and its suppliers.
4 #       All rights reserved.
5 #
6 # By using this file, you agree to the terms and conditions set
7 # forth in the LICENSE file which can be found at the top level of
8 # the sendmail distribution.
9 #
10 #
11 #       $Id: configure.sh,v 8.46 2003/08/20 18:08:35 gshapiro Exp $
12
13 #
14 #  Special script to autoconfigure for M4 generation of Makefile
15 #
16
17 SHELL=/bin/sh
18 os=""
19 resolver=""
20 sflag=""
21 bin_dir=`echo $0 | sed -e 's%\/[^/]*$%%'`
22 if [ ! -d $bin_dir ]
23 then
24         bin_dir="."
25 fi
26 find_prog=$bin_dir/find_in_path.sh
27
28 while [ ! -z "$1" ]
29 do
30         case $1
31         in
32           -s)   # skip auto-configure
33                 sflag=1
34                 shift
35                 ;;
36
37           *)    # OS definition
38                 os=$1
39                 shift
40                 ;;
41         esac
42 done
43
44 usewhoami=0
45 usehostname=0
46 for p in `echo $PATH | sed 's/:/ /g'`
47 do
48         if [ "x$p" = "x" ]
49         then
50                 p="."
51         fi
52         if [ -f $p/whoami ]
53         then
54                 usewhoami=1
55                 if [ $usehostname -ne 0 ]
56                 then
57                         break;
58                 fi
59         fi
60         if [ -f $p/hostname ]
61         then
62                 usehostname=1
63                 if [ $usewhoami -ne 0 ]
64                 then
65                         break;
66                 fi
67         fi
68 done
69 if [ $usewhoami -ne 0 ]
70 then
71         user=`whoami`
72 else
73         user=$LOGNAME
74 fi
75
76 if [ $usehostname -ne 0 ]
77 then
78         host=`hostname`
79 else
80         host=`uname -n`
81 fi
82 echo "PUSHDIVERT(0)"
83 echo "####################################################################"
84 echo "##### This file is automatically generated -- edit at your own risk"
85 echo '#####' Built by $user@$host
86 echo '#####' on `date` using template OS/$os
87 if [ ! -z "$SITECONFIG" ]
88 then
89         echo '#####' including $SITECONFIG
90 fi
91 echo '#####' in `pwd` | sed 's/\/tmp_mnt//'
92 echo "####################################################################"
93 echo ""
94 echo "POPDIVERT"
95 echo "define(\`__HOST__', \`$host')dnl"
96 echo "ifdef(\`confMAPDEF',, \`define(\`confMAPDEF', \`')')dnl"
97 echo "ifdef(\`confLIBS',, \`define(\`confLIBS', \`')')dnl"
98
99 LIBDIRS="$LIBDIRS $LIBPATH"
100 libs=""
101 mapdef=""
102 for l in $LIBSRCH
103 do
104         for p in `echo $LIBDIRS | sed -e 's/:/ /g' -e 's/^-L//g' -e 's/ -L/ /g'`
105         do
106                 if [ "x$p" = "x" ]
107                 then
108                         p = "."
109                 fi
110                 if [ -f $p/lib$l.a -o -f $p/lib$l.so ]
111                 then
112                         case $l
113                         in
114                           db)
115                                 mapdef="$mapdef -DNEWDB"
116                                 ;;
117                           bind|resolv)
118                                 if [ -n "$resolver" ]
119                                 then
120                                         continue
121                                 else
122                                         resolver=$l
123                                 fi
124                                 ;;
125                           44bsd)
126                                 if [ "x$resolver" != "xresolv" ]
127                                 then
128                                         continue
129                                 fi
130                                 ;;
131                         esac
132                         libs="$libs -l$l"
133                         break
134                 fi
135         done
136 done
137
138 for p in `echo $PATH | sed 's/:/ /g'`
139 do
140         pbase=`echo $p | sed -e 's,/bin,,'`
141         if [ "x$p" = "x" ]
142         then
143                 p="."
144         fi
145         if [ -f $p/mkdep ]
146         then
147                 echo "ifdef(\`confDEPEND_TYPE',, \`define(\`confDEPEND_TYPE', \`BSD')')dnl"
148         fi
149 done
150
151 if [ -z "$sflag" ]
152 then
153         echo "define(\`confMAPDEF', \`$mapdef' confMAPDEF)dnl"
154         echo "define(\`confLIBS', \`$libs' confLIBS)dnl"
155 fi
156
157 if [ ! -z "`$SHELL $find_prog ranlib`" ]
158 then
159         echo "define(\`confRANLIB', \`ranlib')dnl"
160 fi
161
162 roff_progs="groff nroff"
163 for roff_prog in $roff_progs
164 do
165         if [ ! -z "`$SHELL $find_prog $roff_prog`" ]
166         then
167                 found_roff=$roff_prog
168                 break;
169         fi
170 done
171
172 case $found_roff
173 in
174         groff)
175                 echo "ifdef(\`confNROFF',,\`define(\`confNROFF', \`$found_roff -Tascii')')dnl"
176                 ;;
177         nroff)
178                 echo "ifdef(\`confNROFF',,\`define(\`confNROFF', \`$found_roff')')dnl"
179                 ;;
180         *)
181                 echo "ifdef(\`confNROFF',,\`define(\`confNO_MAN_BUILD')')dnl"
182                 ;;
183 esac
184