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.26 (Berkeley) 06/20/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 [ "x${1-""}" = "x-m" ] 18then 19 # show Makefile name only 20 mflag=1 21else 22 mflag="" 23fi 24 25# 26# Do heuristic guesses for machines that do not have uname 27# 28if [ -d /LocalApps -a ! -f /bin/uname -a ! -f /usr/bin/uname ] 29then 30 # probably a NeXT box 31 arch=NeXT 32 os=Mach 33 rel=`strings /mach | grep 'Mach.*:' | sed -e 's/.* Mach //' -e 's/:.*//'` 34elif [ -f /usr/sony/bin/machine -a -f /etc/osversion ] 35then 36 # probably a Sony NEWS 4.x 37 os=NEWS-OS 38 rel=`awk '{ print $3}' /etc/osversion` 39 arch=`/usr/sony/bin/machine` 40elif [ -d /usr/omron -a -f /bin/luna ] 41then 42 # probably a Omron LUNA 43 os=LUNA 44 if [ -f /bin/luna1 ] && /bin/luna1 45 then 46 rel=unios-b 47 arch=luna1 48 elif [ -f /bin/luna2 ] && /bin/luna2 49 then 50 rel=Mach 51 arch=luna2 52 elif [ -f /bin/luna88k ] && /bin/luna88k 53 then 54 rel=Mach 55 arch=luna88k 56 fi 57fi 58 59if [ ! "$arch" -a ! "$os" -a ! "$rel" ] 60then 61 arch=`uname -m | sed -e 's/ //g'` 62 os=`uname -s | sed 's/\//-/g'` 63 rel=`uname -r` 64fi 65 66# tweak machine architecture 67case $arch 68in 69 sun4*) arch=sun4;; 70 71 9000/*) arch=`echo $arch | sed -e 's/9000.//' -e 's/..$/xx/'`;; 72esac 73 74# tweak operating system type and release 75case $os 76in 77 DYNIX-ptx) os=PTX;; 78 Paragon*) os=Paragon;; 79 HP-UX) rel=`echo $rel | sed -e 's/^[^.]*\.0*//'`;; 80 AIX) rel=`uname -v`;; 81 BSD-386) os=BSD-OS;; 82esac 83 84# get "base part" of operating system release 85rbase=`echo $rel | sed -e 's/\..*//'` 86 87# heuristic tweaks to clean up names 88if [ "$os" = "unix" ] 89then 90 # might be Altos System V 91 case $rel 92 in 93 5.3*) os=Altos;; 94 esac 95fi 96 97if [ -r /unix -a -r /usr/lib/libseq.a -a -r /lib/cpp ] 98then 99 # might be a DYNIX/ptx 2.x system, which has a broken uname 100 if strings /lib/cpp | grep _SEQUENT_ > /dev/null 101 then 102 os=PTX 103 fi 104fi 105 106if [ -d /usr/nec -a "$os" = "UNIX_System_V" ] 107then 108 os=EWS-UX_V 109fi 110 111# see if there is a "user suffix" specified 112if [ "${SENDMAIL_SUFFIX-}x" = "x" ] 113then 114 sfx="" 115else 116 sfx=".${SENDMAIL_SUFFIX}" 117fi 118 119echo "Configuration: os=$os, rel=$rel, rbase=$rbase, arch=$arch, sfx=$sfx" 120 121# now try to find a reasonable object directory 122if [ -r obj.$os.$rel.$arch$sfx ]; then 123 obj=obj.$os.$rel.$arch$sfx 124elif [ -r obj.$os.$rbase.x.$arch$sfx ]; then 125 obj=obj.$os.$rbase.x.$arch$sfx 126elif [ -r obj.$os.$rel$sfx ]; then 127 obj=obj.$os.$rel$sfx 128elif [ -r obj.$os.$rbase.x$sfx ]; then 129 obj=obj.$os.$rbase.x$sfx 130elif [ -r obj.$os.$arch$sfx ]; then 131 obj=obj.$os.$arch$sfx 132elif [ -r obj.$rel.$arch$sfx ]; then 133 obj=obj.$rel.$arch$sfx 134elif [ -r obj.$rbase.x.$arch$sfx ]; then 135 obj=obj.$rbase.x.$arch$sfx 136elif [ -r obj.$os$sfx ]; then 137 obj=obj.$os$sfx 138elif [ -r obj.$arch$sfx ]; then 139 obj=obj.$arch$sfx 140elif [ -r obj.$rel$sfx ]; then 141 obj=obj.$rel$sfx 142elif [ -r obj$sfx ]; then 143 obj=obj$sfx 144else 145 # no existing obj directory -- try to create one if Makefile found 146 obj=obj.$os.$rel.$arch$sfx 147 if [ -r Makefiles/Makefile.$os.$rel.$arch$sfx ]; then 148 makefile=Makefile.$os.$rel.$arch$sfx 149 elif [ -r Makefiles/Makefile.$os.$rel.$arch ]; then 150 makefile=Makefile.$os.$rel.$arch 151 elif [ -r Makefiles/Makefile.$os.$rbase.x.$arch$sfx ]; then 152 makefile=Makefile.$os.$rbase.x.$arch$sfx 153 elif [ -r Makefiles/Makefile.$os.$rbase.x.$arch ]; then 154 makefile=Makefile.$os.$rbase.x.$arch 155 elif [ -r Makefiles/Makefile.$os.$rel$sfx ]; then 156 makefile=Makefile.$os.$rel$sfx 157 elif [ -r Makefiles/Makefile.$os.$rel ]; then 158 makefile=Makefile.$os.$rel 159 elif [ -r Makefiles/Makefile.$os.$rbase.x$sfx ]; then 160 makefile=Makefile.$os.$rbase.x$sfx 161 elif [ -r Makefiles/Makefile.$os.$rbase.x ]; then 162 makefile=Makefile.$os.$rbase.x 163 elif [ -r Makefiles/Makefile.$os.$arch$sfx ]; then 164 makefile=Makefile.$os.$arch$sfx 165 elif [ -r Makefiles/Makefile.$os.$arch ]; then 166 makefile=Makefile.$os.$arch 167 elif [ -r Makefiles/Makefile.$rel.$arch$sfx ]; then 168 makefile=Makefile.$rel.$arch$sfx 169 elif [ -r Makefiles/Makefile.$rel.$arch ]; then 170 makefile=Makefile.$rel.$arch 171 elif [ -r Makefiles/Makefile.$rbase.x.$arch$sfx ]; then 172 makefile=Makefile.$rbase.x.$arch$sfx 173 elif [ -r Makefiles/Makefile.$rbase.x.$arch ]; then 174 makefile=Makefile.$rbase.x.$arch 175 elif [ -r Makefiles/Makefile.$os$sfx ]; then 176 makefile=Makefile.$os$sfx 177 elif [ -r Makefiles/Makefile.$os ]; then 178 makefile=Makefile.$os 179 elif [ -r Makefiles/Makefile.$arch$sfx ]; then 180 makefile=Makefile.$arch$sfx 181 elif [ -r Makefiles/Makefile.$arch ]; then 182 makefile=Makefile.$arch 183 elif [ -r Makefiles/Makefile.$rel$sfx ]; then 184 makefile=Makefile.$rel$sfx 185 elif [ -r Makefiles/Makefile.$rel ]; then 186 makefile=Makefile.$rel 187 elif [ -r Makefiles/Makefile.$rel$sfx ]; then 188 makefile=Makefile.$rel$sfx 189 else 190 echo "Cannot determine how to support $arch.$os.$rel" 191 exit 1 192 fi 193 if [ "$mflag" ] 194 then 195 echo "Will run in virgin $obj using $makefile" 196 exit 0 197 fi 198 echo "Creating $obj using $makefile" 199 mkdir $obj 200 (cd $obj; ln -s ../*.[ch158] ../sendmail.hf .; ln -s ../Makefiles/$makefile Makefile) 201 echo "Making dependencies in $obj" 202 (cd $obj; ${MAKE-make} depend) 203fi 204 205if [ "$mflag" ] 206then 207 makefile=`ls -l $obj/Makefile | sed 's/.* //'` 208 if [ -z "$makefile" ] 209 then 210 echo "ERROR: $obj exists but has no Makefile" 211 exit 1 212 fi 213 case $makefile 214 in 215 ../Makefiles/*) 216 makefile=`echo $makefile | sed 's/...Makefiles.//'` 217 echo "Will run in existing $obj using $makefile" 218 ;; 219 220 *) 221 echo "Will run in existing $obj using custom $makefile" 222 ;; 223 esac 224 exit 0 225fi 226 227echo "Making in $obj" 228cd $obj 229if [ $# = 0 ] 230then 231 exec ${MAKE-make} 232else 233 exec ${MAKE-make} "$@" 234fi 235