1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323
|
#!/bin/sh
#---------------------------------------------------------------------
#- TkGofer v. 2.0
#- Ton Vullinghs, Koen Claessen, July 1997
#---------------------------------------------------------------------
#- tkgofer.install
set -e
Root="`pwd`"
cd "$Root"
#---------------------------------------------------------------------
#- Firstly, set these variables!
#---------------------------------------------------------------------
#- Location of standard libraries
LibStd="/usr/lib"
#- Location of `libtcl.a' and Tcl include files
LibTcl="/usr/lib"
IncTcl="/usr/include"
#- Location of `libtk.a' and Tk include files
LibTk="$LibTcl"
IncTk="$IncTcl"
#- Location of `libX11.so.?' and X11 include files
LibX11="/usr/X11R6/lib"
IncX11="/usr/X11R6/include"
#- Architecture Settings
Architecture="LINUX"
# Choose from: TURBOC, BCC, WATCOM, ZTC, DJGPP, OS2,
# SUNOS, MIPS, NEXTSTEP, NEXTGCC, MINIX68K,
# AMIGA, HPUX, LINUX, RISCOS, ALPHA, SVR4, ULTRIX,
# AIX, ATARI, SGI4, NETBSD, SOLARIS
ArchMult="no"
# "yes" = install for multiple architectures (renames executables)
# "no" = install for just one architecture
ArchCmd="arch"
# The unix command that prints the architecture
# (Only needed when ArchMult="yes")
#- Various Compiler Flags
LibFlags="-L$LibStd -L$LibTcl -L$LibTk -L$LibX11"
IncFlags="-I$IncTcl -I$IncTk -I$IncX11"
LinkFlags="-ltk8.0 -ltcl8.0 -lX11 -lm -ldl -lnsl -lreadline"
#- Compiler
Compiler="gcc"
CompilerFlags="-DUSE_READLINE -g -Wall"
OptimiserFlags="-O2"
#---------------------------------------------------------------------
#- Derived variables -- Don't change
SkeletonDir="$Root/Skeletons"
SourceDir="$Root/Sources"
PreludeDir="$Root/Preludes"
BinDir="$Root/Bin"
HelpDir="$Root/Doc"
InstallDir="$Root/Bin"
if [ "$ArchMult" = "no" ]
then
ExeExtension="exe"
else
Quote='`'
ExeExtension="${Quote}$ArchCmd${Quote}"
fi
#---------------------------------------------------------------------
#- Help?
if [ "$1" = "-?" -o "$1" = "-help" ]
then
more "$HelpDir/install.help"
exit
fi
#---------------------------------------------------------------------
#- Check Arguments
JobMake="no"
JobInstall="no"
JobPreludes="no"
JobClean="no"
if [ "$1" = "" ]
then
JobMake="yes"
JobInstall="yes"
JobPreludes="yes"
else
while [ "$1" != "" ]
do
if [ "$1" = "-clean" ]
then
JobClean="yes"
else if [ "$1" = "-make" ]
then
JobMake="yes"
else if [ "$1" = "-install" ]
then
JobInstall="yes"
else if [ "$1" = "-preludes" ]
then
JobPreludes="always"
else if [ "$1" = "-nothing" ]
then
JobMake="no"
JobInstall="no"
JobPreludes="no"
JobClean="no"
fi; fi; fi; fi; fi
shift
done
fi
#---------------------------------------------------------------------
#- Functions
stopIt()
{
echo "TkGofer Install stopped."
exit 1
}
valueOf()
{
export $1
echo "echo $""$1" | sh
}
notEmpty()
{
while [ "$1" != "" ]
do
if [ "`valueOf $1`" = "" ]
then
echo "Error: Variable $1 undefined."
echo " Please edit the file and set the"
echo " listed variables to the right values."
stopIt
fi
shift
done
}
architectureChanged()
{
if [ -f "$SourceDir/prelude.h" ]
then
if grep "Arch is now $Architecture" "$SourceDir/prelude.h" > /dev/null
then
echo "no"
else
echo "yes"
fi
else
echo "yes"
fi
}
create()
{
Skeleton="$SkeletonDir/$1.skel"
File="$2/$1"
Mod="$3"
echo " $1"
shift; shift; shift
SedCmds=""
while [ "$1" != "" ]
do
Value=`valueOf $1`
SedCmds="$SedCmds
s!@$1@!$Value!g"
shift
done
rm -f $File
cat "$Skeleton" | sed "$SedCmds" > "$File"
chmod "a+$Mod" "$File"
}
#---------------------------------------------------------------------
#- Clean up?
if [ "$JobClean" = "yes" ]
then
echo "Cleaning up ..."
cd "$BinDir"
rm -f tkgofer make.prelude tkgofer.*
cd "$SourceDir"
rm -f Makefile prelude.h *.o *.exe
cd "$Root"
rm -f -R "$PreludeDir"
echo "Done."
exit
fi
#---------------------------------------------------------------------
#- Check Variables
echo "Checking Variables ..."
notEmpty \
Root InstallDir \
LibStd LibTcl IncTcl LibTk IncTk LibX11 IncX11 \
LibFlags IncFlags LinkFlags Compiler \
Architecture ArchMult
#---------------------------------------------------------------------
#- Create Files from Skeletons
echo "Creating files from skeletons ..."
create Makefile "$SourceDir" r \
InstallDir \
LibFlags IncFlags LinkFlags \
Compiler CompilerFlags \
OptimiserFlags
create tkgofer "$BinDir" rx \
Root ExeExtension
create make.prelude "$BinDir" rx \
Root
if [ "`architectureChanged`" = "yes" ]
then
create prelude.h "$SourceDir" r \
Architecture
fi
#---------------------------------------------------------------------
#- Compile Executable
if [ "$JobMake" = "yes" ]
then
echo "Making ..."
cd "$SourceDir"
if make
then
chmod a+rx tkgofer.exe
else
echo "Error: make had errors."
stopIt
fi
cd "$Root"
fi
#---------------------------------------------------------------------
#- Install Executable
if [ "$JobInstall" = "yes" ]
then
echo "Installing Executable ..."
cd "$SourceDir"
if [ -f tkgofer.exe ]
then
if [ "$ArchMult" = "yes" ]
then
mv tkgofer.exe "$InstallDir/tkgofer.`$ArchCmd`"
echo " This executable is called tkgofer.`$ArchCmd`."
echo " You can now execute tkgofer.install on other architectures as well."
else
mv tkgofer.exe "$InstallDir"
fi
chmod a+x $InstallDir/*
else
echo "Error: no tkgofer.exe"
stopIt
fi
cd "$Root"
fi
#---------------------------------------------------------------------
#- Make Preludes
if [ "$JobPreludes" != "no" ]
then
if [ "$JobPreludes" = "always" -a -d "$PreludeDir" ]
then
rm -R "$PreludeDir"
fi
if [ ! -d "$PreludeDir" ]
then
echo "Creating Preludes ..."
mkdir "$PreludeDir"
chmod a+rx "$PreludeDir"
"$BinDir/make.prelude" -all
chmod a+r "$PreludeDir"/*
else
echo "Preludes were already created."
fi
fi
#---------------------------------------------------------------------
#- Done
echo "Done."
#---------------------------------------------------------------------
#- the end.
|