#!/bin/sh
################################################################################
# #
# Copyright (c) 2000 Tridia Corporation #
# All Rights Reserved. #
# #
################################################################################
#
# build -- Shell script used clean, compile and build completely TridiaVNC
#
################################## Variables ###################################
OK=0
FAIL=1
ARGC=$# # Remember the 'original' number of command
# line arguments
ARGS=$* # Remember the 'orignal' command line
# arguments
ECHO="echo" # Echo command to use.
ENTER_REVERSE="" # Holds enter reverse video.
EXIT_REVERSE="" # Holds exirt reverse video.
NEW_VERSION="" # Used to hold the new version number during
# prompts.
MAJOR_NUM="" # Used to hold the new MAJOR version string.
MINOR_NUM="" # Used to hold the new MINOR version string.
BUILD_NUM="" # Used to hold the new BUILD version string.
ret_prompt_number="" # Global used by prompt_number to return
# numbers read in.
################################################################################
# init_echo -- #
# #
# Based on the current operating system, determine what type of echo #
# command to use. #
# #
################################################################################
init_echo( )
{
# We need to see if we have a uname command that works.
uname -a 2>/dev/null 1>&2 || {
# Default to the standard 'echo' command then.
ECHO="echo"
return
}
CUR_OS_VERSION=`uname -s 2>/dev/null`
# If we are running under any version of Linux ...
if [ "$CUR_OS_VERSION" = "Linux" ]
then
# Then we need to enable the 'backslash' processing.
ECHO="echo -e"
else
# Otherwise the standard command will work just fine.
ECHO="echo"
fi
} # init_echo
################################################################################
# init_rev_attributes -- #
# #
# Proceed to initialize the ENTER and EXIT reverse video attributes. #
# #
################################################################################
init_rev_attributes( )
{
# Initialize our global video attribute variables.
# Proceed to find out the sequence to enter into reverse video.
ENTER_REVERSE=`tput rev 2>/dev/null`
# If there is none ....
if [ "$ENTER_REVERSE" = "" ]
then
# Then try to use 'standout'.
ENTER_REVERSE=`tput smso 2>/dev/null`
fi
# Proceed to find out the sequence to enter exit from reverse video.
EXIT_REVERSE=`tput sgr0 2>/dev/null`
# If there is none ....
if [ "$EXIT_REVERSE" = "" ]
then
# Then try to use 'exit standout'.
EXIT_REVERSE=`tput rmso 2>/dev/null`
fi
# In the end we MUST have the enter/exit attribute pair, and if not
# then don't use them.
if [ "$ENTER_REVERSE" = "" -o "$EXIT_REVERSE" = "" ]
then
ENTER_REVERSE=""
EXIT_REVERSE=""
fi
} # init_rev_attributes
################################################################################
# #
# error2 -- Print an error message. #
# #
################################################################################
error2( ) {
clear
$ECHO "\nERROR: $*" >&2
} # error2
################################################################################
# getyn -- Prompt for yes or no answer - returns non-zero for no. #
################################################################################
getyn( ) {
while $ECHO "$* $ENTER_REVERSE (y/n) $EXIT_REVERSE\c "
do read yn rest
case $yn in
[yY]) return $OK ;;
[nN]) return $FAIL ;;
*) error2 "Please answer y or n" ;;
esac
done
} # getyn
################################################################################
# Prompt -- Prompt the user with a message, and store the response in 'cmd'. #
# Return FAIL if the response is 'q' or 'Q'. #
################################################################################
prompt( ) {
mesg=$1
while $ECHO "\n${mesg}or enter q to quit: \c"
do read cmd
case $cmd in
Q|q) return $FAIL ;;
*) return $OK ;;
esac
done
} # prompt
################################################################################
# prompt_number -- #
# #
# Prompt the user for a number. #
# #
################################################################################
prompt_number( )
{
num=""
mesg=$1
while $ECHO "\n${mesg}or enter q to quit: \c"
do read num
if [ -z "$num" -o "$num" = "" ]
then
$ECHO "\n $ENTER_REVERSE Must enter a value! $EXIT_REVERSE"
continue;
fi
case $num in
Q|q ) return $FAIL ;;
* ) ;;
esac
str_len=`expr length $num`
# If here, then verify that the string is all numbers.
n=`expr "$num" : "[0-9][0-9]*"`
# If the length and the match are not the same ..
if [ $n -ne $str_len ]
then
$ECHO "\n $ENTER_REVERSE Must be all numbers in string! $EXIT_REVERSE"
continue;
else
# The string was valid.
break;
fi
done
# Return in this global the number prompted for.
ret_prompt_number=$num
return $OK
} # prompt_number
################################################################################
# fatal -- A fatal error has occured, so print an error message and exit. #
################################################################################
fatal( ) {
$ECHO "\nFATAL ERROR: $*"
$ECHO "Make aborted!!"
exit $FAIL
} # fatal
################################################################################
# wrong_osversion -- Inform the user that the current value of 'OSVERSION', #
# the environment variable which dictates what the current #
# operating system is, was found to be invalid, and that #
# make process had to be aborted. #
################################################################################
wrong_osversion( ) {
fatal "FATAL ERROR : INVALID OSVERSION VALUE!! \
CURRENT OSVERSION=($OSVERSION)"
} # wrong_osversion
################################################################################
# wrong_os -- Inform the user that an invalid version of HP-UX was encountered #
# thus a proper set of environment variables are not available for #
# and that consequently the make process had to be aborted. #
################################################################################
wrong_os( ) {
fatal "\tWrong operating system version.\n
\n\tThe current operating version is not compatible with this
\n\tversion of the software. HP-UX 8.0.0, 8.0.2, 9.0.0 or 9.0.4
\n\tis required for the proper COMPILATION of the software.\n"
} # wrong_os
################################################################################
# set_sco_unix_env -- Determine what is the current version of SCO UNIX and #
# call the appropiate 'set environment variable' function. #
################################################################################
set_sco_unix_env( ) {
# Test to see if we need to compile for the SCO 3.2.4.0 kernel model.
if [ "$SUB_OSVERSION" = "SCO_UNIX_3_2_4_0" ]
then
set_sco_unix_3_2_4_0
return
fi
# Include SCO MPX support.
MPX="-DSCO_MPX -DLICENSE_MULTI_CPU"
export MPX
if uname -X | grep "3\.2v4" > /dev/null
then
set_sco_unix_3_2_4
return
fi
if uname -X | grep "3\.2v5" > /dev/null
then
set_sco_unix_3_2_5
return
fi
$ECHO "Couldn't detect valid SCO release (only 3.2v4.X and 3.2v5.X)!"
exit $FAIL
} # set_sco_unix_env
################################################################################
# set_unixware_7_env #
# #
# Determine what is the current version of Unixware and call the appropiate#
# 'set environment variable' function. #
# #
################################################################################
set_unixware_7_intel_env( ) {
# Initialize to NO sub-os version.
UNIXWARE_SUB_VERSION=""
OS_RELEASE=`uname -r`
NUM=`expr "$OS_RELEASE" : "5"`
if [ $NUM -gt 0 ]
then
UNIXWARE_SUB_VERSION="-D_UNIXWARE_7_0_1"
fi
export UNIXWARE_SUB_VERSION
# Now call the 'make file' specific function entry point.
set_unixware_7_env
} # set_unixware_7_intel_env
################################################################################
# #
# END -- set_unixware_7_env. #
# #
################################################################################
################################################################################
# wrong_hpux_os -- #
# #
# Explain in some detail to the user that the current operating system #
# version will not be able to support the current software version, and exit #
# with an error message. #
# #
################################################################################
wrong_hpux_os( ) {
fatal "\tWrong operating system version.\n
\n\tThe current operating version is not compatible with this
\n\tversion of DoubleVision. HP-UX 10.20/11.00 is required for
\n\tthe proper operation of DoubleVision.\n"
} # wrong_hpux_os
################################################################################
# set_hpux_env #
# #
# Determine what is the current version of HP-UX and call the appropiate #
# 'set environment variable' function. #
# #
################################################################################
set_hpux_env( )
{
# uname -r should return a string in the following form : 'A.08.02'.
case `uname -r` in
# OBSOLETED OS VERSIONS
# [A-Z]\.09\.04 )
# [A-Z]\.10\.00 )
# [A-Z]\.10\.01 )
# [A-Z]\.10\.10 )
# OBSOLETED OS VERSIONS
[A-Z]\.10\.20 )
;;
[A-Z]\.11\.00 )
;;
* ) wrong_hpux_os # Shouldn't happen, but ...
;;
esac
# First make sure that 'cvs' is within our PATH variable.
type cvs 2>/dev/null >/dev/null
if [ $? -ne 0 ]
then
PATH=$PATH:/usr/local/bin
export PATH
fi
# Now make sure that we do have imake within out path.
type imake 2>/dev/null >/dev/null
if [ $? -ne 0 ]
then
PATH=$PATH:/opt/imake/bin
export PATH
fi
# Now let's make sure we set path where LD can find the Xaw and Xmu
# libraries
LDOPTS="-L/usr/contrib/X11R6/lib"
export LDOPTS
} # set_hpux_env
################################################################################
# set_solaris_sparc_env -- #
# #
# Determine what is the current version of Solaris SPARC and call the #
# appropiate 'set environment variable' function. #
# #
################################################################################
set_solaris_sparc_env( )
{
# Initialize to NO sub-os version.
SOLARIS_SPARC_SUB_VERSION=""
OS_RELEASE=`uname -r` # Should return the string '5.x'.
NUM=`expr "$OS_RELEASE" : "5.5"`
if [ $NUM -gt 0 ]
then
SOLARIS_SPARC_SUB_VERSION="-D_SOLARIS_SPARC_2_5"
else
NUM=`expr "$OS_RELEASE" : "5.6"`
if [ $NUM -gt 0 ]
then
SOLARIS_SPARC_SUB_VERSION="-D_SOLARIS_SPARC_2_6"
else
NUM=`expr "$OS_RELEASE" : "5.7"`
if [ $NUM -gt 0 ]
then
SOLARIS_SPARC_SUB_VERSION="-D_SOLARIS_SPARC_2_7"
else
NUM=`expr "$OS_RELEASE" : "5.[34]"`
if [ $NUM -gt 0 ]
then
fatal "Current version of Solaris is no longer supported!"
return $FAIL # Is Solaris 5.4.X or 5.3.X
fi
fi
fi
fi
# To build with gcc, uncomment the following...
# CC = gcc
# CCOPTIONS =
# CDEBUGFLAGS = -O2
# For imake to be found and to work ...
if [ ${OPENWINHOME:-""} = "" ]
then
OPENWINHOME=/usr/openwin
export OPENWINHOME
fi
} # set_solaris_sparc_env
################################################################################
# #
# END -- set_solaris_sparc_env. #
# #
################################################################################
################################################################################
# set_solaris_intel_env -- #
# #
# Determine what is the current version of Solaris INTEL and call the #
# appropiate 'set environment variable' function. #
# #
################################################################################
set_solaris_intel_env( )
{
# Initialize to NO sub-os version.
SOLARIS_INTEL_SUB_VERSION=""
OS_RELEASE=`uname -r` # Should return the string '5.x'.
NUM=`expr "$OS_RELEASE" : "5.7"`
if [ $NUM -gt 0 ]
then
SOLARIS_INTEL_SUB_VERSION="-D_SOLARIS_INTEL_2_7"
else
NUM=`expr "$OS_RELEASE" : "5.6"`
if [ $NUM -gt 0 ]
then
SOLARIS_INTEL_SUB_VERSION="-D_SOLARIS_INTEL_2_6"
else
NUM=`expr "$OS_RELEASE" : "5.5"`
if [ $NUM -gt 0 ]
then
SOLARIS_INTEL_SUB_VERSION="-D_SOLARIS_INTEL_2_5"
else
NUM=`expr "$OS_RELEASE" : "5.4"`
if [ $NUM -gt 0 ]
then
SOLARIS_INTEL_SUB_VERSION="-D_SOLARIS_INTEL_2_4"
else
NUM=`expr "$OS_RELEASE" : "5.3"`
if [ $NUM -gt 0 ]
then
fatal "Current version of Solaris is no longer \
supported!"
return $FAIL # Is Solaris 5.3.X
fi
fi
fi
fi
fi
# We are not sure where the c compilers are so we perform a test here.
# We start by initializing our variable.
CC_PATH=""
if [ -x "/export/home/SUNWspro/bin/cc" ]
then
CC_PATH="/export/home/SUNWspro/bin/cc"
fi
if [ -x "/opt/SUNWspro/bin/cc" ]
then
CC_PATH="/opt/SUNWspro/bin/cc"
fi
# Check to see if we have a valid compiler path.
if [ "$CC_PATH" = "" ]
then
fatal "setprogenv: Unable to locate the C compilers."
fi
export SOLARIS_INTEL_SUB_VERSION CC_PATH
# Now call the 'make file' specific function entry point.
set_solaris_intel_2px_env
} # set_solaris_sparc_env
################################################################################
# #
# END -- set_solaris_intel_env. #
# #
################################################################################
################################################################################
# set_linux_intel_env -- #
# #
# Perform the necessary preliminary functions for the Linux platform. #
# #
################################################################################
set_linux_intel_env( )
{
# Now proceed to determine the exact version of Linux that we're
# running
ver=`uname -r`
$ECHO -n "Current operating system running = "
# If we have a 2.0.XX kernel ...
if $ECHO $ver | grep "2\.0\.[0-9]"
then
LINUX_SUB_VERSION="-DLINUX_INTEL_2p0"
fi
# If we have a 2.2.XX kernel ...
if $ECHO $ver | grep "2\.2\.[0-9]"
then
LINUX_SUB_VERSION="-DLINUX_INTEL_2p2"
fi
if [ "$LINUX_SUB_VERSION" = "" ]
then
fatal "Cannot determine the current version of Linux"
fi
} # set_linux_intel_env
################################################################################
# #
# END -- pre_set_linux_intel_env. #
# #
################################################################################
################################################################################
# is_sco_intel_platform -- #
# #
# Determine if the current operating system platform is SCO or not. #
# #
################################################################################
is_sco_intel_platform( )
{
RESULT=$FAIL
# uname must be present to make any determination
uname 2>/dev/null 1>&2 && {
# SCO supports "-X"
if `uname -X 2>/dev/null | grep NumCPU 2>/dev/null >/dev/null`
then
if `uname -a 2>/dev/null | grep i386 2>/dev/null >/dev/null`
then
# Must be an SCO 3.2.5 system.
if `uname -a 2>/dev/null | grep SCO_SV 2>/dev/null >/dev/null`
then
return $OK
fi
# Must be an SCO 3.2.4 system.
if `uname -X 2>/dev/null | grep "Release = 3\.2v4\." 2>/dev/null >/dev/null`
then
return $OK
fi
fi
fi
}
return $RESULT
} # is_sco_intel_platform
################################################################################
# is_sco_unixware_2pX_platform -- #
# #
# Determine if the current operating system platform is SCO Unixware 2.X. #
# #
################################################################################
is_sco_unixware_2pX_platform( )
{
RESULT=$FAIL
# uname must be present to make any determination
uname 2>/dev/null 1>&2 && {
# SCO supports "-X"
if `uname -X 2>/dev/null | grep NumCPU 2>/dev/null >/dev/null`
then
if `uname -a 2>/dev/null | grep i386 2>/dev/null >/dev/null`
then
# Must be an SCO Unixware 2.X system.
if `uname -a 2>/dev/null | grep 4.2MP 2>/dev/null >/dev/null`
then
return $OK
fi
fi
fi
}
return $RESULT
} # is_sco_unixware_2pX_platform
################################################################################
# is_sco_unixware_7pX_platform -- #
# #
# Determine if the current operating system platform is SCO Unixware 7.X. #
# #
################################################################################
is_sco_unixware_7pX_platform( )
{
RESULT=$FAIL
# uname must be present to make any determination
uname 2>/dev/null 1>&2 && {
# SCO supports "-X"
if `uname -X 2>/dev/null | grep NumCPU 2>/dev/null >/dev/null`
then
if `uname -a 2>/dev/null | grep i386 2>/dev/null >/dev/null`
then
# Is this a SCO Unixware 7.X system.
if `uname -a 2>/dev/null | grep 7.0 2>/dev/null >/dev/null`
then
return $OK
fi
fi
fi
}
return $RESULT
} # is_sco_unixware_7pX_platform
################################################################################
# is_hp_800_platform -- #
# #
# Determine if the current operating system platform is HP-UX or not. #
# #
################################################################################
is_hp_800_platform( )
{
RESULT=$FAIL
# uname must be present to make any determination
uname 2>/dev/null 1>&2 && {
OS_NAME=`uname -s 2>/dev/null` # Should return the string 'HP-UX'
if [ "$OS_NAME" = "HP-UX" ]
then
RESULT=$OK
fi
}
return $RESULT
} # is_hp_800_platform
################################################################################
# is_aix_rs6k_platform -- #
# #
# Determine if the current operating system platform is AIX or not. #
# #
################################################################################
is_aix_rs6k_platform( )
{
RESULT=$FAIL
# uname must be present to make any determination
uname 2>/dev/null 1>&2 && {
OS_NAME=`uname -s 2>/dev/null` # Should return the string 'AIX'
if [ "$OS_NAME" = "AIX" ]
then
RESULT=$OK
fi
}
return $RESULT
} # is_aix_rs6k_platform
################################################################################
# is_solaris_sparc_platform -- #
# #
# Determine if the current operating system platform is Solaris SPARC. #
# #
################################################################################
is_solaris_sparc_platform( )
{
RESULT=$FAIL
# uname must be present to make any determination
uname 2>/dev/null 1>&2 && {
OS_NAME=`uname -s 2>/dev/null` # Should return the string 'SunOS'
ARCH_NAME=`uname -p 2>/dev/null` # Should return the string 'sparc'
if [ "$OS_NAME" = "SunOS" -a "$ARCH_NAME" = "sparc" ]
then
RESULT=$OK
fi
}
return $RESULT
} # is_solaris_sparc_platform
################################################################################
# is_solaris_intel_platform -- #
# #
# Determine if the current operating system platform is Solaris Intel. #
# #
################################################################################
is_solaris_intel_platform( )
{
RESULT=$FAIL
# uname must be present to make any determination
uname 2>/dev/null 1>&2 && {
OS_NAME=`uname -s 2>/dev/null` # Should return the string 'SunOS'
ARCH_NAME=`uname -p 2>/dev/null` # Should return the string 'i386'
if [ "$OS_NAME" = "SunOS" -a "$ARCH_NAME" = "i386" ]
then
RESULT=$OK
fi
}
return $RESULT
} # is_solaris_intel_platform
################################################################################
# is_dgux_intel_platform -- #
# #
# Determine if the current operating system platform is DG/UX Intel. #
# #
################################################################################
is_dgux_intel_platform( )
{
RESULT=$FAIL
# uname must be present to make any determination
uname -a 2>/dev/null 1>&2 && {
OS_NAME=`uname -s 2>/dev/null` # Should return the string 'dgux'
if [ "$OS_NAME" = "dgux" ]
then
# Use the i386 machine id command to determine if the enduser
# machine is a Intel Pentium or Pentium Pro.
# Should return 0 if TRUE
i386 2>>/dev/null >>/dev/null
# Now record the above commands exit code.
CPU_RET=$?
# If this is NOT an INTEL based machine ...
if [ $CPU_RET -eq 0 ]
then
RESULT=$OK
fi
fi
}
return $RESULT
} # is_dgux_intel_platform
################################################################################
# is_dgux_88k_platform -- #
# #
# Determine if the current operating system platform is DG/UX 88k. #
# #
################################################################################
is_dgux_88k_platform( )
{
RESULT=$FAIL
# uname must be present to make any determination
uname -a 2>/dev/null 1>&2 && {
OS_NAME=`uname -s 2>/dev/null` # Should return the string 'dgux'
if [ "$OS_NAME" = "dgux" ]
then
# Use the i386 machine id command to determine if the enduser
# machine is a 88k
# Should return 0 if TRUE
m88k 2>>/dev/null >>/dev/null
# Now record the above commands exit code.
CPU_RET=$?
# If this is NOT an INTEL based machine ...
if [ $CPU_RET -eq 0 ]
then
RESULT=$OK
fi
fi
}
return $RESULT
} # is_dgux_88k_platform
################################################################################
# is_ncr_unix_platform -- #
# #
# Determine if the current operating system platform is NCR Unix 3.0. #
# #
################################################################################
is_ncr_unix_platform( )
{
RESULT=$FAIL
# uname must be present to make any determination
uname -a 2>/dev/null 1>&2 && {
OS_VERSION=`uname -v 2>/dev/null` # Should return the string '3.0'
if [ "$OS_VERSION" = "3.0" ]
then
OS_RELEASE=`uname -r 2>/dev/null` # Should return the string '4.0'
if [ "$OS_RELEASE" = "4.0" ]
then
RESULT=$OK
fi
fi
}
return $RESULT
} # is_ncr_unix_platform
################################################################################
# is_linux_intel_platform -- #
# #
# Determine if the current operating system platform is Linux on Intel. #
# #
################################################################################
is_linux_intel_platform( )
{
RESULT=$FAIL
# uname must be present to make any determination
uname -a 2>/dev/null 1>&2 && {
OS_VERSION=`uname -s 2>/dev/null` # Should return the string 'Linux'
if [ "$OS_VERSION" = "Linux" ]
then
# Should return the string 'i[3-6]86'
OS_RELEASE=`uname -m 2>/dev/null`
if $ECHO "$OS_RELEASE" | grep "i[3-9]86" 2>/dev/null 1>&2
then
RESULT=$OK
fi
fi
}
return $RESULT
} # is_linux_intel_platform
################################################################################
# set_osversion -- #
# #
# Automatically determine what operating system we are running under and #
# then proceed to set the proper value to OSVERSION. #
# #
################################################################################
set_osversion( )
{
# NOTE : We on purpose return from this function as soon as we detect
# the current operating system. The reason being that it is possible
# for two operating systems to be very similar ( SCO Unix vs
# SCO Unixware ).
is_solaris_sparc_platform
if [ "$?" = "$OK" ]
then
$ECHO "OSVERSION Detected--->\tSolaris 2.X+ on Sparc."
OSVERSION="SolarisSparc2.X"
export OSVERSION
return $OK
fi
is_solaris_intel_platform
if [ "$?" = "$OK" ]
then
$ECHO "OSVERSION Detected--->\tSolaris 2.X+ on Intel."
OSVERSION="SolarisIntel2.X"
export OSVERSION
return $OK
fi
is_aix_rs6k_platform
if [ "$?" = "$OK" ]
then
$ECHO "OSVERSION Detected--->\tAIX."
OSVERSION="AIX"
export OSVERSION
return $OK
fi
is_hp_800_platform
if [ "$?" = "$OK" ]
then
$ECHO "OSVERSION Detected--->\tHP-UX"
OSVERSION="HP-UX"
export OSVERSION
return $OK
fi
is_sco_intel_platform
if [ "$?" = "$OK" ]
then
$ECHO "Detected--->\tSCO Unix/MPX."
OSVERSION="SCO"
export OSVERSION
return $OK
fi
is_sco_unixware_7pX_platform
if [ "$?" = "$OK" ]
then
$ECHO "Detected--->\tSCO Unixware 7.X"
OSVERSION="Unixware7"
export OSVERSION
return $OK
fi
is_sco_unixware_2pX_platform
if [ "$?" = "$OK" ]
then
$ECHO "Detected--->\tSCO Unixware 2.X."
OSVERSION="Unixware"
export OSVERSION
return $OK
fi
is_dgux_intel_platform
if [ "$?" = "$OK" ]
then
$ECHO "Detected--->\tDG/UX Intel 4.11/4.20."
OSVERSION="DGUX-Intel"
export OSVERSION
return $OK
fi
is_dgux_88k_platform
if [ "$?" = "$OK" ]
then
$ECHO "Detected--->\tDG/UX 88k 4.11."
OSVERSION="DGUX-88k"
export OSVERSION
return $OK
fi
is_ncr_unix_platform
if [ "$?" = "$OK" ]
then
$ECHO "Detected--->\tNCR 3.0 Unix."
OSVERSION="NCR"
export OSVERSION
return $OK
fi
is_linux_intel_platform
if [ "$?" = "$OK" ]
then
$ECHO "Detected--->\tLinux Intel."
OSVERSION="LINUX_INTEL"
export OSVERSION
return $OK
fi
# If here then we could not detect the current operating system.
fatal "Unable to determine operating system!"
return $FAIL
} # set_osversion
################################################################################
# set_program_env -- #
# #
# Set the environment variables necessary to compile the target program #
# for the current operating system version. #
# #
################################################################################
set_program_env( ) {
# Proceed to automatically determine what operating system we are running.
set_osversion
# Now based on the current operating system ....
case "$OSVERSION" in
"SCO" ) set_sco_unix_env
;;
"HP-UX" ) set_hpux_env
;;
"AIX" ) # No special setup is needed for AIX.
;;
"Unixware7" ) # Unixware 7.X
set_unixware_7_intel_env
;;
"Unixware" ) # Unixware 2.X
set_unixware_env
;;
"NCR" ) set_ncr_intel_3px_env
;;
"DGUX-5.4" ) set_dgux_5p4_env
;;
"DGUX-Intel" ) set_dgux_intel_env
;;
"DGUX-88k" ) set_dgux_88k_env
;;
"SolarisSparc2.X" )
set_solaris_sparc_env
;;
"SolarisIntel2.X" )
set_solaris_intel_env
;;
"LINUX_INTEL" )
set_linux_intel_env
;;
* ) wrong_osversion
;;
esac
} # set_program_env
################################################################################
# build_vnc_all -- #
# #
# Build the ENTIRE TridiaVNC system. This is a build from scratch. #
# Typically you would run this when you want to recompile everything from #
# scratch. #
# #
################################################################################
build_vnc_all( )
{
# cd to the 'root' directory of the UNIX version of TridiaVNC
cd $VNC_ROOT/src/unix/vnc_unixsrc
# Now proceed to first have Imake make the makefiles ...
xmkmf
# Clean all the .[oa]
make clean
# Make it all.
make World
# Now build the Xvnc 'X' server ...
cd Xvnc
make clean
make World
# Proceed to install the binaries for local testing.
copy_to_test
# Proceed to install the binaries for build distribution purposes.
copy_to_build
#mkdir -p /usr/local/vnc/classes
#cp classes/* /usr/local/vnc/classes
} # build_vnc_all
################################################################################
# build_vnc_Xserver - #
# #
# Builds only the TridiaVNC server from its 'current' point, that is no #
# clean's nor xmkmf are performed. Useful when only working on the server. #
# #
################################################################################
build_vnc_Xserver( )
{
# cd to the 'root' directory of the UNIX version of TridiaVNC
cd $VNC_ROOT/src/unix/vnc_unixsrc/Xvnc
# Now just 'make' the server from its present compilation state.
make
} # build_vnc_Xserver
################################################################################
# #
# build_vnc_passwd -- #
# #
# Builds only the TridiaVNC password module from its 'current' point, that #
# is no clean's nor xmkmf are performed. Useful when only working on the #
# this module. #
# #
################################################################################
build_vnc_passwd( )
{
# cd to the 'root' directory of the UNIX version of TridiaVNC
cd $VNC_ROOT/src/unix/vnc_unixsrc/vncpasswd
# Now just 'make' the server from its present compilation state.
make
} # build_vnc_passwd
################################################################################
# #
# build_vnc_viewer -- #
# #
# Builds only the TridiaVNC viewer module from its 'current' point, that #
# is no clean's nor xmkmf are performed. Useful when only working on the #
# this module. #
# #
################################################################################
build_vnc_viewer( )
{
# cd to the 'root' directory of the UNIX version of TridiaVNC
cd $VNC_ROOT/src/unix/vnc_unixsrc/vncviewer
# Now just 'make' the server from its present compilation state.
make
} # build_vnc_viewer
################################################################################
# #
# build_xrc -- #
# #
# Builds X/RC which is a server for Linux console's. In other words it is #
# a specialized VNC server that allows a viewer to connect to display 0. #
# This binary and sources were not part of AT&T's original work. #
# #
################################################################################
build_xrc( )
{
if [ "$OSVERSION" != "LINUX_INTEL" ]
then
error2 "X/RC is supported only under Linux for Intel systems!"
return $FAIL
fi
# cd to the 'root' directory of the UNIX version of TridiaVNC
cd $VNC_ROOT/src/unix/vnc_unixsrc/xrc/xrc
# Now just 'make' the server from its present compilation state.
make depend
make
} # build_xrc
################################################################################
# copy_to_test -- #
# #
# Copy the current binaries on the target platform onto the standard #
# 'test' subdirectory for further testing ... #
# #
################################################################################
copy_to_test( )
{
# cd to the 'root' directory of the UNIX version of TridiaVNC
cd $VNC_ROOT/src/unix/vnc_unixsrc/
# Now copy onto the standard test sub-directory
./vncinstall ../../test
} # copy_to_test
################################################################################
# copy_to_build -- #
# #
# Copy the current binaries on the target platform onto the standard #
# 'build' subdirectory for distribution purposes. The 'build' directory is an #
# nfs mount sub-directory on apollo currently. #
# #
################################################################################
copy_to_build( )
{
# cd to the 'root' directory of the UNIX version of TridiaVNC
cd $VNC_ROOT/src/unix/vnc_unixsrc/
# Now based on the current operating system ....
case "$OSVERSION" in
"SCO" ) BUILD_DIR="$VNC_ROOT/builds/unix/sco/intel/build"
;;
"HP-UX" ) BUILD_DIR="$VNC_ROOT/builds/unix/hpux/parisc/build"
;;
"AIX" ) BUILD_DIR="$VNC_ROOT/builds/unix/aix/ppc/build"
;;
"Unixware7" ) # Unixware 7.X
BUILD_DIR="$VNC_ROOT/builds/unix/unixware/intel/build"
;;
"Unixware" ) # Unixware 2.X
fatal "Unixware 2.X is currently not supported!"
;;
"NCR" ) fatal "NCR 3.X is currently not supported!"
;;
"DGUX-5.4" ) fatal "DG/UX 88k 5.4 is currently not supported!"
;;
"DGUX-Intel" ) fatal "DG/UX Intel is currently not supported!"
;;
"DGUX-88k" ) fatal "DG/UX 88k is currently not supported!"
;;
"SolarisSparc2.X" )
BUILD_DIR="$VNC_ROOT/builds/unix/solaris/sparc/build"
;;
"SolarisIntel2.X" )
fatal "Solaris Intel is currently not supported!"
;;
"LINUX_INTEL" )
BUILD_DIR="$VNC_ROOT/builds/unix/linux/intel/build"
;;
* ) fatal "Current operating is unknown!"
;;
esac
# Now copy onto the standard test sub-directory
./vncinstall "$BUILD_DIR"
} # copy_to_build
################################################################################
# rpl -- #
# #
# Given a filename, proceed to 'search' for a pattern, and then apply a #
# replacement pattern onto it. #
# #
# PARAMETERS : #
# #
# $1 -- File on which to operate on. #
# $2 -- Pattern to search upon. #
# $3 -- Replacement pattern to use. #
# #
# RETURNS : OK -- If the operation was a success. #
# #
# FAIL -- If the file to operate on, was lost. #
# #
################################################################################
rpl( ) {
RPL_FILE=$1
PAT=$2
RPL=$3
(
ed - $RPL_FILE <<!End
1,\$g/$PAT/s//$RPL/
w
q
!End
)
# If we lost the work file for some reason ...
if [ ! -s $RPL_FILE ]
then
# Let the caller know about the problem.
return $FAIL
fi
# Now 'unset' these local variables.
RPL_FILE=""
PAT=""
RPL=""
# If here, then we have succeeded.
return $OK
} # rpl
################################################################################
# END -- rpl. #
################################################################################
################################################################################
# update_version -- #
# #
# Proceed to update once of the source files with the current version of #
# TridiaVNC. #
# #
# The parameters are : #
# $1 -- File to update. #
# $2 -- Search pattern. #
# $3 -- Replacement pattern. #
# #
################################################################################
update_version( )
{
file=$1
seapat=$2
rplpat=$3
$ECHO "\nUpdating file with new version string ( $file )\n"
rpl "$file" "$seapat" "$rplpat"
if [ $? -ne 0 ]
then
fatal "Unable to update file ( $file )!"
fi
} # update_version
################################################################################
# get_version -- #
# #
# Proceed to prompt the user for the new TridiaVNC version number. #
# #
# The VERSION string is in the form of : #
# #
# MAJOR number.MINOR number.BUILD number #
# #
################################################################################
get_version( )
{
while true
do
NEW_VERSION=""
MAJOR_NUM=""
MINOR_NUM=""
BUILD_NUM=""
# First prompt the user for the proper MAJOR, MINOR, BUILD numbers.
prompt_number "Please enter the MAJOR number " || {
return $FAIL
}
MAJOR_NUM=$ret_prompt_number
prompt_number "Please enter the MINOR number " || {
return $FAIL
}
MINOR_NUM=$ret_prompt_number
prompt_number "Please enter the BUILD number " || {
return $FAIL
}
BUILD_NUM=$ret_prompt_number
# Now build the new version string.
NEW_VERSION=$MAJOR_NUM"."$MINOR_NUM"."$BUILD_NUM
# Now confirm to the user that this is new version to use.
$ECHO "\nThe new version string is : $NEW_VERSION"
getyn "\nIs the version string correct ?" || {
# Prompt to see if the user wishes to try again.
getyn "\nDo you wish to try again ?" || {
# If not then fail the entire operation.
return $FAIL
}
continue;
}
# If here, then we're done.
break;
done # while
# If here, then we're done.
return $OK
} # get_version
################################################################################
# new_version -- #
# #
# Proceed to prompt the user for the new version of TridiaVNC. Once done #
# proceed to then update all the necessary files with the proper version #
# number. #
# #
# Since some of the files to update here have the version string encoded #
# in slightly different fashion, we individually search and replace each file. #
# #
# The VERSION string is in the form of : #
# #
# MAJOR number.MINOR number.BUILD number #
# #
# Below is the list of files to update : #
# #
# ./README #
# ./vncviewer/README #
# ./Xvnc/config/cf/vnc.def #
# ./vncviewer/argsresources.c #
# #
################################################################################
new_version( )
{
# Prompt the user for the new version string to use.
get_version || {
# If here, then abort the procedure.
return $FAIL
}
# Otherwise proceed to update the files with the new string.
update_version "./vnc_unixsrc/README" \
"TridiaVNC [0-9]\.[0-9]\.[0-9]" \
"TridiaVNC $NEW_VERSION"
update_version "./vnc_unixsrc/vncviewer/README" \
"TridiaVNC viewer version [0-9].[0-9].[0-9]" \
"TridiaVNC viewer version $NEW_VERSION"
NEW_VERSION_NO_DOTS=`$ECHO $NEW_VERSION 0 | tr -d "[\.\ ]"`
if [ -z "$NEW_VERSION_NO_DOTS" -o "$NEW_VERSION_NO_DOTS" = "" ]
then
fatal "Could not strip dots from version number!"
fi
update_version "./vnc_unixsrc/Xvnc/config/cf/vnc.def" \
"XVendorRelease.*[0-9][0-9][0-9][0-9]" \
"XVendorRelease $NEW_VERSION_NO_DOTS"
update_version "./vnc_unixsrc/Xvnc/config/cf/vnc.def" \
"TridiaVNCRelease.*\"[0-9]\.[0-9]\.[0-9]\"" \
"TridiaVNCRelease \"$NEW_VERSION\""
update_version "./vnc_unixsrc/vncviewer/argsresources.c" \
"TridiaVNC viewer version [0-9]\.[0-9]\.[0-9]" \
"TridiaVNC viewer version $NEW_VERSION"
# If here all is well.
return $OK
} # new_version
################################################################################
# new_tag -- #
# #
# Proceed to prompt the user for the new CVS version of TridiaVNC. Once #
# done proceed to the COMMIT the current source tree followed by assigning #
# a new cvs 'tag' finally then the source tree is released back to the #
# repository. #
# #
################################################################################
new_tag( )
{
# Give a proper warning message.
clear
$ECHO "\n\n $ENTER_REVERSE WARNING! $EXIT_REVERSE\n\n
\tThis procedures assumes that the current source tree is in a stable
\tcondition and has been completely recompiled AFTER a new source version
\thas been assigned to the proper sources via the command :
\t\tbuild newversion
\tThis procedure will perform the following cvs functions :
cvs commit -m \"Updated source version constants to: \$NEW_VER_TAG\" unix
cvs tag \$NEW_VER_TAG unix
cvs release unix\n\n"
getyn "\nDo you wish to proceed with the update ?" || {
# If here, then abort the procedure.
return $FAIL
}
# Prompt the user for the new version string to use.
get_version || {
# If here, then abort the procedure.
return $FAIL
}
NEW_VER_TAG="TridiaVNC_V_"$MAJOR_NUM"_"$MINOR_NUM"_"$BUILD_NUM
$ECHO "\n\nNEW TAG = " $NEW_VER_TAG
sleep 2
save_dir=`pwd`
cd ..
$ECHO "\n\nCommitting source changes ...."
cvs commit -m "Updated source version constants to: $NEW_VER_TAG" unix
if [ $? -ne 0 ]
then
fatal "CVS commit command failed"
fi
$ECHO "\n\nAssigning new tag to source tree ..."
cvs tag $NEW_VER_TAG unix
if [ $? -ne 0 ]
then
fatal "CVS tag command failed"
fi
$ECHO "\n\nReleasing source tree ..."
cvs release unix
if [ $? -ne 0 ]
then
fatal "CVS release command failed"
fi
# Return to whence we came from.
cd $save_dir
} # new_tag
################################################################################
# usage_build_vnc -- #
# #
# Display the usage statement for this build script. #
# #
################################################################################
usage_build_vnc( )
{
$ECHO "Usage : build [all|server|passwd|viewer|testcopy]"
$ECHO ""
$ECHO " all -- Builds the entire TridiaVNC system"
$ECHO " -- Removes all .o, runs xmkmf, etc."
$ECHO ""
$ECHO " vncserver"
$ECHO " server -- Builds just the TridiaVNC server."
$ECHO " -- From its current state. No cleans are done."
$ECHO ""
$ECHO " vncpasswd"
$ECHO " passwd -- Builds just the TridiaVNC password module."
$ECHO " -- From its current state. No cleans are done."
$ECHO ""
$ECHO " vncviewer"
$ECHO " viewer -- Builds just the TridiaVNC server."
$ECHO " -- From its current state. No cleans are done."
$ECHO ""
$ECHO " xrc -- Builds just the Linux 'Console' only server."
$ECHO " -- From its current state. No cleans are done."
$ECHO ""
$ECHO " copytest -- Copy the current binaries on the target platform"
$ECHO " onto the standard 'test sub-directory."
$ECHO ""
$ECHO " copybuild -- Copy the current binaries on the target platform"
$ECHO " onto the standard 'build sub-directory."
$ECHO ""
$ECHO " newversion -- Prompts for a new version to assigned to all"
$ECHO " TridiaVNC sources."
$ECHO ""
$ECHO " newtag -- Prompts for a new CVS version string to assign"
$ECHO " to the repository and proceeds to check in the"
$ECHO " current source tree and commits the tree as well."
$ECHO ""
$ECHO " -? -- Provides this help message."
$ECHO ""
$ECHO "build with no arguments, just makes whatever needs making ..."
$ECHO ""
$ECHO "All command are case insensitive."
} # usage_build_vnc
################################################################################
# main -- Let it all begin here. #
################################################################################
# Determine what form of the echo command to use.
init_echo
# Find out what video attributes we can use.
init_rev_attributes
# Check command line arguments, if any.
if [ $ARGC -gt 2 ]
then
usage_build_vnc
exit $FAIL
fi
# Make sure we remember what operating system we're running.
set_program_env
BUILD_CMD="$ARGS"
# Check that we have a valid build directory tree.
# The default dir is usually not what the user wants...
: ${VNC_ROOT:=/vnc}
if [ -d $VNC_ROOT/builds -a -d $VNC_ROOT/src/unix/vnc_unixsrc ]
then
$ECHO "Using VNC_ROOT $VNC_ROOT"
else
$ECHO "Source and build tree $VNC_ROOT not found."
$ECHO "Please set VNC_ROOT to the directory containing 'src/unix/vnc_unixsrc'"
$ECHO "and 'builds'."
exit $FAIL
fi
case "$BUILD_CMD" in
# all
[Aa][Ll][Ll] ) # all
build_vnc_all
;;
# Xserver
[Xx][Ss][Ee][Rr][Vv][Ee][Rr] )
# server
build_vnc_Xserver
;;
# server
[Ss][Ee][Rr][Vv][Ee][Rr] )
# server
build_vnc_Xserver
;;
# passwd
[Pp][Aa][Ss][Ss][Ww][Dd] )
# vncpasswd
build_vnc_passwd
;;
# vncpasswd
[Vv][Nn][Cc][Pp][Aa][Ss][Ss][Ww][Dd] )
# vncpasswd
build_vnc_passwd
;;
# vncviewer
[Vv][Nn][Cc][Vv][Ii][Ee][Ww][Ee][Rr] )
# vncviewer
build_vnc_viewer
;;
# viewer
[Vv][Ii][Ee][Ww][Ee][Rr] )
# vncviewer
build_vnc_viewer
;;
# copytest
[Cc][Oo][Pp][Yy][Tt][Ee][Ss][Tt] )
# copy binaries to test sub-directory.
copy_to_test
;;
# copybuild
[Cc][Oo][Pp][Yy][Bb][Uu][Ii][Ll][Dd] )
# copy binaries to test build-directory.
copy_to_build
;;
# newversion
[Nn][Ee][Ww][Vv][Ee][Rr][Ss][Ii][Oo][Nn] )
# Proceed to prompt and assign a new version
# for TridiaVNC
new_version
;;
# newtag
[Nn][Ee][Ww][Tt][Aa][Gg] )
# Proceed to prompt and assign a new CVS version
# tag for TridiaVNC
new_tag
;;
# xrc
[Xx][Rr][Cc] ) # vncviewer
build_xrc
;;
\-\? ) usage_build_vnc
exit $FAIL
;;
* ) # all
build_vnc_all
;;
esac
################################################################################
# end -- main. #
################################################################################
################################################################################
# end -- build. #
################################################################################
syntax highlighted by Code2HTML, v. 0.9.1