summaryrefslogtreecommitdiff
path: root/usr.sbin/sendmail/BuildTools/bin/configure.sh
blob: aff771c8127af5ceefcd2e12f870504baf3feb70 (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
#!/bin/sh

# Copyright (c) 1998 Sendmail, Inc.  All rights reserved.
#
# By using this file, you agree to the terms and conditions set
# forth in the LICENSE file which can be found at the top level of
# the sendmail distribution.
#
#
#	@(#)configure.sh	8.27 (Berkeley) 5/19/1998

#
#  Special script to autoconfigure for M4 generation of Makefile
#

os=""
resolver=""
sflag=""

while [ ! -z "$1" ]
do
	case $1
	in
	  -s)	# skip auto-configure
		sflag=1
		shift
		;;

	  *)	# OS definition
		os=$1
		shift
		;;
	esac
done

usewhoami=0
usehostname=0
for p in `echo $PATH | sed 's/:/ /g'`
do
	if [ "x$p" = "x" ]
	then
		p="."
	fi
	if [ -f $p/whoami ]
	then
		usewhoami=1
		if [ $usehostname -ne 0 ]
		then
			break;
		fi
	fi
	if [ -f $p/hostname ]
	then
		usehostname=1
		if [ $usewhoami -ne 0 ]
		then
			break;
		fi
	fi
done
if [ $usewhoami -ne 0 ]
then
	user=`whoami`
else
	user=$LOGNAME
fi

if [ $usehostname -ne 0 ]
then
	host=`hostname`
else
	host=`uname -n`
fi
echo "PUSHDIVERT(0)"
echo "####################################################################"
echo "##### This file is automatically generated -- edit at your own risk"
echo '#####' Built by $user@$host
echo '#####' on `date` using template OS/$os
if [ ! -z "$SITECONFIG" ]
then
	echo '#####' including $SITECONFIG
fi
echo '#####' in `pwd` | sed 's/\/tmp_mnt//'
echo "####################################################################"
echo ""
echo "POPDIVERT"
echo "define(\`__HOST__', \`$host')dnl"
echo "ifdef(\`confMAPDEF',, \`define(\`confMAPDEF', \`')')dnl"
echo "ifdef(\`confLIBS',, \`define(\`confLIBS', \`')')dnl"

# If user did not supply ABI for Build, use SGI_ABI
# so the proper libraries are checked below.
if [ -z "$ABI" ]
then
	ABI="$SGI_ABI"
fi

case $ABI
in
	-n32)	LIBDIRS="$LIBDIRS /lib32 /usr/lib32"
		;;
	-64)	LIBDIRS="$LIBDIRS /lib64 /usr/lib64"
		;;
	*)	LIBDIRS="$LIBDIRS /lib /usr/lib /usr/shlib"
		;;
esac

libs=""
mapdef=""
for l in $LIBSRCH
do
	for p in `echo $LIBDIRS | sed -e 's/:/ /g' -e 's/^-L//g' -e 's/ -L/ /g'`
	do
		if [ "x$p" = "x" ]
		then
			p = "."
		fi
		if [ -f $p/lib$l.a -o -f $p/lib$l.so ]
		then
			case $l
			in
			  db)
				mapdef="$mapdef -DNEWDB"
				;;
			  bind|resolv)
				if [ -n "$resolver" ]
				then
					continue
				else
					resolver=$l
				fi
				;;
			  44bsd)
				if [ "x$resolver" != "xresolv" ]
				then
					continue
				fi
				;;
			esac
			libs="$libs -l$l"
			break
		fi
	done
done

for p in `echo $PATH | sed 's/:/ /g'`
do
	pbase=`echo $p | sed -e 's,/bin,,'`
	if [ "x$p" = "x" ]
	then
		p="."
	fi
	if [ -f $p/mkdep ]
	then
		echo "ifdef(\`confDEPEND_TYPE',, \`define(\`confDEPEND_TYPE', \`BSD')')dnl"
	fi
done

if [ -z "$sflag" ]
then
	echo "define(\`confMAPDEF', \`$mapdef' confMAPDEF)dnl"
	echo "define(\`confLIBS', \`$libs' confLIBS)dnl"
fi