1#!/bin/sh
2
3# Copyright (c) 1993 Eric P. Allman
4# Copyright (c) 1993 The Regents of the University of California.
5# All rights reserved.
6#
7# %sccs.include.redist.sh%
8#
9#       @(#)makesendmail	8.22 (Berkeley) 05/14/95
10#
11
12#
13#  A quick-and-dirty script to compile sendmail in the presence of
14#  multiple architectures and Makefiles.
15#
16
17#
18#  Do heuristic guesses for machines that do not have uname
19#
20if [ -d /LocalApps -a ! -f /bin/uname -a ! -f /usr/bin/uname ]
21then
22	# probably a NeXT box
23	arch=NeXT
24	os=Mach
25	rel=`strings /mach | grep 'Mach.*:' | sed -e 's/.* Mach //' -e 's/:.*//'`
26elif [ -f /usr/sony/bin/machine -a -f /etc/osversion ]
27then
28	# probably a Sony NEWS 4.x
29	os=NEWS-OS
30	rel=`awk '{ print $3}' /etc/osversion`
31	arch=`/usr/sony/bin/machine`
32elif [ -d /usr/omron -a -f /bin/luna ]
33then
34	# probably a Omron LUNA
35	os=LUNA
36	if [ -f /bin/luna1 ] && /bin/luna1
37	then
38		rel=unios-b
39		arch=luna1
40	elif [ -f /bin/luna2 ] && /bin/luna2
41	then
42		rel=Mach
43		arch=luna2
44	elif [ -f /bin/luna88k ] && /bin/luna88k
45	then
46		rel=Mach
47		arch=luna88k
48	fi
49fi
50
51if [ ! "$arch" -a ! "$os" -a ! "$rel" ]
52then
53	arch=`uname -m | sed -e 's/ //g'`
54	os=`uname -s | sed 's/\//-/g'`
55	rel=`uname -r`
56fi
57
58# tweak machine architecture
59case $arch
60in
61  sun4*)	arch=sun4;;
62
63  9000/*)	arch=`echo $arch | sed -e 's/9000.//' -e 's/..$/xx/'`;;
64esac
65
66# tweak operating system type and release
67case $os
68in
69  DYNIX-ptx)	os=PTX;;
70  Paragon*)	os=Paragon;;
71  HP-UX)	rel=`echo $rel | sed -e 's/^[^.]*\.0*//'`;;
72esac
73
74# get "base part" of operating system release
75rbase=`echo $rel | sed -e 's/\..*//'`
76
77# heuristic tweaks to clean up names
78if [ "$os" = "unix" ]
79then
80	# might be Altos System V
81	case $rel
82	in
83	  5.3*)		os=Altos;;
84	esac
85fi
86
87if [ -r /unix -a -r /usr/lib/libseq.a -a -r /lib/cpp ]
88then
89	# might be a DYNIX/ptx 2.x system, which has a broken uname
90	if strings /lib/cpp | grep _SEQUENT_ > /dev/null
91	then
92		os=PTX
93	fi
94fi
95
96if [ -d /usr/nec -a "$os" = "UNIX_System_V" ]
97then
98	os=EWS-UX_V
99fi
100
101# see if there is a "user suffix" specified
102if [ "${SENDMAIL_SUFFIX-}x" = "x" ]
103then
104	sfx=""
105else
106	sfx=".${SENDMAIL_SUFFIX}"
107fi
108
109echo "Making sendmail with os=$os, rel=$rel, rbase=$rbase, arch=$arch, sfx=$sfx"
110
111# now try to find a reasonable object directory
112if [ -r obj.$os.$rel.$arch$sfx ]; then
113	obj=obj.$os.$rel.$arch$sfx
114elif [ -r obj.$os.$rbase.x.$arch$sfx ]; then
115	obj=obj.$os.$rbase.x.$arch$sfx
116elif [ -r obj.$os.$rel$sfx ]; then
117	obj=obj.$os.$rel$sfx
118elif [ -r obj.$os.$rbase.x$sfx ]; then
119	obj=obj.$os.$rbase.x$sfx
120elif [ -r obj.$os.$arch$sfx ]; then
121	obj=obj.$os.$arch$sfx
122elif [ -r obj.$rel.$arch$sfx ]; then
123	obj=obj.$rel.$arch$sfx
124elif [ -r obj.$rbase.x.$arch$sfx ]; then
125	obj=obj.$rbase.x.$arch$sfx
126elif [ -r obj.$os$sfx ]; then
127	obj=obj.$os$sfx
128elif [ -r obj.$arch$sfx ]; then
129	obj=obj.$arch$sfx
130elif [ -r obj.$rel$sfx ]; then
131	obj=obj.$rel$sfx
132elif [ -r obj$sfx ]; then
133	obj=obj$sfx
134else
135	# no existing obj directory -- try to create one if Makefile found
136	obj=obj.$os.$rel.$arch$sfx
137	if [ -r Makefiles/Makefile.$os.$rel.$arch$sfx ]; then
138		makefile=Makefile.$os.$rel.$arch$sfx
139	elif [ -r Makefiles/Makefile.$os.$rel.$arch ]; then
140		makefile=Makefile.$os.$rel.$arch
141	elif [ -r Makefiles/Makefile.$os.$rbase.x.$arch$sfx ]; then
142		makefile=Makefile.$os.$rbase.x.$arch$sfx
143	elif [ -r Makefiles/Makefile.$os.$rbase.x.$arch ]; then
144		makefile=Makefile.$os.$rbase.x.$arch
145	elif [ -r Makefiles/Makefile.$os.$rel$sfx ]; then
146		makefile=Makefile.$os.$rel$sfx
147	elif [ -r Makefiles/Makefile.$os.$rel ]; then
148		makefile=Makefile.$os.$rel
149	elif [ -r Makefiles/Makefile.$os.$rbase.x$sfx ]; then
150		makefile=Makefile.$os.$rbase.x$sfx
151	elif [ -r Makefiles/Makefile.$os.$rbase.x ]; then
152		makefile=Makefile.$os.$rbase.x
153	elif [ -r Makefiles/Makefile.$os.$arch$sfx ]; then
154		makefile=Makefile.$os.$arch$sfx
155	elif [ -r Makefiles/Makefile.$os.$arch ]; then
156		makefile=Makefile.$os.$arch
157	elif [ -r Makefiles/Makefile.$rel.$arch$sfx ]; then
158		makefile=Makefile.$rel.$arch$sfx
159	elif [ -r Makefiles/Makefile.$rel.$arch ]; then
160		makefile=Makefile.$rel.$arch
161	elif [ -r Makefiles/Makefile.$rbase.x.$arch$sfx ]; then
162		makefile=Makefile.$rbase.x.$arch$sfx
163	elif [ -r Makefiles/Makefile.$rbase.x.$arch ]; then
164		makefile=Makefile.$rbase.x.$arch
165	elif [ -r Makefiles/Makefile.$os$sfx ]; then
166		makefile=Makefile.$os$sfx
167	elif [ -r Makefiles/Makefile.$os ]; then
168		makefile=Makefile.$os
169	elif [ -r Makefiles/Makefile.$arch$sfx ]; then
170		makefile=Makefile.$arch$sfx
171	elif [ -r Makefiles/Makefile.$arch ]; then
172		makefile=Makefile.$arch
173	elif [ -r Makefiles/Makefile.$rel$sfx ]; then
174		makefile=Makefile.$rel$sfx
175	elif [ -r Makefiles/Makefile.$rel ]; then
176		makefile=Makefile.$rel
177	elif [ -r Makefiles/Makefile.$rel$sfx ]; then
178		makefile=Makefile.$rel$sfx
179	else
180		echo "Cannot determine how to support $arch.$os.$rel"
181		exit 1
182	fi
183	echo "Creating $obj using $makefile"
184	mkdir $obj
185	(cd $obj; ln -s ../*.[ch158] ../sendmail.hf .; ln -s ../Makefiles/$makefile Makefile)
186fi
187echo "Making in $obj"
188cd $obj
189if [ $# = 0 ]
190then
191	exec ${MAKE-make}
192else
193	exec ${MAKE-make} "$@"
194fi
195