configure 6.28 KB
Newer Older
Ted Lemon's avatar
Ted Lemon committed
1 2
#!/bin/sh

Ted Lemon's avatar
Ted Lemon committed
3 4
#sysname=$1

5 6
while [ $# != 0 ]; do
  if [ x$1 = x--with-nsupdate ]; then
7
    echo "nsupdate is always built now."
8
  elif [ x$1 = x--print-sysname ]; then
9
    print_sysname=yes
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
  elif [ x$1 = x--work-dir ]; then
    workname=$2
    shift
  elif [ x$1 = x--dirs ]; then
    dirs=$2
    shift
  elif [ x$1 = x--no-links ]; then
    nolinks=YES
  elif [ x$1 = x--copts ]; then
    copts=$2
    shift
  elif [ x$sysname = x ]; then
    sysname=$1
  else
    echo "Unexpected argument: $1"
25 26 27
  fi
  shift
done
Ted Lemon's avatar
Ted Lemon committed
28 29 30 31 32 33

uname=`uname -s`
machine=`uname -m`

if [ "$sysname" = "" ]; then
  case $uname in
Ted Lemon's avatar
Ted Lemon committed
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
    SCO_SV)
      IFS=":"
      for foo in $PATH; do
	if [ x$gcc_path = x ] && [ -x $foo/gcc ]; then
	  gcc_path=$foo/gcc
	fi 
      done
      IFS=" "
      if [ x$gcc_path = x ]; then
        sysname=sco-cc
        sysname_print=sco
      else
        sysname=sco-gcc
        sysname_print=sco
      fi
    ;;
Ted Lemon's avatar
Ted Lemon committed
50 51
    AIX)
      sysname=aix;;
52 53
    Darwin)
      sysname=darwin;;
Ted Lemon's avatar
Ted Lemon committed
54 55
    Rhapsody)
      sysname=rhapsody;;
Ted Lemon's avatar
Ted Lemon committed
56 57 58
    ULTRIX)
      sysname=ultrix;;
    BSD/OS)
59 60 61 62 63 64 65 66 67 68 69
      release=`uname -r`
      minor=`echo $release |sed -e 's/[0-9]*\.\([0-9][0-9]*\)\(\..*\)*$/\1/'`
      major=`echo $release |sed -e 's/\([0-9][0-9]*\)\..*$/\1/'`
      
      case $major in
	[123]) sysname=bsdos ;;
	*) case $minor in
	     0) sysname=bsdos ;;
	     *) sysname=bsdos-4.1 ;;
	   esac;;
      esac;;
Ted Lemon's avatar
Ted Lemon committed
70 71
    OSF1)
      if [ $machine = 'alpha' ]; then
Ted Lemon's avatar
Ted Lemon committed
72
        sysname=alphaosf
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
	# OSF1 has libc snprintf/vsnprintf support as of 4.0F.  There is
	# no v4 & v5 portable compile-time way of knowing the system's
	# version (we can #include a version-identing file, but it is only
	# present in v5).
	#
	# So we rely on a system command, 'sizer', and default to
	# no-snprintf if we can't find it.
	if [ -x /usr/sbin/sizer ] ; then
		release=`/usr/sbin/sizer -v | cut -d ' ' -f 4 | cut -c 2-`
		major=`echo $release | cut -d . -f 1`
		minor=`echo $release | cut -d . -f 2`
		incr=`echo $minor | sed 's/[0-9]//g' | tr '[A-Z]' '[0-9]'`
		minor=`echo $minor | sed 's/[A-Z]//g'`

		if [ $major -gt 4 -o \
		     $major -eq 4 -a $minor -gt 0 -o \
		     $major -eq 4 -a $minor -eq 0 -a $incr -gt 5 ]; then
			copts="$copts -DHAVE_SNPRINTF"
		fi
	fi
Ted Lemon's avatar
Ted Lemon committed
93 94
      fi;;
    Linux)
95
      release=`uname -r`
96 97
      minor=`echo $release |sed -e 's/[0-9]*\.\([0-9][0-9]*\)\(\..*\)*$/\1/'`
      major=`echo $release |sed -e 's/\([0-9][0-9]*\)\..*$/\1/'`
98 99 100 101 102 103 104 105 106
      
      case $major in
	1) sysname=linux-1 ;;
	2) case $minor in
	     0) sysname=linux-2.0 ;;
	     1) sysname=linux-2.1 ;;
	     2) sysname=linux-2.2 ;;
	     *) sysname=linux-2.2 ;;
	   esac;;
107
      esac;;
Ted Lemon's avatar
Ted Lemon committed
108
    SunOS)
Ted Lemon's avatar
Ted Lemon committed
109 110 111
      release=`uname -r`
      minor=`echo $release |sed -e 's/.*[0-9]*\.\([0-9][0-9]*\).*$/\1/'`
      major=`echo $release |sed -e 's/\([0-9][0-9]*\)\..*$/\1/'`
Ted Lemon's avatar
Ted Lemon committed
112 113 114 115 116 117
      IFS=":"
      for foo in $PATH; do
        if [ x$gcc_path = x ] && [ -x $foo/gcc ]; then
	  gcc_path=$foo/gcc
        fi
      done
118
      IFS=" "
Ted Lemon's avatar
Ted Lemon committed
119

Ted Lemon's avatar
Ted Lemon committed
120
      case $major in
Ted Lemon's avatar
Ted Lemon committed
121
        4) 
Ted Lemon's avatar
Ted Lemon committed
122
	  if [ x$gcc_path = x ]; then
Ted Lemon's avatar
Ted Lemon committed
123 124 125 126
	    echo SunOS 4 build will not work without the GNU C Compiler.
	    exit 1
	  fi
	  sysname=sunos4;;
Ted Lemon's avatar
Ted Lemon committed
127
        5)
Ted Lemon's avatar
Ted Lemon committed
128 129
	  if [ x$gcc_path = x ]; then
	    sysname=sunos5-cc
130
	    sysname_print=sunos5
Ted Lemon's avatar
Ted Lemon committed
131
	  else
Ted Lemon's avatar
Ted Lemon committed
132
	    sysname=sunos5-gcc
133
	    sysname_print=sunos5
Ted Lemon's avatar
Ted Lemon committed
134
	  fi;;
Ted Lemon's avatar
Ted Lemon committed
135 136
      esac;;
    NetBSD)
137
      sysname=netbsd;;
138 139
    OpenBSD)
      sysname=openbsd;;
Ted Lemon's avatar
Ted Lemon committed
140 141
    FreeBSD)
      sysname=freebsd;;
Ted Lemon's avatar
Ted Lemon committed
142
    hpux)
143
      IFS=":"
Ted Lemon's avatar
Ted Lemon committed
144 145 146 147 148
      for foo in $PATH; do
        if [ x$gcc_path = x ] && [ -x $foo/gcc ]; then
	  gcc_path=$foo/gcc
        fi
      done
149
      IFS=" "
Ted Lemon's avatar
Ted Lemon committed
150 151 152

      if [ x$gcc_path = x ]; then
	  sysname=hpux-cc
153
	  sysname_print=hpux
Ted Lemon's avatar
Ted Lemon committed
154
	else
Ted Lemon's avatar
Ted Lemon committed
155
	  sysname=hpux-gcc
156
	  sysname_print=hpux
Ted Lemon's avatar
Ted Lemon committed
157
	fi;;
Ted Lemon's avatar
Ted Lemon committed
158
    HP-UX)
159
      IFS=":"
Ted Lemon's avatar
Ted Lemon committed
160 161 162 163 164
      for foo in $PATH; do
        if [ x$gcc_path = x ] && [ -x $foo/gcc ]; then
	  gcc_path=$foo/gcc
        fi
      done
165
      IFS=" "
Ted Lemon's avatar
Ted Lemon committed
166 167 168

      if [ x$gcc_path = x ]; then
	  sysname=hpux-cc
169
	  sysname_print=hpux
Ted Lemon's avatar
Ted Lemon committed
170
	else
Ted Lemon's avatar
Ted Lemon committed
171
	  sysname=hpux-gcc
172
	  sysname_print=hpux
Ted Lemon's avatar
Ted Lemon committed
173
	fi;;
Ted Lemon's avatar
Ted Lemon committed
174
    QNX)
175 176 177 178 179 180 181 182
      release=`uname -r`
      major=`echo $release |sed -e 's/\([0-9][0-9]*\)\..*$/\1/'`
      case $major in
        6)
          sysname=qnxnto;;
        *)
          sysname=qnx;;
      esac;;      
Ted Lemon's avatar
Ted Lemon committed
183 184
    NEXTSTEP)
      sysname=nextstep;;
185 186
    UnixWare)
      sysname=uw7;;
Ted Lemon's avatar
Ted Lemon committed
187 188 189 190
  esac
fi

if [ "$sysname" = "" ]; then
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214
  if [ x$print_sysname = xyes ]; then
    echo "unknown"
  else
    echo "UNIX name: $uname    machine: $machine"
    echo
    echo "Unknown system.   If this is an SCO system running ODT 3.0 or"
    echo "higher, type \`\`./configure sco''.   Otherwise, this is a"
    echo "configuration that isn't supported or hasn't been tested."
    echo
    echo "Supported configurations are:"
    echo "   aix		AIX 4.1.5.0"
    echo "   ultrix	ULTRIX 4.2A or higher"
    echo "   bsdos	BSDI BSD/OS 2.1"
    echo "   alphaosf	DEC Alpha OSF/1"
    echo "   linux	Linux"
    echo "   sunos4	Sunos 4.1.4 (earlier releases may work)"
    echo "   sunos5-cc	Solaris 2.4 or higher with Sun cc"
    echo "   sunos5-gcc	Solaris 2.4 or higher with gcc"
    echo "   netbsd	NetBSD 1.1 or higher"
    echo "   freebsd	FreeBSD"
    echo "   openbsd      OpenBSD (i386/alpha)"
    echo "   hpux		HP-UX"
    echo "   qnx		QNX 4.2 or higher"
    echo "   NEXTSTEP     NeXTSTEP"
Ted Lemon's avatar
Ted Lemon committed
215
    echo "   sco	SCO Open Server"
216 217 218 219 220
    exit 1;
  fi
fi

if [ x$print_sysname = xyes ]; then
221 222 223 224 225
  if [ x$sysname_print != x ]; then
    echo $sysname_print
  else
    echo $sysname
  fi
226
  exit 0
Ted Lemon's avatar
Ted Lemon committed
227 228
fi

229 230 231 232 233 234
if [ x$workname = x ]; then
  if [ x$sysname_print != x ]; then
    workname=work.${sysname_print}
  else
    workname=work.${sysname}
  fi
235 236
fi

237
echo "System Type: $sysname"
238

239 240
if [ x$major != x ] && [ x$minor != x ]; then
  majversubst="-e /^##--majver--/,/^##--majver--/s/MajorVersion/$major/"
241
  minversubst="-e /^##--minver--/,/^##--minver--/s/MinorVersion/$minor/"
242
fi
243

244 245
if [ ! -d $workname ]; then
  mkdir $workname
246 247
fi

248 249 250 251 252 253 254 255
if [ x"$dirs" = x ]; then
  dirs=". client server relay common omapip dhcpctl minires dst"
fi

for foo in $dirs; do
	bar=`basename $foo`
	if [ ! -d ${workname}/$bar ]; then
	  mkdir ${workname}/$bar
256 257
	fi
	(sed $majversubst $minversubst \
258
	      -e "/^##--${sysname}--/,/^##--${sysname}--/s/^#//" \
259 260 261 262 263 264
				<Makefile.conf; \
		cat site.conf; \
		echo "TOP = `pwd`"; \
		echo CC_OPTIONS = $copts; \
		cat $foo/Makefile.dist)	\
				>${workname}/$bar/Makefile
265
done
Ted Lemon's avatar
Ted Lemon committed
266

267
# Make the link tree in which to actually build.
268 269 270
if [ x$nolinks = x ]; then
  make links
fi
271

Ted Lemon's avatar
Ted Lemon committed
272
exit 0