166 lines
3.6 KiB
Bash
Executable File
166 lines
3.6 KiB
Bash
Executable File
#!/bin/sh
|
|
#
|
|
# base/src/tools $Id$
|
|
# Author: Robert Zieman (ANL)
|
|
# Date: 6/03/91
|
|
#
|
|
# Experimental Physics and Industrial Control System (EPICS)
|
|
#
|
|
# Copyright 1991, the Regents of the University of California,
|
|
# and the University of Chicago Board of Governors.
|
|
#
|
|
# This software was produced under U.S. Government contracts:
|
|
# (W-7405-ENG-36) at the Los Alamos National Laboratory,
|
|
# and (W-31-109-ENG-38) at Argonne National Laboratory.
|
|
#
|
|
# Initial development by:
|
|
# The Controls and Automation Group (AT-8)
|
|
# Ground Test Accelerator
|
|
# Accelerator Technology Division
|
|
# Los Alamos National Laboratory
|
|
#
|
|
# Co-developed with
|
|
# The Controls and Computing Group
|
|
# Accelerator Systems Division
|
|
# Advanced Photon Source
|
|
# Argonne National Laboratory
|
|
#
|
|
# Modification Log:
|
|
# -----------------
|
|
# .00 mm-dd-yy iii Comment
|
|
# .01 05-04-94 pg HPUX port modifications.
|
|
# .02 08-25-94 mda use makedepend for HP or Alpha if no GCC
|
|
# .03 04-28-95 anj use GetVar and case for host arch
|
|
# ...
|
|
#
|
|
|
|
# tool to rebuild errSymTbl.c when ../errInc.c or it's depends change
|
|
|
|
# Usage blderrSymTbl EPICS HOST_ARCH MAKE VXLIST - IOC and commmon
|
|
# Usage blderrSymTbl EPICS HOST_ARCH MAKE - just common
|
|
|
|
|
|
GetVar ()
|
|
{
|
|
|
|
if [ -z "$2" ]; then
|
|
echo "usage: $0 EPICS MAKE VAR_NAME [TARGET_ARCH]"
|
|
exit 1
|
|
fi
|
|
|
|
TOP=$1
|
|
MAKE=$2
|
|
|
|
INCLUDE=${TOP}/src/config/CONFIG_BASE
|
|
|
|
if [ -z "$4" ]; then
|
|
OPTS=""
|
|
else
|
|
OPTS="T_A=$4"
|
|
fi
|
|
|
|
PID=$$
|
|
|
|
# Construct temporary makefile
|
|
cat - <<MFILE > /tmp/Makefile.tmp.$$
|
|
|
|
TOP=$TOP
|
|
|
|
include ${INCLUDE}
|
|
|
|
all:
|
|
@echo "\$($3)" > /tmp/Makefile.tmp.out.$PID
|
|
|
|
MFILE
|
|
|
|
$MAKE -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
|
|
|
|
}
|
|
if [ "x" = "x$4" ]; then
|
|
DEF="XXX"
|
|
else
|
|
DEF="${4}"
|
|
fi
|
|
|
|
TMPMAKEFILE=/tmp/tmpmakefile
|
|
SFILES=/tmp/sfiles
|
|
TOP=$1
|
|
HOST_ARCH=$2
|
|
MAKE=$3
|
|
SRC=$TOP/src
|
|
INCLUDEH="-I$SRC/include -I$SRC/as -I$SRC/ca -I$SRC/cas/generic -I$SRC/db -I..\
|
|
-I$SRC/drv/old -I$SRC/drv/ansi -I$SRC/dbStatic -I$SRC/bpt -I$SRC/dev"
|
|
|
|
case $HOST_ARCH in
|
|
alpha | hp700 | sgi | Linux)
|
|
# Use gcc if it can be found, or makedepend
|
|
|
|
GCC=`which gcc`
|
|
if [ -x "$GCC" ]; then
|
|
FILES=`"$GCC" -M -D$DEF $INCLUDEH \
|
|
../errInc.c 2>/dev/null \
|
|
| sed -e 's/errInc\.o.*: errInc\.c//' -e 's/\\\//'`
|
|
else
|
|
MAKEDEPEND=`which makedepend`
|
|
if [ -x "$MAKEDEPEND" ]; then
|
|
FILES=`"$MAKEDEPEND" -f- -D$DEF $INCLUDEH \
|
|
../errInc.c 2>/dev/null | sed -e 's/errInc.o://' -e 's/\\\//'`
|
|
else
|
|
echo Neither GCC or MAKEDEPEND found.
|
|
exit 1
|
|
fi
|
|
fi
|
|
;;
|
|
solaris)
|
|
# use -xM option of ACC to list dependencies
|
|
|
|
#CC=`$EPICS/base/bin/$HOST_ARCH/GetVar $EPICS $MAKE ACC $HOST_ARCH`
|
|
CC=`GetVar $TOP $MAKE ACC $HOST_ARCH`
|
|
FILES=`$CC -xM -D$DEF $INCLUDEH ../errInc.c \
|
|
| grep "errInc.o" | grep -v "errInc.c" \
|
|
| sed -e 's/errInc\.o://'`
|
|
;;
|
|
sun4)
|
|
# use -M option of Sun compiler to list make dependencies
|
|
|
|
FILES=`cc -M -D$DEF $INCLUDEH errInc.c 2>/dev/null \
|
|
| grep "errInc.o" | grep -v "errInc.c" \
|
|
| sed -e 's/errInc\.o://'`
|
|
;;
|
|
*)
|
|
# Unrecognised host architecture
|
|
echo $0: host architecture not supported
|
|
exit 1
|
|
esac
|
|
|
|
|
|
# files with S_ defines
|
|
grep "^#define[ ]*S_" $FILES /dev/null \
|
|
| sed -e 's-:.*--' | sort -u >$SFILES
|
|
|
|
|
|
# create a tmpmakefile
|
|
cat $SFILES | (awk '
|
|
BEGIN {print "errInc.o : ../errInc.c \\"}
|
|
{print " "$0" \\" }
|
|
END {print " ../errMdef.h"}
|
|
|
|
') > $TMPMAKEFILE
|
|
|
|
cat >> $TMPMAKEFILE <<!addon
|
|
/bin/rm -f errSymTbl.c
|
|
../makeStatTbl \`cat $SFILES\` >errSymTbl.c
|
|
/bin/rm -f errInc.o
|
|
touch errInc.o
|
|
!addon
|
|
$MAKE -f $TMPMAKEFILE
|
|
/bin/rm -f $TMPMAKEFILE $SFILES
|
|
exit 0
|