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