ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/makeall
Revision: 1.32
Committed: Tue Dec 3 01:11:43 2024 UTC (4 months, 4 weeks ago) by greg
Branch: MAIN
CVS Tags: HEAD
Changes since 1.31: +14 -21 lines
Log Message:
fix: Added strnstr.c compatibility module for Windows and Linux

File Contents

# Content
1 #!/bin/csh -f
2 # RCSid $Id: makeall,v 1.31 2022/02/16 18:56:32 greg Exp $
3 #
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 echo " or: makeall test"
11 exit 1
12 endif
13 if ( "$1" == library ) then
14 source installib
15 cp -f src/*/*.{cal,tab,hex,dat} $ldir
16 echo ""
17 echo "Set the environment variable RAYPATH=.:$ldir"
18 echo 'For C-shell users, put the following into ~/.cshrc'
19 echo " setenv RAYPATH .:$ldir"
20 echo 'For Bourne shell users, put the following into $HOME/.profile'
21 echo " RAYPATH=.:$ldir"
22 echo " export RAYPATH"
23 echo ""
24 exit 0
25 endif
26 if ( "$1" == test ) then
27 cd test
28 set fails=()
29 foreach d (cv cal gen util px renders)
30 cd $d
31 make -k clean all && make clean
32 if ($status) set fails=($fails $d)
33 cd ..
34 end
35 if ($#fails) then
36 echo "Unit tests failed in $#fails directories"
37 echo "Run 'make' manually in test/ subfolders: $fails"
38 exit 1
39 endif
40 echo "All tests passed successfully."
41 exit 0
42 endif
43 set srcdirs=( common rt meta cv gen ot px hd util cal )
44 if ( "$1" == install ) then
45 cat << _EOF_
46
47 `cat src/rt/VERSION` INSTALLATION
48
49 This script rebuilds all of the Radiance programs and installs
50 them on your system. You should read the file README before running
51 this script. You can type ^C (followed by return) at any time to abort.
52
53 You must first answer the following questions.
54
55 _EOF_
56 if ( ! $?EDITOR ) then
57 echo -n "What is your preferred editor [vi]? "
58 set ans="$<"
59 if ( "$ans" != "" ) then
60 setenv EDITOR "$ans"
61 else
62 setenv EDITOR vi
63 endif
64 endif
65 again1:
66 echo -n "Where do you want the executables [/usr/local/bin]? "
67 set idir=$<
68 (echo $idir) >/dev/null
69 if ( $status ) then
70 goto again1
71 endif
72 set idir=$idir
73 if ( "$idir" == "" ) then
74 set idir=/usr/local/bin
75 else if ( "$idir" !~ /* ) then
76 echo "Directory must be relative to root, please reenter"
77 goto again1
78 endif
79 if ( ! -d $idir ) then
80 mkdir $idir
81 if ( $status ) then
82 echo "Cannot create directory, please reenter"
83 goto again1
84 endif
85 endif
86 set inpath=0
87 foreach i ( $path )
88 if ( "$i" == "$idir" ) then
89 set inpath=1
90 break
91 endif
92 end
93 set rmake=$idir/rmake
94 if ( "`ls -tL $rmake $0 |& head -1`" == $rmake ) then
95 goto gotrmake
96 endif
97 set newrmake
98 more License.txt
99 echo -n "Do you understand and accept the terms of this agreement [n]? "
100 set ans="$<"
101 if ( "$ans" !~ [yY]* ) exit
102 set special=
103 set arch=
104 set opt=
105 set mach=
106 set compat=
107 set extras=
108 set esuffix=
109 cat << _EOF_
110
111 Please select your system type from the following list:
112
113 1) Linux
114 2) MacOS X
115 3) FreeBSD
116 4) Cygwin
117 5) Other
118
119 _EOF_
120 echo -n "Choice? "
121 set arch="$<"
122 switch ("$arch")
123 case 1: # Linux
124 set mach="-Dlinux -D_FILE_OFFSET_BITS=64 -L/usr/X11R6/lib -I/usr/include/X11 -DNOSTEREO"
125 set opt="-O2"
126 set arch=IBMPC
127 set compat="strnstr.o strlcpy.o"
128 set extras=CC=gcc
129 breaksw
130 case 2: # MacOS X
131 set mach="-DBSD -DNOSTEREO -Dfreebsd -I/usr/X11R6/include -L/usr/X11R6/lib"
132 set opt="-O2"
133 set arch=Intel
134 set extras="CC=cc CONFIGURE_ARCH=i386"
135 set special="ogl"
136 breaksw
137 case 3: # FreeBSD
138 set mach="-DBSD -DNOSTEREO -Dfreebsd -I/usr/X11R6/include -L/usr/X11R6/lib"
139 set opt="-O"
140 set compat="erf.o"
141 set extras='CC=cc MLIB="-lcompat -lm"'
142 set arch=IBMPC
143 breaksw
144 case 4: # Cygwin
145 set mach="-Dfreebsd -L/usr/lib -L/usr/X11R6/lib -I/usr/include/X11 -I/usr/X11R6/include -DNOSTEREO"
146 set opt="-O2"
147 set arch=IBMPC
148 set compat="erf.o strnstr.o strlcpy.o"
149 set extras="CC=gcc"
150 set special="ogl"
151 set esuffix=".exe"
152 breaksw
153 case 5: # Other
154 set opt="-O"
155 set compat="erf.o strcmp.o strnstr.o strlcpy.o"
156 echo -n "Are you using the GNU C compiler [n]? "
157 if ( "$<" =~ [yY]* ) then
158 set extras="CC=gcc"
159 else
160 set compat="$compat timegm.o"
161 endif
162 set arch=other
163 breaksw
164 default:
165 echo "Illegal choice\!"
166 echo "Installation aborted."
167 exit 1
168 breaksw
169 endsw
170 source installib
171 sed 's/[ ]*$//' > $rmake << _EOF_
172 #!/bin/sh
173 exec make "SPECIAL=$special" \
174 "OPT=$opt" \
175 "MACH=$mach" \
176 ARCH=$arch "COMPAT=$compat" \
177 INSTDIR=$idir \
178 LIBDIR=$ldir \
179 ESUFFIX=$esuffix \
180 $extras "\$@" -f Rmakefile
181 _EOF_
182 chmod 755 $rmake
183 chmod 644 src/*/Rmakefile src/rt/devtable.c
184 gotrmake:
185 echo "Current rmake command is:"
186 cat $rmake
187 echo -n "Do you want to change it? "
188 set ans="$<"
189 if ( "$ans" =~ [yY]* ) then
190 cp $rmake /tmp/rmake$$
191 $EDITOR $rmake
192 if ( `cat $rmake /tmp/rmake$$ | grep OPT= | uniq | wc -l` == 2 ) set newrmake
193 rm -f /tmp/rmake$$
194 endif
195 if ( ! -d src/lib ) then
196 mkdir src/lib
197 endif
198 if ( $?newrmake ) then
199 echo 'New rmake command -- running "makeall clean"...'
200 csh -f $0 clean
201 endif
202 cd src
203 echo "Making programs..."
204 set errs=0
205 foreach i ( $srcdirs )
206 pushd $i
207 echo "In directory $i..."
208 $rmake -k $*
209 @ errs += $status
210 popd
211 end
212 if ( $errs ) then
213 echo "There were some errors."
214 else
215 echo "Done."
216 endif
217 cd ..
218 if (! $inpath ) then
219 echo ""
220 echo "Add $idir to the beginning of your execution path:"
221 echo 'For C-shell users, put the following into ~/.cshrc'
222 echo " set path=( $idir "'$path )'
223 echo 'For Bourne shell users, put the following into $HOME/.profile'
224 echo " PATH=$idir"':$PATH'
225 echo " export PATH"
226 endif
227 else
228 cd src
229 foreach i ( $srcdirs )
230 pushd $i
231 echo "In directory $i..."
232 make -f Rmakefile $*
233 popd
234 end
235 cd ..
236 foreach i ( $* )
237 if ( "$i" == clean ) then
238 echo "Removing library archives..."
239 rm -f src/lib/*.{a,o,la}
240 endif
241 end
242 echo "Done."
243 endif
244 exit 0