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