| 1 | greg | 1.1 | #!/bin/csh -f | 
| 2 | greg | 1.13 | # RCSid $Id: makeall,v 1.12 2004/10/30 04:59:40 greg Exp $ | 
| 3 | greg | 1.1 | # | 
| 4 |  |  | # Make all the Radiance programs | 
| 5 |  |  | # | 
| 6 |  |  | if ( $#argv < 1 ) then | 
| 7 |  |  | echo "Usage: makeall install [clean] [make options]" | 
| 8 |  |  | echo "   or: makeall clean" | 
| 9 |  |  | echo "   or: makeall library" | 
| 10 |  |  | exit 1 | 
| 11 |  |  | endif | 
| 12 |  |  | if ( "$1" == library ) then | 
| 13 |  |  | source installib | 
| 14 | greg | 1.8 | cp -f src/*/*.{cal,tab,hex} $ldir | 
| 15 | greg | 1.1 | echo "" | 
| 16 |  |  | echo "Set the environment variable RAYPATH=.:$ldir" | 
| 17 |  |  | echo 'For C-shell users, put the following into ~/.cshrc' | 
| 18 |  |  | echo "  setenv RAYPATH .:$ldir" | 
| 19 |  |  | echo 'For Bourne shell users, put the following into $HOME/profile' | 
| 20 |  |  | echo "  RAYPATH=.:$ldir" | 
| 21 |  |  | echo "  export RAYPATH" | 
| 22 |  |  | echo "" | 
| 23 |  |  | exit 0 | 
| 24 |  |  | endif | 
| 25 |  |  | set srcdirs=( common meta cv gen ot rt px hd util cal ) | 
| 26 |  |  | if ( "$1" == install ) then | 
| 27 |  |  | cat << _EOF_ | 
| 28 |  |  |  | 
| 29 |  |  | `cat src/rt/VERSION` INSTALLATION | 
| 30 |  |  |  | 
| 31 |  |  | This script rebuilds all of the Radiance programs and installs | 
| 32 |  |  | them on your system.  You should read the file README before running | 
| 33 |  |  | this script.  You can type ^C (followed by return) at any time to abort. | 
| 34 |  |  |  | 
| 35 |  |  | You must first answer the following questions. | 
| 36 |  |  |  | 
| 37 |  |  | _EOF_ | 
| 38 |  |  | if ( ! $?EDITOR ) then | 
| 39 |  |  | echo -n "What is your preferred editor [vi]? " | 
| 40 |  |  | set ans="$<" | 
| 41 |  |  | if ( "$ans" != "" ) then | 
| 42 |  |  | setenv EDITOR "$ans" | 
| 43 |  |  | else | 
| 44 |  |  | setenv EDITOR vi | 
| 45 |  |  | endif | 
| 46 |  |  | endif | 
| 47 |  |  | again1: | 
| 48 |  |  | echo -n "Where do you want the executables [/usr/local/bin]? " | 
| 49 |  |  | set idir=$< | 
| 50 |  |  | (echo $idir) >/dev/null | 
| 51 | greg | 1.4 | if ( $status ) then | 
| 52 |  |  | goto again1 | 
| 53 |  |  | endif | 
| 54 | greg | 1.1 | set idir=$idir | 
| 55 |  |  | if ( "$idir" == "" ) then | 
| 56 |  |  | set idir=/usr/local/bin | 
| 57 |  |  | else if ( "$idir" !~ /* ) then | 
| 58 |  |  | echo "Directory must be relative to root, please reenter" | 
| 59 |  |  | goto again1 | 
| 60 |  |  | endif | 
| 61 |  |  | if ( ! -d $idir ) then | 
| 62 |  |  | mkdir $idir | 
| 63 |  |  | if ( $status ) then | 
| 64 |  |  | echo "Cannot create directory, please reenter" | 
| 65 |  |  | goto again1 | 
| 66 |  |  | endif | 
| 67 |  |  | endif | 
| 68 |  |  | if ( ! -d $idir/dev ) then | 
| 69 |  |  | mkdir $idir/dev | 
| 70 |  |  | if ( $status ) then | 
| 71 |  |  | echo "Cannot create subdirectory, please reenter" | 
| 72 |  |  | goto again1 | 
| 73 |  |  | endif | 
| 74 |  |  | endif | 
| 75 | greg | 1.10 | set inpath=0 | 
| 76 |  |  | foreach i ( $path ) | 
| 77 |  |  | if ( "$i" == "$idir" ) then | 
| 78 |  |  | set inpath=1 | 
| 79 |  |  | break | 
| 80 |  |  | endif | 
| 81 |  |  | end | 
| 82 | greg | 1.1 | set rmake=$idir/rmake | 
| 83 | greg | 1.4 | if ( "`ls -tL $rmake $0 |& head -1`" == $rmake ) then | 
| 84 |  |  | goto gotrmake | 
| 85 |  |  | endif | 
| 86 | greg | 1.1 | set newrmake | 
| 87 | greg | 1.11 | more src/common/copyright.h | 
| 88 | greg | 1.1 | echo -n "Do you understand and accept the terms of this agreement [n]? " | 
| 89 |  |  | set ans="$<" | 
| 90 |  |  | if ( "$ans" !~ [yY]* ) exit | 
| 91 |  |  | set special= | 
| 92 |  |  | set arch= | 
| 93 |  |  | set opt= | 
| 94 |  |  | set mach= | 
| 95 |  |  | set compat= | 
| 96 |  |  | set extras= | 
| 97 | schorsch | 1.9 | set esuffix= | 
| 98 | greg | 1.1 | cat << _EOF_ | 
| 99 |  |  |  | 
| 100 |  |  | Please select your system type from the following list: | 
| 101 |  |  |  | 
| 102 |  |  | 1)      Sun Solaris | 
| 103 |  |  | 2)      HP workstation | 
| 104 |  |  | 3)      Silicon Graphics | 
| 105 |  |  | 4)      AIX (RS/6000) | 
| 106 |  |  | 5)      BSDI BSD/386 | 
| 107 |  |  | 6)      Linux | 
| 108 | schorsch | 1.9 | 7)      MacOS X | 
| 109 | greg | 1.1 | 8)      FreeBSD | 
| 110 | schorsch | 1.9 | 9)      Cygwin | 
| 111 |  |  | 10)     Other | 
| 112 | greg | 1.1 |  | 
| 113 |  |  | _EOF_ | 
| 114 |  |  | echo -n "Choice? " | 
| 115 |  |  | set arch="$<" | 
| 116 |  |  | switch ("$arch") | 
| 117 |  |  | case 1:                 # SPARC Station | 
| 118 |  |  | set arch=sun | 
| 119 | greg | 1.4 | set mach="-I/usr/openwin/include -L/usr/openwin/lib -DNOSTEREO" | 
| 120 |  |  | set opt="-O -DSPEED=80" | 
| 121 | greg | 1.13 | set compat="bmalloc.o strcmp.o" | 
| 122 | greg | 1.1 | breaksw | 
| 123 |  |  | case 2:                 # HP workstation | 
| 124 |  |  | set mach="" | 
| 125 |  |  | set opt="-O -DSPEED=80 -Aa -D_HPUX_SOURCE" | 
| 126 | greg | 1.13 | set compat="bmalloc.o strcmp.o" | 
| 127 | greg | 1.1 | set arch=hpux | 
| 128 |  |  | breaksw | 
| 129 |  |  | case 3:                 # Silicon Graphics | 
| 130 |  |  | set arch=sgi | 
| 131 |  |  | switch (`uname -r`) | 
| 132 |  |  | case 3.*: | 
| 133 |  |  | set mach="-noprototypes" | 
| 134 |  |  | set opt="-O -DSPEED=80" | 
| 135 |  |  | set special="sgi" | 
| 136 |  |  | set compat="malloc.o strcmp.o" | 
| 137 |  |  | breaksw | 
| 138 |  |  | case 4.*: | 
| 139 |  |  | set mach="" | 
| 140 |  |  | set opt="-O2 -DSPEED=100" | 
| 141 |  |  | set compat="malloc.o strcmp.o" | 
| 142 |  |  | set extras='"MLIB=-lfastm -lm"' | 
| 143 |  |  | breaksw | 
| 144 |  |  | default:        # 5.x or later | 
| 145 |  |  | ln -s `which wish` $idir/wish4.0 | 
| 146 |  |  | set path=($idir $path) | 
| 147 |  |  | set mach="-w" | 
| 148 |  |  | set opt="-O2 -DSPEED=200" | 
| 149 |  |  | set special="ogl" | 
| 150 | greg | 1.3 | set compat="bmalloc.o strcmp.o" | 
| 151 | greg | 1.1 | breaksw | 
| 152 |  |  | endsw | 
| 153 |  |  | breaksw | 
| 154 |  |  | case 4:                 # AIX | 
| 155 |  |  | set opt="-O" | 
| 156 | greg | 1.6 | set compat="bmalloc.o erf.o strcmp.o" | 
| 157 |  |  | set arch=PowerPC | 
| 158 | greg | 1.1 | breaksw | 
| 159 |  |  | case 5:                 # BSDI BSD/386 | 
| 160 |  |  | set mach="-DBSD -L/usr/X11/lib -I/usr/X11/include" | 
| 161 |  |  | set opt="-O -DSPEED=100" | 
| 162 |  |  | set arch=IBMPC | 
| 163 |  |  | set compat="malloc.o erf.o strcmp.o" | 
| 164 |  |  | breaksw | 
| 165 |  |  | case 6:                 # Linux | 
| 166 | schorsch | 1.7 | set mach="-Dlinux -D_FILE_OFFSET_BITS=64 -L/usr/X11R6/lib -I/usr/include/X11 -DNOSTEREO" | 
| 167 | greg | 1.1 | set opt="-O2 -DSPEED=200" | 
| 168 |  |  | set arch=IBMPC | 
| 169 | greg | 1.13 | set compat="bmalloc.o erf.o" | 
| 170 | greg | 1.1 | set extras=CC=gcc | 
| 171 |  |  | breaksw | 
| 172 | schorsch | 1.9 | case 7:                 # MacOS X | 
| 173 |  |  | set mach="-DBSD -DNOSTEREO -Dfreebsd -I/usr/X11R6/include -L/usr/X11R6/lib" | 
| 174 |  |  | set opt="-O2 -DSPEED=200" | 
| 175 |  |  | set arch=PowerPC | 
| 176 |  |  | set compat="bmalloc.o" | 
| 177 |  |  | set extras="CC=cc CONFIGURE_ARCH=powerpc" | 
| 178 | greg | 1.1 | set special="ogl" | 
| 179 | schorsch | 1.9 | breaksw | 
| 180 | greg | 1.1 | case 8:                 # FreeBSD | 
| 181 | schorsch | 1.9 | set mach="-DBSD -DNOSTEREO -Dfreebsd -I/usr/X11R6/include -L/usr/X11R6/lib" | 
| 182 |  |  | set opt="-O -DSPEED=200" | 
| 183 |  |  | set compat="bmalloc.o erf.o" | 
| 184 |  |  | set extras="CC=cc" | 
| 185 | greg | 1.1 | set arch=IBMPC | 
| 186 | schorsch | 1.9 | breaksw | 
| 187 |  |  | case 9:                 # Cygwin | 
| 188 |  |  | set mach="-Dfreebsd -L/usr/lib -L/usr/X11R6/lib -I/usr/include/X11 -I/usr/X11R6/include -DNOSTEREO" | 
| 189 |  |  | set opt="-O2 -DSPEED=200" | 
| 190 |  |  | set arch=IBMPC | 
| 191 | greg | 1.13 | set compat="bmalloc.o erf.o" | 
| 192 | schorsch | 1.9 | set extras="CC=gcc" | 
| 193 |  |  | set special="ogl" | 
| 194 |  |  | set esuffix=".exe" | 
| 195 |  |  | breaksw | 
| 196 |  |  | case 10:                        # Other | 
| 197 | greg | 1.1 | set opt="-O" | 
| 198 |  |  | set compat="bmalloc.o erf.o strcmp.o" | 
| 199 |  |  | echo -n "Are you using the GNU C compiler [n]? " | 
| 200 |  |  | if ( "$<" =~ [yY]* ) then | 
| 201 |  |  | set extras="CC=gcc" | 
| 202 |  |  | endif | 
| 203 | greg | 1.6 | set arch=other | 
| 204 | greg | 1.1 | breaksw | 
| 205 |  |  | default: | 
| 206 |  |  | echo "Illegal choice\!" | 
| 207 |  |  | echo "Installation aborted." | 
| 208 |  |  | exit 1 | 
| 209 |  |  | breaksw | 
| 210 |  |  | endsw | 
| 211 |  |  | source installib | 
| 212 |  |  | sed 's/[        ]*$//' > $rmake << _EOF_ | 
| 213 |  |  | #!/bin/sh | 
| 214 |  |  | exec make "SPECIAL=$special" \ | 
| 215 |  |  | "OPT=$opt" \ | 
| 216 |  |  | "MACH=$mach" \ | 
| 217 |  |  | ARCH=$arch "COMPAT=$compat" \ | 
| 218 |  |  | INSTDIR=$idir \ | 
| 219 |  |  | LIBDIR=$ldir \ | 
| 220 | schorsch | 1.9 | ESUFFIX=$esuffix \ | 
| 221 | greg | 1.1 | $extras "\$@" -f Rmakefile | 
| 222 |  |  | _EOF_ | 
| 223 |  |  | chmod 755 $rmake | 
| 224 |  |  | chmod 644 src/*/Rmakefile src/rt/devtable.c | 
| 225 |  |  | gotrmake: | 
| 226 |  |  | echo "Current rmake command is:" | 
| 227 |  |  | cat $rmake | 
| 228 |  |  | echo -n "Do you want to change it? " | 
| 229 |  |  | set ans="$<" | 
| 230 |  |  | if ( "$ans" =~ [yY]* ) then | 
| 231 |  |  | cp $rmake /tmp/rmake$$ | 
| 232 |  |  | $EDITOR $rmake | 
| 233 |  |  | if ( `cat $rmake /tmp/rmake$$ | grep OPT= | uniq | wc -l` == 2 ) set newrmake | 
| 234 |  |  | rm -f /tmp/rmake$$ | 
| 235 |  |  | endif | 
| 236 |  |  | if ( ! -d src/lib ) then | 
| 237 |  |  | mkdir src/lib | 
| 238 |  |  | endif | 
| 239 |  |  | if ( $?newrmake ) then | 
| 240 |  |  | echo 'New rmake command -- running "makeall clean"...' | 
| 241 |  |  | csh -f $0 clean | 
| 242 |  |  | endif | 
| 243 |  |  | cd src | 
| 244 |  |  | echo "Making programs..." | 
| 245 |  |  | set errs=0 | 
| 246 |  |  | foreach i ( $srcdirs ) | 
| 247 |  |  | pushd $i | 
| 248 |  |  | echo "In directory $i..." | 
| 249 |  |  | $rmake -k $* | 
| 250 |  |  | @ errs += $status | 
| 251 |  |  | popd | 
| 252 |  |  | end | 
| 253 |  |  | if ( $errs ) then | 
| 254 |  |  | echo "There were some errors." | 
| 255 |  |  | else | 
| 256 |  |  | echo "Done." | 
| 257 |  |  | endif | 
| 258 |  |  | cd .. | 
| 259 | greg | 1.10 | if (! $inpath ) then | 
| 260 |  |  | echo "" | 
| 261 |  |  | echo "Add $idir to the beginning of your execution path:" | 
| 262 |  |  | echo 'For C-shell users, put the following into ~/.cshrc' | 
| 263 |  |  | echo "  set path=( $idir "'$path )' | 
| 264 |  |  | echo 'For Bourne shell users, put the following into $HOME/profile' | 
| 265 |  |  | echo "  PATH=$idir"':$PATH' | 
| 266 |  |  | echo "  export PATH" | 
| 267 |  |  | endif | 
| 268 | greg | 1.1 | else | 
| 269 |  |  | cd src | 
| 270 |  |  | foreach i ( $srcdirs ) | 
| 271 |  |  | pushd $i | 
| 272 |  |  | echo "In directory $i..." | 
| 273 |  |  | make -f Rmakefile $* | 
| 274 |  |  | popd | 
| 275 |  |  | end | 
| 276 |  |  | cd .. | 
| 277 |  |  | foreach i ( $* ) | 
| 278 |  |  | if ( "$i" == clean ) then | 
| 279 |  |  | echo "Removing library archives..." | 
| 280 | greg | 1.3 | rm -f src/lib/*.[ao] | 
| 281 | greg | 1.1 | endif | 
| 282 |  |  | end | 
| 283 | greg | 1.10 | echo "Done." | 
| 284 |  |  | endif | 
| 285 | greg | 1.1 | exit 0 |