Files
epics-base/src/libCom/bldEnvData

134 lines
2.7 KiB
Bash
Executable File

#!/bin/sh
#
# base/tools $Id$
# Author: Andrew Johnson (RGO)
# Date: 14-Mar-95
#
# Experimental Physics and Industrial Control System (EPICS)
#
# $Log$
# Revision 1.9 1997/05/01 19:57:10 jhill
# updated dll keywords
#
# Revision 1.8 1997/04/10 19:46:59 jhill
# new env param decl
#
# Revision 1.7 1997/02/24 16:13:03 jba
# Portability change /bin/pwd changed to pwd.
#
# Revision 1.6 1996/11/02 01:57:45 jhill
# use correct form of #include
#
# Revision 1.5 1996/09/16 18:41:13 jhill
# include shareLib.h
#
# Revision 1.4 1996/06/25 21:48:33 jba
# Makefile includes now from base/src/config, removed all soft links
#
# Revision 1.3 1996/05/10 16:10:18 mrk
# remove hard path to base/include
#
# Revision 1.2 1995/09/29 22:16:27 jhill
# ms windows changes
#
# Revision 1.1 1995/08/17 20:22:09 jba
# Moved bldEnvData,blderrSymTbl, makeStatTbl to libCom dir
#
# Revision 1.3 1995/08/14 19:27:24 jhill
# extern => epicsShareExtern
#
# Revision 1.2 1995/05/04 09:49:24 anj
# Added CONFIG_SITE_ENV, changed envData to .c file
#
# Revision 1.1 1995/04/24 16:02:29 anj
# Moved environment parameter defaults to config/CONFIG_ENV
#
#
# tool to build envData.c from envDefs.h and config/CONFIG*ENV
# Usage bldEnvData
HERE=`pwd`
cd $1
CONFIG_DIR=`pwd`
cd ${HERE}
SRC=../envDefs.h
ENV_DATA=${CONFIG_DIR}/CONFIG_ENV
SITE_DATA=${CONFIG_DIR}/CONFIG_SITE_ENV
OBJ=envData.c
TOOL=`basename $0`
# Start by creating a list of the ENV_PARAM declarations
PARAMS=`sed -n -e 's/;//' \
-e 's/^[ ]*epicsShareExtern[ ][ ]*READONLY[ ][ ]*ENV_PARAM[ ][ ]*//p' \
${SRC}`
# Create a new header file
rm -rf ${OBJ}
cat >${OBJ} <<!EOF
/* ${HERE}/${OBJ}
*
* created by ${TOOL}
*
* from:
* ${SRC}
* ${ENV_DATA}
* ${SITE_DATA}
*
* `date`
*
*/
#include "envDefs.h"
#include "shareLib.h"
!EOF
# Make sure no corresponding shell environment variables
unset ${PARAMS}
# Read the default values from the config file into shell variables
. ${ENV_DATA}
. ${SITE_DATA}
# Scan through the parameters to create the definition
for ENV in ${PARAMS}
do
# Get the default, complain if not present
if [ `set | grep -c ${ENV}=` = 0 ];
then
echo No default value for ${ENV}
DEFAULT=""
else
VAR='$'${ENV}
DEFAULT=`eval echo ${VAR}`
fi
# Add this definition to the header file
# echo ${ENV} = ${DEFAULT}
echo epicsShareDef READONLY ENV_PARAM ${ENV}'={"'${ENV}'","'${DEFAULT}'"};' >>${OBJ}
done
# Now create an array pointing to all parameters
cat >>${OBJ} <<!EOF
epicsShareDef READONLY ENV_PARAM* env_param_list[EPICS_ENV_VARIABLE_COUNT+1] = {
!EOF
# Contents are the addresses of each parameter
for ENV in ${PARAMS}
do
echo ' &'${ENV}, >>${OBJ}
done
# Finally finish list with 0
cat >>${OBJ} <<!EOF
0
};
!EOF
exit 0