source: trunk/packs/build/do.sh @ 21140

Revision 21140, 7.2 KB checked in by ghudson, 20 years ago (diff)
Use locally-installed Sun compiler if available.
  • Property svn:executable set to *
Line 
1#!/bin/sh
2# $Id: do.sh,v 1.82 2004-10-26 16:25:00 ghudson Exp $
3
4source=/mit/source
5srvd=/.srvd
6contained=false
7mungepath=true
8n=""
9maybe=""
10
11usage() {
12  echo "Usage: do [-np] [-s srcdir] [-d destdir]" 1>&2
13  echo "        [dist|prepare|clean|all|check|install]" 1>&2
14  exit 1
15}
16
17while getopts pd:ns: opt; do
18  case "$opt" in
19  p)
20    mungepath=false
21    ;;
22  d)
23    srvd=$OPTARG
24    ;;
25  n)
26    n=-n
27    maybe=echo
28    ;;
29  s)
30    source=$OPTARG
31    ;;
32  \?)
33    usage
34    ;;
35  esac
36done
37shift `expr "$OPTIND" - 1`
38operation=${1-all}
39
40case "$operation" in
41dist|prepare|clean|all|check|install)
42  ;;
43*)
44  echo Unknown operation \"$operation\" 1>&2
45  usage
46  ;;
47esac
48
49# Set up the build environment.
50umask 022
51export ATHENA_SYS ATHENA_SYS_COMPAT ATHENA_HOSTTYPE OS PATH
52
53# Determine proper ATHENA_SYS and ATHENA_SYS_COMPAT value.
54case `uname -srm` in
55"SunOS 5.9 sun4"*)
56  ATHENA_SYS=sun4x_59
57  ATHENA_SYS_COMPAT=sun4x_58:sun4x_57:sun4x_56:sun4x_55:sun4m_54:sun4m_53
58  ATHENA_SYS_COMPAT=${ATHENA_SYS_COMPAT}:sun4m_412
59  ;;
60"SunOS 5.8 sun4"*)
61  ATHENA_SYS=sun4x_58
62  ATHENA_SYS_COMPAT=sun4x_57:sun4x_56:sun4x_55:sun4m_54:sun4m_53:sun4m_412
63  ;;
64"SunOS 5.7 sun4"*)
65  ATHENA_SYS=sun4x_57
66  ATHENA_SYS_COMPAT=sun4x_56:sun4x_55:sun4m_54:sun4m_53:sun4m_412
67  ;;
68"SunOS 5.6 sun4"*)
69  ATHENA_SYS=sun4x_56
70  ATHENA_SYS_COMPAT=sun4x_55:sun4m_54:sun4m_53:sun4m_412
71  ;;
72"SunOS 5.5 sun4"*)
73  ATHENA_SYS=sun4x_55
74  ATHENA_SYS_COMPAT=sun4m_54:sun4m_53:sun4m_412
75  ;;
76"SunOS 5.4 sun4"*)
77  ATHENA_SYS=sun4m_54
78  ATHENA_SYS_COMPAT=sun4m_53:sun4m_412
79  ;;
80Linux\ 2.2.*\ i?86)
81  ATHENA_SYS=i386_linux22
82  ATHENA_SYS_COMPAT=i386_linux3:i386_linux2:i386_linux1
83  ;;
84Linux\ 2.4.*\ i?86)
85  case `cat /etc/redhat-release` in
86  "Red Hat Linux release 7.3 "*)
87    ATHENA_SYS=i386_linux24
88    ATHENA_SYS_COMPAT=i386_linux22:i386_linux3:i386_linux2:i386_linux1
89    ;;
90  "Red Hat Linux release 9 "*)
91    ATHENA_SYS=i386_rh9
92    ATHENA_SYS_COMPAT=i386_linux24:i386_linux22:i386_linux3:i386_linux2
93    ATHENA_SYS_COMPAT=${ATHENA_SYS_COMPAT}:i386_linux1
94    ;;
95  "Red Hat Enterprise Linux"*"release 3"*)
96    ATHENA_SYS=i386_rhel3
97    ATHENA_SYS_COMPAT=i386_rh9:i386_linux24:i386_linux22:i386_linux3
98    ATHENA_SYS_COMPAT=${ATHENA_SYS_COMPAT}:i386_linux2:i386_linux1
99    ;;
100  *)
101    echo "Unrecognized Red Hat release, aborting." 1>&2
102    exit 1
103    ;;
104  esac
105  ;;
106*)
107  echo "Unrecognized system type, aborting." 1>&2
108  exit 1
109  ;;
110esac
111
112# Determine platform name.
113case `uname -sm` in
114"SunOS sun4"*)
115  ATHENA_HOSTTYPE=sun4
116  ;;
117"Linux "i?86)
118  ATHENA_HOSTTYPE=linux
119  ;;
120esac
121
122savepath=$PATH
123
124# Determine operating system, appropriate path, and compiler for use
125# with plain Makefiles and some third-party packages.
126case `uname -s` in
127SunOS)
128  OS=solaris
129  LD_LIBRARY_PATH=/usr/openwin/lib export LD_LIBRARY_PATH
130  LD_RUN_PATH=/usr/athena/lib:/usr/openwin/lib export LD_RUN_PATH
131  PATH=/usr/ccs/bin:/usr/bin:/usr/ucb:/usr/openwin/bin
132  if [ -d /opt/SUNWspro/bin ]; then
133    sprobin=/opt/SUNWspro/bin
134  else
135    sprobin=/afs/athena.mit.edu/software/sunsoft/SUNWspro/bin
136  fi
137  export sprobin
138  ;;
139Linux)
140  OS=linux
141  LD_RUN_PATH=/usr/athena/lib export LD_RUN_PATH
142  PATH=/usr/bin:/bin:/usr/X11R6/bin
143  ;;
144esac
145CC=gcc
146CXX=g++
147WARN_CFLAGS="-Wall -Wstrict-prototypes -Wmissing-prototypes"
148ERROR_CFLAGS=-Werror
149PATH=/usr/athena/bin:$PATH
150
151if [ false = "$mungepath" ]; then
152  PATH=$savepath
153fi
154
155if [ dist = "$operation" ]; then
156  # Copy in the version file, for the few packages which need to know
157  # the Athena version.
158  cp $source/packs/build/version athena-version
159
160  # Force all source files to the same timestamp, to prevent third-party
161  # build systems from thinking some are out of date with respect to others.
162  find . ! -type l -exec touch -t `date +%Y%m%d%H%M.%S` {} \;
163fi
164
165# Determine the Athena version and set variables for the build system.
166. ./athena-version
167ATHENA_MAJOR_VERSION=$major
168ATHENA_MINOR_VERSION=$minor
169if [ -z "$ATHENA_PATCH_VERSION" ]; then
170  ATHENA_PATCH_VERSION=$patch
171fi
172export ATHENA_MAJOR_VERSION ATHENA_MINOR_VERSION ATHENA_PATCH_VERSION
173
174# Determine if gmake is available. (It should be, unless this is a
175# full build and we haven't built it yet.)
176if [ -x /usr/athena/bin/gmake ]; then
177  MAKE=gmake
178else
179  MAKE=make
180fi
181
182export WARN_CFLAGS ERROR_CFLAGS CC CXX MAKE
183
184# GConf schemas need to be installed from RPM %post scriptlets, not
185# make install rules.
186GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL=1
187export GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL
188
189# On Linux, we use the native pkg-config, which needs to be able to
190# find our libraries.
191PKG_CONFIG_PATH=/usr/athena/lib/pkgconfig
192export PKG_CONFIG_PATH
193
194if [ -r Makefile.athena ]; then
195  export SRVD SOURCE COMPILER
196  SRVD=$srvd
197  SOURCE=$source
198  COMPILER=$CC
199  if [ dist = "$operation" ]; then
200    export CONFIG_SITE XCONFIGDIR
201    CONFIG_SITE=$source/packs/build/config.site
202    XCONFIGDIR=$source/packs/build/xconfig
203  fi
204  $MAKE $n -f Makefile.athena "$operation"
205elif [ -f configure.in -o -f configure.ac -o -f configure ]; then
206  if [ -f configure.athena ]; then
207    configure=configure.athena
208  else
209    configure=configure
210  fi
211  case $operation in
212  dist)
213    # Copy in support files and run autoconf if this is a directory using the
214    # Athena build system.
215    if [ -f config.do -o ! -f configure ]; then
216      $maybe touch config.do
217      $maybe rm -f mkinstalldirs install-sh config.guess
218      $maybe rm -f config.sub aclocal.m4
219      $maybe cp "$source/packs/build/autoconf/mkinstalldirs" .
220      $maybe cp "$source/packs/build/autoconf/install-sh" .
221      $maybe cp "$source/packs/build/autoconf/config.guess" .
222      $maybe cp "$source/packs/build/autoconf/config.sub" .
223      $maybe cp "$source/packs/build/aclocal.m4" .
224      $maybe cat "$source/packs/build/libtool/libtool.m4" >> aclocal.m4
225      $maybe cp "$source/packs/build/libtool/ltmain.sh" .
226      $maybe autoconf || exit 1
227    fi
228    $maybe cp "$source/packs/build/config.site" config.site.athena
229    ;;
230  prepare)
231    $maybe rm -f config.cache
232    CONFIG_SITE=`pwd`/config.site.athena $maybe "./$configure"
233  ;;
234  clean)
235    $MAKE $n clean
236    ;;
237  all)
238    $MAKE $n all
239    ;;
240  check)
241    $MAKE -n check >/dev/null 2>&1 && $MAKE $n check || true
242    ;;
243  install)
244    $MAKE $n install "DESTDIR=$srvd"
245    ;;
246  esac
247elif [ -r Imakefile ]; then
248  case $operation in
249  dist)
250    $maybe mkdir -p config
251    $maybe cp $source/packs/build/xconfig/README config
252    $maybe cp $source/packs/build/xconfig/mkdirhier.sh config
253    $maybe cp $source/packs/build/xconfig/rtcchack.bac config
254    $maybe cp $source/packs/build/xconfig/site.def config
255    $maybe cp $source/packs/build/xconfig/*.cf config
256    $maybe cp $source/packs/build/xconfig/*.rules config
257    $maybe cp $source/packs/build/xconfig/*.tmpl config
258    ;;
259  prepare)
260    $maybe imake "-Iconfig" -DUseInstalled "-DTOPDIR=`pwd`" \
261      "-DXCONFIGDIR=`pwd`/config"
262    $maybe $MAKE Makefiles
263    ;;
264  clean)
265    $MAKE $n clean
266    ;;
267  all)
268    $MAKE $n includes depend all TOP=`pwd` MAKE="$MAKE TOP=`pwd`"
269    ;;
270  check)
271    ;;
272  install)
273    $MAKE $n install install.man "DESTDIR=$srvd" TOP=`pwd` \
274      MAKE="$MAKE TOP=`pwd`"
275    ;;
276  esac
277elif [ -r Makefile ]; then
278  case $operation in
279  dist|prepare)
280    ;;
281  clean)
282    $MAKE $n clean
283    ;;
284  all)
285    $MAKE $n all CC="$CC"
286    ;;
287  check)
288    $MAKE $n check
289    ;;
290  install)
291    $MAKE $n install "DESTDIR=$srvd"
292    ;;
293  esac
294else
295  echo Nothing to do in `pwd` 1>&2
296  exit 1
297fi
Note: See TracBrowser for help on using the repository browser.