diff --git a/src/tools/GetVar b/src/tools/GetVar new file mode 100755 index 000000000..14e91f808 --- /dev/null +++ b/src/tools/GetVar @@ -0,0 +1,88 @@ +#!/bin/sh +# +# $Id$ +# +# Retrieve a variable value from EPICS configuration makefiles. +# by Matthew Needes +# +# Syntax: +# GetVar VAR_NAME [TARGET_ARCH] +# +# If TARGET_ARCH is NOT specified, only those general variables in +# CONFIG_SITE are available. +# +# If TARGET_ARCH is specified, all EPICS target specific variables +# are accessable in addition to all general variables. +# +# $Log$ +# Revision 1.10 1995/08/18 15:26:39 jba +# Added pathname to gmake +# +# Revision 1.9 1995/08/17 20:30:00 jba +# EPICS now passed as param - FindEpics removed +# +# Revision 1.8 1994/10/25 15:55:28 winans +# Changed 'make' to 'gmake' for performing make operations. +# +# Revision 1.7 1994/10/05 18:39:27 jba +# Modified syntax of makefile usage +# +# Revision 1.6 1994/09/22 01:41:44 mcn +# MakeRelease - MAJOR bug fix. GetVar / MakeDirs - minor fix. +# +# Revision 1.5 1994/09/08 13:47:08 mcn +# Fixed GetVar's inclusions. +# +# Revision 1.4 1994/09/07 20:59:13 mcn +# Revamped GetVar, modified scripts for new GetVar. +# +# Revision 1.3 1994/09/07 19:08:49 jba +# Modified to work with extensions and do depends +# +# Revision 1.2 1994/08/21 00:56:38 mcn +# New Stuff +# +# Revision 1.1 1994/08/16 16:12:18 mcn +# Added GetVar, made use of 'ln' compatible with SYSV Unix. +# +# + + +if [ -z "$2" ]; then + echo "usage: $0 EPICS VAR_NAME [TARGET_ARCH]" + exit 1 +fi + +EPICS=$1 + +INCLUDE=${EPICS}/config/CONFIG_BASE + +if [ -z "$3" ]; then + OPTS="" +else + OPTS="T_A=$3" +fi + +PID=$$ + +# Construct temporary makefile +cat - < /tmp/Makefile.tmp.$$ + +EPICS=$EPICS + +include ${INCLUDE} + +all: + @echo "\$($2)" > /tmp/Makefile.tmp.out.$PID + +MFILE + +gnumake -f /tmp/Makefile.tmp.$$ $OPTS > /dev/null + +# Display value +cat /tmp/Makefile.tmp.out.$$ + +rm -f /tmp/Makefile.tmp.$$ /tmp/Makefile.tmp.out.$$ + +exit 0 + diff --git a/src/tools/InstallVersion b/src/tools/InstallVersion new file mode 100755 index 000000000..1a2d833e5 --- /dev/null +++ b/src/tools/InstallVersion @@ -0,0 +1,113 @@ +#!/usr/bin/sh +####!/usr/bin/sh -xv + +# InstallVerson +# +# InstallVerson is used within makefiles to copy new versions of +# files into a destination directory with file version numbering. +# +# +# Author: JanetAnderson (ANL) +# Date: 7/18/94 +# +# $Log$ +# Revision 1.3 1994/12/07 15:13:03 jba +# Modified comments +# +# Revision 1.2 1994/11/09 22:11:20 jba +# Allow filename parm to include relative dir location +# +# Revision 1.1 1994/09/07 20:50:38 jba +# Files for extensions +# +# +########################################################## +# +# Find the last version number of an installed tool. +# +get_new_version () +{ +if [ $# -ne 1 ] +then + echo Usage: $0 toolname + exit 1 +fi + +VERSION=`ls $1.* 2>/dev/null | tail -1 | nawk -F'.' '{ printf "%05d", $NF + 1 }'` + +if [ -z "$VERSION" ] +then + echo 00001 +else + echo $VERSION +fi + +exit 0 +} +########################################################## +TOOL=`basename $0` +MODE=755 +USAGE="Usage: + $TOOL [ -m mode ] file ... directory + + -m mode Set the mode for the installed file (0755 by default) + file Name of file + directory Destination directory +" +# get command line options +set -- `getopt m:g:o:csd $*` +for i +do + case $i in + -m) MODE=$2; shift 2;; + -g | -o) echo $USAGE; echo "$i not implemented"; shift 2;; + -c | -s | -d ) echo $USAGE; echo "$i not implemented"; shift;; + --) shift; break;; + esac +done + +# at least two args required +if [ $# -lt 2 ] +then + echo "$USAGE" + exit 1 +fi + +ADD_ON_BIN= +FILELIST= +for i +do + FILELIST="${FILELIST} ${ADD_ON_BIN}"; ADD_ON_BIN=$i; shift; +done + +if [ ! -d ${ADD_ON_BIN} ] ;then + echo "$USAGE\n Can't find directory '${ADD_ON_BIN}'" + exit 1 +fi + +for FILE in ${FILELIST} +do + if [ ! -f ${FILE} ] ;then + echo "$USAGE\n Can't find file '${FILE}'" + exit 1 + fi + + TEST= + FILEBASENAME=`basename ${FILE}` + if [ -f ${ADD_ON_BIN}/${FILEBASENAME} ] ; then + #Is ${ADD_ON_BIN}/${FILEBASENAME} link timestamp newer than ${FILE} + TEST=`find ${ADD_ON_BIN} -name "${FILEBASENAME}" -newer ${FILE} -print` + fi + if [ "${TEST}x" = "x" ] ; then + #echo "Installing ${FILEBASENAME}" + /bin/rm -f ${ADD_ON_BIN}/${FILEBASENAME} + VERSION_NAME=${FILEBASENAME}.`get_new_version ${ADD_ON_BIN}/${FILEBASENAME}` + /bin/cp -p ${FILE} ${ADD_ON_BIN}/${VERSION_NAME} + /bin/chmod ${MODE} ${ADD_ON_BIN}/${VERSION_NAME} + /bin/ln -s ${VERSION_NAME} ${ADD_ON_BIN}/${FILEBASENAME} + else + echo "${ADD_ON_BIN}/${FILEBASENAME} is up to date" + fi +done + +exit 0 diff --git a/src/tools/Makefile b/src/tools/Makefile new file mode 100644 index 000000000..977081d2d --- /dev/null +++ b/src/tools/Makefile @@ -0,0 +1,18 @@ +# +# $Id$ +# +# Lowest Level Directroy Makefile +# by Janet Anderson +# +# $Log$ +# Revision 1.1 1994/09/07 19:25:39 jba +# New file +# +# + +EPICS=../../.. + +include $(EPICS)/config/CONFIG_BASE + +include $(EPICS)/config/RULES_ARCHS + diff --git a/src/tools/Makefile.Unix b/src/tools/Makefile.Unix new file mode 100644 index 000000000..f91dd1214 --- /dev/null +++ b/src/tools/Makefile.Unix @@ -0,0 +1,26 @@ +EPICS = ../../../.. +include Target.include +include $(EPICS)/config/CONFIG_BASE + +PROD = installEpics +SCRIPTS = InstallVersion GetVar getrel gmake + +include $(EPICS)/config/RULES.Unix + +$(INSTALL_BIN)/installEpics: installEpics + @echo "Installing $@" + @test -d $(INSTALL_LOCATION_BIN) || mkdir $(INSTALL_LOCATION_BIN) + @test -d $(INSTALL_BIN) || mkdir $(INSTALL_BIN) + @./installEpics -m 555 $< $(INSTALL_BIN) + +$(INSTALL_BIN)/InstallVersion: ../InstallVersion + @echo "Installing $@" + @test -d $(INSTALL_LOCATION_BIN) || mkdir $(INSTALL_LOCATION_BIN) + @test -d $(INSTALL_BIN) || mkdir $(INSTALL_BIN) + @./installEpics -m 555 $< $(INSTALL_BIN) + +installEpics: ../installEpics + @$(RM) $@ + @cp -p $< $@ + @/bin/chmod 755 $@ + diff --git a/src/tools/getrel b/src/tools/getrel new file mode 100755 index 000000000..998524932 --- /dev/null +++ b/src/tools/getrel @@ -0,0 +1,154 @@ +#!/bin/sh +# +# $Id$ +# +# Author: Matthew Needes +# +# $Log$ +# Revision 1.13 1996/01/25 21:03:20 mrk +# Changes for new all ascii database definitions +# +# Revision 1.12 1995/08/18 15:26:05 jba +# Added pathname to GetVar +# +# Revision 1.11 1995/08/17 20:35:20 jba +# EPICS added on calls to GetVar +# +# Revision 1.10 1995/04/26 16:20:35 jba +# Added date to .current_rel_hist file output +# +# Revision 1.9 1995/03/30 23:16:07 jba +# Changed example comment +# +# Revision 1.8 1994/09/15 22:06:36 mcn +# Removed -h from test flags. +# +# Revision 1.7 1994/09/07 20:59:17 mcn +# Revamped GetVar, modified scripts for new GetVar. +# +# Revision 1.6 1994/09/07 19:08:52 jba +# Modified to work with extensions and do depends +# +# Revision 1.5 1994/08/21 00:56:43 mcn +# New Stuff +# +# Revision 1.4 1994/08/16 17:20:45 mcn +# exported variable +# +# Revision 1.3 1994/08/16 16:12:19 mcn +# Added GetVar, made use of 'ln' compatible with SYSV Unix. +# +# Revision 1.2 1994/08/02 18:36:30 mcn +# Support new configuration. +# +# Revision 1.1 1994/07/14 16:17:36 mcn +# Modified to support structure of base, made more intelligent (mcn) +# + +USAGE="Usage: + getrel [arch1 arch2 ...] + +ex: getrel /usr/local/epics/R3.12 + --------- OR ----------- + getrel ~/epics mv197 + + If the optional architecture list is left out links + for supported architectures will automatically be + created. +" + +# one arg +if [ $# -lt 1 ]; then + cat <> .current_rel_hist + +# Create/Parse VX architecture list reliably +if [ $# -eq 1 ]; then + # Find what architectures are supported in + # the release by examining bin + ARCHS=`ls -1 ${BASE}/bin` + # Suppress some error messages in automatic mode. + QUIET="T" +else + # Look at command line arguments 2 and onward + # shift to remove first argument. + shift + ARCHS=${*} + QUIET="F" +fi + +# +# Check architecture list by examining: +# $CONFIG/CONFIG_ARCH.ARCH file +# $BASE/bin/ARCH directory +# +echo +echo "Creating soft links for:" + +for T_A in $ARCHS; do + if [ -f ${CONFIG}/CONFIG_ARCH.${T_A} ]; then + TYPE=`${EPICS}/base/bin'${HOST_ARCH}/GetVar ${EPICS} BUILD_TYPE ${T_A}` + + if [ "${TYPE}" = "Vx" ]; then + if [ ! -f ${BASE}/bin/${T_A}/iocCore ]; then + echo " ${T_A}: Warning: This architecture has not been built in EPICS base." + fi + echo " ${T_A}: Creating soft links." + ln -s base/bin/${T_A} target${T_A} + ln -s ./target${T_A}/vxWorks vxWorks${T_A} + ln -s ./target${T_A}/vxWorks.sym vxWorks${T_A}.sym + else + if [ "${QUIET}" = "F" ]; then + echo " ${T_A}: This is not an IOC architecture." + echo " ${T_A}: NOT creating soft links." + fi + fi + else + echo " ${T_A}: No configuration file exists for ${T_A} in EPICS config." + echo " ${T_A}: Create config/CONFIG_ARCH.${T_A} and build." + echo " ${T_A}: NOT creating soft links." + fi +done + +echo +echo "getrel: - completed!" +echo + +exit 0 diff --git a/src/tools/installEpics b/src/tools/installEpics new file mode 100755 index 000000000..e37077e02 --- /dev/null +++ b/src/tools/installEpics @@ -0,0 +1,72 @@ +#!/usr/bin/sh + +# InstallEpics +# +# InstallEpics is used within makefiles to copy new versions of +# files into a destination directory. +# +########################################################## +TOOL=`basename $0` +MODE=755 +USAGE="Usage: + $TOOL [ -m mode ] file ... directory + + -m mode Set the mode for the installed file (0755 by default) + file Name of file + directory Destination directory +" +# get command line options +set -- `getopt m:g:o:csd $*` +for i +do + case $i in + -m) MODE=$2; shift 2;; + -g | -o) echo $USAGE; echo "$i not implemented"; shift 2;; + -c | -s | -d ) echo $USAGE; echo "$i not implemented"; shift;; + --) shift; break;; + esac +done + +# at least two args required +if [ $# -lt 2 ] +then + echo "$USAGE" + exit 1 +fi + +INSTALL_BIN= +FILELIST= +for i +do + FILELIST="${FILELIST} ${INSTALL_BIN}"; INSTALL_BIN=$i; shift; +done + +if [ ! -d ${INSTALL_BIN} ] ;then + echo "$USAGE\n Can't find directory '${INSTALL_BIN}'" + exit 1 +fi + +for FILE in ${FILELIST} +do + if [ ! -f ${FILE} ] ;then + echo "$USAGE\n Can't find file '${FILE}'" + exit 1 + fi + + TEST= + FILEBASENAME=`basename ${FILE}` + if [ -f ${INSTALL_BIN}/${FILEBASENAME} ] ; then + #Is ${INSTALL_BIN}/${FILEBASENAME} link timestamp newer than ${FILE} + TEST=`find ${INSTALL_BIN} -name "${FILEBASENAME}" -newer ${FILE} -print` + fi + if [ "${TEST}x" = "x" ] ; then + #echo "Installing ${FILEBASENAME}" + /bin/rm -f ${INSTALL_BIN}/${FILEBASENAME} + /bin/cp -p ${FILE} ${INSTALL_BIN}/${FILEBASENAME} + /bin/chmod ${MODE} ${INSTALL_BIN}/${FILEBASENAME} + else + echo "${INSTALL_BIN}/${FILEBASENAME} is up to date" + fi +done + +exit 0