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.15 (Berkeley) 03/23/95
10#
11
12#
13#  A quick-and-dirty script to compile sendmail in the presence of
14#  multiple architectures and Makefiles.
15#
16
17if [ -d /LocalApps -a ! -f /bin/uname -a ! -f /usr/bin/uname ]
18then
19	# probably a NeXT box
20	arch=NeXT
21	os=Mach
22	rel=`strings /mach | grep Mach | sed -e 's/.* Mach //' -e 's/:.*//'`
23else
24	arch=`uname -m | sed -e 's/ //g'`
25	os=`uname -s`
26	rel=`uname -r`
27fi
28
29# tweak machine architecture
30case $arch
31in
32  sun4*)	arch=sun4;;
33
34  9000/*)	arch=`echo $arch | sed -e 's/9000.//' -e 's/..$/xx/'`;;
35esac
36
37# tweak operating system type
38case $os
39in
40  DYNIX/ptx)	os=PTX;;
41  Paragon*)	os=Paragon;;
42esac
43
44# tweak operating system release
45rbase=`echo $rel | sed 's/\..*//''`
46
47# heuristic tweaks to clean up names
48if [ "$os" = "unix" ]
49then
50	# might be Altos System V
51	case $rel
52	in
53	  5.3*)		os=Altos;;
54	esac
55fi
56
57if [ -r /unix -a -r /usr/lib/libseq.a -a -r /lib/cpp ]
58then
59	# might be a DYNIX/ptx 2.x system, which has a broken uname
60	if strings /lib/cpp | grep _SEQUENT_ > /dev/null
61	then
62		os=PTX
63	fi
64fi
65
66# now try to find a reasonable object directory
67if [ -r obj.$os.$rel.$arch ]; then
68	obj=obj.$os.$rel.$arch
69elif [ -r obj.$os.$rbase.x.$arch ]; then
70	obj=obj.$os.$rbase.x.$arch
71elif [ -r obj.$os.$rel ]; then
72	obj=obj.$os.$rel
73elif [ -r obj.$os.$rbase.x ]; then
74	obj=obj.$os.$rbase.x
75elif [ -r obj.$os.$arch ]; then
76	obj=obj.$os.$arch
77elif [ -r obj.$rel.$arch ]; then
78	obj=obj.$rel.$arch
79elif [ -r obj.$rbase.x.$arch ]; then
80	obj=obj.$rbase.x.$arch
81elif [ -r obj.$os ]; then
82	obj=obj.$os
83elif [ -r obj.$arch ]; then
84	obj=obj.$arch
85elif [ -r obj.$rel ]; then
86	obj=obj.$rel
87else
88	# no existing obj directory -- try to create one if Makefile found
89	obj=obj.$os.$rel.$arch
90	if [ -r Makefiles/Makefile.$os.$rel.$arch ]; then
91		makefile=Makefile.$os.$rel.$arch
92	elif [ -r Makefiles/Makefile.$os.$rbase.x.$arch ]; then
93		makefile=Makefile.$os.$rbase.x.$arch
94	elif [ -r Makefiles/Makefile.$os.$rel ]; then
95		makefile=Makefile.$os.$rel
96	elif [ -r Makefiles/Makefile.$os.$rbase.x ]; then
97		makefile=Makefile.$os.$rbase.x
98	elif [ -r Makefiles/Makefile.$os.$arch ]; then
99		makefile=Makefile.$os.$arch
100	elif [ -r Makefiles/Makefile.$rel.$arch ]; then
101		makefile=Makefile.$rel.$arch
102	elif [ -r Makefiles/Makefile.$rbase.x.$arch ]; then
103		makefile=Makefile.$rbase.x.$arch
104	elif [ -r Makefiles/Makefile.$os ]; then
105		makefile=Makefile.$os
106	elif [ -r Makefiles/Makefile.$arch ]; then
107		makefile=Makefile.$arch
108	elif [ -r Makefiles/Makefile.$rel ]; then
109		makefile=Makefile.$rel
110	else
111		echo "Cannot determine how to support $arch.$os.$rel"
112		exit 1
113	fi
114	echo "Creating $obj using $makefile"
115	mkdir $obj
116	(cd $obj; ln -s ../*.[ch158] ../sendmail.hf .; ln -s ../Makefiles/$makefile Makefile)
117fi
118echo "Making in $obj"
119cd $obj
120if [ $# = 0 ]
121then
122	exec ${MAKE-make}
123else
124	exec ${MAKE-make} "$@"
125fi
126