Commit bf9f8290 authored by User Claes's avatar User Claes

FreeBSD build

parent 8c6916b8
...@@ -18,13 +18,8 @@ ...@@ -18,13 +18,8 @@
*/ */
#include <stdio.h> #include <stdio.h>
#if defined OS_VMS #if defined OS_LYNX
# include "co_getopt.h"
#elif defined OS_LYNX
extern int getopt();
# include <sys/wait.h> # include <sys/wait.h>
#elif defined OS_LINUX
extern int getopt();
#elif defined OS_MACOS || defined OS_FREEBSD #elif defined OS_MACOS || defined OS_FREEBSD
# include <sys/wait.h> # include <sys/wait.h>
# include <fcntl.h> # include <fcntl.h>
...@@ -561,25 +556,9 @@ checkErrors ( ...@@ -561,25 +556,9 @@ checkErrors (
static ini_sContext * static ini_sContext *
createContext (int argc, char **argv) createContext (int argc, char **argv)
{ {
int c; int i, j;
extern char *optarg;
extern int optind;
#if 1
extern int optind;
#endif
ini_sContext *cp; ini_sContext *cp;
pwr_tStatus sts; pwr_tStatus sts;
#if defined(OS_LYNX) || defined(OS_LINUX) || defined(OS_MACOS) || defined OS_FREEBSD
char *options = "a:b:c:d:efg:hin:p:q:rsu:vwA:H:V";
#else
char *options = "a:b:d:efhin:p:q:rvwA:H:V";
#endif
#if 0
extern int opterr;
opterr = 0;
#endif
optind = 0;
if ( argc > 1 && strcmp( argv[1], "--version") == 0) { if ( argc > 1 && strcmp( argv[1], "--version") == 0) {
system( "cat $pwr_exe/rt_version.dat"); system( "cat $pwr_exe/rt_version.dat");
...@@ -590,67 +569,138 @@ createContext (int argc, char **argv) ...@@ -590,67 +569,138 @@ createContext (int argc, char **argv)
exit(1); exit(1);
} }
while ((c = getopt(argc, argv, options)) != -1) { for ( i = 1; i < argc; i++) {
switch (c) { if ( argv[i][0] == '-') {
case 'a': int i_incr = 0;
cp->flags.b.applfile = 1; for ( j = 1;
strcpy(cp->applfile.name, optarg); argv[i][j] != 0 && argv[i][j] != ' ' && argv[i][j] != ' ';
break; j++) {
case 'b': switch ( argv[i][j]) {
cp->flags.b.bootfile = 1; case 'a':
strcpy(cp->bootfile.name, optarg); if ( i + 1 >= argc ||
break; !(argv[i][j+1] == ' ' || argv[i][j+1] != ' ')) {
case 'c': usage( argv[0]);
strcpy(cp->console, optarg); exit(0);
break; }
case 'd': cp->flags.b.applfile = 1;
strcpy(cp->dir, optarg); strcpy(cp->applfile.name, argv[i+1]);
break; i++;
case 'e': i_incr = 1;
cp->flags.b.ignoreError = 1; break;
break; case 'b':
case 'f': if ( i + 1 >= argc ||
cp->flags.b.ignoreFatal = 1; !(argv[i][j+1] == ' ' || argv[i][j+1] != ' ')) {
break; usage( argv[0]);
case 'h': exit(0);
cp->flags.b.hostname = 1; }
strcpy(cp->hostname, optarg); cp->flags.b.bootfile = 1;
break; strcpy(cp->bootfile.name, argv[i+1]);
case 'i': break;
cp->flags.b.interactive = 1; case 'c':
break; if ( i + 1 >= argc ||
case 'n': !(argv[i][j+1] == ' ' || argv[i][j+1] != ' ')) {
cp->flags.b.nodename = 1; usage( argv[0]);
strcpy(cp->nodename, optarg); exit(0);
break; }
case 'p': strcpy(cp->console, argv[i+1]);
cp->flags.b.plcfile = 1; i++;
strcpy(cp->plcfile.name, optarg); i_incr = 1;
break; break;
case 'q': case 'd':
cp->flags.b.busid = 1; if ( i + 1 >= argc ||
cp->busid = atoi(optarg); !(argv[i][j+1] == ' ' || argv[i][j+1] != ' ')) {
break; usage( argv[0]);
case 'r': exit(0);
cp->flags.b.restart = 1; }
cp->flags.b.interactive = 1; strcpy(cp->dir, argv[i+1]);
break; i++;
case 's': i_incr = 1;
cp->flags.b.stop = 1; break;
break; case 'e':
case 'v': cp->flags.b.ignoreError = 1;
cp->flags.b.verbose = 1; break;
break; case 'f':
case 'w': cp->flags.b.ignoreFatal = 1;
cp->flags.b.ignoreWarning = 1; break;
break; case 'h':
case 'A': if ( i + 1 >= argc ||
cp->flags.b.aliasfile = 1; !(argv[i][j+1] == ' ' || argv[i][j+1] != ' ')) {
strcpy(cp->aliasfile.name, optarg); usage( argv[0]);
break; exit(0);
case '?': }
usage(argv[0]); cp->flags.b.hostname = 1;
break; strcpy(cp->hostname, argv[i+1]);
i++;
i_incr = 1;
break;
case 'i':
cp->flags.b.interactive = 1;
break;
case 'n':
if ( i + 1 >= argc ||
!(argv[i][j+1] == ' ' || argv[i][j+1] != ' ')) {
usage( argv[0]);
exit(0);
}
cp->flags.b.nodename = 1;
strcpy(cp->nodename, argv[i+1]);
i++;
i_incr = 1;
break;
case 'p':
if ( i + 1 >= argc ||
!(argv[i][j+1] == ' ' || argv[i][j+1] != ' ')) {
usage( argv[0]);
exit(0);
}
cp->flags.b.plcfile = 1;
strcpy(cp->plcfile.name, argv[i+1]);
i++;
i_incr = 1;
break;
case 'q':
if ( i + 1 >= argc ||
!(argv[i][j+1] == ' ' || argv[i][j+1] != ' ')) {
usage( argv[0]);
exit(0);
}
cp->flags.b.busid = 1;
cp->busid = atoi(argv[i+1]);
break;
case 'r':
cp->flags.b.restart = 1;
cp->flags.b.interactive = 1;
break;
case 's':
cp->flags.b.stop = 1;
break;
case 'v':
cp->flags.b.verbose = 1;
break;
case 'w':
cp->flags.b.ignoreWarning = 1;
break;
case 'A':
if ( i + 1 >= argc ||
!(argv[i][j+1] == ' ' || argv[i][j+1] != ' ')) {
usage( argv[0]);
exit(0);
}
cp->flags.b.aliasfile = 1;
strcpy(cp->aliasfile.name, argv[i+1]);
i++;
i_incr = 1;
break;
case '?':
usage(argv[0]);
break;
default:
usage(argv[0]);
exit(0);
}
if ( i_incr)
break;
}
} }
} }
......
#!/bin/bash
#
# Proview $Id: ge_javac.sh,v 1.5 2006-06-14 10:42:48 claes Exp $
# Copyright (C) 2005 SSAB Oxelsund AB.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with the program, if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#
#
function=$1
src_file=$2
systemname=$3
if [ $function == "java_web" ]; then
jarfile="$pwrp_web/pwrp_"$systemname"_web.jar"
if javac -d $pwrp_web -classpath $pwr_lib/pwr_rt.jar:$pwr_lib/pwr_jop.jar:$pwr_lib/pwr_jopc.jar:$jarfile $pwrp_pop/$src_file
then
echo "-- $src_file compiled"
if [ ! -e $jarfile ]; then
cd $pwrp_web
jar -cf $jarfile ${src_file%.java}.class
rm ${src_file%.java}.class
else
cd $pwrp_web
jar -uf $jarfile ${src_file%.java}.class
rm ${src_file%.java}.class
fi
files=`ls $pwrp_web/${src_file%.java}\\$*.class 2>&-`
if [ ! -z "$files" ]; then
# echo "Insert in archive $jarfile"
jar -uf $jarfile ${src_file%.java}\$*.class
rm ${src_file%.java}\$*.class
fi
files=`ls $pwrp_pop/*.gif 2>&-`
if [ ! -z "$files" ]; then
cd $pwrp_pop
jar -uf $jarfile *.gif
fi
files=`ls $pwrp_pop/*.jpg 2>&-`
if [ ! -z "$files" ]; then
cd $pwrp_pop
jar -uf $jarfile *.jpg
fi
fi
fi
if [ $function == "java" ]; then
jarfile="$pwrp_lib/pwrp_"$systemname".jar"
jarfileweb="$pwrp_web/pwrp_"$systemname"_web.jar"
if javac -d $pwrp_web -classpath $pwr_lib/pwr_rt.jar:$pwr_lib/pwr_jop.jar:$pwr_lib/pwr_jopc.jar:$jarfile $pwrp_pop/$src_file
then
echo "-- $src_file compiled"
if [ ! -e $jarfile ]; then
cd $pwrp_web
jar -cf $jarfile ${src_file%.java}.class
else
cd $pwrp_web
jar -uf $jarfile ${src_file%.java}.class
fi
if [ ! -e $jarfileweb ]; then
cd $pwrp_web
jar -cf $jarfileweb ${src_file%.java}.class
else
cd $pwrp_web
jar -uf $jarfileweb ${src_file%.java}.class
fi
rm ${src_file%.java}.class
files=`ls $pwrp_web/${src_file%.java}\\$*.class 2>&-`
if [ ! -z "$files" ]; then
# echo "Insert in archive $jarfile"
jar -uf $jarfile ${src_file%.java}\$*.class
jar -uf $jarfileweb ${src_file%.java}\$*.class
rm ${src_file%.java}\$*.class
fi
files=`ls $pwrp_pop/*.gif 2>&-`
if [ ! -z "$files" ]; then
cd $pwrp_pop
jar -uf $jarfile *.gif
jar -uf $jarfileweb *.gif
fi
files=`ls $pwrp_pop/*.jpg 2>&-`
if [ ! -z "$files" ]; then
cd $pwrp_pop
jar -uf $jarfile *.jpg
jar -uf $jarfileweb *.jpg
fi
fi
fi
if [ $function == "html" ]; then
cp $pwrp_pop/$src_file $pwrp_web/
fi
#!/bin/bash
#
# Proview $Id: jop_start.sh,v 1.2 2005-09-01 14:57:49 claes Exp $
# Copyright (C) 2005 SSAB Oxelösund AB.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with the program, if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
echo "Here in jop start"
#export LD_LIBRARY_PATH=$pwr_exe
#echo $LD_LIBRARY_PATH
#export CLASSPATH=$pwr_lib/pwr_rt.jar:$pwr_lib/pwr_jop.jar
java jpwr.jop.JopSpider $1
#!/bin/bash
#
# Proview $Id: pwr_cleanup.sh,v 1.2 2005-09-01 14:57:49 claes Exp $
# Copyright (C) 2005 SSAB Oxelösund AB.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with the program, if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#
# pwr_cleanup.sh
#
# NOTE! This file removes all IPC objects for the user.
# If you have other program which creates IPC objects,
# then do not use this script
#
# remove semaphores
eval `ipcs -s|grep ^0x|grep "[ \t]$USER[ \t]"|awk '{printf "ipcrm sem %s;", $2}'`
# remove message queues
eval `ipcs -q|grep ^0x|grep "[ \t]$USER[ \t]"|awk '{printf "ipcrm msg %s;", $2}'`
# remove shared memory
eval `ipcs -m|grep ^0x|grep "[ \t]$USER[ \t]"|awk '{printf "ipcrm shm %s;", $2}'`
rm /tmp/pwr*$PWR_BUS_ID
#!/bin/bash
#
# Proview $Id: pwr_pkg.sh,v 1.7 2006-08-22 07:44:25 claes Exp $
# Copyright (C) 2005 SSAB Oxelsund AB.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with the program, if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
pkg_install_func ()
{
pkg_remove_func "force"
if [ $1 == ${1##*/} ]; then
# Add path
pkg="/home/pwrp/$1"
else
pkg=$1
fi
if [ ! -e "$pkg" ]; then
echo "No package $pkg"
exit 1
fi
echo "-- Installing package $1"
cd /tmp
if ! tar -xzf $pkg pkg_unpack.sh; then
echo "Package $1 incomplete"
exit 1
fi
chmod a+x pkg_unpack.sh
./pkg_unpack.sh
}
pkg_list_func ()
{
if [ -z $1 ]; then
# List installed package
if [ ! -e $pwrp_load/pwr_pkg.dat ]; then
echo "-- No package installed"
exit 1
fi
datfile=$pwrp_load/pwr_pkg.dat
else
# Extract datfile from package
if [ $1 == ${1##*/} ]; then
# Add path
pkg="/home/pwrp/$1"
else
pkg=$1
fi
if [ ! -e $pkg ]; then
echo "-- No such package"
exit 1
fi
echo "-- Opening file $pkg"
cd /tmp
if ! tar -xzf $pkg pwr_pkg.dat; then
echo "Package $1 incomplete"
exit 1
fi
datfile=/tmp/pwr_pkg.dat
fi
{
let printout=0
while read line; do
if [ "$line" = "%Description:" ]; then
printout=1
else
if [ "$line" = "%Files:" ]; then
break
fi
if [ $printout -eq 1 ]; then
echo $line
fi
fi
done
} < $datfile
}
pkg_listfiles_func ()
{
if [ -z $1 ]; then
# List installed package
if [ ! -e $pwrp_load/pwr_pkg.dat ]; then
echo "-- No package installed"
exit 1
fi
datfile=$pwrp_load/pwr_pkg.dat
else
# Extract datfile from package
if [ $1 == ${1##*/} ]; then
# Add path
pkg="/home/pwrp/$1"
else
pkg=$1
fi
if [ ! -e $pkg ]; then
echo "-- No such package"
exit 1
fi
echo "-- Opening file $pkg"
cd /tmp
if ! tar -xzf $pkg pwr_pkg.dat; then
echo "Package $1 incomplete"
exit 1
fi
datfile=/tmp/pwr_pkg.dat
fi
{
let printout=0
while read line date time; do
if [ "$line" = "%Files:" ]; then
printout=1
else
if [ "$line" = "%End:" ]; then
break
fi
if [ $printout -eq 1 ]; then
echo $date $time $line
fi
fi
done
} < $datfile
}
pkg_brief_func ()
{
if [ -z $1 ]; then
# List installed package
if [ ! -e $pwrp_load/pwr_pkg.dat ]; then
echo "-- No package installed"
exit 1
fi
datfile=$pwrp_load/pwr_pkg.dat
{
let printout=0
while read line; do
if [ "$line" = "%Brief:" ]; then
printout=1
else
if [ "$line" = "%Description:" ]; then
break
fi
if [ $printout -eq 1 ]; then
echo $line
fi
fi
done
} < $datfile
else
# Extract datfile from package
for file
do
if [ $file == ${file##*/} ]; then
# Add path
pkg="/home/pwrp/$file"
else
pkg=$file
fi
if [ ! -e $pkg ]; then
echo "-- No such package"
exit 1
fi
dir=`eval pwd`
cd /tmp
if ! tar -xzf $pkg pwr_pkg.dat; then
echo "Package $pkg incomplete"
else
datfile=/tmp/pwr_pkg.dat
{
let printout=0
while read line; do
if [ "$line" = "%Brief:" ]; then
printout=1
else
if [ "$line" = "%Description:" ]; then
break
fi
if [ $printout -eq 1 ]; then
fname=`eval basename $pkg`
echo $fname ${line#Proview package}
fi
fi
done
} < $datfile
rm $datfile
fi
cd $dir
done
fi
}
pkg_dir_func()
{
if [ -z $1 ]; then
allpkg=`ls /home/pwrp/pwrp_pkg_*.tgz`
else
if [ $1 == ${1##*/} ]; then
# Add path
pattern="/home/pwrp/*$1*"
elif [ ${1:0:1} == "/" ]; then
pattern=$1*
else
pattern=*$1*
fi
allpkg=`ls $pattern`
fi
for pkg in $allpkg ; do
if [ -z ${pkg##*pwrp_pkg_*.tgz} ]; then
pkg_brief_func $pkg
fi
done
}
pkg_dirbrief_func()
{
if [ -z "$1" ]; then
allpkg=`ls /home/pwrp/pwrp_pkg_*.tgz`
else
if [ "$1" == "${1##*/}" ]; then
# Add path
pattern="/home/pwrp/*$1*"
elif [ ${1:0:1} == "/" ]; then
pattern=$1*
else
pattern=*$1*
fi
allpkg=`ls $pattern`
fi
for pkg in $allpkg ; do
if [ -z ${pkg##*pwrp_pkg_*.tgz} ]; then
fname=`eval basename $pkg`
ftime=`eval stat $pkg --print=%z | cut -b -19`
# echo $fname $ftime
echo $fname
fi
done
}
pkg_remove_func ()
{
if [ ! -e $pwrp_load/pwr_pkg.dat ]; then
echo "-- No package installed"
return
fi
# Get the name of the current package
{
let found=0
while read line; do
if [ "$line" = "%Package:" ]; then
found=1
else
if [ $found -eq 1 ]; then
pkg=$line
break
fi
fi
done
} < $pwrp_load/pwr_pkg.dat
if [ ! "$1" = "force" ]; then
echo ""
echo -n "Do you wan't to remove package $pkg (y/n) [n] "
read remove_pkg
if [ ! "$remove_pkg" = "y" ]; then
return
fi
fi
echo "-- Removing package $pkg"
{
let removefile=0
while read line date time; do
if [ "$line" = "%Files:" ]; then
removefile=1
else
if [ "$line" = "%End:" ]; then
break
fi
if [ $removefile -eq 1 ]; then
file=`eval echo $line`
#echo "rm $file"
rm $file
fi
fi
done
} < $pwrp_load/pwr_pkg.dat
rm $pwrp_load/pwr_pkg.dat
}
force="no"
while [ -n "$(echo $1 | grep '-')" ]; do
OPTARG=$2
case $1 in
-i ) pkg_install_func $OPTARG ;;
-la ) pkg_list_func $OPTARG ;;
-lf ) pkg_listfiles_func $OPTARG;;
-lp ) shift
pkg_brief_func $@ ;;
-r ) pkg_remove_func ;;
-rf ) force="force"
pkg_remove_func $force ;;
-ld ) pkg_dir_func $OPTARG ;;
-l ) pkg_dirbrief_func "$OPTARG";;
* ) cat <<EOF
usage: pwr_pkg [-i pkg] [-l [pkg]] [-b [pkg]] [-r]
pwr_pkg -i 'pkg' Install package 'pkg'
pwr_pkg -r Remove currently installed package
pwr_pkg -lp ['pkg'] List installed package, or package 'pkg'
pwr_pkg -la ['pkg'] List installed package, or package 'pkg', all info
pwr_pkg -lf ['pkg'] List files in installed package, or package 'pkg'
pwr_pkg -l List all packages
EOF
exit 1
esac
shift
done
#!/bin/bash
#
# Proview $Id: pwr_stop.sh,v 1.3 2008-11-24 15:22:42 claes Exp $
# Copyright (C) 2005 SSAB Oxelsund AB.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with the program, if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
kill -9 `ps ax | grep "rt_neth_acp" | awk '{ print $1}'`
kill -9 `ps ax | grep "rt_neth" | awk '{ print $1}'`
kill -9 `ps ax | grep "rt_qmon" | awk '{ print $1}'`
kill -9 `ps ax | grep "rt_emon" | awk '{ print $1}'`
kill -9 `ps ax | grep "rt_tmon" | awk '{ print $1}'`
kill -9 `ps ax | grep "rt_\|/pwr/exe/rs" | awk '{ print $1}'`
kill -9 `ps ax | grep "\[rt_" | awk '{ print $1}'`
kill -9 `ps ax | grep "plc_" | awk '{ print $1}'`
kill -9 `ps ax | grep "jpwr.rt" | awk '{ print $1}'`
kill -9 `ps ax | grep "rs_nmps" | awk '{ print $1}'`
kill -9 `ps ax | grep "rs_remote" | awk '{ print $1}'`
kill -9 `ps ax | grep "sev_server" | awk '{ print $1}'`
kill -9 `ps ax | grep "opc_server" | awk '{ print $1}'`
if [ -u $pwr_exe/rt_ini ]; then
user=`ls -al $pwr_exe/rt_ini | awk '{ print $3}'`
else
user=$USER
fi
echo "User $user"
eval `ipcs -s|grep ^s|grep "[ \t]$user[ \t]"|awk '{printf "ipcrm -s %s;", $2
}'`
# remove message queues
eval `ipcs -q|grep ^q|grep "[ \t]$user[ \t]"|awk '{printf "ipcrm -q %s;", $2
}'`
# remove shared memory
eval `ipcs -m|grep ^m|grep "[ \t]$user[ \t]"|awk '{printf "ipcrm -m %s;", $2
}'`
if [ -e $pwrp_exe/pwrp_stop.sh ]; then
source $pwrp_exe/pwrp_stop.sh
fi
rm /tmp/pwr*$PWR_BUS_ID
#rm -f /tmp/pwr*
#id=`ipcs -s | grep $user | awk '{print $2}'`
#id1=`echo $id | awk '{print $1}'`
#id2=`echo $id | awk '{print $2}'`
#id3=`echo $id | awk '{print $3}'`
#ipcrm sem $id1
#ipcrm sem $id2
#ipcrm sem $id3
#id=`ipcs -q | grep $user | awk '{print $2}'`
#id1=`echo $id | awk '{print $1}'`
#id2=`echo $id | awk '{print $2}'`
#id3=`echo $id | awk '{print $3}'`
#ipcrm msg $id1
#ipcrm msg $id2
#ipcrm msg $id3
#!/bin/bash
#
# Proview $Id: pwrp_env.sh,v 1.15 2008-10-28 09:38:07 claes Exp $
# Copyright (C) 2005 SSAB Oxelsund AB.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with the program, if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#
#
#
declare -ix pwrc_status=$pwrc__success
declare -i pwrc__success=0
declare -i pwrc__dbnotfound=1
declare -i pwrc__noproj=3
declare -i pwrc__rootexist=4
declare -i pwrc__notconfigured=5
declare -i pwrc__projlistfile=6
declare -i pwrc__projalrexist=7
declare -i pwrc__basealrexist=8
declare -i pwrc__nobase=9
declare -i pwrc__projlistfileacc=10
declare -i pwrc__syntax=11
declare -i pwrc__rootacc=12
declare -i pwrc__rootcreate=13
declare -i pwrc__rootdelete=14
declare -i pwrc__dbdelete=15
declare -i pwrc__baseexist=16
declare -i pwrc__move=17
declare -i pwrc__notmysqlsrv=18
declare -i pwrc__datadir=19
declare -i pwrc__nodb=20
declare -i pwrc__notemplatedb=21
declare -i pwrc__dbalrexist=22
declare -i pwrc__copy=23
declare -i pwrc__dbcreate=24
declare -i pwrc__projnotset=25
declare -i pwrc__projnameinv=26
declare -i pwrc__mysqldbcopy=27
declare -i pwrc__mysqldbrena=28
declare -i pwrc__mysql=29
declare -i pwrc__noroot=30
pwrc_get_variables()
{
local socket
if [ -e /etc/proview.cnf ]; then
socket=`eval cat /etc/proview.cnf | grep "\bmysql_socket\b" | awk '{print $2}'`
if [ ! -z $socket ]; then
mysql_socket="--socket $socket"
fi
pwr_projectroot=`eval cat /etc/proview.cnf | grep "\bprojectroot\b" | awk '{print $2}'`
if [ -z $pwr_projectroot ]; then
pwr_projectroot=/home/pwrp
fi
fi
if [ -e $pwr_inc/pwr_version.h ]; then
# pwr_dbversion=`eval grep "\bpwrv_cWbdbVersionShortStr\b" $pwr_inc/pwr_version.h | awk '{print $2}'`
pwr_dbversion=`eval cat $pwr_inc/pwr_version.h | grep "\bpwrv_cWbdbVersionShortStr\b" | awk '{print $3}'`
if [ -z $pwr_dbversion ]; then
echo "Unable to get pwr db version"
fi
pwr_dbversion=${pwr_dbversion:1:3}
fi
}
#
# Check project name syntax
#
# Arguments $1 project name
# Returns pwrc_status: 0 Success
#
pwrc_check_project_name()
{
local pname=$1
if [ "$pname" != "${pname/_/}" ]; then
pwrc_status=$pwrc__projnameinv
return
fi
pwrc_status=$pwrc__success
}
#
# Get the databases in a project
#
# Arguments 1: project root
# Returns pwrc_status : 0 Success
#
#
pwrc_dblist_read()
{
local volume
local volid
local volclass
local volcnf
local volenum
local volserver
local dbfile
local db
local proot=$1
let i=0
let j=0
let k=0
pwrc_status=$pwrc__success
if [ -n "${db_array[*]}" ]; then
unset db_array
fi
dbfile=$proot/src/db/pwrp_cnf_volumelist.dat
if [ ! -e $dbfile ]; then
echo "Can't find $dbfile"
return
fi
while read volume volid volclass volcnf volenum volserver; do
if [ -n "$volume" ] && [ "${volume:0:1}" != "!" ]; then
if [ $volcnf == "cnf" ]; then
if [ $volclass == "ClassVolume" ]; then
if [ $volenum -eq 0 ]; then
wbl_array[$k]=`eval echo $volume | tr "[:upper:]" "[:lower:]"`
k=$k+1
elif [ $volenum -eq 1 ]; then
db_array[$i]=`eval echo $volume | tr "[:upper:]" "[:lower:]"`
i=$i+1
elif [ $volenum -eq 2 ]; then
dbms_array[$j]=`eval echo $volume | tr "[:upper:]" "[:lower:]"`
dbms_server_array[$j]=$volserver
j=$j+1
fi
else
if [ $volenum -eq 0 ]; then
db_array[$i]=`eval echo $volume | tr "[:upper:]" "[:lower:]"`
i=$i+1
elif [ $volenum -eq 1 ]; then
dbms_array[$j]=`eval echo $volume | tr "[:upper:]" "[:lower:]"`
dbms_server_array[$j]=$volserver
j=$j+1
fi
fi
fi
fi
done < $dbfile
}
#
# Read the project list
#
# Arguments No
# Returns pwrc_status : 0 Success
# 1 File not found
#
pwrc_prlist_read()
{
local name
local base
local root
local path
local descr
if [ -n "${name_array[*]}" ]; then
unset name_array
unset base_array
unset root_array
unset path_array
unset desc_array
fi
if [ -n "${b_name_array[*]}" ]; then
unset b_name_array
unset b_root_array
fi
if [ ! -e $pwra_db/pwr_projectlist.dat ]; then
echo "Can't find projectlist file"
pwrc_status=$pwrc__projlistfile
return
fi
let i=0
let j=0
while read name base root path descr; do
if [ -n "$name" ] && [ "${name:0:1}" != "!" ] && [ "${name:0:1}" != "#" ]; then
if [ "$name" == "%base" ]; then
b_name_array[$j]=$base
b_root_array[$j]=$root
j=$j+1
else
name_array[$i]=$name
base_array[$i]=$base
root_array[$i]=$root
path_array[$i]=$path
descr=${descr#\"}
descr=${descr%\"}
desc_array[$i]=$descr
i=$i+1
fi
fi
done < $pwra_db/pwr_projectlist.dat
pwrc_status=$pwrc__success
}
#
# List the project list
#
# Arguments No
# Returns nothing
#
pwrc_prlist_list()
{
let i=0
local blank24=" "
local blank16=" "
local blank8=" "
echo ""
while [ "${name_array[$i]}" != "" ]; do
if [ "${base_array[$i]}" != "" ]; then
if [ -n "$1" ]; then
echo -n ${name_array[$i]} "${blank16:${#name_array[$i]}} "
echo -n ${base_array[$i]} "${blank8:${#base_array[$i]}} "
echo -n ${root_array[$i]} "${blank24:${#root_array[$i]}} "
echo ${path_array[$i]} "${blank16:${#path_array[$i]}}"
# echo ${desc_array[$i]}
else
echo ${name_array[$i]} "${blank16:${#name_array[$i]}} " ${desc_array[$i]}
fi
fi
i=$i+1
done
echo ""
}
pwrc_prlist_list_project()
{
let i=0
local blank24=" "
local blank14=" "
local blank6=" "
while [ "${name_array[$i]}" != "" ]; do
if [ "${base_array[$i]}" != "" ]; then
if [ $1 == ${name_array[$i]} ]; then
echo -n ${name_array[$i]} "${blank14:${#name_array[$i]}} "
echo -n ${base_array[$i]} "${blank6:${#base_array[$i]}} "
echo ${desc_array[$i]}
fi
fi
i=$i+1
done
}
pwrc_prlist_get_index()
{
let i=0
pwrc_status=$pwrc__noproj
while [ "${name_array[$i]}" != "" ]; do
if [ "${base_array[$i]}" != "" ] && [ "${name_array[$i]}" == $1 ]; then
pwrc_current_index=$i
pwrc_status=$pwrc__success
break;
fi
i=$i+1
done
}
pwrc_prlist_get_base_index()
{
let i=0
pwrc_status=$pwrc__nobase
while [ "${b_name_array[$i]}" != "" ]; do
if [ "${b_root_array[$i]}" != "" ] && [ "${b_name_array[$i]}" == $1 ]; then
pwrc_current_index=$i
pwrc_status=$pwrc__success
break;
fi
i=$i+1
done
}
#
# Delete a project in the project list
#
# Arguments 1: project name
# Returns pwrc_status : 0 Success
# 1 Project not found
#
pwrc_prlist_delete()
{
pwrc_prlist_get_index $1
if [ $pwrc_status -ne $pwrc__success ]; then
return
fi
unset base_array[$pwrc_current_index]
pwrc_status=$pwrc__success
}
#
# Delete a base in the project list
#
# Arguments 1: base name
# Returns pwrc_status : 0 Success
# 1 Base not found
#
pwrc_prlist_base_delete()
{
pwrc_prlist_get_base_index $1
if [ $pwrc_status -ne $pwrc__success ]; then
return
fi
unset b_root_array[$pwrc_current_index]
pwrc_status=$pwrc__success
}
#
# Add a project to the project list
#
# Arguments 1: dummy
# 2: project name
# 3: base name
# 4: project root
# 5: project hierarchy
# 6-: description
# Returns pwrc_status : Success
# projalrexist
#
pwrc_prlist_add()
{
let i=0
shift
echo "-- Adding project $1 to ProjectList"
# Check if project exist
pwrc_prlist_get_index $1
if [ $pwrc_status -eq $pwrc__success ]; then
pwrc_status=$pwrc__projalrexist
return
fi
while [ "${name_array[$i]}" != "" ]; do
i=$i+1
done
name_array[$i]=$1
base_array[$i]=$2
root_array[$i]=$3
if [ -z $4 ]; then
path_array[$i]="-"
else
path_array[$i]=$4
fi
shift 4
desc_array[$i]=$@
pwrc_status=$pwrc__success
}
# Arguments 1: base name
# 2: base root
# Returns pwrc_status : Success
# basealrexist Base already exist
#
pwrc_prlist_base_add()
{
let i=0
shift
echo "Adding Base $1"
# Check if base exist
pwrc_prlist_get_base_index $1
if [ $pwrc_status -eq $pwrc__success ]; then
echo "Base already exist"
pwrc_status=$pwrc__basealrexist
return
fi
while [ "${b_name_array[$i]}" != "" ]; do
i=$i+1
done
b_name_array[$i]=$1
b_root_array[$i]=$2
pwrc_status=$pwrc__success
}
#
# Write the project list
#
# Arguments No
# Returns pwrc_status : 0 Success
# 1 No write access
#
pwrc_prlist_write()
{
let i=0
if [ -e $pwra_db/pwr_projectlist.dat ] && [ ! -w $pwra_db/pwr_projectlist.dat ]; then
echo "Error: No write access to projectlist file"
pwrc_status=$pwrc__projlistfileacc
return
fi
{
echo "! Name base root path"
# Write base array
while [ "${b_name_array[$i]}" != "" ]; do
if [ "${b_root_array[$i]}" != "" ]; then
echo "%base "${b_name_array[$i]}" "${b_root_array[$i]}
fi
i=$i+1
done
# Write project array
i=0
while [ "${name_array[$i]}" != "" ]; do
if [ "${base_array[$i]}" != "" ]; then
echo ${name_array[$i]}" "${base_array[$i]}" "${root_array[$i]}" "${path_array[$i]}" \""${desc_array[$i]}"\""
fi
i=$i+1
done
} > $pwra_db/pwr_projectlist.dat
pwrc_status=$pwrc__success
}
pwrc_get_projectname()
{
# If the project is configured, get name from config file,
# else get it from env
local pname
let found=0
# if [ -e $pwrp_db/pwrp_cnf_sysobject.dat ]; then
# pname=`eval cat -n $pwrp_db/pwrp_cnf_sysobject.dat | grep "\b1\b" | awk '{print $2}'`
# if [ ! -z $pname ]; then
# found=1
# fi
# fi
projectname=$pwrp_projectname
}
pwrc_create_func()
{
local cmd
local user_pwrp
local proot
local bname
local pname
local platforms="x86_linux x86_64_linux x86_64_macos"
let argc=$#
cmd="project"
if [ $1 = $cmd ] || [ ${cmd#$1} != $cmd ]; then
#
# Command is "create project"
#
# Arguments 2: project name
# 3: base name
# 4: project root
# 5: project hierarchy
# 6-: description
pname=$2
bname=$3
proot=$4
if [ $argc -lt 4 ]; then
echo "Argument is missing"
pwrc_status=$pwrc__syntax
return
fi
pwrc_check_project_name $pname
if [ $pwrc_status -ne $pwrc__success ]; then
echo "Invalid project name '$pname'"
return
fi
pwrc_prlist_read
pwrc_prlist_get_base_index $bname
if [ $pwrc_status -ne $pwrc__success ]; then
echo "No such base '$bname'"
return
fi
pwrc_prlist_get_index $pname
if [ $pwrc_status -eq $pwrc__success ]; then
echo "Project already exist '$pname'"
pwrc_status=$pwrc__projalrexist
return
fi
if [ -e "$proot" ]; then
if [ ! -w "$proot" ]; then
echo "No write access to project root"
pwrc_status=$pwrc__rootacc
return
else
if [ -e "$proot/common" ]; then
echo "Error: project already exist"
pwrc_status=$pwrc__rootexist
return
fi
fi
else
if mkdir $proot
then
# Project root created
echo "Project root created"
else
echo "Can't create project root"
pwrc_status=$pwrc__rootcreate
return
fi
fi
mkdir $proot/bld
mkdir $proot/src
mkdir $proot/src/pop
mkdir $proot/src/rtt
mkdir $proot/src/tlog
mkdir $proot/src/login
mkdir $proot/src/db
mkdir $proot/src/doc
mkdir $proot/src/cnf
mkdir $proot/src/appl
mkdir $proot/bld/common
mkdir $proot/bld/common/load
mkdir $proot/bld/common/inc
mkdir $proot/bld/common/tmp
mkdir $proot/bld/common/web
mkdir $proot/bld/common/log
mkdir $proot/bld/common/rttbld
for pl in $platforms
do
mkdir $proot/bld/$pl
mkdir $proot/bld/$pl/exe
mkdir $proot/bld/$pl/lib
mkdir $proot/bld/$pl/obj
mkdir $proot/bld/$pl/lis
done
# Create project info file
sysinfo="$proot/src/login/sysinfo.txt"
echo "Revision history" >> $sysinfo
echo "`date +%F` $USER Project created" >> $sysinfo
# Create local setup script
cat > $proot/src/login/login.sh << EOF
#! /bin/bash
#
# Local setup
# Printer command for plc documents
#export pwr_foe_gre_print="lpr -P lp1"
if [ -e "\$pwrp_login/sysinfo.txt" ]; then
echo "-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_"
echo "Welcome to"
echo "\`\$pwr_exe/pwrp_env.sh show project\`"
echo ""
cat \$pwrp_login/sysinfo.txt
echo "-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_"
fi
EOF
chmod a+x $proot/src/login/login.sh
# Create a xtt_help.dat
cat > $proot/src/cnf/xtt_help.dat << EOF
<topic> index
<image> pwr_logga.gif
<h1>Welcome to $pname
<h2>Description
Edit file \$pwrp_cnf/xtt_help.dat to write this description.
</topic>
<include> \$pwr_lang/profibus_xtthelp.dat
<include> \$pwr_lang/opc_xtthelp.dat
<include> \$pwr_lang/basecomponent_xtthelp.dat
<include> \$pwr_lang/othermanufacturer_xtthelp.dat
<include> \$pwr_lang/abb_xtthelp.dat
<include> \$pwr_lang/siemens_xtthelp.dat
<include> \$pwr_lang/remote_xtthelp.dat
<include> \$pwr_lang/nmps_xtthelp.dat
<include> \$pwr_lang/ssabox_xtthelp.dat
EOF
# Create an empty directory database
echo "Creating directory database"
cat > $proot/src/db/directory.wb_load << EOF
Volume directory \$DirectoryVolume 254.254.254.253
EndVolume
EOF
# Set ownership to user and group pwrp
user_pwrp=`eval cat /etc/passwd | grep "\bpwrp:"`
#if [ ! -z "$user_pwrp" ]; then
# chown -R pwrp $proot/
#fi
user_pwrp=`eval cat /etc/group | grep "\bpwrp:"`
if [ ! -z "$user_pwrp" ]; then
chgrp -R pwrp $proot/
chmod -R g+w $proot/
fi
pwrc_status=$pwrc__success
return
fi
echo "Unknown command"
}
pwrc_add_func()
{
local cmd
local bname
local broot
let argc=$#
cmd="base"
if [ $1 = $cmd ] || [ ${cmd#$1} != $cmd ]; then
#
# Command is "add base"
#
# Arguments 2: base name
# 3: base root
bname=$2
broot=$3
if [ $argc -le 2 ]; then
echo "Argument is missing"
pwrc_status=$pwrc__syntax
return
fi
pwrc_prlist_read
if [ $pwrc_status -eq $pwrc__success ]; then
pwrc_prlist_get_base_index $bname
if [ $pwrc_status -eq $pwrc__success ]; then
echo "Base already exist '$bname'"
pwrc_status=$pwrc__basealrexist
return
fi
fi
# Insert in projectlist
pwrc_prlist_base_add $@
if [ $pwrc_status -ne $pwrc__success ]; then
return
fi
# pwrc_prlist_write
if [ $pwrc_status -ne $pwrc__success ]; then
return
fi
pwrc_status=$pwrc__success
return
fi
echo "Unknown command"
}
pwrc_delete_func()
{
local cmd
local proot
cmd="project"
if [ $1 = $cmd ] || [ ${cmd#$1} != $cmd ]; then
local pname=$2
local confirm=$3
let i=0
# Command is "delete project"
if [ -z "$2" ]; then
echo "Enter project name"
pwrc_status=$pwrc__syntax
fi
pwrc_prlist_read
if [ $pwrc_status -ne $pwrc__success ]; then
return
fi
pwrc_prlist_get_index $pname
if [ $pwrc_status -ne $pwrc__success ]; then
echo "No such project '$pname'"
return
fi
proot=${root_array[$pwrc_current_index]}
pwrc_dblist_read $proot
if [ -z $confirm ] || [ $confirm != "noconfirm" ]; then
echo "Delete project will"
echo " remove '$2' from the project list"
echo " delete all databases in project '$2'"
echo " delete all files in $proot"
echo "Do you want do continue ? [y/n] "
read REPLY
if [ -z $REPLY ] || [ $REPLY != "y" ]; then
return
fi
fi
# Delete mysql databases
pwrc_dblist_read $proot
i=0
while [ "${dbms_array[$i]}" != "" ]; do
dbname="pwrp_"$pname"__"${dbms_array[$i]}
if mysqladmin -h ${dbms_server_array[$i]} -upwrp drop $dbname -f
then
echo "-- Mysql database $dbname deleted"
else
echo "** Unable to delete mysql database $dbname"
fi
i=$i+1
done
if [ ! -e "$proot" ]; then
# Project root doesn't exist, remove from projectlist only
echo "** Warning: Project root not found"
else
if [ ! -w "$proot" ]; then
echo "Error: no write access to project root"
pwrc_status=$pwrc__rootacc
return
fi
# Delete project directory tree
if rm -R $proot
then
echo "-- Project tree deleted"
else
if rmdir $proot
then
echo "-- Project root deleted"
else
echo "** Unable to delete project root"
pwrc_status=$pwrc__rootdelete
return
fi
fi
fi
pwrc_prlist_delete $2
if [ $pwrc_status -eq $pwrc__success ]; then
echo "-- Project $2 removed from projectlist"
# pwrc_prlist_write
else
echo "** Something went wrong..."
fi
return
fi
cmd="base"
if [ $1 = $cmd ] || [ ${cmd#$1} != $cmd ]; then
local bname=$2
local confirm=$3
let i=0
# Command is "delete base"
if [ -z "$2" ]; then
echo "Enter base name"
pwrc_status=$pwrc__syntax
fi
pwrc_prlist_read
if [ $pwrc_status -ne $pwrc__success ]; then
return
fi
pwrc_prlist_get_base_index $bname
if [ $pwrc_status -ne $pwrc__success ]; then
echo "No such base '$bname'"
return
fi
pwrc_prlist_base_delete $2
if [ $pwrc_status -eq $pwrc__success ]; then
echo "Base $2 removed from projectlist"
# pwrc_prlist_write
else
echo "** Something went wrong..."
fi
return
fi
echo "Unknown command"
}
pwrc_set_func()
{
local cmd
local pname
local broot
if [ -z $1 ]; then
echo "Qualifier is missing"
pwrc_status=$pwrc__syntax
return
fi
cmd="project"
if [ $1 = $cmd ] || [ ${cmd#$1} != $cmd ]; then
# Command is "set project"
pname=$2
# Load project list
pwrc_prlist_read
if [ $pwrc_status -ne $pwrc__success ]; then
return
fi
# Get project in project list
pwrc_prlist_get_index $pname
if [ $pwrc_status -ne $pwrc__success ]; then
echo "No such project '$pname'"
return
fi
proot=${root_array[$pwrc_current_index]}
# Remove current pwrp_exe in PATH
if [ ! -z $pwrp_exe ]; then
exe_str=:$pwrp_exe
export PATH=${PATH/$exe_str/}
fi
export pwrp_root=$proot
export pwrp_login=$pwrp_root/src/login
export pwrp_src=$pwrp_root/src
export pwrp_pop=$pwrp_root/src/pop
export pwrp_rtt=$pwrp_root/src/rtt
export pwrp_appl=$pwrp_root/src/appl
export pwrp_doc=$pwrp_root/src/doc
export pwrp_db=$pwrp_root/src/db
export pwrp_cnf=$pwrp_root/src/cnf
export pwrp_tlog=$pwrp_root/src/tlog
export pwrp_rttbld=$pwrp_root/bld/common/rttbld
export pwrp_load=$pwrp_root/bld/common/load
export pwrp_inc=$pwrp_root/bld/common/inc
export pwrp_tmp=$pwrp_root/bld/common/tmp
export pwrp_web=$pwrp_root/bld/common/web
export pwrp_log=$pwrp_root/bld/common/log
export pwrp_exe=$pwrp_root/bld/$platform/exe
export pwrp_lib=$pwrp_root/bld/$platform/lib
export pwrp_obj=$pwrp_root/bld/$platform/obj
export pwrp_lis=$pwrp_root/bld/$platform/lis
export pwrp_cmn=$pwrp_root
export PATH=$PATH:$pwrp_exe
export CDPATH=
export pwrp_projectname=$pname
# Set directorydb as default database
# pwrc_setdb_func ""
# Execute local setup script
if [ -e "$pwrp_login/login.sh" ]; then
source $pwrp_login/login.sh
fi
cd $pwrp_login
pwrc_status=$pwrc__success
return
fi
cmd="baseroot"
if [ $1 = $cmd ] || [ ${cmd#$1} != $cmd ]; then
# Command is "set baseroot"
baseroot=$2
baseroot=${baseroot%/}
if [ ! -e "$baseroot" ]; then
echo "Base $baseroot doesn't exist"
pwrc_status=$pwrc__baseexist
else
echo "Setting base $baseroot"
# Remove current pwr_exe in PATH
if [ ! -z $pwr_exe ]; then
exe_str=:$pwr_exe
export PATH=${PATH/$exe_str/}
fi
export pwrb_root=$baseroot
export pwr_src=$baseroot/$os/$hw/exp/src
export pwr_db=$baseroot/$os/$hw/exp/db
export pwr_doc=$baseroot/$os/$hw/exp/doc
export pwr_exe=$baseroot/$os/$hw/exp/exe
export pwr_inc=$baseroot/$os/$hw/exp/inc
export pwr_lib=$baseroot/$os/$hw/exp/lib
export pwr_lis=$baseroot/$os/$hw/exp/lis
export pwr_obj=$baseroot/$os/$hw/exp/obj
export pwr_load=$baseroot/$os/$hw/exp/load
export PATH=$PATH:$pwr_exe
fi
pwrc_status=$pwrc__success
return
fi
cmd="bus"
if [ $1 = $cmd ] || [ ${cmd#$1} != $cmd ]; then
# Command is "set bus"
bus_id=$2
if [ "$bus_id" == "" ]; then
if [ -e /etc/proview.cnf ]; then
bus_id=`eval cat /etc/proview.cnf | grep "\\bqcomBusId\\b" | awk '{print $2}'`
fi
fi
export PWR_BUS_ID=$bus_id
pwrc_status=$pwrc__success
return
fi
if [ $1 = "db" ]; then
pwrc_setdb_func $2
else
echo "Unknown command"
fi
}
pwrc_show_func()
{
local cmd
if [ -z $1 ]; then
echo "Qualifier is missing"
pwrc_status=$pwrc__syntax
return
fi
cmd="project"
if [ $1 = $cmd ] || [ ${cmd#$1} != $cmd ]; then
# Command is "show project"
pwrc_get_projectname
if [ -z "$pwrp_root" ]; then
echo "No project is set"
else
pwrc_prlist_read
pwrc_prlist_list_project $projectname
if [ ! -e "$pwrp_root" ]; then
echo "Project doesn't exist"
fi
fi
return
fi
cmd="projects"
if [ $1 = $cmd ] || [ ${cmd#$1} != $cmd ]; then
# Command is "show projects"
pwrc_prlist_read
pwrc_prlist_list $2
return
fi
cmd="base"
if [ $1 = $cmd ] || [ ${cmd#$1} != $cmd ]; then
# Command is "show base"
baseroot=$pwrb_root
if [ -z "$pwrb_root" ]; then
echo "No base is set"
else
echo "Current base: $pwrb_root"
if [ ! -e "$pwrb_root" ]; then
echo "Base doesn't exist"
fi
fi
return
fi
cmd="db"
if [ $1 = $cmd ] || [ ${cmd#$1} != $cmd ]; then
db=$2
pwrc_get_projectname
if [ -z "$pwrp_root" ]; then
echo "No project is set"
return
fi
if [ -z "$2" ]; then
# Display current database
current_db=${PWRP_DB#*:}
current_db=${current_db%"_"$pwr_dbversion}
if [ $current_db = $projectname ]; then
echo "Current database is dbdirectory ($PWRP_DB)"
else
current_db=${PWRP_DB#:$projectname"_"}
current_db=${current_db%"_"$pwr_dbversion}
echo "Current database is '$current_db' ($PWRP_DB)"
fi
elif [ $2 == "-a" ] || [ $2 == "-l" ]; then
# Display all databases
# Check if database db exist, this can only be done on the sqlserver
server=0
if [ -z "$pwrp_mysql_server" ]; then
server=1
else
node="`eval uname -n`"
if [ $node = $pwrp_mysql_server ]; then
server=1
fi
fi
if [ $server = 0 ]; then
pwrc_status=$pwrc__notmysqlsrv
return
fi
# Get location for mysql database
datadir=`eval mysqladmin $mysql_socket variables| grep datadir | awk '{ print $4 }'`
datadir=${datadir%/}
if [ -z $datadir ]; then
echo "Error: Can't get database directory from mysql"
pwrc_status=$pwrc__datadir
return
fi
databases=`eval ls -d $datadir/$projectname"_*_"$pwr_dbversion`
let first=1
for dbname in $databases
do
if [ $first != 1 ]; then
echo -n " "
else
first=0;
fi
if [ $2 == "-a" ]; then
dbname=${dbname#$datadir/$projectname"_"}
echo -n "${dbname%"_"$pwr_dbversion}"
else
echo -n $dbname
fi
done
echo ""
return
else
# Check if database db exist, this can only be done on the sqlserver
server=0
if [ -z "$pwrp_mysql_server" ]; then
server=1
else
node="`eval uname -n`"
if [ $node = $pwrp_mysql_server ]; then
server=1
fi
fi
if [ $server = 0 ]; then
pwrc_status=$pwrc__notmysqlsrv
return
fi
# Get location for mysql database
datadir=`eval mysqladmin $mysql_socket variables| grep datadir | awk '{ print $4 }'`
datadir=${datadir%/}
if [ -z $datadir ]; then
echo "Error: Can't get database directory from mysql"
pwrc_status=$pwrc__datadir
return
fi
if [ "$db" = "dbdirectory" ]; then
dbname=$projectname"_"$pwr_dbversion
else
dbname=$projectname"_"$db"_"$pwr_dbversion
fi
if [ -e "$datadir/$dbname" ]; then
echo "Database '"${dbname%"_"$pwr_dbversion}"'"
else
echo "Database doesn't exist"
pwrc_status=$pwrc__dbnotfound
return
fi
fi
return
fi
echo "Unknown command"
}
pwrc_modify_func()
{
local cmd
if [ -z $1 ]; then
echo "Qualifier is missing"
pwrc_status=$pwrc__syntax
return
fi
cmd="project"
if [ $1 = $cmd ] || [ ${cmd#$1} != $cmd ]; then
# Command is "modify project"
#
# Argments $2 project name
# -n 'name' modify project name
# -r 'root' modify project root
# -b 'base' modify base
# -d 'descr' modify description
local dbname
local pname
local new_pname
local path
local root
local base
local desc
let argc=$#
let modify_name=0
let modify_path=0
let modify_root=0
let modify_base=0
let modify_desc=0
let something_modified=0
echo "Modify project: $@"
pname=$2
shift 2
while [ -n "$1" ]; do
if [ "$1" == "-n" ]; then
shift
new_pname=$1
modify_name=1
shift
elif [ "$1" == "-r" ]; then
shift
root=$1
modify_root=1
shift
elif [ "$1" == "-h" ]; then
shift
path=$1
modify_path=1
shift
elif [ "$1" == "-b" ]; then
shift
base=$1
modify_base=1
shift
elif [ "$1" == "-d" ]; then
shift
desc=$@
modify_desc=1
shift
break;
else
echo "Syntax error"
return
fi
done
pwrc_prlist_read
if [ $pwrc_status -ne $pwrc__success ]; then
return
fi
pwrc_prlist_get_index $pname
if [ $pwrc_status -ne $pwrc__success ]; then
echo "No such project '$pname'"
pwrc_status=$pwrc__noproj
return
fi
if [ $modify_name -eq 1 ]; then
# Rename mysql databases
pwrc_prlist_read
if [ $pwrc_status -ne $pwrc__success ]; then
return
fi
pwrc_prlist_get_index $pname
if [ $pwrc_status -ne $pwrc__success ]; then
echo "** No such project '$pname'"
return
fi
proot=${root_array[$pwrc_current_index]}
pwrc_dblist_read $proot
i=0
while [ "${dbms_array[$i]}" != "" ]; do
dbname="pwrp_"$pname"__"${dbms_array[$i]}
new_dbname="pwrp_"$new_pname"__"${dbms_array[$i]}
if mysqladmin -h ${dbms_server_array[$i]} -upwrp create $new_dbname
then
if mysqldump -h ${dbms_server_array[$i]} -upwrp $dbname | mysql -h ${dbms_server_array[$i]} -upwrp -D $new_dbname
then
echo "-- Mysql database copied from $dbname to $new_dbname"
if mysqladmin -h ${dbms_server_array[$i]} -upwrp drop $dbname -f
then
echo "-- Mysql database $dbname deleted"
else
echo "** Unable to delete mysql database from $dbname"
fi
else
echo "** Unable to copy mysql database from $dbname to $new_dbname"
pwrc_status=$pwrc__mysqldbcopy
return
fi
else
echo "** Unable to create mysql database $new_dbname"
pwrc_status=$pwrc__mysqldbcopy
return
fi
i=$i+1
done
name_array[$pwrc_current_index]=$new_pname
if [ $pwrc_status -ne $pwrc__success ]; then
return
fi
fi
if [ $modify_root -eq 1 ]; then
# Check that new root doesn't exist
if [ -e "$root" ]; then
echo "New root already exist"
pwrc_status=$pwrc__rootexist
return
fi
if mv ${root_array[$pwrc_current_index]} $root
then
root_array[$pwrc_current_index]=$root
something_modified=1
else
echo "Error from mv"
pwrc_status=$pwrc__move
return
fi
fi
if [ $modify_path -eq 1 ]; then
path_array[$pwrc_current_index]=$path
something_modified=1
fi
if [ $modify_base -eq 1 ];then
pwrc_prlist_get_base_index $base
if [ $pwrc_status -ne $pwrc__success ]; then
echo "No such base $base"
pwrc_status=$pwrc__nobase
return
fi
pwrc_prlist_get_index $pname
base_array[$pwrc_current_index]=$base
something_modified=1
fi
if [ $modify_desc -eq 1 ];then
desc_array[$pwrc_current_index]=$desc
something_modified=1
fi
if [ $something_modified -eq 1 ]; then
# pwrc_prlist_write
if [ $pwrc_status -ne $pwrc__success ]; then
return
fi
fi
pwrc_status=$pwrc__success
else
echo "Unknown command"
fi
}
pwrc_copy_func()
{
local cmd
if [ -z $1 ]; then
echo "Qualifier is missing"
pwrc_status=$pwrc__syntax
return
fi
cmd="project"
if [ $1 = $cmd ] || [ ${cmd#$1} != $cmd ]; then
# Command is "copy project"
#
# Argments $2: from-project name
# $3: to-project name
# $4: to-project root
# $5: to-project hierarchy
# $6: confirm ("noconfirm" if no confirmation)
local from_pname=$2
local to_pname=$3
local to_proot=$4
local to_phier=$5
local confirm=$6
local dbname
local ver
let argc=$#
if [ $argc -lt 4 ]; then
echo "Argument is missing"
pwrc_status=$pwrc__syntax
return
fi
if [ -z "$to_phier" ]; then
to_phier="-"
fi
# Load project list
pwrc_prlist_read
if [ $pwrc_status -ne $pwrc__success ]; then
return
fi
# Check that to-project doesn't exist in project list
pwrc_prlist_get_index $to_pname
if [ $pwrc_status -eq $pwrc__success ]; then
echo "Project already exist '$to_pname'"
pwrc_status=$pwrc__projalrexist
return
fi
# Get from-project in project list
pwrc_prlist_get_index $from_pname
if [ $pwrc_status -ne $pwrc__success ]; then
echo "No such project '$from_pname'"
return
fi
# Check to-project root
if [ -e "$to_proot" ]; then
if [ ! -w "$to_proot" ]; then
echo "No write access to project root"
pwrc_status=$pwrc__rootacc
return
else
if [ -e "$to_proot/common" ]; then
echo "Error: project root '$to_proot' already exist"
pwrc_status=$pwrc__rootexist
return
fi
fi
else
# Check permission to create directory tree
if mkdir $to_proot
then
# Project root created
rmdir $to_proot
else
echo "Can't create project root '$to_proot'"
pwrc_status=$pwrc__rootcreate
return
fi
fi
from_proot=${root_array[$pwrc_current_index]}
# Confirmation
if [ -z $confirm ] || [ $confirm != "noconfirm" ]; then
echo "Copy project will"
echo " add '$to_pname' to the project list"
echo " copy directory tree '$from_proot' to '$to_proot'"
echo "Do you want do continue ? [y/n] "
read REPLY
if [ -z $REPLY ] || [ $REPLY != "y" ]; then
return
fi
fi
# Copy directory tree
echo "-- Copying project tree..."
if cp -R $from_proot $to_proot
then
echo "-- Project tree copied"
else
echo "** Unable to copy directory tree"
pwrc_status=$pwrc__copy
return
fi
# Add new project into project list
pwrc_prlist_add dummy $to_pname ${base_array[pwrc_current_index]} $to_proot $to_phier ${desc_array[pwrc_current_index]} "(Copy of $from_pname)"
# pwrc_prlist_write
if [ $pwrc_status -ne $pwrc__success ]; then
return
fi
# Copy mysql databases
pwrc_dblist_read $from_proot
i=0
while [ "${dbms_array[$i]}" != "" ]; do
to_dbname="pwrp_"$to_pname"__"${dbms_array[$i]}
from_dbname="pwrp_"$from_pname"__"${dbms_array[$i]}
if mysqladmin -h ${dbms_server_array[$i]} -upwrp create $to_dbname
then
if mysqldump -h ${dbms_server_array[$i]} -upwrp $from_dbname | mysql -h ${dbms_server_array[$i]} -upwrp -D $to_dbname
then
echo "-- Mysql database copied from $from_dbname to $to_dbname"
else
echo "** Unable to copy mysql database from $from_dbname to $to_dbname"
fi
else
echo "** Unable to create mysql database $to_dbname"
fi
i=$i+1
done
pwrc_status=$pwrc__success
else
echo "Unknown command"
fi
}
pwrc_setdb_func()
{
echo "setdb is obsolete"
pwrc_status=$pwrc__success
}
pwrc_save_func()
{
local cmd
local pname
local broot
if [ -z $1 ]; then
echo "Qualifier is missing"
pwrc_status=$pwrc__syntax
return
fi
if [ $1 = "file" ]; then
pwrc_save_file_func $2
else
echo "Unknown command"
fi
}
pwrc_save_file_func()
{
new_file=$1
if [ -e $new_file ]; then
let version=9
while [ $version -ge 1 ]
do
old_file=$new_file.$version
old_file_ren=$new_file.$((version+1))
if [ -e $old_file ]; then
mv $old_file $old_file_ren
fi
let version=$version-1
done
old_file=$new_file.1
echo "-- Saving file $new_file -> $old_file"
mv $new_file $old_file
fi
}
pwrc_help_func()
{
cat << EOF
pwrp_env.sh - Utilities for pwr project environment
help - Display help
create project 'name' - Create at new project
set project 'name' - Setup environment to a project
set baseroot 'root' - Setup environment to proview base distribution
set db ['db'] - Set database. If db ommitted, directory db is set.
show project - Show current project
show projects - Show all projects
show base - Show current base root
EOF
}
pwrp_env ()
{
source pwrp_env.sh $1 $2 $3 $4
}
pwrc_parse ()
{
unamestr=`eval uname`
machine=`eval uname -m`
if [ $unamestr == "Darwin" ]; then
os="os_macos"
hw="hw_x86_64"
platform="x86_64_macos"
elif [ $unamestr == "FreeBSD" ]; then
os="os_freebsd"
hw="hw_x86_64"
platform="x86_64_freebsd"
else
if [ $machine != "x86_64" ]; then
machine="x86"
fi
platform=$machine"_linux"
os="os_linux"
hw="hw_"$machine
fi
local cmd
pwrc_get_variables
cmd="help"
if [ -z $1 ] || [ $1 = $cmd ] || [ ${cmd#$1} != $cmd ]; then
shift
pwrc_help_func $@
return
fi
cmd="show"
if [ $1 = $cmd ] || [ ${cmd#$1} != $cmd ]; then
shift
pwrc_show_func $@
return $pwrc_status
fi
cmd="delete"
if [ $1 = $cmd ] || [ ${cmd#$1} != $cmd ]; then
shift
pwrc_delete_func $@
return $pwrc_status
fi
cmd="create"
if [ $1 = $cmd ] || [ ${cmd#$1} != $cmd ]; then
shift
pwrc_create_func $@
return $pwrc_status
fi
cmd="add"
if [ $1 = $cmd ] || [ ${cmd#$1} != $cmd ]; then
shift
pwrc_add_func $@
return $pwrc_status
fi
cmd="copy"
if [ $1 = $cmd ] || [ ${cmd#$1} != $cmd ]; then
shift
pwrc_copy_func $@
return $pwrc_status
fi
cmd="modify"
if [ $1 = $cmd ] || [ ${cmd#$1} != $cmd ]; then
shift
pwrc_modify_func $@
return $pwrc_status
fi
cmd="set"
if [ $1 = $cmd ] || [ ${cmd#$1} != $cmd ]; then
shift
pwrc_set_func $@
return $pwrc_status
fi
cmd="save"
if [ $1 = $cmd ] || [ ${cmd#$1} != $cmd ]; then
shift
pwrc_save_func $@
return $pwrc_status
fi
cmd="setdb"
if [ $1 = $cmd ] || [ ${cmd#$1} != $cmd ]; then
shift
pwrc_setdb_func $@
return $pwrc_status
else
echo "Unknown command"
fi
}
#set -o xtrace
pwrc_parse $@
#set +o xtrace
#!/bin/bash
#
# Proview $Id: reload.sh,v 1.11 2008-04-10 10:38:30 claes Exp $
# Copyright (C) 2005 SSAB Oxelsund AB.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with the program, if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#
#
#
#
let reload__success=0
let reload__userclasses=1
let reload__usertypes=2
let reload__settemplate=3
let reload__loaddb=4
let pass__continue=1
let pass__execute=2
reload_dblist_read()
{
local volume
local volid
local volclass
local volcnf
local volenum
local volserver
local dbfile
local db
let i=0
let j=0
let k=0
pwrc_status=$pwrc__success
if [ -n "${db_array[*]}" ]; then
unset db_array
fi
dbfile=$pwrp_root/src/db/pwrp_cnf_volumelist.dat
if [ ! -e $dbfile ]; then
echo "Can't find $dbfile"
return
fi
while read volume volid volclass volcnf volenum volserver; do
if [ -n "$volume" ] && [ "${volume:0:1}" != "!" ]; then
if [ $volcnf == "cnf" ]; then
if [ $volclass == "ClassVolume" ]; then
if [ $volenum -eq 0 ]; then
wbl_array[$k]=`eval echo $volume | tr "[:upper:]" "[:lower:]"`
k=$k+1
elif [ $volenum -eq 1 ]; then
db_array[$i]=`eval echo $volume | tr "[:upper:]" "[:lower:]"`
i=$i+1
elif [ $volenum -eq 2 ]; then
dbms_array[$j]=`eval echo $volume | tr "[:upper:]" "[:lower:]"`
dbms_server_array[$j]=$volserver
j=$j+1
fi
else
if [ $volenum -eq 0 ]; then
db_array[$i]=`eval echo $volume | tr "[:upper:]" "[:lower:]"`
i=$i+1
elif [ $volenum -eq 1 ]; then
dbms_array[$j]=`eval echo $volume | tr "[:upper:]" "[:lower:]"`
dbms_server_array[$j]=$volserver
j=$j+1
fi
fi
fi
fi
done < $dbfile
}
reload_restoredb()
{
echo file $1
if [ -z $pwrp_db/$1 ]; then
echo "** Database backup not found"
reload_status=$reload__success
return
fi
db=${1%.[1-9]}
reload_dblist_read
if [ "${db#[a-z]*.}" == "dbms" ]; then
echo "Restore mysql database $db"
found=0
idx=0
i=0
while [ "${dbms_array[$i]}" != "" ]; do
if [ "${dbms_array[$i]}" == "${db%.[a-z]*}" ]; then
found=1
idx=$i
break
fi
i=$i+1
done
if [ $found -eq 0 ]; then
echo "** Volume ${db%.[a-z]*} is not configured"
reload_exit
fi
if [ -e $pwrp_db/$db ]; then
# Delete the current database
echo -n "Do you want to delete $db ? [y/n] "
read repl
if [ "$repl" != "y" ]; then
reload_exit
fi
echo "-- Deleting ${dbms_array[$idx]} on server ${dbms_server_array[$idx]}"
dbname="pwrp_"$pwrp_projectname"__"${dbms_array[$idx]}
mysqladmin -h ${dbms_server_array[$idx]} -upwrp drop -f $dbname
rm -r $pwrp_db/$db
fi
dbname="pwrp_"$pwrp_projectname"__"${dbms_array[$idx]}
if [ ! -e $pwrp_db/$1/$dbname.mysqldump ]; then
echo "** No mysql dump found, $pwrp_db/$1/$dbname.mysqldump"
reload_exit
fi
mv $pwrp_db/$1 $pwrp_db/$db
mysqladmin -h ${dbms_server_array[$idx]} -upwrp create $dbname
cat $pwrp_db/$db/$dbname.mysqldump | mysql -h ${dbms_server_array[$idx]} -upwrp -D $dbname
elif [ "${db#[a-z]*.}" == "db" ]; then
echo "Restore BerkeleyDb database $db"
fi
}
reload_classvolumes()
{
reload_checkpass "classvolumes" $start_pass
if [ $pass_status -ne $pass__execute ]; then
reload_status=$reload__success
return
fi
list=`eval ls -1d $pwrp_db/*.wb_load`
echo ""
for file in $list; do
volume=`eval grep pwr_eClass_ClassVolume $file | awk '{ print $2 }'`
if [ "$volume" == "" ]; then
volume=`eval grep ClassVolume $file | awk '{ print $2 }'`
volumelow=`eval grep ClassVolume $file | awk '{ print tolower($2) }'`
fi
if [ "$volume" != "" ]; then
echo $file
fi
done
echo ""
reload_continue "Pass create structfiles and loadfiles for classvolumes"
list=`eval ls -1d $pwrp_db/*.wb_load`
for file in $list; do
if [ ${file##/*/} != "directory.wb_load" ]; then
volume=`eval grep pwr_eClass_ClassVolume $file | awk '{ print $2 }'`
volumelow=`eval grep pwr_eClass_ClassVolume $file | awk '{ print tolower($2) }'`
if [ "$volume" == "" ]; then
volume=`eval grep ClassVolume $file | awk '{ print $2 }'`
volumelow=`eval grep ClassVolume $file | awk '{ print tolower($2) }'`
fi
if [ "$volume" != "" ]; then
echo "-- Creating structfile and loadfile for $volume"
if co_convert -sv -d $pwrp_inc $file
then
reload_status=$reload__success
else
reload_status=$reload__userclasses
return
fi
if wb_cmd -q create snapshot/file=\"$file\"/out=\"$pwrp_load/$volumelow.dbs\"
then
reload_status=$reload__success
else
reload_status=$reload__userclasses
return
fi
fi
fi
done
}
reload_dumpdb()
{
reload_checkpass "dumpdb" $start_pass
if [ $pass_status -ne $pass__execute ]; then
reload_status=$reload__success
return
fi
reload_continue "Pass dump database"
# Rename old dumpfiles
dmpfiles=`eval ls -1 $pwrp_db/*.wb_dmp 2> /dev/null`
for dmpfile in $dmpfiles; do
reload_save_file $dmpfile
done
if [ $arg_found -eq 1 ]; then
# Dump supplied database
if [ $arg_db -eq 1 ]; then
cdb=${db_array[$arg_idx]}
else
cdb=${dbms_array[$arg_idx]}
fi
dump_file=$pwrp_db/$cdb.wb_dmp
echo "-- Dumping volume $cdb into $dump_file"
wb_cmd -q -v $cdb wb dump/nofocode/out=\"$dump_file\"
else
# Dump all databases
i=0
while [ "${db_array[$i]}" != "" ]; do
dump_file=$pwrp_db/${db_array[$i]}.wb_dmp
echo "-- Dumping volume ${db_array[$i]} into $dump_file"
wb_cmd -q -v ${db_array[$i]} wb dump/nofocode/out=\"$dump_file\"
i=$i+1
done
i=0
while [ "${dbms_array[$i]}" != "" ]; do
dump_file=$pwrp_db/${dbms_array[$i]}.wb_dmp
echo "-- Dumping volume ${dbms_array[$i]} into $dump_file"
wb_cmd -q -v ${dbms_array[$i]} wb dump/nofocode/out=\"$dump_file\"
i=$i+1
done
fi
}
reload_renamedb()
{
reload_checkpass "renamedb" $start_pass
if [ $pass_status -ne $pass__execute ]; then
reload_status=$reload__success
return
fi
reload_continue "Pass rename old database"
if [ $arg_found -eq 1 ]; then
# Rename supplied database
if [ $arg_db -eq 1 ]; then
reload_save_file $pwrp_db/${db_array[$arg_idx]}.db
else
dbname="pwrp_"$pwrp_projectname"__"${dbms_array[$arg_idx]}
mysqldump -h ${dbms_server_array[$arg_idx]} -upwrp $dbname > $pwrp_db/${dbms_array[$arg_idx]}.dbms/$dbname.mysqldump
mysqladmin -h ${dbms_server_array[$arg_idx]} -upwrp drop -f $dbname
reload_save_file $pwrp_db/${dbms_array[$arg_idx]}.dbms
fi
else
# Rename all databases
i=0
while [ "${db_array[$i]}" != "" ]; do
reload_save_file $pwrp_db/${db_array[$i]}.db
i=$i+1
done
i=0
while [ "${dbms_array[$i]}" != "" ]; do
dbname="pwrp_"$pwrp_projectname"__"${dbms_array[$i]}
mysqldump -h ${dbms_server_array[$i]} -upwrp $dbname > $pwrp_db/${dbms_array[$i]}.dbms/$dbname.mysqldump
mysqladmin -h ${dbms_server_array[$i]} -upwrp drop -f $dbname
reload_save_file $pwrp_db/${dbms_array[$i]}.dbms
i=$i+1
done
fi
}
reload_dirvolume()
{
if [ -e "$pwrp_db/directory.db" ]; then
return
fi
reload_checkpass "dirvolume" $start_pass
if [ $pass_status -ne $pass__execute ]; then
reload_status=$reload__success
return
fi
reload_continue "Pass dirvolume"
wb_cmd -q create volume/directory
wb_cmd -q wb load /load=\"$pwrp_db/directory.wb_dmp\"
}
reload_loaddb()
{
reload_checkpass "loaddb" $start_pass
if [ $pass_status -ne $pass__execute ]; then
reload_status=$reload__success
return
fi
reload_continue "Pass load database"
for cdb in $databases; do
echo "-- Loading volume $cdb"
dump_file=$pwrp_db/$cdb.wb_dmp
list_file=$pwrp_db/$cdb.lis
if wb_cmd -q wb load/nofocode/load=\"$dump_file\"/out=\"$list_file\"
then
reload_status=$reload__success
else
cat $list_file
reload_status=$reload__loaddb
fi
done
}
reload_compile()
{
reload_checkpass "compile" $start_pass
if [ $pass_status -ne $pass__execute ]; then
reload_status=$reload__success
return
fi
reload_continue "Pass compile plcprograms"
for cdb in $databases; do
wb_cmd -q -v $cdb compile /all
done
reload_status=$reload__success
}
reload_removeload()
{
reload_checkpass "removeload" $start_pass
if [ $pass_status -ne $pass__execute ]; then
reload_status=$reload__success
return
fi
reload_continue "Pass remove old loadfiles"
reload_status=$reload__success
}
reload_createload()
{
reload_checkpass "createload" $start_pass
if [ $pass_status -ne $pass__execute ]; then
reload_status=$reload__success
return
fi
reload_continue "Pass create loadfiles"
for cdb in $databases; do
echo "-- Creating loadfiles for database $cdb"
wb_cmd -q -v $cdb create load
done
reload_status=$reload__success
}
reload_createboot()
{
reload_checkpass "createboot" $start_pass
if [ $pass_status -ne $pass__execute ]; then
reload_status=$reload__success
return
fi
reload_continue "Pass create bootfiles"
echo "-- Creating bootfiles for all nodes"
wb_cmd -q create boot/all
reload_status=$reload__success
}
reload_exit()
{
exit $reload_status
}
reload_continue()
{
echo
echo "----------------------------------------------------------------------------------------"
echo " $1"
echo "----------------------------------------------------------------------------------------"
if [ $go -eq 1 ]; then
return
fi
echo -n "Do you want to continue ? [y/n/go] "
read repl
case $repl in
go ) go=1; return ;;
y ) return ;;
n ) reload_exit ;;
esac
reload_continue "$1"
}
reload_checkpass()
{
checkpass=$1
wantedpass=$2
pass_status=$pass__continue
for item in $passes; do
if [ $item = $wantedpass ]; then
pass_status=$pass__execute
fi
if [ $item = $checkpass ]; then
return
fi
done
echo "No such pass"
reload_exit
}
reload_save_file()
{
new_file=$1
if [ -e $new_file ]; then
let version=9
while [ $version -ge 1 ]
do
old_file=$new_file.$version
old_file_ren=$new_file.$((version+1))
if [ -e $old_file ]; then
mv $old_file $old_file_ren
fi
let version=$version-1
done
old_file=$new_file.1
echo "-- Saving file $new_file -> $old_file"
mv $new_file $old_file
fi
}
usage()
{
cat << EOF
reload.sh Dump and reload of database.
Arguments Database or databases to reload.
I no arguments is supplied, all databases will be reloaded.
Pass
dumpdb Dump database to textfile \$pwrp_db/'volume'.wb_dmp
classvolumes Create structfiles and loadfiles for classvolumes
renamedb Rename the old database
loaddb Load the dump into the new database
compile Compile all plcprograms in the database
createload Create new loadfiles.
createboot Create bootfiles for all nodes in the project.
EOF
}
if [ "$1" = "help" ] || [ "$1" = "-h" ]; then
usage
exit
fi
let reload_status=$reload__success
let check_status=0
let go=0
let arg_found=0
let arg_dbms=0
let arg_db=0
let arg_wbl=0
let arg_idx=0
reload_dblist_read
if [ "$1" == "restore" ]; then
if [ $# -ne 2 ]; then
echo "Invalid arguments"
reload_exit
fi
shift
reload_restoredb $1
reload_exit
fi
if [ "$1" != "" ]; then
i=0
while [ "${db_array[$i]}" != "" ]; do
if [ $1 == ${db_array[$i]} ]; then
arg_found=1
arg_idx=i
arg_db=1
databases=${db_array[$i]}
break
fi
i=$i+1
done
i=0
while [ "${dbms_array[$i]}" != "" ]; do
if [ $1 == ${dbms_array[$i]} ]; then
arg_found=1
arg_idx=i
arg_dbms=1
databases=${dbms_array[$i]}
break
fi
i=$i+1
done
i=0
while [ "${wbl_array[$i]}" != "" ]; do
if [ $1 == ${wbl_array[$i]} ]; then
arg_found=1
arg_idx=1
arg_wbl=1
break
fi
i=$i+1
done
if [ $arg_found -eq 0 ]; then
echo "** No such database"
reload_exit
fi
if [ $arg_wbl -eq 1 ]; then
echo "** Database has wb_load format, no reload possible"
reload_exit
fi
else
i=0
databases=""
while [ "${db_array[$i]}" != "" ]; do
databases="$databases ${db_array[$i]}"
i=$i+1
done
i=0
while [ "${dbms_array[$i]}" != "" ]; do
databases="$databases ${dbms_array[$i]}"
i=$i+1
done
fi
usage
echo ""
echo "-- Reloading volume $databases"
echo ""
passes="dumpdb classvolumes renamedb loaddb compile createload createboot"
echo "Pass: $passes"
echo ""
echo -n "Enter start pass [dumpdb] > "
read start_pass
if [ -z $start_pass ]; then
start_pass="dumpdb"
fi
for cpass in $passes; do
reload_$cpass
if [ $reload_status -ne $reload__success ]; then
echo "Exiting due to error"
reload_exit
fi
done
echo ""
echo "-- The reload is now accomplished."
echo " Please remove the dumpfiles: \$pwrp_db/*.wb_dmp*"
echo " when you are satisfied with the reload."
echo ""
reload_exit
!** Invisible: Script used by reload.sh to save classvolume versions
!
! Proview $Id: reload_vol_versions.pwr_com,v 1.2 2005-09-01 14:57:49 claes Exp $
! Copyright (C) 2005 SSAB Oxelsund AB.
!
! This program is free software; you can redistribute it and/or
! modify it under the terms of the GNU General Public License as
! published by the Free Software Foundation, either version 2 of
! the License, or (at your option) any later version.
!
! This program is distributed in the hope that it will be useful
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with the program, if not, write to the Free Software
! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
!
!
main()
string v;
string class;
string attr;
int version;
int sts;
int file;
string fname;
string cmd;
int file_open;
printf("\n");
printf("-- ssab_exe:ssab_reload_vol_versions\n");
printf("-- Script to store current classvolume versions\n\n");
fname = "$pwrp_db/reload_vol_versions_" + p1 + ".pwr_com";
fname = translate_filename( fname);
file_open = 0;
v = GetVolumeList();
while( v != "")
class = GetVolumeClass( v);
if ( class == "$ClassVolume" && v != "pwrs" && v != "pwrb" && v != "mps" && v != "NMps" && v != "TLog" && v != "SSAB" && v != "SA")
if ( !file_open)
file = fopen( fname, "w");
if ( !file)
printf("Unable to open file %s\n", fname);
exit(0);
endif
fprintf( file, "printf(\"\\n\");\n");
fprintf( file, "printf(\"-- %s\\n\");\n", fname);
fprintf( file, "printf(\"-- Script to restore current classvolume versions\\n\\n\");\n");
file_open = 1;
endif
attr = v + ":.RtVersion";
version = GetAttribute( attr, sts);
printf( "-- Store version %d of volume '%s'\n", version, v);
fprintf(file, "printf( \"-- Restore version number %d in volume '%s'\\n\");\n", version, v);
fprintf(file, "set volume/volume=%s\n", v);
fprintf(file, "set attr/name=%s:/attr=RtVersion/value=%d/noconf\n", v, version);
fprintf(file, "save\n");
endif
v = GetNextVolume(v);
endwhile
if ( file_open)
fclose(file);
endif
endmain
!** Invisible: Load a backup dumpfile into development data base.
!
! Proview $Id: restore_bck.pwr_com,v 1.3 2008-11-28 17:15:37 claes Exp $
! Copyright (C) 2005 SSAB Oxelsund AB.
!
! This program is free software; you can redistribute it and/or
! modify it under the terms of the GNU General Public License as
! published by the Free Software Foundation, either version 2 of
! the License, or (at your option) any later version.
!
! This program is distributed in the hope that it will be useful
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with the program, if not, write to the Free Software
! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
!
function int usage()
printf( "Script to load backup dumpfile into development database.\n\n");
printf( "pwrc -v 'volumename' @pwr_exe:restore_bck 'nodename' 'dumpfile'\n\n");
printf( "Create a dumpfile on an process station with rt_bck -p\n\n");
endfunction
main()
int dump_file;
int alias_file;
string str;
string dbname;
string volname;
int i;
int j;
int first;
int len;
string start;
string objname;
string attrname;
string db_attrname;
string value;
string answer;
int loaddb;
int export_alias;
string alias_filename;
printf("\n");
if (p1 == "" || p2 == "")
usage();
exit(0);
endif
dump_file = fopen(p2, "r");
if (!dump_file)
printf( "Unable to open dumpfile %s\n", p2);
exit();
endif
loaddb = 0;
ask("Do you want to load values from the dumpfile into the database? (Y/N) ", answer);
if (answer == "y" || answer == "Y")
loaddb = 1;
endif
export_alias = 0;
ask("Do you wan to create an alias-file with values from the dumpfile? (Y/N) ", answer);
if (answer == "y" || answer == "Y")
ask("Alias-file name: ", answer);
alias_file = fopen(answer, "w");
if (!alias_file)
printf( "Unable to open output alias file %s\n", answer);
exit();
endif
export_alias = 1;
alias_filename = answer;
endif
while (fgets(str, dump_file))
start = extract(1, 2, str);
i = strstr(start, "/");
if (!i)
i = strstr(str, ".");
j = strstr(str, " ");
first = 1;
len = i-1;
objname = extract(first, len, str);
first = i+1;
len = j-i-1;
attrname = extract(first, len, str);
first = j+1;
len = strlen(str) - j;
value = extract(first, len, str);
db_attrname = attrname;
if (attrname == "ActualValue")
db_attrname = "InitialValue";
endif
if (loaddb)
set attr/attr='db_attrname'/value="'value'"/name='objname'/noconf/log
endif
if (export_alias)
fprintf(alias_file, "%s_setvalp %s.%s = \"%s\"\n", p1, objname, attrname, value);
endif
endif
endwhile
if (dump_file)
fclose(dump_file);
endif
if (alias_file)
printf("Alias-file created, %s\n", alias_filename);
fclose(alias_file);
endif
if (loaddb)
ask("Do you wan to save the database changes? (Y/N) ", answer);
if (answer == "y" || answer == "Y")
printf("Saving changes...\n");
save
else
printf("Not saving any changes\n");
endif
endif
endmain
#!/bin/bash
#
# Proview $Id: rt_print.sh,v 1.2 2005-09-01 14:57:49 claes Exp $
# Copyright (C) 2005 SSAB Oxelösund AB.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with the program, if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#
FileName="$1"
Color="$2"
Printer="$pwr_rt_print"
ColorPrinter="$pwr_rt_colorprint"
if [ "$Color" == "1" ]; then
if [ -z "$pwr_rt_colorprint" ]; then
Printer=$pwr_rt_print
else
Printer=$pwr_rt_colorprint
fi
else
if [ -z "$pwr_rt_print" ]; then
Printer=$pwr_rt_colorprint
else
Printer=$pwr_rt_print
fi
fi
if [ -z "$Printer" ]; then
echo "Printer is not defined in env 'pwr_rt_print'"
else
echo "Printing $1"
$Printer $1
fi
#!/bin/bash
#
# Proview $Id: rt_webmon.sh,v 1.5 2007-10-30 07:48:50 claes Exp $
# Copyright (C) 2005 SSAB Oxelsund AB.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with the program, if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#
export LD_LIBRARY_PATH=$pwr_exe
export CLASSPATH=$pwr_lib/pwr_rt.jar:$pwr_lib/pwr_jop.jar
#$jdk_home/java jpwr.rt.GdhServer
$jdk_home/java -Djava.library.path=$jdk/lib/i386/client:$jdk/lib/i386:$jdk/../lib/i386:$pwr_exe jpwr.rt.GdhServer
\ No newline at end of file
#!/bin/bash
#
# Proview $Id: rt_webmonelog.sh,v 1.3 2007-10-30 07:48:50 claes Exp $
# Copyright (C) 2005 SSAB Oxelsund AB.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with the program, if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#
export LD_LIBRARY_PATH=$pwr_exe
export CLASSPATH=$pwr_lib/pwr_rt.jar:$pwr_lib/pwr_jop.jar
#$jdk_home/java jpwr.rt.HistServer
$jdk_home/java -Djava.library.path=$jdk/lib/i386/client:$jdk/lib/i386:$jdk/../lib/i386:$pwr_exe jpwr.rt.HistServer
#!/bin/bash
#
# Proview $Id: rt_webmonmh.sh,v 1.4 2007-10-30 07:48:50 claes Exp $
# Copyright (C) 2005 SSAB Oxelsund AB.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with the program, if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#
export LD_LIBRARY_PATH=$pwr_exe
export CLASSPATH=$pwr_lib/pwr_rt.jar:$pwr_lib/pwr_jop.jar
$jdk_home/java -Djava.library.path=$jdk/lib/i386/client:$jdk/lib/i386:$jdk/../lib/i386:$pwr_exe jpwr.rt.MhServer
!** Invisible: Include file for io configuration script
!
! Proview $Id: ssab_config_card.pwr_com,v 1.3 2005-09-01 14:57:49 claes Exp $
! Copyright (C) 2005 SSAB Oxelsund AB.
!
! This program is free software; you can redistribute it and/or
! modify it under the terms of the GNU General Public License as
! published by the Free Software Foundation, either version 2 of
! the License, or (at your option) any later version.
!
! This program is distributed in the hope that it will be useful
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with the program, if not, write to the Free Software
! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
!
!
! Create a signal.
! If the card of the signal does not exist, the card with channels, and signals
! positioned in the reservhierarchy, will be created, and signals and channels
! will be connected.
! If the card already exist the signal will be move from the reservhierarchy
! to the given destination
!
function int ssab_create_signal( string rname, string resname, string chname, string signame, string chan_descr, string chan_ident, string sig_descr)
string cname;
string cardclass;
string type;
int channels;
int i;
int j;
string newname;
string oldname;
string rnam;
string chnam;
string cnam;
string hnam;
string snam;
string chnr_str;
string tnam;
int sts;
! Check if card exist
cname = extract( 1, 4, chname);
chname = toupper( chname);
type = extract( 1, 2, chname);
chnr_str = extract( 5, 2, chname);
cnam=rname + "-" + cname;
if ( type == "DI")
cardclass = "Ssab_DI32D";
channels = 32;
endif
if ( type == "DO")
cardclass = "Ssab_DO32DKS";
channels = 32;
endif
if ( type == "AI")
cardclass = "Ssab_AI32uP";
channels = 32;
endif
if ( type == "AO")
cardclass = "Ssab_AO8uP";
channels = 8;
endif
if ( type == "CO")
cardclass = "Ssab_Co4uP";
channels = 4;
endif
if (!ObjectExist(cnam))
! Create the rack and reservhierarchy if not created
ssab_create_object( rname, "Rack_SSAB");
ssab_create_object( resname, "$PlantHier");
! The card didn't exist, create it
! Create the card
create object/dest="'rname'"/class='cardclass'/name="'cname'"
! Create signalobjects in reserv hierarchy
for ( i = 1; i < channels + 1; i++)
sprintf( rnam, "Reserv_%s%02.2d", cname, i);
sprintf( hnam, "%s-%s", resname, rnam);
if (!ObjectExist(hnam))
create object/dest='resname'/class='type'/name="'rnam'"
sprintf( chnam, "Ch%02.2d", i);
! Connect to channel
set attr/noco/name='hnam'/attr=SigChanCon/value='rname'-'cname'.'chnam'
endif
endfor
endif
! Set description in signal
sprintf( rnam, "Reserv_%s%s", cname, chnr_str);
set attr/noco/name='resname'-'rnam'/attr=Description/value="'sig_descr'"
! Move signal to the final destination
i = strrchr( signame, "-");
if ( i)
i++;
j = i - 2;
hnam = extract( 1, j, signame);
snam = extract( i, 80, signame);
endif
ssab_create_object( hnam, "$PlantHier");
move obj/source='resname'-'rnam'/dest='hnam'/rename="'snam'"
endfunction
!
! Create an object and it's ancestors if they doesn't exist
!
function int ssab_create_object( string name, string class)
int i;
int j;
string parent;
string object;
int sts;
i = strrchr( name, "-");
if ( i)
i++;
j = i - 2;
parent = extract( 1, j, name);
object = extract( i, 80, name);
else
object = name;
parent = "";
endif
if ( !ObjectExist( name))
if ( parent != "")
ssab_create_object( parent, class);
endif
create object/dest="'parent'"/class='class'/name="'object'"
endif
endfunction
#!/bin/bash
#
# Proview $Id: upgrade.sh,v 1.17 2008-11-10 08:00:40 claes Exp $
# Copyright (C) 2005 SSAB Oxelsund AB.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with the program, if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
let reload__success=0
let reload__userclasses=1
let reload__usertypes=2
let reload__settemplate=3
let reload__loaddb=4
let pass__continue=1
let pass__execute=2
if [ -e /usr/pwr46 ]; then
v46_root="/usr/pwr46"
fi
if [ -e /data1/pwr/x4-6-0/rls_dbg ]; then
v46_root="/data1/pwr/x4-6-0/rls_dbg"
fi
reload_dumpdb()
{
# Dump V4.6 databases
reload_checkpass "dumpdb" $start_pass
if [ $pass_status -ne $pass__execute ]; then
reload_status=$reload__success
return
fi
reload_continue "Pass dump database"
export pwrp_db=$pwrp_root/common/db
tmp=`eval ls -1d $pwrp_db/*.db`
databases=""
for db in $tmp; do
db=${db##/*/}
db="${db%.*}"
if [ "$db" != "rt_eventlog" ]; then
databases="$databases $db"
fi
done
dmpfiles=`eval ls $pwrp_db/*.wb_dmp`
if [ ! -z "$dmpfiles" ]; then
rm $pwrp_db/*.wb_dmp
fi
for cdb in $databases; do
dump_file=$pwrp_db/$cdb.wb_dmp
echo "Dumping volume $cdb in $dump_file"
export pwr_load=$v46_root/os_linux/hw_x86/exp/load
$v46_root/os_linux/hw_x86/exp/exe/wb_cmd -v $cdb wb dump/out=\"$dump_file\"
export pwr_load=$pwrb_root/os_linux/hw_x86/exp/load
# wb_cmd -v $cdb wb dump/out=\"$dump_file\"
done
export pwrp_db=$pwrp_root/src/db
}
reload_classvolumes()
{
reload_checkpass "classvolumes" $start_pass
if [ $pass_status -ne $pass__execute ]; then
reload_status=$reload__success
return
fi
list=`eval ls -1d $pwrp_db/*.wb_load`
echo ""
for file in $list; do
volume=`eval grep pwr_eClass_ClassVolume $file | awk '{ print $2 }'`
if [ "$volume" == "" ]; then
volume=`eval grep ClassVolume $file | awk '{ print $2 }'`
volumelow=`eval grep ClassVolume $file | awk '{ print tolower($2) }'`
fi
if [ "$volume" != "" ]; then
echo $file
fi
done
echo ""
reload_continue "Pass create structfiles and loadfiles for classvolumes"
list=`eval ls -1d $pwrp_db/*.wb_load`
for file in $list; do
volume=`eval grep pwr_eClass_ClassVolume $file | awk '{ print $2 }'`
volumelow=`eval grep pwr_eClass_ClassVolume $file | awk '{ print tolower($2) }'`
if [ "$volume" == "" ]; then
volume=`eval grep ClassVolume $file | awk '{ print $2 }'`
volumelow=`eval grep ClassVolume $file | awk '{ print tolower($2) }'`
fi
if [ "$volume" != "" ]; then
echo "-- Creating structfile and loadfile for $volume"
if co_convert -sv -d $pwrp_inc $file
then
reload_status=$reload__success
else
reload_status=$reload__userclasses
return
fi
if wb_cmd create snapshot/file=\"$file\"/out=\"$pwrp_load/$volumelow.dbs\"
then
reload_status=$reload__success
else
reload_status=$reload__userclasses
return
fi
fi
done
}
reload_renamedb()
{
reload_checkpass "renamedb" $start_pass
if [ $pass_status -ne $pass__execute ]; then
reload_status=$reload__success
return
fi
reload_continue "Pass rename old databases"
for cdb in $databases; do
reload_save_file $pwrp_db/$cdb.db
done
}
reload_dirvolume()
{
if [ -e "$pwrp_db/directory.db" ]; then
return
fi
reload_checkpass "dirvolume" $start_pass
if [ $pass_status -ne $pass__execute ]; then
reload_status=$reload__success
return
fi
reload_continue "Pass dirvolume"
if [ -e "$pwrp_db/directory.wb_dmp" ]; then
echo "$pwrp_db/directory.wb_dmp -> $pwrp_db/directory.wb_load"
mv $pwrp_db/directory.wb_dmp $pwrp_db/directory.wb_load
fi
#wb_cmd create volume/directory
#wb_cmd wb load /load=\"$pwrp_db/directory.wb_dmp\"
}
reload_cnvclassvolume()
{
reload_checkpass "cnvclassvolume" $start_pass
if [ $pass_status -ne $pass__execute ]; then
reload_status=$reload__success
return
fi
reload_continue "Pass convert classvolume wb_load files"
dmpfiles=`eval ls $pwrp_db/*.wb_load`
echo $dmpfiles
for dmpfile in $dmpfiles; do
reload_save_file $dmpfile
source $pwr_exe/upgrade_cnvdmp.sh $dmpfile.1 $pwrp_tmp/t.wb_dmp
mv $pwrp_tmp/t.wb_dmp $dmpfile
done
}
reload_cnvdump()
{
reload_checkpass "cnvdump" $start_pass
if [ $pass_status -ne $pass__execute ]; then
reload_status=$reload__success
return
fi
reload_continue "Pass convert dumpfiles"
dmpfiles=`eval ls $pwrp_db/*.wb_dmp`
echo $dmpfiles
for dmpfile in $dmpfiles; do
file=${dmpfile##/*/}
db="${file%.*}.db"
if [ $db = "wb.db" ]; then
db=""
else
awk -f $pwr_exe/upgrade_dmp.awk $dmpfile > $pwrp_tmp/t.wb_dmp
mv $pwrp_tmp/t.wb_dmp $dmpfile
fi
done
}
reload_loaddb()
{
reload_checkpass "loaddb" $start_pass
if [ $pass_status -ne $pass__execute ]; then
reload_status=$reload__success
return
fi
reload_continue "Pass load database"
if [ -z "$1" ]; then
tmp=`eval ls -1 $pwrp_db/*.wb_dmp`
databases=""
for db in $tmp; do
db=${db##/*/}
db="${db%.*}"
if [ "$db" != "directory" ]; then
databases="$databases $db"
fi
done
else
databases=$@
fi
for cdb in $databases; do
if [ $cdb != "directory" ]; then
echo "-- Loading volume $cdb"
dump_file=$pwrp_db/$cdb.wb_dmp
list_file=$pwrp_db/$cdb.lis
if wb_cmd wb load/nofocode/load=\"$dump_file\"/out=\"$list_file\"
then
reload_status=$reload__success
else
cat $list_file
reload_status=$reload__loaddb
fi
fi
done
}
reload_cnvobjects()
{
reload_checkpass "cnvobjects" $start_pass
if [ $pass_status -ne $pass__execute ]; then
reload_status=$reload__success
return
fi
reload_continue "Pass convert objects in loaded db"
list=`eval ls -1d $pwrp_db/*.db`
for file in $list; do
file=${file##/*/}
file=${file%%.*}
if [ $file != "directory" ] && [ $file != "rt_eventlog" ]; then
wb_cmd -v $file @$pwr_exe/upgrade_pb.pwr_com
fi
done
reload_status=$reload__success
}
reload_compile()
{
reload_checkpass "compile" $start_pass
if [ $pass_status -ne $pass__execute ]; then
reload_status=$reload__success
return
fi
reload_continue "Pass compile plcprograms"
list=`eval ls -1d $pwrp_db/*.db`
for file in $list; do
file=${file##/*/}
file=${file%%.*}
if [ $file != "directory" ] && [ $file != "rt_eventlog" ]; then
wb_cmd -v $file compile /all
fi
done
# wb_cmd compile /all
reload_status=$reload__success
}
reload_removeload()
{
reload_checkpass "removeload" $start_pass
if [ $pass_status -ne $pass__execute ]; then
reload_status=$reload__success
return
fi
reload_continue "Pass remove old loadfiles"
# Remove all old loadfiles
echo "-- Removing old loadfiles"
rm $pwrp_load/ld_vol*.dat
reload_status=$reload__success
}
reload_createload()
{
reload_checkpass "createload" $start_pass
if [ $pass_status -ne $pass__execute ]; then
reload_status=$reload__success
return
fi
reload_continue "Pass create loadfiles"
# Remove all old loadfiles
echo "-- Removing old loadfiles"
rm $pwrp_load/ld_vol*.dat
list=`eval ls -1d $pwrp_db/*.db`
for file in $list; do
file=${file##/*/}
file=${file%%.*}
if [ $file != "directory" ] && [ $file != "rt_eventlog" ]; then
wb_cmd -v $file create load/volume=$file
fi
done
# wb_cmd create load/all
reload_status=$reload__success
}
reload_createboot()
{
reload_checkpass "createboot" $start_pass
if [ $pass_status -ne $pass__execute ]; then
reload_status=$reload__success
return
fi
echo ""
echo "Before this pass you should compile the modules included by ra_plc_user."
echo ""
reload_continue "Pass create bootfiles"
echo "-- Creating bootfiles for all nodes"
wb_cmd create boot/all
reload_status=$reload__success
}
reload_convertge()
{
reload_checkpass "convertge" $start_pass
if [ $pass_status -ne $pass__execute ]; then
reload_status=$reload__success
return
fi
reload_continue "Pass convert ge graphs"
# Create a script that dumps each volume
tmpfile=$pwrp_tmp/convertv451.ge_com
cat > $tmpfile << EOF
function int process( string graph)
printf( "Converting %s...\n", graph);
open 'graph'
convert v45
save
endfunction
main()
EOF
list=`eval ls -1 $pwrp_pop/*.pwg`
for file in $list; do
file=${file##/*/}
file=${file%%.*}
echo "process( \"$file\");" >> $tmpfile
done
echo "exit" >> $tmpfile
echo "endmain" >> $tmpfile
chmod a+x $tmpfile
wb_ge @$tmpfile
reload_status=$reload__success
}
reload_directorystructure()
{
reload_checkpass "directorystructure" $start_pass
if [ $pass_status -ne $pass__execute ]; then
reload_status=$reload__success
return
fi
reload_continue "Pass change directory structure"
machine=`eval uname -m`
if [ $machine != "x86_64" ]; then
machine="x86"
fi
platform=$machine"_linux"
mkdir $pwrp_root/bld
mkdir $pwrp_root/src
# mv $pwrp_root/src $pwrp_root/
mv $pwrp_root/login $pwrp_root/src/
mv $pwrp_root/common/db $pwrp_root/src/
mv $pwrp_root/common/src/pop $pwrp_root/src/
if [ -e $pwrp_root/common/doc ]; then
mv $pwrp_root/common/doc $pwrp_root/src/
else
mkdir $pwrp_root/src/doc
fi
mv $pwrp_root/common/src/rtt $pwrp_root/src/
mv $pwrp_root/common/src/tlog $pwrp_root/src/
mv $pwrp_root/common/src/rttbld $pwrp_root/common/
mv $pwrp_root/common/src $pwrp_root/src/appl
mkdir $pwrp_root/src/cnf
mv $pwrp_root/common $pwrp_root/bld/
if [ -e $pwrp_root/x86_linux ]; then
mv $pwrp_root/x86_linux $pwrp_root/bld/
mkdir $pwrp_root/bld/x86_64_linux
mkdir $pwrp_root/bld/x86_64_linux/exe
mkdir $pwrp_root/bld/x86_64_linux/lib
mkdir $pwrp_root/bld/x86_64_linux/obj
mkdir $pwrp_root/bld/x86_64_linux/lis
fi
if [ -e $pwrp_root/x86_64_linux ]; then
mv $pwrp_root/x86_64_linux $pwrp_root/bld/
mkdir $pwrp_root/bld/x86_linux
mkdir $pwrp_root/bld/x86_linux/exe
mkdir $pwrp_root/bld/x86_linux/lib
mkdir $pwrp_root/bld/x86_linux/obj
mkdir $pwrp_root/bld/x86_linux/lis
fi
mv $pwrp_load/ld_appl_*.txt $pwrp_cnf/ 2> /dev/null
if [ -e $pwrp_root/bld/x86_linux/exe/xtt_help.dat ]; then
mv $pwrp_root/bld/x86_linux/exe/xtt_help.dat $pwrp_cnf/
fi
if [ -e $pwrp_pop/xtt_setup.pwr_com ]; then
mv $pwrp_pop/xtt_setup.rtt_com $pwrp_cnf
fi
if [ -e $pwrp_pop/Rt_xtt ]; then
mv $pwrp_pop/Rt_xtt $pwrp_cnf
fi
reload_status=$reload__success
}
reload_exit()
{
source pwrp_env.sh setdb
exit $reload_status
}
reload_continue()
{
echo
echo "----------------------------------------------------------------------------------------"
echo " $1"
echo "----------------------------------------------------------------------------------------"
if [ $go -eq 1 ]; then
return
fi
echo -n "Do you want to continue ? [y/n/go] "
read repl
case $repl in
go ) go=1; return ;;
y ) return ;;
n ) reload_exit ;;
esac
reload_continue "$1"
}
reload_checkpass()
{
checkpass=$1
wantedpass=$2
pass_status=$pass__continue
for item in $passes; do
if [ $item = $wantedpass ]; then
pass_status=$pass__execute
fi
if [ $item = $checkpass ]; then
return
fi
done
echo "No such pass"
reload_exit
}
reload_save_file()
{
new_file=$1
if [ -e $new_file ]; then
let version=9
while [ $version -ge 1 ]
do
old_file=$new_file.$version
old_file_ren=$new_file.$((version+1))
if [ -e $old_file ]; then
mv $old_file $old_file_ren
fi
let version=$version-1
done
old_file=$new_file.1
echo "-- Saving file $new_file -> $old_file"
mv $new_file $old_file
fi
}
usage()
{
cat << EOF
upgrade.sh Upgrade from V4.6 to V4.7
Pass
dumpdb Dump database to textfile \$pwrp_db/'volume'.wb_dmp
directorystructure Change directory structure.
classvolumes Create loadfiles for classvolumes.
renamedb Rename old databases.
dirvolume Create directory volume.
loaddb Load dumpfiles.
cnvobjects Convert objects in the database.
compile Compile all plcprograms in the database
createload Create new loadfiles.
createboot Create bootfiles for all nodes in the project.
EOF
}
if [ "$1" = "help" ] || [ "$1" = "-h" ]; then
usage
exit
fi
let reload_status=$reload__success
let check_status=0
let go=0
#if [ -z "$1" ]; then
# usage
# exit
#fi
project=${pwrp_root##/*/}
usage
echo ""
echo "-- Upgrade $project"
echo ""
tmp=`eval ls -1d $pwrp_db/*.db`
databases=""
for db in $tmp; do
db=${db##/*/}
db="${db%.*}"
if [ "$db" != "rt_eventlog" ]; then
databases="$databases $db"
fi
done
passes="dumpdb directorystructure classvolumes renamedb dirvolume loaddb cnvobjects compile createload createboot"
#echo "Pass: $passes"
echo ""
echo -n "Enter start pass [dumpdb] > "
read start_pass
if [ -z $start_pass ]; then
start_pass="dumpdb"
fi
for cpass in $passes; do
reload_$cpass
if [ $reload_status -ne $reload__success ]; then
echo "Exiting due to error"
reload_exit
fi
done
echo ""
echo "-- The upgrade procedure is now accomplished."
echo ""
reload_exit
#! /bin/bash
#
# Proview $Id: upgradeV451.sh,v 1.1 2008-06-26 13:13:41 claes Exp $
# Copyright (C) 2005 SSAB Oxelsund AB.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with the program, if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
let reload__success=0
let reload__userclasses=1
let reload__usertypes=2
let reload__settemplate=3
let reload__loaddb=4
let pass__continue=1
let pass__execute=2
#v44_root="/data1/pwr/x4-4-4/rls_dbg"
v44_root="/usr/pwr44"
reload_dumpdb()
{
# Dump V4.4 databases
reload_checkpass "dumpdb" $start_pass
if [ $pass_status -ne $pass__execute ]; then
reload_status=$reload__success
return
fi
reload_continue "Pass dump database"
dmpfiles=`eval ls $pwrp_db/*.wb_dmp`
if [ ! -z "$dmpfiles" ]; then
rm $pwrp_db/*.wb_dmp
fi
for cdb in $databases; do
dump_file=$pwrp_db/$cdb.wb_dmp
echo "Dumping volume $cdb in $dump_file"
export pwr_load=$v44_root/os_linux/hw_x86/exp/load
$v44_root/os_linux/hw_x86/exp/exe/wb_cmd -v $cdb wb dump/out=\"$dump_file\"
export pwr_load=$pwrb_root/os_linux/hw_x86/exp/load
# wb_cmd -v $cdb wb dump/out=\"$dump_file\"
done
}
reload_classvolumes()
{
reload_checkpass "classvolumes" $start_pass
if [ $pass_status -ne $pass__execute ]; then
reload_status=$reload__success
return
fi
list=`eval ls -1d $pwrp_db/*.wb_load`
echo ""
for file in $list; do
volume=`eval grep pwr_eClass_ClassVolume $file | awk '{ print $2 }'`
if [ "$volume" == "" ]; then
volume=`eval grep ClassVolume $file | awk '{ print $2 }'`
volumelow=`eval grep ClassVolume $file | awk '{ print tolower($2) }'`
fi
if [ "$volume" != "" ]; then
echo $file
fi
done
echo ""
reload_continue "Pass create structfiles and loadfiles for classvolumes"
list=`eval ls -1d $pwrp_db/*.wb_load`
for file in $list; do
volume=`eval grep pwr_eClass_ClassVolume $file | awk '{ print $2 }'`
volumelow=`eval grep pwr_eClass_ClassVolume $file | awk '{ print tolower($2) }'`
if [ "$volume" == "" ]; then
volume=`eval grep ClassVolume $file | awk '{ print $2 }'`
volumelow=`eval grep ClassVolume $file | awk '{ print tolower($2) }'`
fi
if [ "$volume" != "" ]; then
echo "-- Creating structfile and loadfile for $volume"
if co_convert -sv -d $pwrp_inc $file
then
reload_status=$reload__success
else
reload_status=$reload__userclasses
return
fi
if wb_cmd create snapshot/file=\"$file\"/out=\"$pwrp_load/$volumelow.dbs\"
then
reload_status=$reload__success
else
reload_status=$reload__userclasses
return
fi
fi
done
}
reload_renamedb()
{
reload_checkpass "renamedb" $start_pass
if [ $pass_status -ne $pass__execute ]; then
reload_status=$reload__success
return
fi
reload_continue "Pass rename old databases"
for cdb in $databases; do
reload_save_file $pwrp_db/$cdb.db
done
}
reload_dirvolume()
{
if [ -e "$pwrp_db/directory.db" ]; then
return
fi
reload_checkpass "dirvolume" $start_pass
if [ $pass_status -ne $pass__execute ]; then
reload_status=$reload__success
return
fi
reload_continue "Pass dirvolume"
wb_cmd create volume/directory
wb_cmd wb load /load=\"$pwrp_db/directory.wb_dmp\"
}
reload_cnvclassvolume()
{
reload_checkpass "cnvclassvolume" $start_pass
if [ $pass_status -ne $pass__execute ]; then
reload_status=$reload__success
return
fi
reload_continue "Pass convert classvolume wb_load files"
dmpfiles=`eval ls $pwrp_db/*.wb_load`
echo $dmpfiles
for dmpfile in $dmpfiles; do
reload_save_file $dmpfile
source $pwr_exe/upgrade_cnvdmp.sh $dmpfile.1 $pwrp_tmp/t.wb_dmp
mv $pwrp_tmp/t.wb_dmp $dmpfile
done
}
reload_cnvdump()
{
reload_checkpass "cnvdump" $start_pass
if [ $pass_status -ne $pass__execute ]; then
reload_status=$reload__success
return
fi
reload_continue "Pass convert dumpfiles"
dmpfiles=`eval ls $pwrp_db/*.wb_dmp`
echo $dmpfiles
for dmpfile in $dmpfiles; do
file=${dmpfile##/*/}
db="${file%.*}.db"
if [ $db = "wb.db" ]; then
db=""
else
awk -f $pwr_exe/upgrade_dmp.awk $dmpfile > $pwrp_tmp/t.wb_dmp
mv $pwrp_tmp/t.wb_dmp $dmpfile
fi
done
}
reload_loaddb()
{
reload_checkpass "loaddb" $start_pass
if [ $pass_status -ne $pass__execute ]; then
reload_status=$reload__success
return
fi
reload_continue "Pass load database"
if [ -z "$1" ]; then
tmp=`eval ls -1 $pwrp_db/*.wb_dmp`
databases=""
for db in $tmp; do
db=${db##/*/}
db="${db%.*}"
if [ "$db" != "directory" ]; then
databases="$databases $db"
fi
done
else
databases=$@
fi
for cdb in $databases; do
if [ $cdb != "directory" ]; then
echo "-- Loading volume $cdb"
dump_file=$pwrp_db/$cdb.wb_dmp
list_file=$pwrp_db/$cdb.lis
if wb_cmd wb load/nofocode/load=\"$dump_file\"/out=\"$list_file\"
then
reload_status=$reload__success
else
cat $list_file
reload_status=$reload__loaddb
fi
fi
done
}
reload_cnvobjects()
{
reload_checkpass "cnvobjects" $start_pass
if [ $pass_status -ne $pass__execute ]; then
reload_status=$reload__success
return
fi
reload_continue "Pass convert objects in loaded db"
list=`eval ls -1d $pwrp_db/*.db`
for file in $list; do
file=${file##/*/}
file=${file%%.*}
if [ $file != "directory" ] && [ $file != "rt_eventlog" ]; then
wb_cmd -v $file @$pwr_exe/upgrade_pb.pwr_com
fi
done
reload_status=$reload__success
}
reload_compile()
{
reload_checkpass "compile" $start_pass
if [ $pass_status -ne $pass__execute ]; then
reload_status=$reload__success
return
fi
reload_continue "Pass compile plcprograms"
list=`eval ls -1d $pwrp_db/*.db`
for file in $list; do
file=${file##/*/}
file=${file%%.*}
if [ $file != "directory" ] && [ $file != "rt_eventlog" ]; then
wb_cmd -v $file compile /all
fi
done
# wb_cmd compile /all
reload_status=$reload__success
}
reload_removeload()
{
reload_checkpass "removeload" $start_pass
if [ $pass_status -ne $pass__execute ]; then
reload_status=$reload__success
return
fi
reload_continue "Pass remove old loadfiles"
# Remove all old loadfiles
echo "-- Removing old loadfiles"
rm $pwrp_load/ld_vol*.dat
reload_status=$reload__success
}
reload_createload()
{
reload_checkpass "createload" $start_pass
if [ $pass_status -ne $pass__execute ]; then
reload_status=$reload__success
return
fi
reload_continue "Pass create loadfiles"
# Remove all old loadfiles
echo "-- Removing old loadfiles"
rm $pwrp_load/ld_vol*.dat
list=`eval ls -1d $pwrp_db/*.db`
for file in $list; do
file=${file##/*/}
file=${file%%.*}
if [ $file != "directory" ] && [ $file != "rt_eventlog" ]; then
wb_cmd -v $file create load/volume=$file
fi
done
# wb_cmd create load/all
reload_status=$reload__success
}
reload_createboot()
{
reload_checkpass "createboot" $start_pass
if [ $pass_status -ne $pass__execute ]; then
reload_status=$reload__success
return
fi
echo ""
echo "Before this pass you should compile the modules included by ra_plc_user."
echo ""
reload_continue "Pass create bootfiles"
echo "-- Creating bootfiles for all nodes"
wb_cmd create boot/all
reload_status=$reload__success
}
reload_convertge()
{
reload_checkpass "convertge" $start_pass
if [ $pass_status -ne $pass__execute ]; then
reload_status=$reload__success
return
fi
reload_continue "Pass convert ge graphs"
# Create a script that dumps each volume
tmpfile=$pwrp_tmp/convertv451.ge_com
cat > $tmpfile << EOF
function int process( string graph)
printf( "Converting %s...\n", graph);
open 'graph'
convert v45
save
endfunction
main()
EOF
list=`eval ls -1 $pwrp_pop/*.pwg`
for file in $list; do
file=${file##/*/}
file=${file%%.*}
echo "process( \"$file\");" >> $tmpfile
done
echo "exit" >> $tmpfile
echo "endmain" >> $tmpfile
chmod a+x $tmpfile
wb_ge @$tmpfile
reload_status=$reload__success
}
reload_exit()
{
exit $reload_status
}
reload_continue()
{
echo
echo "----------------------------------------------------------------------------------------"
echo " $1"
echo "----------------------------------------------------------------------------------------"
if [ $go -eq 1 ]; then
return
fi
echo -n "Do you want to continue ? [y/n/go] "
read repl
case $repl in
go ) go=1; return ;;
y ) return ;;
n ) reload_exit ;;
esac
reload_continue "$1"
}
reload_checkpass()
{
checkpass=$1
wantedpass=$2
pass_status=$pass__continue
for item in $passes; do
if [ $item = $wantedpass ]; then
pass_status=$pass__execute
fi
if [ $item = $checkpass ]; then
return
fi
done
echo "No such pass"
reload_exit
}
reload_save_file()
{
new_file=$1
if [ -e $new_file ]; then
let version=9
while [ $version -ge 1 ]
do
old_file=$new_file.$version
old_file_ren=$new_file.$((version+1))
if [ -e $old_file ]; then
mv $old_file $old_file_ren
fi
let version=$version-1
done
old_file=$new_file.1
echo "-- Saving file $new_file -> $old_file"
mv $new_file $old_file
fi
}
usage()
{
cat << EOF
upgrade.sh Upgrade from V4.5.0 to V4.5.1
Pass
dumpdb Dump database to textfile \$pwrp_db/'volume'.wb_dmp
classvolumes Create loadfiles for classvolumes.
renamedb Rename old databases.
dirvolume Load the directory volume.
loaddb Load dumpfiles.
compile Compile all plcprograms in the database
createload Create new loadfiles.
createboot Create bootfiles for all nodes in the project.
EOF
}
if [ "$1" = "help" ] || [ "$1" = "-h" ]; then
usage
exit
fi
let reload_status=$reload__success
let check_status=0
let go=0
#if [ -z "$1" ]; then
# usage
# exit
#fi
project=${pwrp_root##/*/}
# fix V4.5.1, this is the only pass
start_pass="convertge"
passes="convertge"
reload_convertge
reload_exit
# end fix
usage
echo ""
echo "-- Upgrade $project"
echo ""
tmp=`eval ls -1d $pwrp_db/*.db`
databases=""
for db in $tmp; do
db=${db##/*/}
db="${db%.*}"
if [ "$db" != "rt_eventlog" ]; then
databases="$databases $db"
fi
done
passes="dumpdb classvolumes renamedb dirvolume loaddb compile createload createboot"
#echo "Pass: $passes"
echo ""
echo -n "Enter start pass [dumpdb] > "
read start_pass
if [ -z $start_pass ]; then
start_pass="dumpdb"
fi
for cpass in $passes; do
reload_$cpass
if [ $reload_status -ne $reload__success ]; then
echo "Exiting due to error"
reload_exit
fi
done
echo ""
echo "-- The upgrade procedure is now accomplished."
echo " Please remove the dumpfiles: \$pwrp_db/*.wb_dmp*"
echo " when you are satisfied with the upgrade."
echo ""
echo "-- Remaining tasks:"
echo " Build the applications"
echo " Create packages from the distributor"
echo ""
reload_exit
#!/bin/bash
#
# Proview $Id: upgrade_cnvdmp.sh,v 1.4 2006-01-30 09:02:51 claes Exp $
# Copyright (C) 2005 SSAB Oxelsund AB.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with the program, if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
sed '
/\"$/{
N
h
s/\"\n.*Attr Parameter = \"/\./
}
s/Attr object_did = /Attr oid = /
s/Attr window_did = /Attr woid = /
s/Attr subwind_objdid/Attr subwind_oid/
s/Attr parent_node_did = /Attr poid = /
s/Attr dest_node_did = /Attr dest_oid = /
s/Attr source_node_did = /Attr source_oid = /
s/Attr reset_objdid = /Attr reset_oid = /
s/pwrb:Class-Ai_AI32uP/SsabOx:Class-Ai_AI32uP/
s/pwrb:Class-Ai_HVAI32/SsabOx:Class-Ai_HVAI32/
s/pwrb:Class-Ao_AO8uP/SsabOx:Class-Ao_AO8uP/
s/pwrb:Class-Ao_HVAO4/SsabOx:Class-Ao_HVAO4/
s/pwrb:Class-Co_CO4uP/SsabOx:Class-Co_CO4uP/
s/pwrb:Class-Co_PI24BO/SsabOx:Class-Co_PI24BO/
s/pwrb:Class-Di_DIX2/SsabOx:Class-Di_DIX2/
s/pwrb:Class-Do_HVDO32/SsabOx:Class-Do_HVDO32/
s/NMps:Class-RemTransSend/Remote:Class-RemTransSend/
s/NMps:Class-RemTransRcv/Remote:Class-RemTransRcv/
/PlcProgram$/{
N
N
h
s/Attr objdid = /Attr oid =/
s/Attr classid = /Attr cid =/
}
/PlcWindow$/{
N
N
h
s/Attr objdid = /Attr oid =/
s/Attr classid = /Attr cid =/
}
/PlcNode$/{
N
N
h
s/Attr classid = /Attr cid =/
}
/PlcConnection$/{
N
N
N
h
s/Attr objdid = /Attr oid =/
s/Attr classid = /Attr cid =/
}
' $1 > $2
BEGIN {
innum = 0;
inbody = 0;
par = "";
}
{
if ( $3 == "CStoNumSp") {
innum = 1;
inbody = 0;
}
if ( innum) {
if ( $1 == "Body" && $2 == "DevBody") {
inbody = 1;
}
if ( inbody) {
if ( $1 == "EndBody") {
printf( "Attr Object = \"%s\"\n", par);
printf( "%s\n", $0);
innum = 0;
}
else if ( $1 == "EndObject") {
innum = 0;
printf( "%s\n", $0);
}
else if ( $1 == "Attr" && $2 == "Object") {
par = substr( $4, 2, length($4)-2);
}
else if ( $1 == "Attr" && $2 == "Parameter") {
par = par "." substr($4,2,length($4)-2);
printf( "Attr Object = \"%s\"\n", par);
innum = 0;
}
else {
printf( "%s\n", $0);
}
}
else {
printf( "%s\n", $0);
}
}
else {
printf( "%s\n", $0);
}
}
!** Invisible: Script for converting OpPlace and WebHandler objects during upgrading from v4.6 to v4.7.0
!
! Proview $Id: upgrade_pb.pwr_com,v 1.3 2008-11-28 17:15:37 claes Exp $
! Copyright (C) 2005 SSAB Oxelsund AB.
!
! This program is free software; you can redistribute it and/or
! modify it under the terms of the GNU General Public License as
! published by the Free Software Foundation, either version 2 of
! the License, or (at your option) any later version.
!
! This program is distributed in the hope that it will be useful
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with the program, if not, write to the Free Software
! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
!
!
! Script for converting OpPlace and WebHandler objects during upgrading from V4.6 to V4.7.0,
! and to remove User and RttConfig objects.
!
! Find all OpPlace objects and move UserName, FastAvail and SelectList from the user object
! to the opplace object.
! Replace RttConfig with an OpPlace object named OpDefault.
! Move SelectList from user object to WebHandler object.
!
main
string op;
string user;
string aname;
int sts;
int opnumber;
int usernumber;
int found;
string value;
int ivalue;
int i;
string rttconfig;
string webhandler;
!verify(1);
! For all OpPlace objects
op = GetClassList( "OpPlace");
while ( op != "")
aname = op + ".OpNumber";
opnumber = GetAttribute( aname, sts);
if ( !sts)
op = GetNextObject( op);
continue;
endif
found = 0;
user = GetClassList( "User");
while ( user != "")
aname = user + ".OpNumber";
usernumber = GetAttribute( aname, sts);
if ( usernumber == opnumber)
found = 1;
break;
endif
user = GetNextObject( user);
endwhile
if ( !found)
printf( "No corresponding User object for %s\n", op);
op = GetNextObject( op);
continue;
endif
printf( "Processing %s\n", op);
aname = user + ".UserName";
value = GetAttribute( aname, sts);
aname = op + ".UserName";
SetAttribute( aname, value);
for ( i = 0; i < 15; i++)
aname = user + ".FastAvail[" + i + "]";
value = GetAttribute( aname, sts);
if ( value != "" && value != "Undefined attribute")
aname = op + ".FastAvail[" + i + "]";
SetAttribute( aname, value);
endif
endfor
for ( i = 0; i < 20; i++)
aname = user + ".SelectList[" + i + "]";
value = GetAttribute( aname, sts);
if ( value != "")
aname = op + ".EventSelectList[" + i + "]";
SetAttribute( aname, value);
endif
endfor
aname = user + ".MaxNoOfAlarms";
ivalue = GetAttribute( aname, sts);
aname = op + ".MaxNoOfAlarms";
SetAttribute( aname, ivalue);
aname = user + ".MaxNoOfEvents";
ivalue = GetAttribute( aname, sts);
aname = op + ".MaxNoOfEvents";
SetAttribute( aname, ivalue);
ivalue = 3;
aname = op + ".OpWindPop";
SetAttribute( aname, ivalue);
ivalue = 14;
aname = op + ".OpWindLayout";
SetAttribute( aname, ivalue);
ivalue = 1;
aname = op + ".AlarmBell";
SetAttribute( aname, ivalue);
delete object/name='user'/noconf
op = GetNextObject( op);
endwhile
! Create OpDefault
op = GetNodeObject();
create object/name="OpDefault"/class=opplace/dest='op'/last
op = op + "-OpDefault";
ivalue = 1;
aname = op + ".OpWindLayout";
SetAttribute( aname, ivalue);
! For the RttConfig object
rttconfig = GetClassList( "RttConfig");
if ( rttconfig != "")
aname = rttconfig + ".UserObject";
user = GetAttribute( aname, sts);
if ( user != "" && user != "Undefined attribute")
printf( "Processing %s\n", op);
aname = rttconfig + ".SymbolFileName";
value = GetAttribute( aname, sts);
aname = op + ".SetupScript";
SetAttribute( aname, value);
for ( i = 0; i < 20; i++)
aname = user + ".SelectList[" + i + "]";
value = GetAttribute( aname, sts);
if ( value != "")
aname = op + ".EventSelectList[" + i + "]";
SetAttribute( aname, value);
endif
endfor
aname = user + ".MaxNoOfAlarms";
ivalue = GetAttribute( aname, sts);
aname = op + ".MaxNoOfAlarms";
SetAttribute( aname, ivalue);
aname = user + ".MaxNoOfEvents";
ivalue = GetAttribute( aname, sts);
aname = op + ".MaxNoOfEvents";
SetAttribute( aname, ivalue);
delete object/name='user'/noconf
delete object/name='rttconfig'/noconf
endif
endif
! For the WebHandler object
webhandler = GetClassList( "WebHandler");
if ( webhandler != "")
aname = webhandler + ".UserObject";
user = GetAttribute( aname, sts);
if ( user != "" && user != "Undefined attribute")
printf( "Processing %s\n", webhandler);
for ( i = 0; i < 20; i++)
aname = user + ".SelectList[" + i + "]";
value = GetAttribute( aname, sts);
if ( value != "")
aname = webhandler + ".EventSelectList[" + i + "]";
SetAttribute( aname, value);
endif
endfor
aname = user + ".MaxNoOfAlarms";
ivalue = GetAttribute( aname, sts);
aname = webhandler + ".MaxNoOfAlarms";
SetAttribute( aname, ivalue);
aname = user + ".MaxNoOfEvents";
ivalue = GetAttribute( aname, sts);
aname = webhandler + ".MaxNoOfEvents";
SetAttribute( aname, ivalue);
delete object/name='user'/noconf
endif
endif
save
endmain
#!/bin/bash
#
# Proview $Id: wb_rtt_appl.sh,v 1.4 2005-09-01 14:57:49 claes Exp $
# Copyright (C) 2005 SSAB Oxelsund AB.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with the program, if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#
# Link rtt application
#
#
name=$1
action=$2
is_rttsys=$3
opsys=$4
menuname=dtt_appl_${name}_m
applname=ra_rtt_${name}
exename=ra_rtt_${name}
arname=ra_rtt_${name}.a
arname_pict=ra_rtt_${name}_pict.a
if [ $is_rttsys = "0" ]
then
# echo "Not rttsys"
if [ $action = "1" ]
then
# echo "Link"
if [ ! -e $pwrp_lib/${arname} ]
then
# echo "Creating archive $arname"
ar rc $pwrp_lib/${arname}
fi
if [ ! -e $pwrp_lib/${arname_pict} ]
then
# echo "Creating archive $arname_pict"
ar rc $pwrp_lib/${arname_pict}
fi
#link option file exists and is not empty
if [ -s $pwrp_exe/ra_rtt.opt ]; then
ld_opt_tmp="`cat $pwrp_exe/ra_rtt.opt`"
ld_opt="`eval echo $ld_opt_tmp`"
else
ld_opt=""
fi
cc=gcc
cinc="-I$pwr_inc -I$pwrp_rttbld -I-"
cflags="-DOS_FREEBSDOS=1 -DOS=freebsd -DHW_X86_64=1 -DHW=x86_64 -O3 -DGNU_SOURCE -DPWR_NDEBUG -D_REENTRANT"
${cc} -c -o $pwrp_obj/${menuname}.o \
$pwrp_rttbld/${menuname}.c \
${cinc} ${cflags}
ld=g++
linkflags="-g -L/lib/thread -L$pwrp_lib -L$pwr_lib"
${ld} ${linkflags} -o $pwrp_exe/${exename} $pwrp_obj/${menuname}.o \
$pwr_obj/dtt_rttsys.o $pwr_obj/rt_io_user.o \
$pwrp_lib/${arname_pict} $pwrp_lib/${arname} \
$ld_opt \
-lpwr_dtt\
-lpwr_rt -lpwr_co -lpwr_flow -lpwr_msg_dummy -lrpcsvc -lpthread -lm -lrt -lcrypt
fi
if [ $action = "2" ]
then
# echo "Compile"
cc=gcc
cinc="-I$pwr_inc -I$pwrp_rttbld -I$pwrp_inc -I$pwrp_cmn/common/inc -I-"
cflags="-DOS_FREEBSD=1 -DOS=freebsd -DHW_X86_64=1 -DHW=x86_64 -O3 -DGNU_SOURCE -DPWR_NDEBUG -D_REENTRANT"
${cc} -c -o $pwrp_obj/${applname}.o \
$pwrp_rtt/${applname}.c \
${cinc} ${cflags}
ar rc $pwrp_lib/${arname} $pwrp_obj/${applname}.o
fi
fi
#!/bin/bash
#
# Proview $Id: wb_rtt_comppicture.sh,v 1.2 2005-09-01 14:57:49 claes Exp $
# Copyright (C) 2005 SSAB Oxelsund AB.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with the program, if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#
# Compile a rtt picture
#
# set -o xtrace
name=$1
pgmname=$2
is_rttsys=$3
opsys=$4
# echo $name $pgmname $is_rttsys $opsys
if [ $opsys = "1024" ]
then
# echo "Opsys is FreeBSD"
if [ $is_rttsys = "0" ]
then
ar_name_pict=${pwrp_lib}/ra_rtt_${pgmname}_pict.a
cc=gcc
cinc="-I$pwr_inc -I$pwrp_rttbld"
cflags="-DOS_FREEBSD -DOS=freebsd -DHW_X86_64=1 -DPOSIX_SOURCE -DWall"
${cc} -c -o $pwrp_obj/${name}.o $pwrp_rttbld/${name}.c ${cinc} ${cflags}
ar rc ${ar_name_pict} $pwrp_obj/${name}.o
else
# echo "Is rttsys"
ar_name_pict=${pwr_lib}/libpwr_dtt.a
bld_dir=$pwre_broot/$pwre_os/$pwre_hw/bld/lib/dtt
# echo $ar_name $ar_name_pict
cc=gcc
cinc="-I$pwr_inc -I${bld_dir}"
cflags="-DOS_FREEBSD -DOS=freebsd -DHW_X86_64=1 -DPOSIX_SOURCE -DWall"
${cc} -c -o ${bld_dir}/${name}.o \
${bld_dir}/${name}.c ${cinc} ${cflags}
ar rc ${ar_name_pict} ${bld_dir}/${name}.o
fi
else
echo "Opsys is not linux, not yet supported"
# if [ $is_rttsys = "0" ]
# then
# echo "Not rttsys"
# else
# echo "Is rttsys"
# fi
fi
/*
* Proview $Id: co_clock.c,v 1.2 2005-09-01 14:57:52 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* co_clock.c -- .
*/
#ifndef OS_FREEBSD
# error This file is only for FreeBSD
#endif
#include <sys/time.h>
#include <errno.h>
#include "pwr.h"
#include "co_time.h"
#include "co_time_msg.h"
int
clock_gettime (
clockid_t clockid,
struct timespec *pt
)
{
if (clockid == CLOCK_REALTIME) {
struct timeval tv;
gettimeofday( &tv, 0);
pt->tv_sec = tv.tv_sec;
pt->tv_nsec = tv.tv_usec * 1000;
}
else if ( clockid == CLOCK_MONOTONIC) {
// TODO
struct timeval tv;
gettimeofday( &tv, 0);
pt->tv_sec = tv.tv_sec;
pt->tv_nsec = tv.tv_usec * 1000;
}
else {
errno = EINVAL;
return -1;
}
return 0;
}
/*
* Proview $Id: co_errno.c,v 1.2 2005-09-01 14:57:52 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* co_errno.c -- Translate UNIX errno to Proview status.
NOTE! The actual values of errno codes in <errno.h> must match
the vector index used in 'errno_status'. */
#ifndef OS_FREEBSD
# error This file is only for FreeBSD
#endif
#include <errno.h>
#include "pwr.h"
#include "co_errno.h"
#include "co_errno_msg.h"
static struct {
int err_no;
pwr_tStatus sts;
} errno_status[] = {
{0, ERRNO__SUCCESS},
{EPERM, ERRNO__PERM},
{ENOENT, ERRNO__NOENT},
{ESRCH, ERRNO__SRCH},
{EINTR, ERRNO__INTR},
{EIO, ERRNO__IO},
{ENXIO, ERRNO__NXIO},
{E2BIG, ERRNO__2BIG},
{ENOEXEC, ERRNO__NOEXEC},
{EBADF, ERRNO__BADF},
{ECHILD, ERRNO__CHILD},
{EAGAIN, ERRNO__AGAIN},
{ENOMEM, ERRNO__NOMEM},
{EACCES, ERRNO__ACCES},
{EFAULT, ERRNO__FAULT},
{ENOTBLK, ERRNO__NOTBLK},
{EBUSY, ERRNO__BUSY},
{EEXIST, ERRNO__EXIST},
{EXDEV, ERRNO__XDEV},
{ENODEV, ERRNO__NODEV},
{ENOTDIR, ERRNO__NOTDIR},
{EISDIR, ERRNO__ISDIR},
{EINVAL, ERRNO__INVAL},
{ENFILE, ERRNO__NFILE},
{EMFILE, ERRNO__MFILE},
{ENOTTY, ERRNO__NOTTY},
{ETXTBSY, ERRNO__TXTBSY},
{EFBIG, ERRNO__FBIG},
{ENOSPC, ERRNO__NOSPC},
{ESPIPE, ERRNO__SPIPE},
{EROFS, ERRNO__ROFS},
{EMLINK, ERRNO__MLINK},
{EPIPE, ERRNO__PIPE},
{EDOM, ERRNO__DOM},
{ERANGE, ERRNO__RANGE},
{EDEADLK, ERRNO__DEADLK},
{ENAMETOOLONG, ERRNO__NAMETOOLONG},
{ENOLCK, ERRNO__NOLCK},
{ENOSYS, ERRNO__NOSYS},
{ENOTEMPTY, ERRNO__NOTEMPTY},
{ELOOP, ERRNO__LOOP},
{EBADCODE, ERRNO__BADCODE},
{ENOMSG, ERRNO__NOMSG},
{EIDRM, ERRNO__IDRM},
//{ECHRNG, ERRNO__CHRNG},
//{EL2NSYNC, ERRNO__L2NSYNC},
//{EL3HLT, ERRNO__L3HLT},
//{EL3RST, ERRNO__L3RST},
//{ELNRNG, ERRNO__LNRNG},
//{EUNATCH, ERRNO__UNATCH},
//{ENOCSI, ERRNO__NOCSI},
//{EL2HLT, ERRNO__L2HLT},
//{EBADE, ERRNO__BADE},
//{EBADR, ERRNO__BADR},
//{EXFULL, ERRNO__XFULL},
//{ENOANO, ERRNO__NOANO},
//{EBADRQC, ERRNO__BADRQC},
//{EBADSLT, ERRNO__BADSLT},
//{EBADCODE, ERRNO__BADCODE},
//{EBFONT, ERRNO__BFONT},
//{ENOSTR, ERRNO__NOSTR},
//{ENODATA, ERRNO__NODATA},
//{ETIME, ERRNO__TIME},
//{ENOSR, ERRNO__NOSR},
//{ENONET, ERRNO__NONET},
//{ENOPKG, ERRNO__NOPKG},
{EREMOTE, ERRNO__REMOTE},
{ENOLINK, ERRNO__NOLINK},
//{EADV, ERRNO__ADV},
//{ESRMNT, ERRNO__SRMNT},
//{ECOMM, ERRNO__COMM},
{EPROTO, ERRNO__PROTO},
{EMULTIHOP, ERRNO__MULTIHOP},
//{EDOTDOT, ERRNO__DOTDOT},
{EBADMSG, ERRNO__BADMSG},
{EOVERFLOW, ERRNO__OVERFLOW},
//{ENOTUNIQ, ERRNO__NOTUNIQ},
//{EBADFD, ERRNO__BADFD},
//{EREMCHG, ERRNO__REMCHG},
//{ELIBACC, ERRNO__LIBACC},
//{ELIBBAD, ERRNO__LIBBAD},
//{ELIBSCN, ERRNO__LIBSCN},
//{ELIBMAX, ERRNO__LIBMAX},
//{ELIBEXEC, ERRNO__LIBEXEC},
//{EILSEQ, ERRNO__ILSEQ},
//{ERESTART, ERRNO__RESTART},
//{ESTRPIPE, ERRNO__STRPIPE},
{EUSERS, ERRNO__USERS},
{ENOTSOCK, ERRNO__NOTSOCK},
{EDESTADDRREQ, ERRNO__DESTADDRREQ},
{EMSGSIZE, ERRNO__MSGSIZE},
{EPROTOTYPE, ERRNO__PROTOTYPE},
{ENOPROTOOPT, ERRNO__NOPROTOOPT},
{EPROTONOSUPPORT, ERRNO__PROTONOSUPPORT},
{ESOCKTNOSUPPORT, ERRNO__SOCKTNOSUPPORT},
{EOPNOTSUPP, ERRNO__OPNOTSUPP},
{EPFNOSUPPORT, ERRNO__PFNOSUPPORT},
{EAFNOSUPPORT, ERRNO__AFNOSUPPORT},
{EADDRINUSE, ERRNO__ADDRINUSE},
{EADDRNOTAVAIL, ERRNO__ADDRNOTAVAIL},
{ENETDOWN, ERRNO__NETDOWN},
{ENETUNREACH, ERRNO__NETUNREACH},
{ENETRESET, ERRNO__NETRESET},
{ECONNABORTED, ERRNO__CONNABORTED},
{ECONNRESET, ERRNO__CONNRESET},
{ENOBUFS, ERRNO__NOBUFS},
{EISCONN, ERRNO__ISCONN},
{ENOTCONN, ERRNO__NOTCONN},
{ESHUTDOWN, ERRNO__SHUTDOWN},
{ETOOMANYREFS, ERRNO__TOOMANYREFS},
{ETIMEDOUT, ERRNO__TIMEDOUT},
{ECONNREFUSED, ERRNO__CONNREFUSED},
{EHOSTDOWN, ERRNO__HOSTDOWN},
{EHOSTUNREACH, ERRNO__HOSTUNREACH},
{EALREADY, ERRNO__ALREADY},
{EINPROGRESS, ERRNO__INPROGRESS},
{ESTALE, ERRNO__STALE},
//{EUCLEAN, ERRNO__UCLEAN},
//{ENOTNAM, ERRNO__NOTNAM},
//{ENAVAIL, ERRNO__NAVAIL},
//{EISNAM, ERRNO__ISNAM},
//{EREMOTEIO, ERRNO__REMOTEIO},
{EDQUOT, ERRNO__DQUOT},
//{ENOMEDIUM, ERRNO__NOMEDIUM},
//{EMEDIUMTYPE, ERRNO__MEDIUMTYPE}
};
#define cMaxErrno ((int) (sizeof(errno_status) / sizeof(errno_status[0])))
int
errno_ExitStatus (
pwr_tStatus sts
)
{
if (ODD(sts))
return 0;
else
return (int)sts;
}
int
errno_ExitErrno (
int err_no
)
{
return err_no;
}
/* Check a POSIX return code and return
status on PWR format, using errno. */
pwr_tStatus
errno_Pstatus (
int psts
)
{
if (psts == 0)
return ERRNO__SUCCESS;
// pthread_cond_timedwait returns other values than -1
// pwr_Assert(psts == -1);
if (errno < 0 || errno >= cMaxErrno)
return ERRNO_BADCODE(errno);
if (errno_status[errno].err_no == errno)
return errno_status[errno].sts;
return ERRNO_BADCODE(errno);
}
pwr_tStatus
errno_Status (
int err_no
)
{
if (err_no < 0 || err_no >= cMaxErrno)
return ERRNO_BADCODE(err_no);
if (errno_status[err_no].err_no == err_no)
return errno_status[err_no].sts;
return ERRNO_BADCODE(err_no);
}
pwr_tStatus
errno_GetStatus ()
{
if (errno < 0 || errno >= cMaxErrno)
return ERRNO_BADCODE(errno);
if (errno_status[errno].err_no == errno)
return errno_status[errno].sts;
return ERRNO_BADCODE(errno);
}
/*
* Proview $Id: co_syi.c,v 1.2 2008-06-24 07:03:42 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* co_syi.c -- System information
This module gives information about the system. */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <netdb.h>
#include <errno.h>
#include "pwr.h"
#include "co_errno.h"
#include "co_syi.h"
#include "co_syi_msg.h"
char *
syi_HostName (
pwr_tStatus *status,
char *ibuffer,
int isize
)
{
return syi_NodeName(status, ibuffer, isize);
}
char *
syi_NodeName (
pwr_tStatus *status,
char *ibuffer,
int isize
)
{
char* cp;
pwr_dStatus(sts, status, SYI__SUCCESS);
if (gethostname(ibuffer, isize) != 0) {
if (errno == EINVAL) {
*sts = SYI__TRUNCATED;
} else {
*sts = errno_Status(errno);
ibuffer = NULL;
}
}
/* Remove domain */
if ((cp = strchr(ibuffer, '.')))
*cp = 0;
return ibuffer;
}
char *
syi_Ethernet (
pwr_tStatus *status,
char *ibuffer,
int size
)
{
pwr_dStatus(sts, status, SYI__NYI);
return NULL;
}
char *
syi_NodeSpec (
pwr_tStatus *status,
char *ibuffer,
int size
)
{
pwr_dStatus(sts, status, SYI__NYI);
return NULL;
}
char *
syi_HostSpec (
pwr_tStatus *status,
char *ibuffer,
int size
)
{
return syi_NodeSpec(status, ibuffer, size);
}
/* Return true if node is booted locally or
false if booted from remote node via network. */
pwr_tBoolean
syi_LocalBoot (
pwr_tStatus *status
)
{
return YES;
}
/* . */
char*
syi_BootDisk (
pwr_tStatus *status,
char *ibuffer,
int size
)
{
pwr_dStatus(sts, status, SYI__NYI);
return NULL;
}
pwr_tStatus syi_UserName( char *user, int len)
{
char *p;
p = getlogin();
if ( !p)
return 0;
strncpy( user, p, len);
return 1;
}
const char *syi_Hardware()
{
#if defined HW_X86_64
static const char hw[] = "x86_64";
#else
static const char hw[] = "x86";
#endif
return hw;
}
const char *syi_OpSys()
{
#if defined OS_LINUX
static const char opsys[] = "Linux";
#elif defined OS_MACOS
static const char opsys[] = "MacOS";
#elif defined OS_FREEBSD
static const char opsys[] = "FreeBSD";
#else
static const char opsys[] = "Unknown";
#endif
return opsys;
}
char *syi_ProcessId()
{
static char pidstr[40];
sprintf( pidstr, "%u", getpid());
return pidstr;
}
/*
* Proview $Id: co_time_os.c,v 1.4 2005-09-01 14:57:52 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* co_time_os.c -- OS specific time routines.
*/
#ifndef OS_FREEBSD
# error This file is only for FreeBSD
#endif
#include <unistd.h>
#include <sys/times.h>
#include <string.h>
#include "pwr.h"
#include "co_time.h"
#include "co_time_msg.h"
/* Return delta time since system start.
Add delta time 'add'. */
#if 0
pwr_tDeltaTime *
time_Uptime (
pwr_tStatus *status,
pwr_tDeltaTime *tp,
pwr_tDeltaTime *ap
)
{
pwr_tDeltaTime time;
long tics;
struct tms buff;
static int tics_per_sec = 0;
static pwr_tTime boot_time = {0,0};
static pwr_tDeltaTime max_diff = {0,20000000};
pwr_tDeltaTime uptime_tics;
pwr_tTime current_time;
pwr_tDeltaTime diff;
pwr_dStatus(sts, status, TIME__SUCCESS);
if ( !tics_per_sec)
tics_per_sec = sysconf(_SC_CLK_TCK);
if (tp == NULL)
tp = &time;
tics = times(&buff);
uptime_tics.tv_sec = tics / tics_per_sec;
uptime_tics.tv_nsec = (tics % tics_per_sec) * (1000000000 / tics_per_sec);
// pwr_Assert(tp->tv_sec >= 0 && tp->tv_nsec >= 0);
clock_gettime( CLOCK_REALTIME, &current_time);
if ( !boot_time.tv_sec) {
time_Asub( &boot_time, &current_time, &uptime_tics);
*tp = uptime_tics;
}
else {
time_Adiff( tp, &current_time, &boot_time);
time_Dsub( &diff, tp, &uptime_tics);
time_Dabs(NULL, &diff);
if ( time_Dcomp(&diff, &max_diff) > 0) {
time_Asub( &boot_time, &current_time, &uptime_tics);
*tp = uptime_tics;
*status = TIME__CLKCHANGE;
}
}
if (ap != NULL)
return time_Dadd(tp, tp, ap);
else
return tp;
}
#endif
/* Modified to keep uptime tics as a 64-bit unsigned.
* This way uptime tics won't wrap around for another 8000 years or so
* when HZ is at a 1000.
* RK 031112
*/
pwr_tDeltaTime *
time_Uptime (
pwr_tStatus *status,
pwr_tDeltaTime *tp,
pwr_tDeltaTime *ap
)
{
pwr_tDeltaTime time;
unsigned long tics;
static pwr_tUInt64 tics_64;
struct tms buff;
static int tics_per_sec = 0;
static pwr_tTime boot_time = {0,0};
static pwr_tDeltaTime max_diff = {0, 20000000};
pwr_tDeltaTime uptime_tics;
pwr_tTime current_time;
pwr_tDeltaTime diff;
static pwr_tUInt16 msb_flips = 0;
static pwr_tBoolean old_high_bit = 0;
pwr_tBoolean high_bit;
lldiv_t uptime_s;
pwr_dStatus(sts, status, TIME__SUCCESS);
if ( !tics_per_sec)
tics_per_sec = sysconf(_SC_CLK_TCK);
if (tp == NULL)
tp = &time;
tics = times(&buff);
high_bit = tics >> (32 - 1);
if (!high_bit && old_high_bit)
msb_flips++;
old_high_bit = high_bit;
tics_64 = ((pwr_tUInt64) msb_flips << 32) | tics;
uptime_s = lldiv(tics_64, (pwr_tInt64) tics_per_sec);
uptime_tics.tv_sec = (pwr_tInt64) uptime_s.quot;
uptime_tics.tv_nsec = ((pwr_tUInt64) uptime_s.rem) * (1000000000 / tics_per_sec);
// pwr_Assert(tp->tv_sec >= 0 && tp->tv_nsec >= 0);
time_GetTime( &current_time);
if ( !boot_time.tv_sec) {
time_Asub( &boot_time, &current_time, &uptime_tics);
*tp = uptime_tics;
}
else {
time_Adiff( tp, &current_time, &boot_time);
time_Dsub( &diff, tp, &uptime_tics);
time_Dabs(NULL, &diff);
if ( time_Dcomp(&diff, &max_diff) > 0) {
time_Asub( &boot_time, &current_time, &uptime_tics);
*tp = uptime_tics;
if (status != NULL) {
*status = TIME__CLKCHANGE;
}
}
}
if (ap != NULL)
return time_Dadd(tp, tp, ap);
else
return tp;
}
/* Return number of clock ticks since system start.
Add number of tics corresponding to delta time 'add'. */
time_tClock
time_Clock (
pwr_tStatus *status,
pwr_tDeltaTime *ap
)
{
long tics;
struct tms buff;
static int tics_per_sec = 0;
pwr_dStatus(sts, status, TIME__SUCCESS);
if ( !tics_per_sec)
tics_per_sec = sysconf(_SC_CLK_TCK);
tics = times(&buff);
if (ap != NULL) {
tics += (ap->tv_sec * tics_per_sec) + (ap->tv_nsec / (1000000000 / tics_per_sec));
}
return tics;
}
time_tOs *
time_Os (
pwr_tStatus *status,
time_tOs *tp
)
{
static time_tOs os_time;
pwr_dStatus(sts, status, TIME__SUCCESS);
if (tp == NULL)
tp = &os_time;
time_GetTime(tp);
return tp;
}
/* Set system time */
pwr_tStatus
time_SetTime(
pwr_tTime *pt
)
{
pwr_tStatus sts = TIME__SUCCESS;
return sts;
}
time_tOs *
time_AtoOs (
pwr_tStatus *status,
time_tOs *tp,
pwr_tTime *ap
)
{
time_tOs os_time;
pwr_dStatus(sts, status, TIME__SUCCESS);
if (tp == NULL)
tp = &os_time;
*tp = *ap;
return tp;
}
/* Convert from Proview delta time format
to native time format. */
time_tOs *
time_DtoOs (
pwr_tStatus *status,
time_tOs *tp,
pwr_tDeltaTime *dp
)
{
time_tOs os_time;
pwr_dStatus(sts, status, TIME__SUCCESS);
if (tp == NULL)
tp = &os_time;
memcpy(tp, dp, sizeof(*tp));
return tp;
}
/*
* Proview $Id: pbus.h,v 1.3 2005-09-01 14:57:57 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __PBDRVR__
#define __PBDRVR__
#define INIT_MODE 0x00
#define CONFIG_MODE 0x05
#define COMM_MODE 0x08
#define H_READY_MASK 0x874B2D1E
#define C_READY_MASK 0x78B4D2E1
#define IDLE 0x00
#define BUSY 0x01
#define D_DATA_IDLE 0x00
#define D_DATA_APPLY 0xF0
#define D_DATA_BUSY 0x0F
// Macros for defining ioctl commands
#define PB_IOCTL_MAGIC 'c'
#define PB_IOCTL_READCMIDESC _IO(PB_IOCTL_MAGIC, 1)
#define PB_IOCTL_READLOCALREG _IO(PB_IOCTL_MAGIC, 2)
#define PB_IOCTL_WRITECMIDESC _IO(PB_IOCTL_MAGIC, 3)
#define PB_IOCTL_HWRESET _IO(PB_IOCTL_MAGIC, 4)
#define PB_IOCTL_CMI_INIT _IO(PB_IOCTL_MAGIC, 5)
#define PB_IOCTL_READDATADESC _IO(PB_IOCTL_MAGIC, 6)
#define PB_IOCTL_CMI_WRITE _IO(PB_IOCTL_MAGIC, 7)
#define PB_IOCTL_READ_SDB _IO(PB_IOCTL_MAGIC, 8)
#define PB_IOCTL_READ_DB _IO(PB_IOCTL_MAGIC, 9)
#define PB_IOCTL_CMI_READ _IO(PB_IOCTL_MAGIC, 10)
#define PB_IOCTL_READ_IRQ_VALUES _IO(PB_IOCTL_MAGIC, 11)
#define PB_IOCTL_READ_FIRST_SLAVE _IO(PB_IOCTL_MAGIC, 12)
#define PB_IOCTL_WRITE_FIRST_SLAVE _IO(PB_IOCTL_MAGIC, 13)
#define PB_IOCTL_READVERSION _IO(PB_IOCTL_MAGIC, 14)
#define PB_IOCTL_READSERIAL _IO(PB_IOCTL_MAGIC, 15)
#define PB_IOCTL_SET_STALLTIME _IO(PB_IOCTL_MAGIC, 16)
#define ERROR_DESCR_LENGTH 32
typedef struct {
unsigned int h_ready_mask;
unsigned int h_base_address;
unsigned char h_id;
unsigned char h_int_enable;
unsigned char h_address_swap_mode;
unsigned char h_state;
unsigned int h_param_addr;
unsigned int h_data_addr;
unsigned short h_param_size;
unsigned short h_data_size;
unsigned char h_sema;
unsigned char h_ret_val;
unsigned char h_head;
unsigned char h_tail;
unsigned int h_data_descr_addr;
unsigned int c_ready_mask;
unsigned int c_base_address;
unsigned char c_id;
unsigned char c_int_enable;
unsigned char c_address_swap_mode;
unsigned char c_state;
unsigned int c_param_addr;
unsigned int c_data_addr;
unsigned short c_param_size;
unsigned short c_data_size;
unsigned char c_sema;
unsigned char c_ret_val;
unsigned char c_head;
unsigned char c_tail;
unsigned int c_data_descr_addr;
}T_CMI_DESCRIPTOR;
typedef struct {
unsigned int reg[21];
} T_LOCALREG;
typedef struct {
unsigned char d_id;
unsigned char dummy;
unsigned char d_sema_c;
unsigned char d_sema_h;
unsigned short d_data_size;
unsigned int d_data_addr;
} T_DATA_DESCR;
typedef struct {
T_PROFI_SERVICE_DESCR *sdb_ptr;
USIGN8 *data_ptr;
USIGN16 *data_len_ptr;
USIGN16 *retval_ptr;
} cmi_request_access_struct;
typedef struct {
USIGN8 data_id; // Id of data structure
USIGN16 offset; // Offset in data area
USIGN8 *data_ptr; // Pointer to data to write/to be read
USIGN16 *retval_ptr; // Pointer to return value
} cmi_data_access_struct;
#endif
/*
* Proview $Id: rt_errl.c,v 1.8 2006-07-20 10:23:52 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* rt_errl.c -- Logging module
Handles logging for Linux.
*/
#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/msg.h>
#include <sys/ipc.h>
#include <limits.h>
#include <pthread.h>
#include <sys/time.h>
#include "rt_errl.h"
#include "rt_errh.h"
#define MAX_NO_MSG 100;
#define DEF_MAX_NO_MSG 10;
static pthread_mutex_t fileMutex;
static pthread_mutex_t termMutex;
static int mqid = -1;
static int logFile = -1;
static int newLogFile = 1;
static int term = -1;
static pthread_t tid = 0;
static int yday = -1;
static pwr_tBoolean logToStdout = FALSE;
static void (*errl_log_cb)( void *, char *, char, pwr_tStatus, int, int) = 0;
static void *errl_log_userdata = 0;
static void CheckTimeStamp(int force);
static void *log_thread(void *arg);
void
errl_Init (
const char *termName,
void (*log_cb)( void *, char *, char, pwr_tStatus, int, int),
void *userdata
)
{
pthread_mutexattr_t mutexattr;
pthread_attr_t pthreadattr;
#if 0
struct mq_attr mqattr;
#endif
char name[64];
char *busid = getenv(pwr_dEnvBusId);
static int initDone = 0;
int policy;
struct sched_param param;
key_t key;
errl_log_cb = log_cb;
errl_log_userdata = userdata;
if (initDone)
return;
if ((pthread_getschedparam(pthread_self(), &policy, &param)) == -1) {
perror("rt_errl: pthread_getprio(pthread_self() ");
return;
}
pthread_mutexattr_init(&mutexattr);
if (pthread_mutex_init(&fileMutex, &mutexattr) == -1) {
perror("rt_logmod: pthread_mutex_init(&fileMutex, mutexattr) ");
return;
}
if (pthread_mutex_init(&termMutex, &mutexattr) == -1) {
perror("rt_logmod: pthread_mutex_init(&termMutex, mutexattr) ");
return;
}
pthread_mutexattr_destroy(&mutexattr);
#if 0
mqattr.mq_msgsize = LOG_MAX_MSG_SIZE; /* max mess size */
mqattr.mq_maxmsg = MAX_NO_MSG; /* max no of msg in this queue */
mqattr.mq_flags = 0; // O_NONBLOCK;
oflags = O_CREAT | O_RDWR;
mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
#endif
sprintf(name, "%s_%s", LOG_QUEUE_NAME, busid ? busid : "");
key = ftok(name, 'm');
mqid = msgget( key, IPC_CREAT | 0660);
if (mqid == -1) {
perror("Open message queue: msgget ");
return;
}
pthread_attr_init(&pthreadattr);
if (pthread_create(&tid, &pthreadattr, log_thread, NULL) == -1) {
perror("rt_logmod: pthread_create ");
pthread_attr_destroy(&pthreadattr);
return;
}
pthread_attr_destroy(&pthreadattr);
param.sched_priority -= 1;
pthread_setschedparam(tid, policy, &param);
if (termName && *termName)
errl_SetTerm(termName);
logToStdout = getenv("PWR_LOG_TO_STDOUT") != NULL ? TRUE : FALSE;
initDone = 1;
return;
}
void
errl_Unlink ()
{
pthread_cancel(tid);
/* Remove the message queue */
msgctl( mqid, IPC_RMID, 0);
}
void
errl_SetFile (
const char *logFileName)
{
pwr_tStatus sts = 1;
int oflags = O_CREAT | O_APPEND | O_WRONLY;
int mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH;
pthread_mutex_lock(&fileMutex);
if (logFile != -1) {
close(logFile);
logFile = -1;
}
if ((logFile = open(logFileName, oflags, mode)) == -1) {
errh_Error("Cannot open log file: %s", logFileName);
sts = 2;
} else {
// errh_Info("Logging to %s", logFileName);
newLogFile = 1;
}
pthread_mutex_unlock(&fileMutex);
}
void
errl_SetTerm (
const char *termName
)
{
int oflags = O_APPEND | O_WRONLY;
pthread_mutex_lock(&termMutex);
if (term != -1) {
close(term);
term = -1;
}
if (termName && *termName) {
if ((term = open(termName, oflags)) == -1) {
errh_Error("Cannot open terminal: %s", termName);
}
}
pthread_mutex_unlock(&termMutex);
}
static void
CheckTimeStamp (
int force
)
{
time_t t;
struct tm tmpTm;
t = time(NULL);
localtime_r(&t, &tmpTm);
if (force || (yday != tmpTm.tm_yday)) {
char buf[64];
#define STAMP "DATE STAMP: "
write(logFile, STAMP, strlen(STAMP));
strftime(buf, sizeof(buf), "%e-%b-%Y\n", &tmpTm);
write(logFile, buf, strlen(buf));
pthread_mutex_lock(&termMutex);
if (term != -1)
write(term, buf, strlen(buf));
pthread_mutex_unlock(&termMutex);
if (logToStdout)
printf("%.*s", (int)strlen(buf), buf);
yday = tmpTm.tm_yday;
}
}
static void *
log_thread (void *arg)
{
int len;
errh_sMsg buf;
while (1) {
len = msgrcv(mqid, (char *)&buf, LOG_MAX_MSG_SIZE, 0, 0);
if (len == -1) {
if (errno != EINTR)
perror("rt_logmod.c: mq_receive ");
} else {
switch ( buf.message_type) {
case errh_eMsgType_Log:
len -= (sizeof(buf) - sizeof(buf.str) - sizeof(buf.message_type) + 1);
buf.str[len] = 0;
pthread_mutex_lock(&fileMutex);
if (logFile != -1) {
/* Set up a timer if you want better performance, ML */
CheckTimeStamp(newLogFile);
newLogFile = 0;
write(logFile, buf.str, len);
write(logFile, "\n", 1);
}
pthread_mutex_unlock(&fileMutex);
pthread_mutex_lock(&termMutex);
if (term != -1) {
write(term, buf.str, len);
write(term, "\n", 1);
}
pthread_mutex_unlock(&termMutex);
if (logToStdout)
printf("%.*s\n", len, buf.str);
if ( errl_log_cb)
(errl_log_cb)( errl_log_userdata, buf.str, buf.severity, buf.sts, buf.anix, buf.message_type);
break;
case errh_eMsgType_Status:
if ( errl_log_cb)
(errl_log_cb)( errl_log_userdata, 0, 0, buf.sts, buf.anix, buf.message_type);
}
}
}
return 0;
}
/*
* Proview $Id: rt_futex.c,v 1.2 2005-09-01 14:57:57 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* rt_futex.c -- Futex operations
PROVIEW/R
Contains functions that are heavily os-dependant.
Author: Robert Karlsson 21 Apr 2004
Description:
This module provides an interface to futexes - "fast user level
locking in Linux". This is achieved through the multiplexing
system call sys_futex(). As implemented below this interface provides
a synchronization mechanism that can be used both between threads
in one process as well as between threads in different processes */
#if !defined(OS_MACOS)
# error "This file is valid only for Mac OS"
#endif
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/syscall.h>
#include <unistd.h>
#define FUTEX_WAIT (0)
#define FUTEX_WAKE (1)
#define FUTEX_FD (2)
#define FUTEX_REQUEUE (3)
int
futex_wait (
int *futex,
int val
)
{
int ok;
ok = syscall(SYS_futex, futex, FUTEX_WAIT, val, NULL);
if (ok == -1) {
return errno;
}
else {
return ok;
}
}
int
futex_timed_wait (
int *futex,
int val,
const struct timespec * timespec
)
{
int ok;
ok = syscall(SYS_futex, futex, FUTEX_WAIT, val, timespec);
if (ok == -1) {
return errno;
}
else {
return ok;
}
}
int
futex_wake (
int *futex,
int nr
)
{
int ok;
ok = syscall(SYS_futex, futex, FUTEX_WAKE, nr, NULL);
if (ok == -1) {
return errno;
}
else {
return ok;
}
}
/*
* Proview $Id: rt_futex.h,v 1.2 2005-09-01 14:57:57 claes Exp $
* Copyright (C) 2005 SSAB Oxelösund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef rt_futex_h
#define rt_futex_h
#ifdef __cplusplus
extern "C" {
#endif
int futex_wait(int *futex, int val);
int futex_timed_wait(int *futex, int val, const struct timespec * timespec);
int futex_wake(int *futex,int nr);
#ifdef __cplusplus
}
#endif
#endif
/*
* Proview $Id: rt_inet.c,v 1.2 2005-09-01 14:57:57 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* rt_inet.c -- Internet help functions */
#include "rt_inet.h"
#include <net/if_arp.h>
pwr_tBoolean
inet_SetArpEntry (
pwr_tStatus *sts,
int s,
struct arpreq *rp
)
{
#if 0
return (ioctl(s, SIOCSARP, (caddr_t)rp) == 0);
#else
return 1;
#endif
}
pwr_tBoolean
inet_DeleteArpEntry (
pwr_tStatus *sts,
int s,
struct arpreq *rp
)
{
#if 0
return (ioctl(s, SIOCDARP, (caddr_t)rp) == 0);
#else
return 1;
#endif
}
pwr_tBoolean
inet_GetArpEntry (
pwr_tStatus *sts,
int s,
struct arpreq *rp
)
{
#if 0
return (ioctl(s, SIOCGARP, (caddr_t)rp) == 0);
#else
return 1;
#endif
}
/*
* Proview $Id: rt_proc.c,v 1.4 2006-03-29 12:24:24 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#if !defined(OS_LYNX) && !defined(OS_LINUX) && !defined(OS_MACOS) && !defined OS_FREEBSD
# error "This file is valid only for OS_LYNX and OS_LINUX and OS_MACOS and OS_FREEBSD"
#endif
#include <string.h>
#include <sched.h>
#include <unistd.h>
#include <errno.h>
#include <sys/resource.h>
#include "pwr.h"
#include "co_cdh.h"
#include "co_errno.h"
#include "co_strtoargv.h"
#include "rt_proc.h"
#include "rt_proc_msg.h"
#include "rt_errh.h"
pwr_tStatus
proc_Load (
proc_sProcess *p
)
{
pwr_tStatus sts = PROC__SUCCESS;
return sts;
}
pwr_tStatus
proc_Start (
proc_sProcess *p
)
{
pwr_tStatus sts = PROC__SUCCESS;
char **argv;
p->pid = fork();
if (p->pid) {
if (p->pid == -1) {
errh_Error("Could not start %s, %m\nfile: %s", p->name, errno_GetStatus(), p->file);
} else {
errh_Info("Started %s, prio: %d, pid: %d\nfile: %s", p->name, p->p_prio, (int)p->pid, p->file);
}
} else {
sts = proc_SetPriority(p->p_prio);
if (EVEN(sts)) errh_Warning("%s: error setprio, %m\nfile: %s", p->name, sts, p->file);
argv = co_StrToArgv(p->file, p->arg);
execvp(p->file, argv);
errh_Error("%s: error execvp, %m\nfile: %s", p->name, errno_GetStatus(), p->file);
exit(EXIT_FAILURE);
}
return sts;
}
pwr_tStatus
proc_SetPriority (
int prio
)
{
// struct sched_param param;
// int rc;
int pid;
char set[100];
pwr_tStatus sts = PROC__SUCCESS;
pid = getpid();
// rc = sched_getparam((pid_t)0, &param);
// if (rc != 0)
// return errno_GetStatus();
// param.sched_priority = prio;
// rc = sched_setscheduler((pid_t)0, SCHED_RR, &param);
// if (rc != 0)
// return errno_GetStatus();
// Priorities set from rt_ini after start of all processes
sprintf(set, "rt_prio -rp %d %d", prio, pid);
// system(set);
return sts;
}
pwr_tStatus
proc_UnloadProgram (
proc_sProcess *p
)
{
pwr_tStatus sts = PROC__SUCCESS;
return sts;
}
/*
* Proview $Id: rt_qos.c,v 1.9 2007-09-21 09:05:41 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* rt_qos.c -- Queue Communication
Contains functions that are heavily os-dependant. */
#if !defined(OS_FREEBSD)
# error "This file is valid only for FreeBSD"
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <errno.h>
#include "pwr.h"
#include "pwr_class.h"
#include "co_errno.h"
#include "co_platform.h"
#include "rt_qdb_msg.h"
#include "rt_qcom_msg.h"
#include "rt_hash_msg.h"
#include "co_time.h"
#include "rt_errh.h"
#include "rt_qdb.h"
#include "rt_pool.h"
#include "rt_hash.h"
//#include "rt_futex.h"
#if 0
pwr_tBoolean
qos_WaitQueOld (
pwr_tStatus *status,
qdb_sQue *qp,
int tmo
)
{
pwr_tDeltaTime dtime;
struct timespec dtime_ts;
sigset_t newset;
siginfo_t info;
int ok;
pwr_tBoolean signal = FALSE;
pwr_dStatus (sts, status, QCOM__SUCCESS);
qdb_AssumeLocked;
if (tmo == qcom_cTmoNone)
return FALSE;
qp->lock.waiting = TRUE;
sigemptyset(&newset);
sigaddset(&newset, qdb_cSigMsg);
// qp->lock.pid = BUILDPID(getpid(), pthread_self());
// I think that each thread has it's own pid in Linux. ML
qp->lock.pid = getpid();
qdb_Unlock;
if (tmo != qcom_cTmoEternal) {
time_MsToD(&dtime, tmo);
dtime_ts.tv_sec = dtime.tv_sec;
dtime_ts.tv_nsec = dtime.tv_nsec;
ok = sigtimedwait(&newset, &info, &dtime_ts);
} else {
for (;;) {
ok = sigwaitinfo(&newset, &info);
if ( ok == -1 && errno == EINTR)
continue;
break;
}
}
if (ok == -1 && errno != EAGAIN) {
errh_Error("waitQue (%d) %s", errno, strerror(errno));
}
else if (!(ok == -1 || ok == qdb_cSigMsg)) {
errh_Error("qos waitQue signr %d", ok);
}
qdb_Lock;
if (qp->lock.waiting) {
*sts = QCOM__TMO;
qp->lock.waiting = FALSE;
} else {
signal = TRUE;
}
return signal;
}
#endif
#if 0
pwr_tBoolean
qos_WaitQue (
pwr_tStatus *status,
qdb_sQue *qp,
int tmo
)
{
pwr_tDeltaTime dtime;
pwr_tTime atime;
struct timespec atime_ts;
int ok;
pwr_tBoolean signal = FALSE;
pwr_dStatus (sts, status, QCOM__SUCCESS);
qdb_AssumeLocked;
if (tmo == qcom_cTmoNone)
return FALSE;
pthread_mutex_lock(&qp->lock.mutex);
qp->lock.waiting = TRUE;
qp->lock.pid = 0;
qdb_Unlock;
if (tmo != qcom_cTmoEternal) {
time_GetTime(&atime);
time_MsToD(&dtime, tmo);
time_Aadd(&atime, &atime, &dtime);
atime_ts.tv_sec = atime.tv_sec;
atime_ts.tv_nsec = atime.tv_nsec;
ok = pthread_cond_timedwait(&qp->lock.cond, &qp->lock.mutex, &atime_ts);
} else {
ok = pthread_cond_wait(&qp->lock.cond, &qp->lock.mutex);
}
pthread_mutex_unlock(&qp->lock.mutex);
qdb_Lock;
if ((qp->lock.waiting) || (ok == ETIMEDOUT)) {
*sts = QCOM__TMO;
qp->lock.waiting = FALSE;
} else {
signal = TRUE;
}
return signal;
}
#endif
pwr_tBoolean
qos_WaitQue (
pwr_tStatus *status,
qdb_sQue *qp,
int tmo
)
{
struct timespec ts;
int remaining_time = tmo;
int delta = 100;
ts.tv_sec = 0;
qdb_AssumeLocked;
qp->lock.waiting = TRUE;
qdb_Unlock;
if ( tmo == -1) {
ts.tv_nsec = delta * 1000000;
while (1) {
if ( !qp->lock.waiting) {
*status = QCOM__SUCCESS;
qdb_Lock;
return 1;
}
nanosleep( &ts, 0);
}
}
else {
while (1) {
if ( !qp->lock.waiting) {
*status = QCOM__SUCCESS;
qdb_Lock;
return 1;
}
if ( !remaining_time) {
/* Timeout */
*status = QCOM__TMO;
qdb_Lock;
return 0;
}
if ( remaining_time <= delta) {
ts.tv_nsec = remaining_time * 1000000;
remaining_time = 0;
}
else {
ts.tv_nsec = delta * 1000000;
remaining_time -= delta;
}
nanosleep( &ts, 0);
}
}
return 0;
}
#if 0
pwr_tStatus
qos_SignalQueOld (
pwr_tStatus *status,
qdb_sQue *qp
)
{
union sigval value;
int ok;
pwr_dStatus (sts, status, QCOM__SUCCESS);
qdb_AssumeLocked;
if (qp->lock.waiting) {
// value.sival_int = BUILDPID(getpid(), pthread_self());
value.sival_int = getpid();
qp->lock.waiting = FALSE;
ok = sigqueue(qp->lock.pid, qdb_cSigMsg, value);
if (ok == -1) {
*sts = errno_Status(errno);
}
}
return TRUE;
}
#endif
pwr_tStatus
qos_SignalQue (
pwr_tStatus *status,
qdb_sQue *qp
)
{
pwr_dStatus (sts, status, QCOM__SUCCESS);
qp->lock.waiting = FALSE;
return TRUE;
}
#if 0
pwr_tStatus
qos_SignalQue (
pwr_tStatus *status,
qdb_sQue *qp
)
{
pwr_dStatus (sts, status, QCOM__SUCCESS);
qdb_AssumeLocked;
pthread_mutex_lock(&qp->lock.mutex);
qp->lock.waiting = FALSE;
pthread_cond_signal(&qp->lock.cond);
pthread_mutex_unlock(&qp->lock.mutex);
return TRUE;
}
#endif
qdb_sQlock *
qos_CreateQlock (
pwr_tStatus *sts,
qdb_sQue *qp
)
{
qdb_AssumeLocked;
return &qp->lock;
}
void
qos_DeleteQlock (
pwr_tStatus *sts,
qdb_sQue *qp
)
{
qdb_AssumeLocked;
}
/*
* Proview $Id: rt_semaphore.c,v 1.4 2006-02-01 09:12:17 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* Distribution terms
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the Software), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following
* conditions:
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHOR OF THIS SOFTWARE BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/*-< SEMAPHORE.C >--------------------------------------------------*--------*/
/* POSIX.1b Version 1.0 (c) 1998 GARRET * ? */
/* (POSIX.1b implementation for Linux) * /\| */
/* * / \ */
/* Created: 25-Aug-98 K.A. Knizhnik * / [] \ */
/* Last update: 27-Aug-98 K.A. Knizhnik * GARRET */
/*------------------------------------------------------------------*--------*/
/* Semaphore implementation * */
/*------------------------------------------------------------------*--------*/
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <stdarg.h>
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>
#include "rt_semaphore.h"
#if 0
union semun {
int val;
struct semid_ds *buf;
u_short *array;
};
#endif
sem_t *posix_sem_open(const char *name, int oflag, ...)
{
key_t key = IPC_PRIVATE;
int semid, mode = 0;
struct sembuf sops[2];
sem_t* s;
if (name != NULL) {
int fd = open(name, O_WRONLY|O_CREAT, 0777);
if (fd < 0) {
return(sem_t*)-1;
}
close(fd);
key = ftok(name, 'P');
if (key < 0) {
return(sem_t*)-1;
}
}
if (oflag & O_CREAT) {
int init_value;
va_list ap;
va_start(ap, oflag);
mode = va_arg(ap, int);
init_value = va_arg(ap, unsigned int);
if (init_value < 0) {
errno = EINVAL;
return(sem_t*)-1;
}
va_end(ap);
sops[0].sem_num = 1;
sops[0].sem_op = 1; /* mark sempahore as initialuzed */
sops[0].sem_flg = 0;
sops[1].sem_num = 0;
sops[1].sem_op = init_value;
sops[1].sem_flg = 0;
mode |= IPC_CREAT;
} else {
sops[0].sem_num = 1;
sops[0].sem_op = -1; /* wait until semaphore is initialized */
sops[0].sem_flg = 0;
sops[1].sem_num = 1;
sops[1].sem_op = 1; /* restore initialized flag */
sops[1].sem_flg = 0;
}
if (oflag & O_EXCL) {
mode |= IPC_EXCL;
}
semid = semget(key, 2, mode);
if (semid < 0) {
return(sem_t*)-1;
}
if (semop(semid, sops, 2) != 0) {
return(sem_t*)-1;
}
s = (sem_t*)malloc(sizeof(sem_t));
s->semid = semid;
s->initialized = 1;
s->semkey = key;
return s;
}
int posix_sem_init_shared(sem_t *sem, int key, unsigned int value)
{
int semid;
if (value < 0) {
errno = EINVAL;
return -1;
}
sem->semkey = key;
sem->initialized = 0;
sem->semid = -1;
semid = semget(sem->semkey, 1, IPC_CREAT|IPC_EXCL|0777);
if (semid < 0) {
return -1;
}
sem->initialized = 1;
sem->semid = semid;
if (value != 0) {
struct sembuf sops[1];
sops[0].sem_num = 0;
sops[0].sem_op = value;
sops[0].sem_flg = 0;
if (semop(semid, sops, 1) != 0) {
return -1;
}
}
return 0;
}
int posix_sem_init(sem_t *sem, int pshared, unsigned int value)
{
int semid;
if (value < 0) {
errno = EINVAL;
return -1;
}
sem->semkey = pshared ? (long)sem : IPC_PRIVATE;
sem->initialized = 0;
sem->semid = -1;
semid = semget(sem->semkey, 1, IPC_CREAT|0777);
if (semid < 0) {
return -1;
}
sem->initialized = 1; // Initialize, so we don't need the hash table. ML
sem->semid = semid;
if (value != 0) {
struct sembuf sops[1];
sops[0].sem_num = 0;
sops[0].sem_op = value;
sops[0].sem_flg = 0;
if (semop(semid, sops, 1) != 0) {
return -1;
}
}
return 0;
}
int posix_sem_post(sem_t *sem)
{
static struct sembuf sops[] = {{0, 1, SEM_UNDO}};
return semop(sem->semid, sops, 1);
}
int posix_sem_getvalue(sem_t *sem, int *sval)
{
int result;
if (sval == NULL) {
errno = EINVAL;
return -1;
}
result = semctl(sem->semid, 0, GETVAL, (union semun)0);
if (result == -1) {
return -1;
}
*sval = result;
return 0;
}
int posix_sem_wait(sem_t *sem)
{
static struct sembuf sops[] = {{0, -1, SEM_UNDO}};
return semop(sem->semid, sops, 1);
}
int posix_sem_trywait(sem_t *sem)
{
static struct sembuf sops[] = {{0, -1, SEM_UNDO|IPC_NOWAIT}};
return semop(sem->semid, sops, 1);
}
int posix_sem_unlink(const char *name)
{
int key, semid;
key = ftok(name, 'P');
if (key < 0) {
return -1;
}
semid = semget(key, 1, 0);
if (semid < 0) {
return -1;
}
unlink(name);
return semctl(semid, 0, IPC_RMID, (union semun)0);
}
int posix_sem_close(sem_t *sem)
{
free(sem);
return 0;
}
int posix_sem_destroy(sem_t* sem)
{
return semctl(sem->semid, 0, IPC_RMID, (union semun)0);
}
/*
* Proview $Id: rt_semaphore.h,v 1.2 2005-09-01 14:57:57 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* rt_sect.h */
/*-< SEMAPHORE.H >--------------------------------------------------*--------*/
/* POSIX.1b Version 1.0 (c) 1998 GARRET * ? */
/* (POSIX.1b implementation for Linux) * /\| */
/* * / \ */
/* Created: 25-Aug-98 K.A. Knizhnik * / [] \ */
/* Last update: 27-Aug-98 K.A. Knizhnik * GARRET */
/*------------------------------------------------------------------*--------*/
/* Semaphore interface * */
/*------------------------------------------------------------------*--------*/
#ifndef rt_semaphore_h
#define rt_semaphore_h
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
long semkey;
int semid;
int initialized;
} sem_t;
// Not POSIX. The caller generates the key
int posix_sem_init_shared(sem_t *sem, int key, unsigned int value);
int posix_sem_init(sem_t *sem, int pshared, unsigned int value);
sem_t *posix_sem_open(const char *name, int oflag, ...);
int posix_sem_post(sem_t *sem);
int posix_sem_getvalue(sem_t *sem, int *sval);
int posix_sem_wait(sem_t *sem);
int posix_sem_trywait(sem_t *sem);
int posix_sem_unlink(const char *name);
int posix_sem_close(sem_t *sem);
int posix_sem_destroy(sem_t *sem);
#ifdef __cplusplus
}
#endif
#endif
# exe_generic.mk -- generic makefile for executables
#
# PROVIEW/R
# Copyright (C) 1996 by Comator Process AB.
#
# To build an executable.
#
ifndef exe_generic_mk
exe_generic_mk := 1
ifndef variables_mk
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/variables.mk
endif
ifndef variables_mk
include $(pwre_kroot)/tools/bld/src/$(os_name)/variables.mk
endif
ifndef rules_mk
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/rules.mk
endif
ifndef rules_mk
include $(pwre_kroot)/tools/bld/src/$(os_name)/rules.mk
endif
ifndef link_rule_mk
link_rule := link_rule.mk
-include $(link_rule)
endif
ifndef link_rule_mk
link_rule := ../link_rule.mk
-include $(link_rule)
endif
ifndef link_rule_mk
link_rule := $(pwre_kroot)/tools/bld/src/$(os_name)/link_rule_generic.mk
include $(link_rule)
endif
vpath %.c $(hw_source):$(os_source):$(co_source)
vpath %.cpp $(hw_source):$(os_source):$(co_source)
vpath %.l $(hw_source):$(os_source):$(co_source)
vpath %.h $(hw_source):$(os_source):$(co_source)
vpath %.hpp $(hw_source):$(os_source):$(co_source)
source_dirs = $(hw_source) $(os_source) $(co_source)
c_sources := $(sort \
$(foreach file, \
$(foreach dir, \
$(source_dirs), \
$(wildcard $(dir)/*.c $(dir)/*.cpp) \
), $(notdir $(file)) \
) \
)
l_sources := $(sort \
$(foreach file, \
$(foreach dir, \
$(source_dirs), \
$(wildcard $(dir)/*.l) \
), $(notdir $(file)) \
) \
)
h_includes := $(sort \
$(foreach file, \
$(foreach dir, \
$(source_dirs), \
$(wildcard $(dir)/$(comp_name)*.h) \
), $(notdir $(file)) \
) \
)
hpp_includes := $(sort \
$(foreach file, \
$(foreach dir, \
$(source_dirs), \
$(wildcard $(dir)/$(comp_name)*.hpp) \
), $(notdir $(file)) \
) \
)
exe_name := $(comp_name)
exe_source := $(filter $(exe_name).%, $(c_sources))
c_sources := $(filter-out $(exe_source), $(c_sources))
export_exe := $(exe_dir)/$(exe_name)$(exe_ext)
#export_obj := $(obj_dir)/$(exe_name)$(obj_ext)
export_obj := $(bld_dir)/$(exe_name)$(obj_ext)
export_includes := $(addprefix $(inc_dir)/,$(h_includes) $(hpp_includes))
l_targets := $(addprefix $(bld_dir)/,$(basename $(l_sources)))
l_targets := $(addsuffix $(c_ext),$(l_targets))
objects := $(addprefix $(bld_dir)/,$(basename $(c_sources)))
objects += $(addprefix $(bld_dir)/,$(basename $(l_sources)))
objects := $(strip $(addsuffix $(obj_ext),$(objects)))
lc_src_dep := $(objects:$(obj_ext)=$(d_ext))
exe_src_dep := $(obj_dir)/$(exe_name)$(d_ext)
source_dependencies := $(lc_src_dep) $(exe_src_dep)
link_dependencies := $(bld_dir)/$(exe_name)$(d_ld_ext)
clean_h_includes := $(patsubst %.h,clean_%.h, $(h_includes))
clean_hpp_includes := $(patsubst %.hpp,clean_%.hpp, $(hpp_includes))
.PHONY : all init copy lib exe clean realclean \
dirs $(clean_includes) clean_bld clean_dirs\
clean_exe
all : init copy lib exe
init : dirs
copy : $(export_includes)
lib :
exe : $(l_targets) $(objects) $(export_obj) $(export_exe)
dirs : $(bld_dir)$(dir_ext)
$(bld_dir)$(dir_ext) :
@ $(mkdir) $(mkdirflags) $(basename $@)
clean : clean_exe clean_bld
realclean : clean $(clean_h_includes) $(clean_hpp_includes) clean_dirs
$(export_exe) : $(link_rule) $(export_obj) $(objects)
@ $(log_link_exe)
@ $(link)
clean_exe :
@ if [ -e $(export_exe) ]; then \
$(rm) $(export_exe); \
fi
@ if [ -e $(export_obj) ]; then \
$(rm) $(export_obj); \
fi
clean_bld :
@ $(rm) $(rmflags) $(bld_dir)/*
clean_dirs :
@ $(rm) $(rmflags) $(bld_dir)
$(clean_h_includes) : clean_%.h : %.h
@ $(rm) $(rmflags) $(inc_dir)/$*.h
$(clean_hpp_includes) : clean_%.hpp : %.hpp
@ $(rm) $(rmflags) $(inc_dir)/$*.hpp
-include $(source_dependencies)
-include $(link_dependencies)
endif
# variables.mk -- variables common to all makefiles
#
# PROVIEW/R
# Copyright (C) 1996 by Comator Process AB.
#
# <Description>
#
ifndef variables_mk
variables_mk := 1
release_root := $(pwre_broot)/$(os_name)/$(hw_name)
module_root := $(release_root)/$(pwre_bmodule)
export_type := $(export_type)
exe_dir := $(module_root)/exe
lib_dir := $(module_root)/lib
obj_dir := $(module_root)/obj
cnf_dir := $(module_root)/cnf
db_dir := $(module_root)/db
inc_dir := $(module_root)/inc
lis_dir := $(module_root)/lis
kit_dir := $(module_root)/kit
src_dir := $(module_root)/src
load_dir := $(module_root)/load
doc_dir := $(release_root)/exp/doc
elib_dir := $(release_root)/exp/lib
einc_dir := $(release_root)/exp/inc
eobj_dir := $(release_root)/exp/obj
eexe_dir := $(release_root)/exp/exe
bld_dir := $(release_root)/bld/$(type_name)/$(comp_name)
tmp_dir := $(release_root)/tmp
c_ext := .c
d_ext := .d
d_ld_ext:= .d_ld
h_ext := .h
lib_ext := .a
obj_ext := .o
map_ext := .map
# Full names of source directories
fhw_source := $(pwre_sroot)/$(type_name)/$(comp_name)/src/$(os_name)/$(hw_name)
fos_source := $(pwre_sroot)/$(type_name)/$(comp_name)/src/$(os_name)
fco_source := $(pwre_sroot)/$(type_name)/$(comp_name)/src
# Relative names of source directories
hw_source := .
os_source := ../
co_source := ../../
ifndef pwre_lang
lang_dir := $(exe_dir)
lang_bld_dir := $(bld_dir)
else
ifeq ($(pwre_lang),en_us)
lang := en
endif
ifeq ($(pwre_lang),sv_se)
lang := sw
pwr_lang := 1
endif
lang_hw_source := $(pwre_sroot)/$(type_name)/$(comp_name)/$(pwre_lang)/$(os_name)/$(hw_name)
lang_os_source := $(pwre_sroot)/$(type_name)/$(comp_name)/$(pwre_lang)/$(os_name)
lang_co_source := $(pwre_sroot)/$(type_name)/$(comp_name)/$(pwre_lang)
lang_dir := $(exe_dir)/$(pwre_lang)
lang_bld_dir := $(bld_dir)/$(pwre_lang)
endif
source = $<
sname = $(notdir $(basename $<))
ssuff = $(suffix $<)
sdir = $(dir $<)/
target = $@
tname = $(notdir $(basename $@))
tsuff = $(suffix $@)
tdir = $(dir $@)/
libobj = $(bld_dir)/$*$(obj_ext)
cobj = -c -o $(target)
clibobj = -c -o $(libobj)
rt_msg_objs := $(obj_dir)/pwr_msg_co.o $(obj_dir)/pwr_msg_rt.o
rs_msg_objs := $(obj_dir)/pwr_msg_rs.o
wb_msg_objs := $(obj_dir)/pwr_msg_wb.o $(obj_dir)/pwr_msg_ge.o $(obj_dir)/pwr_msg_flow.o
rt_msg_eobjs := $(eobj_dir)/pwr_msg_co.o $(eobj_dir)/pwr_msg_rt.o
rs_msg_eobjs := $(eobj_dir)/pwr_msg_rs.o
wb_msg_eobjs := $(eobj_dir)/pwr_msg_wb.o $(eobj_dir)/pwr_msg_ge.o $(eobj_dir)/pwr_msg_flow.o
# Configuration
#ifeq ($(pwre_conf_mysql),1)
# cmysql := -DPWRE_CONF_MYSQL=1
# linkmysql := -L/usr/lib/mysql -lmysqlclient
#else
# cmysql :=
# linkmysql :=
#endif
#ifeq ($(pwre_conf_gtk),1)
# cgtk := -DPWRE_CONF_GTK=1
# linkgtk := `pkg-config --libs gtk+-2.0`
#else
# cgtk :=
# linkgtk :=
#endif
#ifeq ($(pwre_conf_libusb),1)
# clibusb := -DPWRE_CONF_LIBUSB=1
# linklibusb := -lusb-1.0
#else
# clibusb :=
# linklibusb :=
#endif
log_done =
#csetos := -DOS_LINUX=1 -DOS=linux -D_LINUX -DHW_X86=1 -DHW=x86
#cinc := -I$(inc_dir) -I$(einc_dir) -I$(hw_source) -I$(os_source) -I$(co_source) -I/usr/X11R6/include -I$(jdk)/include -I$(jdk)/include/linux \
`pkg-config --cflags gtk+-2.0` -DPREFIX=\"/usr/local\" -DSYSCONFDIR=\"/etc\" -DDATADIR=\"/usr/share\" -DLIBDIR=\"/usr/lib\" $(cmysql) $(cgtk) $(clibusb)
csetos := $(pwre_conf_cc_define)
cinc := -I$(inc_dir) -I$(einc_dir) -I$(hw_source) -I$(os_source) -I$(co_source) $(pwre_conf_incdir) $(pwre_conf_incdirgtk)
rm := rm
cp := cp
cpflags :=
arflags := r
obj := -c -o $(target)
lex := flex
javac := javac
ifdef pwre_ar
ar := $(pwre_ar)
else
ar := ar
endif
ifdef pwre_cc
cc := $(pwre_cc)
ld := $(pwre_cc)
else
cc := gcc
ld := gcc
endif
ifdef pwre_cxx
cxx := $(pwre_cxx)
ldxx := $(pwre_cxx)
else
cxx := g++
ldxx := g++
endif
ifdef pwre_host_exe
tools_msg2cmsg := $(pwre_host_exe)/tools_msg2cmsg
tools_cmsg2c := $(pwre_host_exe)/tools_cmsg2c
tools_pdrgen := $(pwre_host_exe)/tools_pdrgen
wb_rtt := $(pwre_host_exe)/wb_rtt
co_convert := $(pwre_host_exe)/co_convert
co_merge := $(pwre_host_exe)/co_merge
else
tools_msg2cmsg := $(eexe_dir)/tools_msg2cmsg
tools_cmsg2c := $(eexe_dir)/tools_cmsg2c
tools_pdrgen := $(eexe_dir)/tools_pdrgen
wb_rtt := $(eexe_dir)/wb_rtt
co_convert := $(eexe_dir)/co_convert
co_merge := $(eexe_dir)/co_merge
endif
#docbook-related, added by jonas_h 2006-04-nn
#xsltproc := xsltproc
#fop := fop
#above is a symlink from /usr/local/bin/fop -> /usr/local/fop-0.92beta/fop
#xsltproc_args := --xinclude
#chunk_args_en_us = --stringparam root.filename $(basename $(notdir $(target))) --stringparam base.dir $(doc_dir)/en_us/
#chunk_args_sv_se = --stringparam root.filename $(basename $(notdir $(target))) --stringparam base.dir $(doc_dir)/sv_se/
#pwr_stylesheetdir = $(pwre_sroot)/doc/man/src
#docbook_stylesheetdir = /usr/local/share/xml/docbook/stylesheet/snapshot
#html_xsl = $(pwr_stylesheetdir)/pwrxsl-html.xsl
#chunk_xsl = $(pwr_stylesheetdir)/pwrxsl-chunk.xsl
#fo_xsl = $(pwr_stylesheetdir)/pwrxsl-fo.xsl
#end of
#list = $(to-vms $(lis_dir)/$(sname)$(lis_ext))
map = $(bld_dir)/$(tname)$(map_ext)
mkdir := mkdir
# Set to /buildversion for frozen dbs versions
wblflags :=
ifeq ($(pwre_btype),rls)
cflags := -c -O3 -D_GNU_SOURCE -DPWR_NDEBUG -D_REENTRANT -fPIC
cxxflags := $(cflags)
linkflags := -O3 -L$(lib_dir)
elinkflags := -O3 -L$(lib_dir) -L$(elib_dir)
explinkflags := -g -L$(elib_dir)
clis = /lis=$(list)
dolist = /lis=$(list)
domap =
else
cflags := -c -g -Wall -D_GNU_SOURCE -D_REENTRANT -fPIC
cxxflags := $(cflags) -Wno-deprecated
mmflags := -Wno-deprecated
linkflags := -g -L$(lib_dir) $(pwre_conf_libdir)
elinkflags := -g -L$(lib_dir) -L$(elib_dir) $(pwre_conf_libdir)
explinkflags := -g -L$(elib_dir) $(pwre_conf_libdir)
dolist = /lis=$(list)
clis :=
domap =
endif
log_h_h = echo "Exporting $<"
log_x_h = echo "Exporting $< to $(notdir $@)"
log_l_obj = echo "Compiling $<"
log_l_lib = echo "Compiling $(notdir $(basename $@))($<)"
#log_c_d = echo "Updating dependencies $<"
log_c_obj = echo "Compiling $<"
log_c_lib = echo "Compiling $(notdir $(basename $@))($<)"
log_x_lib = echo "Compiling $(notdir $(basename $@))($<)"
log_obj_lib = echo "Archiving lasse $(notdir $(basename $@))($(notdir $<))"
log_hlp_hlb = echo "Exporting $(notdir $(basename $@))($<)"
log_sc_lib = echo "Compiling $(notdir $(basename $@))($<)"
log_sc_obj = echo "Compiling $<"
log_uil_uid = echo "Compiling $<"
log_g_m1 = echo "Exporting $<"
log_cld_lib = echo "Compiling $(notdir $(basename $@))($<)"
log_link_exe = echo "Linking $@"
log_wb_load_wb_vers = echo "Exporting $<"
log_xbm_xbm = echo "Exporting $<"
log_frm_frm = echo "Exporting $<"
log_graph_graph = echo "Exporting $<"
log_msg_h = echo "Compiling $<"
log_java_class = echo "Compiling $<"
endif
# lib_generic.mk -- generic makefile for libraries
#
# PROVIEW/R
# Copyright (C) 1996 by Comator Process AB.
#
# To build a library.
#
ifndef jpwr_generic_mk
jpwr_generic_mk := 1
ifndef variables_mk
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/variables.mk
endif
ifndef variables_mk
include $(pwre_kroot)/tools/bld/src/$(os_name)/variables.mk
endif
ifndef rules_mk
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/rules.mk
endif
ifndef rules_mk
include $(pwre_kroot)/tools/bld/src/$(os_name)/rules.mk
endif
vpath %.java $(hw_source):$(os_source):$(co_source)
vpath %.gif $(hw_source):$(os_source):$(co_source)
vpath %.png $(hw_source):$(os_source):$(co_source)
#VPATH = $(hw_source):$(os_source):$(co_source)
source_dirs = $(hw_source) $(os_source) $(co_source)
java_sources := $(sort \
$(foreach file, \
$(foreach dir, \
$(source_dirs), \
$(wildcard $(dir)/*.java) \
), $(notdir $(file)) \
) \
)
gif_sources := $(sort \
$(foreach file, \
$(foreach dir, \
$(source_dirs), \
$(wildcard $(dir)/*.gif) \
), $(notdir $(file)) \
) \
)
gif_exe_sources := $(sort \
$(foreach file, \
$(foreach dir, \
$(source_dirs), \
$(wildcard $(dir)/$(comp_name)_*.gif) \
), $(notdir $(file)) \
) \
)
png_sources := $(sort \
$(foreach file, \
$(foreach dir, \
$(source_dirs), \
$(wildcard $(dir)/*.png) \
), $(notdir $(file)) \
) \
)
png_exe_sources := $(sort \
$(foreach file, \
$(foreach dir, \
$(source_dirs), \
$(wildcard $(dir)/$(comp_name)_*.png) \
), $(notdir $(file)) \
) \
)
jpwr_name := pwr_$(comp_name)
export_lib := $(lib_dir)/$(jpwr_name).jar
java_classes := $(addsuffix .class, $(basename $(local_java_sources)))
gif_objects := $(addprefix $(bld_dir)/, $(gif_sources))
gif_exe_objects := $(addprefix $(exe_dir)/, $(gif_exe_sources))
png_objects := $(addprefix $(bld_dir)/, $(png_sources))
png_exe_objects := $(addprefix $(exe_dir)/, $(png_exe_sources))
java_objects := $(addprefix $(bld_dir)/, $(java_classes))
objects := $(gif_objects) $(gif_exe_objects) $(png_objects) $(png_exe_objects) $(java_objects)
source_dependencies := $(notdir $(basename $(sources)))
source_dependencies := $(addprefix $(bld_dir)/, $(source_dependencies))
source_dependencies := $(addsuffix $(d_ext), $(source_dependencies))
.PHONY : all init copy lib exe clean realclean \
dirs clean_includes \
clean_bld clean_dirs clean_lib
# dirs $(clean_h_includes) $(clean_hpp_includes)
all : init copy lib exe
init : dirs
copy :
lib : $(export_lib)
exe :
dirs : $(bld_dir)$(dir_ext)
$(bld_dir)$(dir_ext) :
@ $(mkdir) $(mkdirflags) $(basename $@)/
clean : clean_bld clean_lib
realclean : clean clean_includes clean_dirs
clean_bld :
@ echo "Cleaning build directory"
@ $(rm) $(rmflags) $(bld_dir)/*
clean_dirs :
@ echo "Removing build directory"
@ $(rm) -r $(rmflags) $(bld_dir)
clean_lib :
@ echo "Removing archive $(notdir $(export_lib))"
@ $(rm) $(rmflags) $(export_lib)
clean_includes : $(clean_h_includes) $(clean_hpp_includes)
$(clean_h_includes) : clean_%.h : %.h
@ echo "Removing h-includes"
@ $(rm) $(rmflags) $(inc_dir)/$*.h
$(clean_hpp_includes) : clean_%.hpp : %.hpp
@ echo "Removing hpp-includes"
@ $(rm) $(rmflags) $(inc_dir)/$*.hpp
$(export_lib) : $(objects)
@ echo "Building archive $(notdir $(export_lib))"
@ if [ -e $(export_lib) ]; then \
$(rm) $(export_lib); \
fi
@ cd $(pwre_broot)/$(pwre_target)/bld; \
echo "Inserting png and gif files"; \
jar cf $(export_lib) jpwr/$(comp_name)/*.gif; \
jar uf $(export_lib) jpwr/$(comp_name)/*.png; \
find jpwr/$(comp_name) -name "*.class" -exec jar uf $(export_lib) {} \;;
# @ jar cvfm $(export_lib) ../../manifest.stub jpwr/$(comp_name)/*.class jpwr/$(comp_name)/*.gif
#-include $(source_dependencies)
endif
# lib_generic.mk -- generic makefile for libraries
#
# PROVIEW/R
# Copyright (C) 1996 by Comator Process AB.
#
# To build a library.
#
ifndef lib_generic_mk
lib_generic_mk := 1
ifndef variables_mk
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/variables.mk
endif
ifndef variables_mk
include $(pwre_kroot)/tools/bld/src/$(os_name)/variables.mk
endif
ifndef rules_mk
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/rules.mk
endif
ifndef rules_mk
include $(pwre_kroot)/tools/bld/src/$(os_name)/rules.mk
endif
source_dirs = $(hw_source) $(os_source) $(co_source)
-include ../../lib_local.mk
-include ../lib_local.mk
-include lib_local.mk
vpath %.h $(hw_source):$(os_source):$(co_source)
vpath %.hpp $(hw_source):$(os_source):$(co_source)
vpath %.c $(hw_source):$(os_source):$(co_source)
vpath %.cpp $(hw_source):$(os_source):$(co_source)
vpath %.x $(hw_source):$(os_source):$(co_source)
vpath %.pdr $(hw_source):$(os_source):$(co_source)
vpath %.java $(hw_source):$(os_source):$(co_source)
vpath %.pwsg $(hw_source):$(os_source):$(co_source)
vpath %.meth $(hw_source):$(os_source):$(co_source)
source_dirs = $(hw_source) $(os_source) $(co_source)
sources := $(sort \
$(foreach file, \
$(foreach dir, \
$(source_dirs), \
$(wildcard $(dir)/$(comp_name)*.c $(dir)/$(comp_name)*.cpp) \
), $(notdir $(file)) \
) \
)
h_includes := $(sort \
$(foreach file, \
$(foreach dir, \
$(source_dirs), \
$(wildcard $(dir)/$(comp_name)*.h) \
), $(notdir $(file)) \
) \
)
hpp_includes := $(sort \
$(foreach file, \
$(foreach dir, \
$(source_dirs), \
$(wildcard $(dir)/$(comp_name)*.hpp) \
), $(notdir $(file)) \
) \
)
xdr_sources := $(sort \
$(foreach file, \
$(foreach dir, \
$(source_dirs), \
$(wildcard $(dir)/$(comp_name)*.x) \
), $(notdir $(file)) \
) \
)
pdr_sources := $(sort \
$(foreach file, \
$(foreach dir, \
$(source_dirs), \
$(wildcard $(dir)/$(comp_name)*.pdr) \
), $(notdir $(file)) \
) \
)
java_sources := $(sort \
$(foreach file, \
$(foreach dir, \
$(source_dirs), \
$(wildcard $(dir)/*.java) \
), $(notdir $(file)) \
) \
)
pwsg_sources := $(sort \
$(foreach file, \
$(foreach dir, \
$(source_dirs), \
$(wildcard $(dir)/*.pwsg) \
), $(notdir $(file)) \
) \
)
meth_sources := $(sort \
$(foreach file, \
$(foreach dir, \
$(source_dirs), \
$(wildcard $(dir)/*.meth) \
), $(notdir $(file)) \
) \
)
xdr_includes := $(addprefix $(inc_dir)/,$(patsubst %.x, %.h, $(xdr_sources)))
xdr_objects := $(patsubst %.x, %_xdr.o, $(xdr_sources))
pdr_includes := $(addprefix $(inc_dir)/,$(patsubst %.pdr, %.h, $(pdr_sources)))
pdr_objects := $(patsubst %.pdr, %_pdr.o, $(pdr_sources))
export_includes := $(addprefix $(inc_dir)/,$(h_includes) $(hpp_includes))
export_includes += $(xdr_includes) $(pdr_includes)
export_pwsg := $(addprefix $(exe_dir)/,$(pwsg_sources))
export_meth := $(addprefix $(inc_dir)/,$(meth_sources))
clean_h_includes := $(patsubst %.h,clean_%.h, $(h_includes))
clean_hpp_includes := $(patsubst %.hpp,clean_%.hpp, $(hpp_includes))
lib_name := libpwr_$(comp_name)
ifneq ($(src_name),src)
lib_name := libpwr_$(comp_name)_$(src_name)
endif
export_lib := $(lib_dir)/$(lib_name)$(lib_ext)
java_classes := $(addsuffix .class, $(basename $(java_sources)))
objects := $(addsuffix $(obj_ext), $(basename $(sources)))
objects += $(xdr_objects) $(pdr_objects)
objects += $(java_classes)
objects := $(addprefix $(bld_dir)/, $(objects))
source_dependencies := $(notdir $(basename $(sources) $(pdr_objects) $(xdr_objects)))
source_dependencies := $(addprefix $(bld_dir)/, $(source_dependencies))
source_dependencies := $(addsuffix $(d_ext), $(source_dependencies))
.PHONY : all init copy lib exe $(l_copy) clean realclean \
dirs clean_includes \
clean_bld clean_dirs clean_lib $(l_clean_copy)
# dirs $(clean_h_includes) $(clean_hpp_includes)
all : init copy lib exe
init : dirs
copy : $(export_includes) $(l_copy) $(export_pwsg) $(export_meth)
lib : $(export_lib)
exe :
echo:
echo $(source_dependencies)
dirs : $(bld_dir)$(dir_ext)
$(bld_dir)$(dir_ext) :
@ $(mkdir) $(mkdirflags) $(basename $@)/
clean : clean_bld clean_lib
clean_copy: $(l_clean_copy)
realclean : clean clean_includes clean_pwsg clean_dirs
clean_bld :
@ echo "Cleaning build directory"
@ $(rm) $(rmflags) $(bld_dir)/*
clean_dirs :
@ echo "Removing build directory"
@ $(rm) -r $(rmflags) $(bld_dir)
clean_lib :
@if [ -e $(export_lib) ]; then \
echo "Removing archive $(notdir $(export_lib))" \
$(rm) $(export_lib); \
fi
clean_includes : $(clean_h_includes) $(clean_hpp_includes)
$(clean_h_includes) : clean_%.h : %.h
@ echo "Removing h-include: $(inc_dir)/$*.h"
@ $(rm) $(rmflags) $(inc_dir)/$*.h
$(clean_hpp_includes) : clean_%.hpp : %.hpp
@ echo "Removing hpp-include: $(inc_dir)/$*.hpp"
@ $(rm) $(rmflags) $(inc_dir)/$*.hpp
$(clean_pwsg) : clean_%.pwsg : %.pwsg
@ echo "Removing pwsg: $(exe_dir)/$*.pwsg"
@ $(rm) $(rmflags) $(exe_dir)/$*.pwsg
$(export_lib) : $(objects)
@ echo "Building archive $(notdir $(export_lib))"
@ if [ "$(objects)" != "" ]; then \
$(ar) -cr $(export_lib) $(objects); \
fi
# @ if [ -e $(export_lib) ]; then \
# $(rm) $(export_lib); \
# fi
-include $(source_dependencies)
endif
ifndef link_rule_mk
link_rule_mk := 1
link = $(ld) $(elinkflags) $(domap) -o $(export_exe) \
$(export_obj) $(objects) $(rt_msg_objs) \
$(pwre_conf_libpwrrt) $(pwre_conf_lib)
endif
# mmi_generic.mk -- generic make file for building mmi components
#
# PROVIEW/R
# Copyright (C) 1996 by Comator Process AB.
#
# <Description>
#
ifndef mmi_generic_mk
mmi_generic_mk := 1
ifndef variables_mk
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/variables.mk
endif
ifndef variables_mk
include $(pwre_kroot)/tools/bld/src/$(os_name)/variables.mk
endif
ifndef rules_mk
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/rules.mk
endif
ifndef rules_mk
include $(pwre_kroot)/tools/bld/src/$(os_name)/rules.mk
endif
vpath %.uil $(hw_source):$(os_source):$(co_source)
vpath %.pwg $(hw_source):$(os_source):$(co_source)
vpath %.pwsg $(hw_source):$(os_source):$(co_source)
vpath %.png $(hw_source):$(os_source):$(co_source)
source_dirs := $(hw_source) $(os_source) $(co_source)
uil_sources := $(sort \
$(foreach file, \
$(foreach dir, \
$(source_dirs), \
$(wildcard $(dir)/$(comp_name)*.uil) \
), $(notdir $(file)) \
) \
)
pwg_c_sources := $(sort \
$(foreach file, \
$(foreach dir, \
$(source_dirs), \
$(wildcard $(dir)/pwr_c_*.pwg) \
), $(notdir $(file)) \
) \
)
pwg_sources := $(sort \
$(foreach file, \
$(foreach dir, \
$(source_dirs), \
$(wildcard $(dir)/$(comp_name)*.pwg) \
), $(notdir $(file)) \
) \
)
pwsg_sources := $(sort \
$(foreach file, \
$(foreach dir, \
$(source_dirs), \
$(wildcard $(dir)/$(comp_name)*.pwsg) \
), $(notdir $(file)) \
) \
)
png_sources := $(sort \
$(foreach file, \
$(foreach dir, \
$(source_dirs), \
$(wildcard $(dir)/*.png) \
), $(notdir $(file)) \
) \
)
export_uid := $(addprefix $(exe_dir)/, $(patsubst %.uil, %.uid, $(uil_sources)))
export_c_pwg := $(addprefix $(exe_dir)/, $(pwg_c_sources))
export_pwg := $(addprefix $(exe_dir)/, $(pwg_sources))
export_pwsg := $(addprefix $(exe_dir)/, $(pwsg_sources))
export_png := $(addprefix $(exe_dir)/, $(png_sources))
$(exe_dir)/%.uid : %.uil
@ $(log_uil_uid)
@ export LANG; uil -o $(target) $(source)
clean_uid := $(patsubst %.uil,clean_%.uid,$(uil_sources))
clean_c_pwg := $(patsubst %.pwg,clean_%.pwg,$(pwg_c_sources))
clean_pwg := $(patsubst %.pwg,clean_%.pwg,$(pwg_sources))
clean_pwsg := $(patsubst %.pwsg,clean_%.pwsg,$(pwsg_sources))
clean_png := $(patsubst %.png,clean_%.png,$(png_sources))
.PHONY : all init copy lib exe clean realclean\
dirs clean_bld clean_dirs $(clean_uid)
all : init copy
init : dirs
copy : $(export_uid) $(export_c_pwg) $(export_pwg) $(export_pwsg) $(export_png)
lib :
exe :
clean : $(clean_uid) $(clean_pwg) $(clean_pwsg) $(clean_png)
realclean : clean
dirs :
$(clean_uid) : clean_%.uid : %.uil
@ echo "Removing uid"
@ $(rm) $(rmflags) $(exe_dir)/$*.uid
$(clean_pwg) : clean_%.pwg : %.pwg
@ echo "Removing pwg"
@ $(rm) $(rmflags) $(exe_dir)/$*.pwg
$(clean_c_pwg) : clean_%.pwg : %.pwg
@ echo "Removing pwg"
@ $(rm) $(rmflags) $(exe_dir)/$*.pwg
$(clean_pwsg) : clean_%.pwsg : %.pwsg
@ echo "Removing pwsg"
@ $(rm) $(rmflags) $(exe_dir)/$*.pwsg
$(clean_png) : clean_%.png : %.png
@ echo "Removing png"
@ $(rm) $(rmflags) $(exe_dir)/$*.png
endif
# msg_generic.mk -- generic makefile for messages
#
# PROVIEW/R
# Copyright (C) 1996 by Comator Process AB.
#
# To build a message file.
#
ifndef msg_generic_mk
msg_generic_mk := 1
ifndef variables_mk
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/variables.mk
endif
ifndef variables_mk
include $(pwre_kroot)/tools/bld/src/$(os_name)/variables.mk
endif
ifndef rules_mk
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/rules.mk
endif
ifndef rules_mk
include $(pwre_kroot)/tools/bld/src/$(os_name)/rules.mk
endif
vpath %.msg $(hw_source):$(os_source):$(co_source)
source_dirs = $(hw_source) $(os_source) $(co_source)
sources := $(sort \
$(foreach file, \
$(foreach dir, \
$(source_dirs), \
$(wildcard $(dir)/$(comp_name)*.msg) \
), $(notdir $(file)) \
) \
)
export_includes := $(addprefix $(inc_dir)/, $(patsubst %.msg, %.h, $(sources)))
clean_includes := $(patsubst %.msg, clean_%.h, $(sources))
cmsgs := $(addprefix $(bld_dir)/,$(basename $(sources)))
cmsgs := $(strip $(addsuffix .cmsg,$(cmsgs)))
export_cmsg = $(obj_dir)/pwr_msg_$(comp_name).cmsg
export_obj = $(obj_dir)/pwr_msg_$(comp_name)$(obj_ext)
.PHONY : all init copy lib exe clean realclean\
dirs $(clean_includes) clean_lib clean_obj clean_dirs
all : init copy lib
init : dirs
copy : $(export_includes) $(export_cmsg)
lib : $(export_obj)
exe :
dirs : $(bld_dir)$(dir_ext)
$(bld_dir)$(dir_ext) :
$(mkdir) $(mkdirflags) $(basename $@)
clean :
realclean : $(clean_includes) clean_obj clean_dirs
$(export_cmsg) : $(cmsgs)
@ echo Creating: obj_dir/$(notdir $@)
@ cat $(cmsgs) > $(export_cmsg)
$(export_obj) : $(export_cmsg)
clean_lib :
@ $(rm) $(rmflags) $(export_lib)
clean_obj :
@ $(rm) $(rmflags) $(export_obj)
$(clean_includes) : clean_%.h : %.msg
@ $(rm) $(rmflags) $(inc_dir)/$*.h
clean_dirs :
@ $(rmdir) $(rmdirflags) $(bld_dir)
endif
# rules.mk -- rules common for all makefiles
#
# PROVIEW/R
# Copyright (C) 1996 by Comator Process AB.
#
# <Description>
#
ifndef rules_mk
rules_mk := 1
ifndef variables_mk
-include $(pwre_sroot)/tools/bld/src/$(os_name)/$(hw_name)/variables.mk
endif
ifndef variables_mk
include $(pwre_sroot)/tools/bld/src/$(os_name)/variables.mk
endif
.SUFFIXES:
$(bld_dir)/%.cmsg $(inc_dir)/%.h: %.msg
@ $(log_msg_h)
@ $(tools_msg2cmsg) $(source) $(bld_dir)/$(tname).cmsg $(inc_dir)/$(tname).h
$(obj_dir)/%.cmsg $(inc_dir)/%.h : %.msg
@ $(log_msg_h)
@ $(tools_msg2cmsg) $(source) $(obj_dir)/$(tname).cmsg $(inc_dir)/$(tname).h
$(obj_dir)/%.o : $(obj_dir)/%.cmsg
@ $(log_cmsg_obj)
@ $(tools_cmsg2c) -b $(comp_name) $(source) $(tmp_dir)/$(sname).c
@ $(cc) $(cflags) $(csetos) $(cinc) $(cobj) $(tmp_dir)/$(sname).c
$(bld_dir)/%.c : %.l
@ $(log_l_obj)
@ $(lex) -o$(bld_dir)/$(sname).c $(source)
%.o : %.c
@ echo "Warning, rule shall normally not be used: %.o : %.c"
ifeq ($(nodep),)
@ $(log_c_d)
@ $(SHELL) -ec '$(cc) -MM $(cinc) $(csetos) $(source) \
| sed '\''s|$(notdir $*)\.o[ ]*|$(bld_dir)/&|g'\'' > $(bld_dir)/$(sname).d'
endif
@ $(log_c_obj)
@ $(cc) $(cflags) $(csetos) $(cinc) $(cobj) $(source)
(%.o) : %.c
@ echo "Error, rule shall not be used: (%.o) : %.c"
$(bld_dir)/%.o : %.c
ifeq ($(nodep),)
@ $(log_c_d)
@ $(SHELL) -ec '$(cc) -MM $(cinc) $(csetos) $(source) \
| sed '\''s|$*\.o[ ]*|$(bld_dir)/&|g'\'' > $(bld_dir)/$(sname).d'
endif
@ $(log_c_obj)
@ $(cc) $(cflags) $(csetos) $(cinc) $(cobj) $(source)
$(bld_dir)/%.o : $(tmp_dir)/%.c
ifeq ($(nodep),)
@ $(log_c_d)
@ $(SHELL) -ec '$(cc) -MM $(cinc) $(csetos) $(source) \
| sed '\''s|$*\.o[ ]*|$(bld_dir)/&|g'\'' > $(bld_dir)/$(sname).d'
endif
@ $(log_c_obj)
@ $(cc) $(cflags) $(csetos) $(cinc) $(cobj) $(source)
$(obj_dir)/%.o : %.c
ifeq ($(nodep),)
@ $(log_c_d)
@ $(SHELL) -ec '$(cc) -MM $(cinc) $(csetos) $(source) \
| sed '\''s|$*\.o[ ]*|$(obj_dir)/&|g'\'' > $(obj_dir)/$(sname).d'
endif
@ $(log_c_obj)
@ $(cc) $(cflags) $(csetos) $(cinc) $(cobj) $(source)
%.o : %.cpp
@ echo "Error, rule shall not be used: %.o : %.cpp"
(%.o) : %.cpp
@ echo "Error, rule shall not be used: (%.o) : %.cpp"
$(bld_dir)/%.o : %.cpp
ifeq ($(nodep),)
@ $(log_c_d)
@ $(SHELL) -ec '$(cxx) -MM $(csetos) $(mmflags) $(cinc) $(source) \
| sed '\''s|$*\.o[ ]*|$(bld_dir)/&|g'\'' > $(bld_dir)/$(sname).d'
endif
@ $(log_c_obj)
@ $(cxx) $(cxxflags) $(csetos) $(cinc) $(cobj) $(source)
$(bld_dir)/%.o : $(tmp_dir)/%.cpp
ifeq ($(nodep),)
@ $(log_c_d)
@ $(SHELL) -ec '$(cxx) -MM $(cinc) $(csetos) $(mmflags) $(source) \
| sed '\''s|$*\.o[ ]*|$(bld_dir)/&|g'\'' > $(bld_dir)/$(sname).d'
endif
@ $(log_c_obj)
@ $(cxx) $(cxxflags) $(csetos) $(cinc) $(cobj) $(source)
$(obj_dir)/%.o : %.cpp
ifeq ($(nodep),)
@ $(log_c_d)
@ $(SHELL) -ec '$(cxx) -MM $(cinc) $(csetos) $(mmflags) $(source) \
| sed '\''s|$*\.o[ ]*|$(obj_dir)/&|g'\'' > $(obj_dir)/$(sname).d'
endif
@ $(log_c_obj)
@ $(cxx) $(cxxflags) $(csetos) $(cinc) $(cobj) $(source)
$(inc_dir)/%.h : %.x
@ $(log_x_h)
@ if [ -e $(target) ]; then \
$(rm) $(target); \
fi
@ rpcgen -h -o $(target) $(source)
$(bld_dir)/%_xdr.o : %.x
@ $(log_x_lib)
@ rpcgen -c -o $(bld_dir)/$(sname)_xdr.t $(source)
@ sed 's/\(#include "\)\(.*$(sname)[^"]*\)/\1$(sname).h/' $(bld_dir)/$(sname)_xdr.t \
| grep -v "register int32_t \*buf\;"> $(bld_dir)/$(sname)_xdr.c
@ rm $(bld_dir)/$(sname)_xdr.t
ifeq ($(nodep),)
@ $(SHELL) -ec '$(cc) -MM $(cinc) $(csetos) $(bld_dir)/$(sname)_xdr.c \
| sed '\''s|$*_xdr\.o[ ]*|$(bld_dir)/&|g'\'' \
| sed '\''s|$(bld_dir)/$(sname)_xdr.c||'\'' > $(bld_dir)/$(sname)_xdr.d'
endif
@ $(cc) $(cflags) $(csetos) $(cinc) -c -o $(bld_dir)/$(sname)_xdr.o $(bld_dir)/$(sname)_xdr.c
@ mv $(bld_dir)/$(sname)_xdr.c $(bld_dir)/$(sname)_xdr_compiled.c
$(inc_dir)/%.h : %.pdr
@ $(log_x_h)
@ if [ -e $(target) ]; then \
$(rm) $(target); \
fi
@ $(tools_pdrgen) -h -o $(target) $(source)
$(bld_dir)/%_pdr.o : %.pdr
@ $(log_x_lib)
@ $(tools_pdrgen) -c -o $(bld_dir)/$(sname)_pdr.c $(source)
ifeq ($(nodep),)
@ $(SHELL) -ec '$(cc) -MM $(cinc) $(csetos) $(bld_dir)/$(sname)_pdr.c \
| sed '\''s|$*_pdr\.o[ ]*|$(bld_dir)/&|g'\'' \
| sed '\''s|$(bld_dir)/$(sname)_pdr.c||'\'' > $(bld_dir)/$(sname)_pdr.d'
endif
@ $(cc) $(cflags) $(csetos) $(cinc) -c -o $(bld_dir)/$(sname)_pdr.o $(bld_dir)/$(sname)_pdr.c
@ mv $(bld_dir)/$(sname)_pdr.c $(bld_dir)/$(sname)_pdr_compiled.c
(%.o) : %.o
@ echo "Error, rule shall not be used: (%.o) : %.o"
$(inc_dir)/%.h : %.h
@ $(log_h_h)
@ $(cp) $(cpflags) $(source) $(target)
@ chmod u+w $(target)
$(inc_dir)/%.hpp : %.hpp
@ $(log_h_h)
@ $(cp) $(cpflags) $(source) $(target)
@ chmod u+w $(target)
%.class : %.java
@ echo "Warning, rule shall not be used: %.class : %.java"
$(bld_dir)/%.class : %.java
@ $(log_java_class)
@ $(javac) -encoding Latin1 -d $(pwre_broot)/$(pwre_target)/bld $(source)
# @ $(javac) -Xlint:unchecked,deprecation -d $(pwre_broot)/$(pwre_target)/bld $(source)
$(bld_dir)/%.gif : %.gif
@ $(log_h_h)
@ $(cp) $(cpflags) $(source) $(target)
$(exe_dir)/%.gif : %.gif
@ $(log_h_h)
@ $(cp) $(cpflags) $(source) $(target)
$(doc_dir)/orm/%.gif : %.gif
@ $(log_h_h)
@ $(cp) $(cpflags) $(source) $(target)
$(doc_dir)/%.gif : %.gif
@ $(log_h_h)
@ $(cp) $(cpflags) $(source) $(target)
$(doc_dir)/sv_se/%.gif : %.gif
@ $(log_h_h)
@ $(cp) $(cpflags) $(source) $(target)
$(cnf_dir)/%.wb_vers : %.wb_load
@ $(log_wb_load_wb_vers)
@ wb_load $(source) $(lis_dir)/$(tname).wb_list
@ $(pwre_sroot)/tools/com/src/$(os_name)/$(hw_name)/pwr_show_version.sh $(source) $(target)
$(exe_dir)/%.pwsg : %.pwsg
@ $(log_h_h)
@ $(cp) $(cpflags) $(source) $(target)
$(exe_dir)/%.pwg : %.pwg
@ $(log_h_h)
@ $(cp) $(cpflags) $(source) $(target)
$(bld_dir)/%.png : %.png
@ $(log_h_h)
@ $(cp) $(cpflags) $(source) $(target)
$(exe_dir)/%.png : %.png
@ $(log_h_h)
@ $(cp) $(cpflags) $(source) $(target)
$(exe_dir)/%.html : ../../%.html
@ $(log_h_h)
@ $(cp) $(cpflags) $(source) $(target)
$(doc_dir)/%.html : ../../%.html
@ $(log_h_h)
@ $(cp) $(cpflags) $(source) $(target)
$(inc_dir)/%.meth : %.meth
@ $(log_h_h)
@ $(cp) $(cpflags) $(source) $(target)
endif
# wbl_generic.mk -- generic make file for building wbl components
#
# PROVIEW/R
# Copyright (C) 1996 by Comator Process AB.
#
# <Description>
#
ifndef wbl_generic_mk
wbl_generic_mk := 1
ifndef variables_mk
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/variables.mk
endif
ifndef variables_mk
include $(pwre_kroot)/tools/bld/src/$(os_name)/variables.mk
endif
ifndef rules_mk
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/rules.mk
endif
ifndef rules_mk
include $(pwre_kroot)/tools/bld/src/$(os_name)/rules.mk
endif
vpath %.wb_load $(hw_source):$(os_source):$(co_source)
source_dirs := $(hw_source) $(os_source) $(co_source)
wblsources := $(sort \
$(foreach file, \
$(foreach dir, \
$(source_dirs), \
$(wildcard $(dir)/*.wb_load) \
), $(notdir $(file)) \
) \
)
flwsources := $(sort \
$(foreach file, \
$(foreach dir, \
$(source_dirs), \
$(wildcard $(dir)/*.flw) \
), $(notdir $(file)) \
) \
)
pdfsources := $(sort \
$(foreach file, \
$(foreach dir, \
$(source_dirs), \
$(wildcard $(dir)/*.pdf) \
), $(notdir $(file)) \
) \
)
wbl_sources := $(filter %.wb_load,$(wblsources))
flw_sources := $(filter %.flw,$(flwsources))
pdf_sources := $(filter %.pdf,$(pdfsources))
export_wbl := $(addprefix $(load_dir)/, $(patsubst %.wb_load, %.dbs, $(wbl_sources)))
export_flw := $(patsubst %.flw,$(load_dir)/%.flw,$(flw_sources))
export_pdf_en_us := $(patsubst %.pdf,$(doc_dir)/en_us/orm/%.pdf,$(pdf_sources))
export_pdf_sv_se := $(patsubst %.pdf,$(doc_dir)/sv_se/orm/%.pdf,$(pdf_sources))
export_wbl_dbs := $(patsubst %.wb_load,$(load_dir)/%.dbs,$(wbl_sources))
export_wbl_h := $(patsubst %.wb_load,$(inc_dir)/pwr_%classes.h,$(wbl_sources))
export_wbl_hpp := $(patsubst %.wb_load,$(inc_dir)/pwr_%classes.hpp,$(wbl_sources))
export_wbl_xtthelp_en_us := $(patsubst %.wb_load,$(exe_dir)/en_us/%_xtthelp.dat,$(wbl_sources))
export_wbl_xtthelp_sv_se := $(patsubst %.wb_load,$(exe_dir)/sv_se/%_xtthelp.dat,$(wbl_sources))
export_wbl_html_en_us := $(patsubst %.wb_load,$(doc_dir)/en_us/orm/%_allclasses.html,$(wbl_sources))
export_wbl_html_sv_se := $(patsubst %.wb_load,$(doc_dir)/sv_se/orm/%_allclasses.html,$(wbl_sources))
export_wbl_ps_en_us := $(patsubst %.wb_load,$(doc_dir)/en_us/%.ps,$(wbl_sources))
export_wbl_ps_sv_se := $(patsubst %.wb_load,$(doc_dir)/sv_se/%.ps,$(wbl_sources))
clean_dbs := $(patsubst %.wb_load,clean_%.dbs,$(wbl_sources))
clean_h := $(patsubst %.wb_load,clean_%.h,$(wbl_sources))
clean_hpp := $(patsubst %.wb_load,clean_%.hpp,$(wbl_sources))
clean_xtthelp_sv_se := $(patsubst %.wb_load,clean_%_sv_se.xtthelp,$(wbl_sources))
clean_xtthelp_en_us := $(patsubst %.wb_load,clean_%_en_us.xtthelp,$(wbl_sources))
clean_html_sv_se := $(patsubst %.wb_load,clean_%_sv_se.html,$(wbl_sources))
clean_html_en_us := $(patsubst %.wb_load,clean_%_en_us.html,$(wbl_sources))
clean_ps_sv_se := $(patsubst %.wb_load,clean_%_sv_se.ps,$(wbl_sources))
clean_ps_en_us := $(patsubst %.wb_load,clean_%_en_us.ps,$(wbl_sources))
.SUFFIXES:
$(load_dir)/%.dbs : ../../%.wb_load
@ echo "Generating loadfile for $(source)"
@ export pwr_load=$(pwr_eload);\
wb_cmd -q -i create snapshot $(wblflags) /file=\"$(source)\"/out=\"$(target)\"
@ chmod a+w $(target)
$(inc_dir)/pwr_%classes.h : ../../%.wb_load
@ echo "Generating struct files for $(source) classes..."
@ $(co_convert) -so -d $(inc_dir) "$(source)"
$(inc_dir)/pwr_%classes.hpp : ../../%.wb_load
@ echo "Generating hpp files for $(source) classes..."
@ $(co_convert) -po -d $(inc_dir) "$(source)"
$(doc_dir)/en_us/orm/%.pdf : ../../%.pdf
@ echo "Copy en_us $(source)"
@ $(cp) $(cpflags) $(source) $(target)
$(doc_dir)/sv_se/orm/%.pdf : ../../%.pdf
@ echo "Copy sv_se $(source)"
@ $(cp) $(cpflags) $(source) $(target)
$(doc_dir)/en_us/orm/%_allclasses.html : ../../%.wb_load
@ echo "Generating html files for $(source) classes en_us..."
@ $(co_convert) -w -d $(doc_dir)/en_us/orm -g $(pwre_sroot)/wbl/mcomp/src/cnv_setup.dat "$(source)"
@ $(co_convert) -c -d $(doc_dir)/en_us/orm $(inc_dir)/pwr_$(pwre_module)classes.h
@ $(co_convert) -c -d $(doc_dir)/en_us/orm $(inc_dir)/pwr_$(pwre_module)classes.hpp
@ $(co_convert) -k -d $(doc_dir)/en_us/orm -l en_us
$(doc_dir)/sv_se/orm/%_allclasses.html : ../../%.wb_load
@ echo "Generating html files for $(source) classes sv_se..."
@ $(co_convert) -w -l sv_se -d $(doc_dir)/sv_se/orm -g $(pwre_sroot)/wbl/mcomp/src/cnv_setup.dat "$(source)"
@ $(co_convert) -c -d $(doc_dir)/sv_se/orm $(inc_dir)/pwr_$(pwre_module)classes.h
@ $(co_convert) -c -d $(doc_dir)/sv_se/orm $(inc_dir)/pwr_$(pwre_module)classes.hpp
@ $(co_convert) -k -d $(doc_dir)/sv_se/orm -l sv_se
$(doc_dir)/en_us/%.ps : ../../%.wb_load
@ echo "Generating postscript file for $(source) classes en_us..."
@ $(co_convert) -q -l en_us -d $(doc_dir)/en_us "$(source)"
$(doc_dir)/sv_se/%.ps : ../../%.wb_load
@ echo "Generating postscript file for $(source) classes sv_se..."
@ $(co_convert) -q -l sv_se -d $(doc_dir)/sv_se "$(source)"
$(exe_dir)/en_us/%_xtthelp.dat : ../../%.wb_load
@ echo "Generating xtt help files for $(source) classes en_us"
@ $(co_convert) -x -d $(exe_dir)/en_us "$(source)"
$(exe_dir)/sv_se/%_xtthelp.dat : ../../%.wb_load
@ echo "Generating xtt help files for $(source) classes sv_se"
@ $(co_convert) -x -l sv_se -d $(exe_dir)/sv_se "$(source)"
$(exe_dir)/%.pwg : ../../%.pwg
@ $(log_h_h)
@ $(cp) $(cpflags) $(source) $(target)
$(exe_dir)/%.pwsg : ../../%.pwsg
@ $(log_h_h)
@ $(cp) $(cpflags) $(source) $(target)
$(load_dir)/%.flw : ../../%.flw
@ $(log_h_h)
@ $(cp) $(cpflags) $(source) $(target)
.PHONY : all init copy lib exe clean realclean\
$(clean_wbl)
all : init copy exe
init :
lib : $(export_wbl_dbs)
copy : $(export_wbl_h) \
$(export_wbl_hpp) \
$(export_pwg) \
$(export_pwsg) \
$(export_flw)
exe: $(export_wbl_xtthelp_en_us) \
$(export_wbl_xtthelp_sv_se) \
$(export_wbl_html_en_us) \
$(export_wbl_html_sv_se) \
$(export_wbl_ps_en_us) \
$(export_wbl_ps_sv_se) \
$(export_pdf_en_us) \
$(export_pdf_sv_se)
clean : \
$(clean_xtthelp_sv_se) $(clean_xtthelp_en_us) \
$(clean_html_sv_se) $(clean_html_en_us) \
$(clean_ps_sv_se) $(clean_ps_en_us)
realclean : clean \
$(clean_dbs) \
$(clean_h) \
$(clean_hpp) \
$(clean_dbs) : clean_%.dbs : $(load_dir)/%.dbs
@ echo "rm $(source)"
@ if [ -e $(source) ]; then \
$(rm) $(rmflags) $(source); \
fi
$(clean_h) : clean_%.h : $(inc_dir)/pwr_%classes.h
@ echo "rm $(source)"
@ if [ -e $(source) ]; then \
$(rm) $(rmflags) $(source); \
fi
$(clean_hpp) : clean_%.hpp : $(inc_dir)/pwr_%classes.hpp
@ echo "rm $(source)"
@ if [ -e $(source) ]; then \
$(rm) $(rmflags) $(source); \
fi
$(clean_ps_sv_se) : clean_%_sv_se.ps : $(doc_dir)/sv_se/%.ps
@ echo "rm $(source)"
@ if [ -e $(source) ]; then \
$(rm) $(rmflags) $(source); \
fi
$(clean_ps_en_us) : clean_%_en_us.ps : $(doc_dir)/en_us/%.ps
@ echo "rm $(source)"
@ if [ -e $(source) ]; then \
$(rm) $(rmflags) $(source); \
fi
$(clean_html_sv_se) : clean_%_sv_se.html : $(doc_dir)/sv_se/orm/%_allclasses.html
@ echo "rm $(source)"
@ if [ -e $(source) ]; then \
$(rm) $(rmflags) $(source); \
fi
$(clean_html_en_us) : clean_%_en_us.html : $(doc_dir)/en_us/orm/%_allclasses.html
@ echo "rm $(source)"
@ if [ -e $(source) ]; then \
$(rm) $(rmflags) $(source); \
fi
$(clean_xtthelp_sv_se) : clean_%_sv_se.xtthelp : $(exe_dir)/sv_se/%_xtthelp.dat
@ echo "rm $(source)"
@ if [ -e $(source) ]; then \
$(rm) $(rmflags) $(source); \
fi
$(clean_xtthelp_en_us) : clean_%_en_us.xtthelp : $(exe_dir)/en_us/%_xtthelp.dat
@ echo "rm $(source)"
@ if [ -e $(source) ]; then \
$(rm) $(rmflags) $(source); \
fi
endif
# dir_symbols.mk - get directory symbols
#
#
#
comma := ,
empty :=
space := $(empty) $(empty)
pred_13 := 12
pred_12 := 11
pred_11 := 10
pred_10 := 9
pred_9 := 8
pred_8 := 7
pred_7 := 6
pred_6 := 5
pred_5 := 4
pred_4 := 3
pred_3 := 2
pred_2 := 1
pred_1 := 0
cwd_dirs := $(subst /,$(space),$(PWD))
cwd_dirs := $(subst .hw_,hw_,$(cwd_dirs))
cwd_dirs := $(subst .os_,os_,$(cwd_dirs))
word := $(words $(cwd_dirs))
hw_name := $(word $(word), $(cwd_dirs))
ifneq ($(findstring hw, $(hw_name)),hw)
include ___error___hw
endif
prev := pred_ $(word)
pred := $(subst $(space),$(empty),$(prev))
word := $($(pred))
os_name := $(word $(word), $(cwd_dirs))
ifneq ($(findstring os,$(os_name)),os)
include ___error___os
endif
prev := pred_ $(word)
pred := $(subst $(space),$(empty),$(prev))
word := $($(pred))
src_name := $(word $(word), $(cwd_dirs))
#ifneq ($(src_name),src)
#include ___error___no_source_subdirectory
#endif
prev := pred_ $(word)
pred := $(subst $(space),$(empty),$(prev))
word := $($(pred))
comp_name := $(word $(word), $(cwd_dirs))
prev := pred_ $(word)
pred := $(subst $(space),$(empty),$(prev))
word := $($(pred))
type_name := $(word $(word), $(cwd_dirs))
prev := pred_ $(word)
pred := $(subst $(space),$(empty),$(prev))
word := $($(pred))
root_name := $(word $(word), $(cwd_dirs))
#ifneq ($(src_name),src)
#include ___error___incorrect_source_root1
#endif
#rest = /$(type_name)/$(comp_name)/src/$(os_name)/$(hw_name)/
#test_source_root := $(subst $(rest),$(empty),$(PWD))
#ifneq ($(pwre_sroot),$(test_source_root))
#include ___error___incorrect_source_root2
#endif
bcomp 1
java 1
remote 1
nmps 1
sev 1
opc 1
profibus 1
otherio 1
ssabox 1
tlog 1
othermanu 1
abb 1
siemens 1
klocknermoeller 1
inor 1
telemecanique 1
\ No newline at end of file
#!/bin/bash
#
# Import loadfile
# Arg1 import base root
# Arg2 target base root
#
tst=`eval echo $1 | grep :`
if [ -z $tst ]; then
# Local import root, use cp
copy="cp"
else
# Remote import root, use scp
copy="scp"
fi
$copy $1/exp/load/*.dbs $2/exp/load/
cp -p $2/exp/load/pwrs.dbs $2/rt/load/
cp -p $2/exp/load/pwrb.dbs $2/rt/load/
cp -p $2/exp/load/rt.dbs $2/rt/load/
cp -p $2/exp/load/basecomponent.dbs $2/bcomp/load/
cp -p $2/exp/load/nmps.dbs $2/nmps/load/
cp -p $2/exp/load/opc.dbs $2/opc/load/
cp -p $2/exp/load/profibus.dbs $2/profibus/load/
cp -p $2/exp/load/otherio.dbs $2/otherio/load/
cp -p $2/exp/load/remote.dbs $2/remote/load/
cp -p $2/exp/load/tlog.dbs $2/tlog/load/
cp -p $2/exp/load/abb.dbs $2/abb/load/
cp -p $2/exp/load/inor.dbs $2/inor/load/
cp -p $2/exp/load/klocknermoeller.dbs $2/klocknermoeller/load/
cp -p $2/exp/load/othermanufacturer.dbs $2/othermanu/load/
cp -p $2/exp/load/siemens.dbs $2/siemens/load/
cp -p $2/exp/load/ssabox.dbs $2/ssabox/load/
cp -p $2/exp/load/telemecanique.dbs $2/telemecanique/load/
import_top : import_files
source = $<
target = $@
rt_modules = \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/exp/load/pwrs.dbs \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/exp/load/pwrb.dbs \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/exp/load/rt.dbs \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/exp/load/basecomponent.dbs \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/exp/load/nmps.dbs \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/exp/load/opc.dbs \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/exp/load/profibus.dbs \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/exp/load/otherio.dbs \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/exp/load/remote.dbs \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/exp/load/tlog.dbs \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/exp/load/abb.dbs \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/exp/load/inor.dbs \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/exp/load/klocknermoeller.dbs \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/exp/load/othermanufacturer.dbs \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/exp/load/siemens.dbs \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/exp/load/ssabox.dbs \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/exp/load/telemecanique.dbs \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/rt/inc/pwr_systemclasses.h \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/rt/inc/pwr_systemclasses.hpp \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/rt/inc/pwr_baseclasses.h \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/rt/inc/pwr_baseclasses.hpp \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/bcomp/inc/pwr_basecomponentclasses.h \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/bcomp/inc/pwr_basecomponentclasses.hpp \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/nmps/inc/pwr_nmpsclasses.h \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/nmps/inc/pwr_nmpsclasses.hpp \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/opc/inc/pwr_opcclasses.h \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/opc/inc/pwr_opcclasses.hpp \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/profibus/inc/pwr_profibusclasses.h \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/profibus/inc/pwr_profibusclasses.hpp \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/otherio/inc/pwr_otherioclasses.h \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/otherio/inc/pwr_otherioclasses.hpp \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/remote/inc/pwr_remoteclasses.h \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/remote/inc/pwr_remoteclasses.hpp \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/abb/inc/pwr_abbclasses.h \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/abb/inc/pwr_abbclasses.hpp \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/inor/inc/pwr_inorclasses.h \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/inor/inc/pwr_inorclasses.hpp \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/klocknermoeller/inc/pwr_klocknermoellerclasses.h \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/klocknermoeller/inc/pwr_klocknermoellerclasses.hpp \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/othermanu/inc/pwr_othermanufacturerclasses.h \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/othermanu/inc/pwr_othermanufacturerclasses.hpp \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/siemens/inc/pwr_siemensclasses.h \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/siemens/inc/pwr_siemensclasses.hpp \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/ssabox/inc/pwr_ssaboxclasses.h \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/ssabox/inc/pwr_ssaboxclasses.hpp \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/telemecanique/inc/pwr_telemecaniqueclasses.h \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/telemecanique/inc/pwr_telemecaniqueclasses.hpp \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/exp/exe/wb_gcg.sh \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/exp/inc/wb_ldh.h \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/exp/inc/wb_vext.h
op_modules = \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/exp/inc/wb_wnav_selformat.h \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/exp/inc/wb_nav.h \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/exp/inc/wb_pal.h \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/exp/inc/wb_palfile.h \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/exp/inc/wb_wccm.h \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/exp/inc/wb_log.h \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/exp/inc/wb_trv.h
op_gtk_modules = \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/exp/inc/wb_nav_gtk.h \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/exp/inc/wb_log_gtk.h
op_motif_modules = \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/exp/inc/wb_nav_motif.h
java_modules = \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/exp/lib/pwr_rt.jar \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/exp/lib/pwr_jop.jar \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/exp/lib/pwr_jopc.jar \
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/exp/lib/pwr_rt_client.jar
import_files : $(rt_modules) $(op_modules) $(java_modules) $(op_gtk_modules)
@ echo ""
.PHONY: rt
.PHONY: op
.PHONY: java
_gtk :
rt : $(rt_modules)
rt_gtk :
rt_motif :
op : $(op_modules)
op_gtk : $(op_gtk_modules)
op_motif : $(op_motif_modules)
java : $(java_modules)
java_gtk :
java_motif :
.SUFFIXES:
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/exp/load/%.dbs : $(pwre_vmsinc)/exp/load/%.dbs
@ echo Import ${target}
@ cp $(source) $(target)
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/rt/inc/%.h : $(pwre_vmsinc)/exp/inc/%.h
@ echo Import ${target}
@ cp $(source) $(target)
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/rt/inc/%.hpp : $(pwre_vmsinc)/exp/inc/%.hpp
@ echo Import ${target}
@ cp $(source) $(target)
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/bcomp/inc/%.h : $(pwre_vmsinc)/exp/inc/%.h
@ echo Import ${target}
@ cp $(source) $(target)
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/bcomp/inc/%.hpp : $(pwre_vmsinc)/exp/inc/%.hpp
@ echo Import ${target}
@ cp $(source) $(target)
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/nmps/inc/%.h : $(pwre_vmsinc)/exp/inc/%.h
@ echo Import ${target}
@ cp $(source) $(target)
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/nmps/inc/%.hpp : $(pwre_vmsinc)/exp/inc/%.hpp
@ echo Import ${target}
@ cp $(source) $(target)
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/opc/inc/%.h : $(pwre_vmsinc)/exp/inc/%.h
@ echo Import ${target}
@ cp $(source) $(target)
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/opc/inc/%.hpp : $(pwre_vmsinc)/exp/inc/%.hpp
@ echo Import ${target}
@ cp $(source) $(target)
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/profibus/inc/%.h : $(pwre_vmsinc)/exp/inc/%.h
@ echo Import ${target}
@ cp $(source) $(target)
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/profibus/inc/%.hpp : $(pwre_vmsinc)/exp/inc/%.hpp
@ echo Import ${target}
@ cp $(source) $(target)
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/otherio/inc/%.h : $(pwre_vmsinc)/exp/inc/%.h
@ echo Import ${target}
@ cp $(source) $(target)
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/otherio/inc/%.hpp : $(pwre_vmsinc)/exp/inc/%.hpp
@ echo Import ${target}
@ cp $(source) $(target)
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/remote/inc/%.h : $(pwre_vmsinc)/exp/inc/%.h
@ echo Import ${target}
@ cp $(source) $(target)
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/remote/inc/%.hpp : $(pwre_vmsinc)/exp/inc/%.hpp
@ echo Import ${target}
@ cp $(source) $(target)
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/abb/inc/%.h : $(pwre_vmsinc)/exp/inc/%.h
@ echo Import ${target}
@ cp $(source) $(target)
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/abb/inc/%.hpp : $(pwre_vmsinc)/exp/inc/%.hpp
@ echo Import ${target}
@ cp $(source) $(target)
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/inor/inc/%.h : $(pwre_vmsinc)/exp/inc/%.h
@ echo Import ${target}
@ cp $(source) $(target)
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/inor/inc/%.hpp : $(pwre_vmsinc)/exp/inc/%.hpp
@ echo Import ${target}
@ cp $(source) $(target)
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/klocknermoeller/inc/%.h : $(pwre_vmsinc)/exp/inc/%.h
@ echo Import ${target}
@ cp $(source) $(target)
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/klocknermoeller/inc/%.hpp : $(pwre_vmsinc)/exp/inc/%.hpp
@ echo Import ${target}
@ cp $(source) $(target)
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/othermanu/inc/%.h : $(pwre_vmsinc)/exp/inc/%.h
@ echo Import ${target}
@ cp $(source) $(target)
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/othermanu/inc/%.hpp : $(pwre_vmsinc)/exp/inc/%.hpp
@ echo Import ${target}
@ cp $(source) $(target)
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/siemens/inc/%.h : $(pwre_vmsinc)/exp/inc/%.h
@ echo Import ${target}
@ cp $(source) $(target)
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/siemens/inc/%.hpp : $(pwre_vmsinc)/exp/inc/%.hpp
@ echo Import ${target}
@ cp $(source) $(target)
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/ssabox/inc/%.h : $(pwre_vmsinc)/exp/inc/%.h
@ echo Import ${target}
@ cp $(source) $(target)
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/ssabox/inc/%.hpp : $(pwre_vmsinc)/exp/inc/%.hpp
@ echo Import ${target}
@ cp $(source) $(target)
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/telemecanique/inc/%.h : $(pwre_vmsinc)/exp/inc/%.h
@ echo Import ${target}
@ cp $(source) $(target)
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/telemecanique/inc/%.hpp : $(pwre_vmsinc)/exp/inc/%.hpp
@ echo Import ${target}
@ cp $(source) $(target)
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/exp/exe/%.sh : $(pwre_vmsinc)/exp/exe/%.sh
@ echo Import ${target}
@ cp $(source) $(target)
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/exp/inc/wb_%_motif.h : $(pwre_croot)/wb/lib/wb/motif/wb_%_motif.h
@ echo Import ${target}
@ cp $(source) $(target)
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/exp/inc/wb_%_gtk.h : $(pwre_croot)/wb/lib/wb/gtk/wb_%_gtk.h
@ echo Import ${target}
@ cp $(source) $(target)
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/exp/inc/wb_%.h : $(pwre_croot)/wb/lib/wb/src/wb_%.h
@ echo Import ${target}
@ cp $(source) $(target)
$(pwre_broot)/$(pwre_os)/$(pwre_hw)/exp/lib/%.jar : $(pwre_vmsinc)/exp/lib/%.jar
@ echo Import ${target}
@ cp $(source) $(target)
#!/usr/bin/perl
#
# pwre.pl
#
%verbs = (
"add", "add:usage_add",
"configure", "configure:usage_configure",
"build", "build:usage_build",
"build_all", "build_all:usage_build_all",
"build_kernel", "build_kernel:usage_build_kernel",
"build_all_modules", "build_all_modules:usage_build_all_modules",
"build_all_wbl", "build_all_wbl:usage_build_all_wbl",
"ebuild", "ebuild:usage_ebuild",
"clean_exe_all", "clean_exe_all:usage_clean_exe_all",
"method_build", "method_build:usage_method_build",
"copy", "copy:usage_copy",
"create", "create:usage_create",
"create_all_modules", "create_all_modules:usage_create_all_modules",
"delete", "dele:usage_dele",
"help", "help:usage_help",
"list", "list:usage_list",
"init", "init:usage_init",
"import", "import:usage_import",
"module", "module:usage_module",
"merge", "merge:usage_merge",
"modify", "modify:usage_modify",
"show", "show:usage_show",
"tags", "tags:usage_tags",
"_build", "_build:",
"_exists", "_exists:",
"_print", "_print:"
);
#
# Variables
#
$user = $ENV{"USER"};
$label = $ENV{"pwre_env"};
$sroot = "/view/$user/vobs/pwr_src/src";
$vmsinc = "";
$broot = "/usr/users/$user/$user" . "_dbg";
$btype = "dbg";
$os = "freebsd";
if ($ENV{"pwre_hosttype"} eq "rs6000") {
$hw = "ppc";
} else {
if ($ENV{"pwre_hosttype"} eq "x86_64") {
$hw = "x86_64";
} else {
$hw = "x86";
}
}
$desc = $user. "'s environment";
@vars;
$varstr;
if (($dbname = $ENV{"pwre_env_db"}) eq "") {
$dbname = $ENV{"HOME"} . "/pwre/pwre";
}
$os = substr( $ENV{"pwre_os"}, 3, 100);
$hw = substr( $ENV{"pwre_hw"}, 3, 100);
$configfile = $ENV{"pwre_broot"} . "/pwre_" . $hw . "_" . $os . ".cnf";
$arg1 = $ARGV[0];
shift;
if ($arg1 eq "") {
help();
}
$amb = 0;
$found = 0;
@ambs;
foreach $key (sort keys (%verbs)) {
if ($key =~ /^$arg1/) {
if ($key =~ /$arg1\b/) {
$amb = 0;
$found = 1;
($verb, $usage) = split(/:/, $verbs{$key});
last;
}
push(@ambs, $key);
if ($found == 1) {
$amb = 1;
} else {
$found = 1;
($verb, $usage) = split(/:/, $verbs{$key});
}
}
}
if ($amb == 1) {
printf("++\n++ Verb \"%s\" is ambigous\n", $arg1);
printf("++ Select one of: ");
foreach (@ambs) {
printf("%s ", $_);
}
print("\n");
exit 1;
} elsif ($found == 1) {
&$verb(@ARGV);
exit 0;
} else {
help();
exit 1;
}
#
# Verb subroutines
#
# add()
#
sub add ()
{
use DB_File;
tie(%envdb, "DB_File", $dbname, O_CREAT|O_RDWR, 0644) || die "++ can't tie $dbname!";
$label = $_[0];
$varstr = $envdb{$label};
if ($varstr ne "") {
printf("++ Environment %s already exists\n", $_[0]);
} else {
get_vars(@_);
update_db();
}
untie(%envdb)|| die "++ can't untie $dbname!";
}
#
# configure()
#
sub configure()
{
if (!defined($ENV{"pwre_env"})) {
print("++ Environment is not initialized!\n");
exit 1;
}
my $fname = $ENV{"pwre_bin"} . "/pwre_configure.sh";
system( $fname);
}
#
# build()
#
sub build () # args: branch, subbranch, flavour, phase
{
if (!defined($ENV{"pwre_env"})) {
print("++ Environment is not initialized!\n");
exit 1;
}
if ( ! -e $configfile ) {
print("++ Environment is not configured!\n");
exit 1;
}
use DB_File;
tie(%envdb, "DB_File", $dbname, O_CREAT|O_RDWR, 0644) || die "++ can't tie $dbname!";
read_vars();
my($branch) = $_[0];
if (!defined($branch)) {
usage_build();
exit 1;
}
my($subbranch) = $_[1];
if (!defined($subbranch)) {
usage_build();
exit 1;
}
shift(@_);
shift(@_);
if ( $_[0] eq "") {
$flavour = "src";
}
else {
$flavour = $_[0];
shift(@_);
}
printf("--\n");
printf("-- Build\n");
printf("-- Branch.............: %s\n", $branch);
printf("-- Sub branch.........: %s\n", $subbranch);
printf("-- Sub branch flavour.: %s\n", $flavour);
printf("-- Args...............: ");
foreach (@_) {
printf("%s ", $_);
$ENV{"PWRE_ARGS"} = $_;
}
printf("\n--\n");
_build($branch, $subbranch, $flavour, @_);
}
#
# build_kernel()
#
sub build_kernel # args: flavour
{
my $flavour = $_[0];
_module("xtt");
build_all("copy", $flavour);
merge();
_module("rt");
build_all("copy", $flavour);
merge();
_module("wb");
build_all("copy", $flavour);
merge();
_module("rt");
build_all("lib", $flavour);
merge();
_module("xtt");
build_all("lib", $flavour);
merge();
_module("wb");
build_all("lib", $flavour);
merge();
_module("otherio");
_build("exp","rt","src","copy");
_build("lib","usbio_dummy","src","init lib");
_build("lib","usb_dummy","src","init lib");
merge();
_module("xtt");
build_all("exe", $flavour);
merge();
_module("wb");
build_all("exe", $flavour);
merge();
_module("rt");
build_all("exe", $flavour);
merge();
}
#
# ebuild()
#
sub ebuild # args: pass flavour
{
use DB_File;
tie(%envdb, "DB_File", $dbname, O_CREAT|O_RDWR, 0644) || die "++ can't tie $dbname!";
read_vars();
my $fname = $ENV{"pwre_bin"} . "/ebuild.dat";
open FILE, $fname or die $!;
my $build_bcomp = 0;
my $build_java = 0;
my $build_remote = 0;
my $build_nmps = 0;
my $build_sev = 0;
my $build_opc = 0;
my $build_profibus = 0;
my $build_otherio = 0;
my $build_ssabox = 0;
my $build_tlog = 0;
my $build_othermanu = 0;
my $build_abb = 0;
my $build_siemens = 0;
my $build_klocknermoeller = 0;
my $build_inor = 0;
my $build_telemecanique = 0;
printf( "-- Building modules\n");
while ( <FILE>) {
my @value = split( ' ', $_);
if ( $value[0] eq "bcomp" && $value[1] eq "1" ) { $build_bcomp = 1; printf( "-- bcomp\n");}
elsif ( $value[0] eq "remote" && $value[1] eq "1" ) { $build_remote = 1; printf( "-- remote\n");}
elsif ( $value[0] eq "java" && $value[1] eq "1" ) { $build_java = 1; printf( "-- java\n");}
elsif ( $value[0] eq "nmps" && $value[1] eq "1" ) { $build_nmps = 1; printf( "-- nmps\n");}
elsif ( $value[0] eq "sev" && $value[1] eq "1" ) { $build_sev = 1; printf( "-- sev\n");}
elsif ( $value[0] eq "opc" && $value[1] eq "1" ) { $build_opc = 1; printf( "-- opc\n");}
elsif ( $value[0] eq "profibus" && $value[1] eq "1" ) { $build_profibus = 1; printf( "-- profibus\n");}
elsif ( $value[0] eq "otherio" && $value[1] eq "1" ) { $build_otherio = 1; printf( "-- otherio\n");}
elsif ( $value[0] eq "ssabox" && $value[1] eq "1" ) { $build_ssabox = 1; printf( "-- ssabox\n");}
elsif ( $value[0] eq "tlog" && $value[1] eq "1" ) { $build_tlog = 1; printf( "-- tlog\n");}
elsif ( $value[0] eq "othermanu" && $value[1] eq "1" ) { $build_othermanu = 1; printf( "-- othermanu\n");}
elsif ( $value[0] eq "abb" && $value[1] eq "1" ) { $build_abb = 1; printf( "-- abb\n");}
elsif ( $value[0] eq "siemens" && $value[1] eq "1" ) { $build_siemens = 1; printf( "-- siemens\n");}
elsif ( $value[0] eq "klocknermoeller" && $value[1] eq "1" ) { $build_klocknermoeller = 1; printf( "-- klocknermoeller\n");}
elsif ( $value[0] eq "inor" && $value[1] eq "1" ) { $build_inor = 1; printf( "-- inor \n");}
elsif ( $value[0] eq "telemecanique" && $value[1] eq "1" ) { $build_telemecanique = 1; printf( "-- telemecanique\n");}
}
printf( "\n");
close FILE;
my $pass = $_[0];
my $flavour = $_[1];
if ( $_[1] eq "motif") {
$flavour = "motif";
}
else {
$flavour = "gtk";
}
if ( $pass eq "rt" ) {
_module("rt");
_build("exp", "inc", "src", "all");
_build("exp", "com", "src", "all");
_build("tools/exe", "*", "src", "all");
merge("exe/tools_cmsg2c");
merge("exe/tools_msg2cmsg");
merge("exe/tools_pdrgen");
_build("msg", "*", "src", "all");
_build("lib", "rt", "src", "init copy");
_build("lib", "rt", $flavour, "copy");
_build("lib", "co", "src", "init copy");
_build("lib", "co", $flavour, "copy");
_build("lib", "dtt", "src", "init copy");
_build("lib", "statussrv", "src", "init copy");
_build("lib", "co", "src", "all");
_build("lib", "co", $flavour, "all");
_build("exe", "co*", "src", "all");
_build("exe", "*", "src", "copy");
_build("exp", "stdsoap2", "src", "copy");
_build("lib", "rt", "src", "all");
_build("lib", "statussrv", "src", "all");
_build("lib", "msg_dummy", "src", "init copy lib");
_build("exp", "rt", "src", "all");
_build("exe", "wb_rtt", "src", "all");
_build("lib", "dtt", "src", "all");
_build("exp", "stdsoap2", "src", "all");
_module("otherio");
_build("exp","rt","src","copy");
_build("lib","usbio_dummy","src","init lib");
_build("lib","usb_dummy","src","init lib");
merge();
_module("rt");
_build("exe", "rt*", "src", "all");
_build("exe", "co*", $flavour, "all");
_build("exe", "pwr_user", "src", "all");
if ( $build_nmps == 1) {
merge();
_module("nmps");
_build("lib", "nmps", "src", "all");
merge();
}
if ( $build_bcomp == 1) {
_module("profibus");
merge();
_module("bcomp");
_build("lib", "rt", "src", "all");
merge();
}
if ( $build_ssabox == 1) {
_module("ssabox");
_build("lib", "rt", "src", "all");
_build("lib", "ssabox", "src", "all");
merge();
}
if ( $build_otherio == 1) {
_module("otherio");
_build("lib", "rt", "src", "all");
merge();
}
if ( $build_profibus == 1) {
_module("profibus");
_build("lib", "rt", "src", "all");
merge();
}
if ( $build_remote == 1) {
_module("remote");
_build("lib", "remote", "src", "all");
_build("exe", "*", "src", "all");
merge();
}
if ( $build_opc == 1) {
_module("opc");
_build("lib", "opc", "src", "all");
_build("exe", "*", "src", "all");
merge();
}
if ( $build_tlog == 1) {
_module("tlog");
_build("lib", "tlog", "src", "all");
merge();
}
if ( $build_java == 1) {
_module("java");
_build("exe", "jpwr_rt_gdh", "src", "all");
merge();
}
if ( $build_sev == 1) {
_module("sev");
_build("lib", "sev", "src", "all");
_build("exe", "sev_server", "src", "all");
merge();
}
if ( $build_abb == 1) {
_module("abb");
merge();
}
if ( $build_siemens == 1) {
_module("siemens");
merge();
}
if ( $build_othermanu == 1) {
_module("othermanu");
merge();
}
if ( $build_inor == 1) {
_module("inor");
merge();
}
if ( $build_klocknermoeller == 1) {
_module("klocknermoeller");
merge();
}
if ( $build_telemecanique == 1) {
_module("telemecanique");
merge();
}
}
elsif ( $pass eq "op" ) {
_module("xtt");
_build("lib", "*", "src", "init copy");
_build("lib", "*", $flavour, "copy");
_build("exp", "*", "src", "init copy");
_build("mmi", "*", "src", "copy");
_build("mmi", "*", $flavour, "copy");
_build("exe", "*", "src", "copy");
_build("lib", "*", "src", "lib");
_build("lib", "*", $flavour, "lib");
_build("exp", "*", "src", "lib");
_build("exe", "rt*", "src", "all");
_build("exe", "xtt*", "src", "all");
_build("exe", "co*", "src", "all");
_build("exe", "pwr*", "src", "all");
_build("exe", "rt*", $flavour, "all");
_build("exe", "xtt*", $flavour, "all");
_build("exe", "co*", $flavour, "all");
_build("exe", "pwr*", $flavour, "all");
merge();
if ( $build_bcomp == 1) {
_module("bcomp");
_build("mmi", "*", "src", "copy");
merge();
}
if ( $build_profibus == 1) {
_module("profibus");
_build("mmi", "*", "src", "copy");
_build("lib", "cow", "src", "init copy lib");
_build("lib", "cow", $flavour, "init copy lib");
_build("lib", "xtt", "src", "init copy lib");
_build("lib", "xtt", $flavour, "init copy lib");
merge();
}
if ( $build_opc == 1) {
_module("opc");
_build("mmi", "*", "src", "copy");
merge();
}
if ( $build_otherio == 1) {
_module("otherio");
_build("mmi", "*", "src", "copy");
merge();
}
if ( $build_sev == 1) {
_module("sev");
_build("exe", "sev_xtt", "src", "all");
_build("exe", "sev_xtt", $flavour, "all");
merge();
}
if ( $build_othermanu == 1) {
_module("othermanu");
_build("mmi", "*", "src", "copy");
merge();
}
if ( $build_abb == 1) {
_module("abb");
_build("mmi", "*", "src", "copy");
merge();
}
if ( $build_inor == 1) {
_module("inor");
_build("mmi", "*", "src", "copy");
merge();
}
if ( $build_siemens == 1) {
_module("siemens");
_build("mmi", "*", "src", "copy");
merge();
}
if ( $build_klocknermoeller == 1) {
_module("klocknermoeller");
_build("mmi", "*", "src", "copy");
merge();
}
if ( $build_ssabox == 1) {
_module("ssabox");
_build("mmi", "*", "src", "copy");
merge();
}
if ( $build_telemecanique == 1) {
_module("telemecanique");
_build("mmi", "*", "src", "copy");
merge();
}
method_build( "rt_io_comm", $flavour);
method_build( "rt_xtt", $flavour);
}
}
#
# import()
#
sub import ()
{
my $flavour = $_[1];
if ( $_[1] eq "motif") {
$flavour = "motif";
}
else {
$flavour = "gtk";
}
my($vmsinc) = $ENV{"pwre_vmsinc"};
if ( $vmsinc ne "" ) {
copy( $_[0], $flavour);
_module("rt");
merge();
_module("bcomp");
merge();
_module("nmps");
merge();
_module("opc");
merge();
_module("profibus");
merge();
_module("otherio");
merge();
_module("remote");
merge();
}
}
#
# build_all()
#
sub build_all_modules ()
{
my $flavour = $_[0];
build_kernel( $flavour);
_module("nmps");
build_all( $flavour);
merge();
_module("tlog");
build_all( $flavour);
merge();
_module("remote");
build_all( $flavour);
merge();
_module("profibus");
build_all( $flavour);
merge();
_module("bcomp");
build_all( $flavour);
merge();
_module("java");
build_all( $flavour);
merge();
_module("opc");
build_all( $flavour);
merge();
_module("ssabox");
build_all( $flavour);
merge();
_module("othermanu");
build_all( $flavour);
merge();
_module("otherio");
build_all( $flavour);
merge();
_module("sev");
build_all( $flavour);
merge();
_module("abb");
build_all( $flavour);
merge();
_module("siemens");
build_all( $flavour);
merge();
_module("inor");
build_all( $flavour);
merge();
_module("klocknermoeller");
build_all( $flavour);
merge();
_module("telemecanique");
build_all( $flavour);
merge();
method_build( $flavour);
}
#
# clean_exe_all()
#
sub clean_exe_all ()
{
_module("xtt");
_build("exe","*","src","clean_exe");
_module("rt");
_build("exe","rt*","src","clean_exe");
_build("exe","co*","src","clean_exe");
_build("exe","wb*","src","clean_exe");
_module("wb");
_build("exe","*","src","clean_exe");
_module("nmps");
_build("exe","*","src","clean_exe");
_module("tlog");
_build("exe","*","src","clean_exe");
_module("remote");
_build("exe","*","src","clean_exe");
_module("rt");
}
#
# build_all_wbl()
#
sub build_all_wbl ()
{
_module("rt");
my($load_dir) = $ENV{"pwr_load"};
system( "rm $load_dir/*.dbs");
_build("wbl", "pwrs", "src", "lib");
_build("wbl", "pwrb", "src", "lib");
_build("wbl", "wb", "src", "lib");
_build("wbl", "rt", "src", "lib");
merge();
_module("nmps");
my($load_dir) = $ENV{"pwr_load"};
system( "rm $load_dir/*.dbs");
_build("wbl", "nmps", "src", "lib");
merge();
_module("tlog");
my($load_dir) = $ENV{"pwr_load"};
system( "rm $load_dir/*.dbs");
_build("wbl", "tlog", "src", "lib");
merge();
_module("profibus");
my($load_dir) = $ENV{"pwr_load"};
system( "rm $load_dir/*.dbs");
_build("wbl", "mcomp", "src", "lib");
merge();
_module("opc");
my($load_dir) = $ENV{"pwr_load"};
system( "rm $load_dir/*.dbs");
_build("wbl", "mcomp", "src", "lib");
merge();
_module("remote");
my($load_dir) = $ENV{"pwr_load"};
system( "rm $load_dir/*.dbs");
_build("wbl", "remote", "src", "lib");
merge();
_module("bcomp");
my($load_dir) = $ENV{"pwr_load"};
system( "rm $load_dir/*.dbs");
_build("wbl", "bcomp", "src", "lib");
merge();
_module("ssabox");
my($load_dir) = $ENV{"pwr_load"};
system( "rm $load_dir/*.dbs");
_build("wbl", "mcomp", "src", "lib");
merge();
_module("abb");
my($load_dir) = $ENV{"pwr_load"};
system( "rm $load_dir/*.dbs");
_build("wbl", "mcomp", "src", "lib");
merge();
_module("siemens");
my($load_dir) = $ENV{"pwr_load"};
system( "rm $load_dir/*.dbs");
_build("wbl", "mcomp", "src", "lib");
merge();
_module("telemecanique");
my($load_dir) = $ENV{"pwr_load"};
system( "rm $load_dir/*.dbs");
_build("wbl", "mcomp", "src", "lib");
merge();
_module("inor");
my($load_dir) = $ENV{"pwr_load"};
system( "rm $load_dir/*.dbs");
_build("wbl", "mcomp", "src", "lib");
merge();
_module("klocknermoeller");
my($load_dir) = $ENV{"pwr_load"};
system( "rm $load_dir/*.dbs");
_build("wbl", "mcomp", "src", "lib");
merge();
_module("othermanu");
my($load_dir) = $ENV{"pwr_load"};
system( "rm $load_dir/*.dbs");
_build("wbl", "mcomp", "src", "lib");
merge();
_module("otherio");
my($load_dir) = $ENV{"pwr_load"};
system( "rm $load_dir/*.dbs");
_build("wbl", "mcomp", "src", "lib");
merge();
_module("rt");
}
sub method_build ()
{
my $flavour;
my $program;
if ( $_[0] eq "motif" || $_[0] eq "gtk") {
$flavour = $_[0];
}
else {
$program = $_[0];
$flavour = $_[1];
}
if (!defined($program)) {
printf("-- Relink method dependent programs $flavour");
_module("rt");
$ENV{"export_type"} = "exp";
my($exe_dir) = $ENV{"pwr_exe"};
system("rm $exe_dir/rt_io_comm");
_build("exe", "rt_io_comm", "src", "all");
# system("rm $exe_dir/rt_ini");
# _build("exe", "rt_ini", $flavour, "all");
merge();
method_build( "wb", $flavour);
# _module("wb");
# my($exe_dir) = $ENV{"pwr_exe"};
# system("rm $exe_dir/wb");
# _build("exe", "wb", "src", "all");
# _build("exe", "wb", $flavour, "all");
# merge();
method_build( "rt_xtt", $flavour);
# _module("xtt");
# my($exe_dir) = $ENV{"pwr_exe"};
# system("rm $exe_dir/rt_xtt");
# _build("exe", "rt_xtt", "src", "all");
# _build("exe", "rt_xtt", $flavour, "all");
# merge();
}
if ( $_[0] eq "rt_io_comm" ) {
printf("-- Method build $program");
_module("rt");
$ENV{"export_type"} = "exp";
my($exe_dir) = $ENV{"pwr_exe"};
system("rm $exe_dir/rt_io_comm");
_build("exe", "rt_io_comm", "src", "all");
merge();
}
if ( $_[0] eq "wb" ) {
printf("-- Method build $program $flavour");
_module("wb");
$ENV{"export_type"} = "exp";
my($exe_dir) = $ENV{"pwr_exe"};
system("rm $exe_dir/wb");
_build("exe", "wb", $flavour, "all");
_build("exe", "wb", "src", "all");
merge();
}
if ( $_[0] eq "rt_xtt" ) {
printf("-- Method build $program $flavour");
_module("xtt");
$ENV{"export_type"} = "exp";
my($exe_dir) = $ENV{"pwr_exe"};
system("rm $exe_dir/rt_xtt");
_build("exe", "rt_xtt", $flavour, "all");
_build("exe", "rt_xtt", "src", "all");
merge();
}
}
sub create_all_modules ()
{
if ( ! -e $configfile ) {
configure();
}
_module("rt");
create();
_module("xtt");
create();
_module("wb");
create();
_module("nmps");
create();
_module("tlog");
create();
_module("remote");
create();
_module("java");
create();
_module("bcomp");
create();
_module("profibus");
create();
_module("sev");
create();
_module("opc");
create();
_module("ssabox");
create();
_module("othermanu");
create();
_module("otherio");
create();
_module("abb");
create();
_module("siemens");
create();
_module("inor");
create();
_module("klocknermoeller");
create();
_module("telemecanique");
create();
}
#
# build_all()
#
sub build_all ()
{
$copy = 0;
$lib = 0;
$exe = 0;
if ( $_[0] eq "copy" || $_[1] eq "copy" || $_[2] eq "copy") {
$copy = 1;
}
if ( $_[0] eq "lib" || $_[1] eq "lib" || $_[2] eq "lib") {
$lib = 1;
}
if ( $_[0] eq "exe" || $_[1] eq "exe" || $_[2] eq "exe") {
$exe = 1;
}
if ( $copy == 0 && $lib == 0 && $exe == 0) {
$copy = 1;
$lib = 1;
$exe = 1;
}
if ( $_[0] eq "motif" || $_[1] eq "motif" || $_[2] eq "motif" || $_[3] eq "motif") {
$flavour = "motif";
}
else {
$flavour = "gtk";
}
if (!defined($ENV{"pwre_env"})) {
print("++ Environment is not initialized!\n");
exit 1;
}
my($module) = $ENV{"pwre_module"};
my($einc) = $ENV{"pwr_einc"};
my($remoteclasses) = $einc . "/pwr_remoteclasses.h";
my($nmpsclasses) = $einc . "/pwr_nmpsclasses.h";
printf("--\n");
printf("-- Build all\n");
show();
if ( $module eq "rt") {
if ( $copy == 1) {
_build("exp", "inc", "src", "all");
_build("exp", "com", "src", "all");
_build("tools/exe", "*", "src", "all");
merge("exe/tools_cmsg2c");
merge("exe/tools_msg2cmsg");
merge("exe/tools_pdrgen");
_build("msg", "*", "src", "all");
_build("lib", "rt", "src", "init copy");
_build("lib", "co", "src", "init copy");
_build("lib", "dtt", "src", "init copy");
_build("lib", "statussrv", "src", "init copy");
_build("lib", "co", "src", "all");
_build("exe", "co*", "src", "all");
_build("wbl", "pwrs", "src", "copy");
_build("wbl", "pwrb", "src", "copy");
_build("exe", "*", "src", "copy");
_build("exp", "stdsoap2", "src", "copy");
}
if ( $lib == 1) {
_build("lib", "ge", "all");
if ( ! -e $nmpsclasses ) {
_module("nmps");
_build("wbl", "nmps", "src", "init copy");
merge("inc/pwr_nmpsclasses.h");
}
if ( ! -e $remoteclasses ) {
_module("remote");
_build("wbl", "remote", "src", "init copy");
merge("inc/pwr_remoteclasses.h");
}
_module("rt");
_build("lib", "rt", "src", "all");
_build("exp", "rt", "src", "all");
_build("lib", "msg_dummy", "src", "all");
_build("exp", "rt", "src", "all");
_build("lib", "statussrv", "src", "all");
_build("exp", "stdsoap2", "src", "all");
}
if ( $exe == 1) {
_build("exe", "wb_rtt", "src", "all");
_build("lib", "dtt", "src", "all");
_build("exe", "rt*", "src", "all");
_build("exe", "co*", $flavour, "all");
_build("exe", "pwr_user", "src", "all");
_build("exe", "pwr_rtmon", "src", "all");
_build("exe", "pwr_rtmon", "$flavour", "all");
_build("exp", "ge", "src", "all");
_build("mmi", "*", "src", "copy");
_build("mmi", "*", $flavour, "copy");
_build("wbl", "pwrs", "src", "lib");
_build("wbl", "pwrb", "src", "lib");
_build("wbl", "wb", "src", "lib");
_build("wbl", "rt", "src", "lib");
_build("doc", "web", "src", "all");
_build("doc", "dweb", "src", "all");
_build("doc", "orm", "src", "all");
_build("doc", "prm", "src", "all");
_build("doc", "man", "src", "all");
_build("doc", "dox", "src", "all");
_build("wbl", "pwrs", "src", "exe");
_build("wbl", "pwrb", "src", "exe");
}
}
elsif ( $module eq "java") {
if ( $lib == 1) {
_build("jpwr", "rt", "src", "all");
_build("jpwr", "jop", "src", "all");
_build("jpwr", "jopc", "src", "all");
_build("jpwr", "beans", "src", "all");
_build("jpwr", "rt_client", "src", "all");
}
if ( $exe == 1) {
_build("exe", "jpwr_rt_gdh", "src", "all");
}
}
else {
if ( $copy == 1) {
_build("wbl", "*", "src", "copy");
_build("lib", "*", "src", "init copy");
_build("lib", "*", $flavour, "copy");
_build("exp", "*", "src", "init copy");
_build("mmi", "*", "src", "copy");
_build("mmi", "*", $flavour, "copy");
_build("exe", "*", "src", "copy");
}
if ( $lib == 1) {
_build("lib", "*", "src", "lib");
_build("lib", "*", $flavour, "lib");
_build("exp", "*", "src", "lib");
}
if ( $exe == 1) {
_build("wbl", "*", "src", "lib");
_build("wbl", "*", "src", "exe");
_build("exe", "*", "src", "all");
_build("exe", "*", $flavour, "all");
_build("doc", "dsh", "src", "copy");
_build("doc", "orm", "src", "copy");
}
}
}
#
# copy()
#
sub copy ()
{
if (!defined($ENV{"pwre_env"})) {
print("++ Environment is not initialized!\n");
exit 1;
}
my($vmsinc) = $ENV{"pwre_vmsinc"};
my($bindir) = $ENV{"pwre_bin"} . "/" . $ENV{"pwre_hw"};
my($docroot) = $ENV{"pwre_broot"} . "/" . $ENV{"pwre_os"} . "/" . $ENV{"pwre_hw"} . "/exp/doc/";
my($exproot) = $ENV{"pwre_broot"} . "/" . $ENV{"pwre_os"} . "/" . $ENV{"pwre_hw"};
printf("--\n");
printf("-- Copy file from Import root\n");
printf("-- Import root: %s\n", $vmsinc);
printf("--\n");
if ( $_[0] eq "doc" ) {
my($cmd) = "cp -r " . $vmsinc . "/exp/doc/* " . $docroot;
system("$cmd");
}
elsif ( $_[0] eq "dbs" ) {
my($cmd) = "$bindir/import_dbs.sh " . $vmsinc . " " . $exproot;
system("$cmd");
}
else {
my($cmd) = "gmake -f $bindir/import_files.mk" . " " . $_[0];
system("$cmd");
my $flavour = $_[1];
if ( $_[1] eq "motif") {
$flavour = "motif";
}
else {
$flavour = "gtk";
}
my($cmd) = "gmake -f $bindir/import_files.mk" . " " . $_[0] . "_" . $flavour;
system("$cmd");
}
}
#
# create
#
sub create()
{
my($newdir);
my($root) = $ENV{"pwre_broot"};
my($module) = $ENV{"pwre_bmodule"};
if (!defined($root)) {
printf("++\n++ No build root is defined\n");
exit 1;
}
create_dir($root);
$root .= "/" . $ENV{"pwre_os"};
create_dir($root);
$root .= "/" . $ENV{"pwre_hw"};
create_dir($root);
$newdir = $root . "/bld";
create_dir($newdir);
create_dir($newdir . "/exe");
create_dir($newdir . "/lib");
create_dir($newdir . "/msg");
create_dir($newdir . "/jpwr");
create_dir($newdir . "/wbl");
if ($module eq "rt") {
$newdir = $root . "/exp";
create_base($newdir);
}
# else {
$newdir = $root . "/$module";
create_base($newdir);
# }
$newdir = $root . "/tmp";
create_dir($newdir);
}
#
# dele()
#
sub dele ()
{
use DB_File;
tie(%envdb, "DB_File", $dbname, O_CREAT|O_RDWR, 0644) || die "++ can't tie $dbname!";
$label = $_[0];
if (defined($envdb{$label})) {
print("-- Delete environment \"$label\" [n]? ");
my($tmp);
chomp($tmp = <STDIN>);
if ($tmp =~ /^[yY]/) {
delete $envdb{$label};
printf("-- Environment \"%s\" has been deleted\n", $label);
}
} else {
printf("++ Environment \"%s\" doesn't exists\n", $label);
}
untie(%envdb)|| die "++ can't untie $dbname!";
}
#
# help
#
sub help ()
{
my($key);
printf("++\n");
printf("++ Usage: pwre verb [...]\n");
printf("++ A verb name may be shortned as long as it isn't ambiguos, eg. pwre h[elp]\n");
printf("++ Verbs:\n");
foreach $key (sort keys (%verbs)) {
($verb, $usage) = split(/:/, $verbs{$key});
if (!($verb =~ /^_/)) {
&$usage();
}
}
printf("++\n");
exit 1;
}
#
# list()
#
sub list ()
{
my($env);
printf("Using Database:%s\n",$dbname);
use DB_File;
tie(%envdb, "DB_File", $dbname, O_CREAT|O_RDWR, 0644) || die "++ can't tie $dbname!";
print("-- Defined environments:\n");
foreach $env (sort keys (%envdb)) {
$varstr = $envdb{$env};
($sroot, $vmsinc, $broot, $btype, $os, $hw, $desc) = split(/:/, $varstr);
@vars = ($sroot, $vmsinc, $broot, $btype, $os, $hw, $desc);
printf(" %s %s\n", $env, $desc);
}
print("--\n");
untie(%envdb)|| die "++ can't untie $dbname!";
}
#
# modify()
#
sub modify ()
{
use DB_File;
tie(%envdb, "DB_File", $dbname, O_CREAT|O_RDWR, 0644) || die "++ can't tie $dbname!";
$label = $_[0];
$varstr = $envdb{$label};
if ($varstr ne "") {
read_vars();
get_vars();
update_db();
} else {
printf("Environment %s doesn't exists\n", $label);
}
untie(%envdb)|| die "++ can't untie $dbname!";
}
#
# show
#
sub show ()
{
if ($_[0] ne "") {
$label = $_[0];
} else {
$label = $ENV{"pwre_env"};
if (!defined($label)) {
print("++ Environment is not initialized!\n");
exit 1;
}
}
use DB_File;
tie(%envdb, "DB_File", $dbname, O_CREAT|O_RDWR, 0644) || die "++ can't tie $dbname!";
read_vars();
if ($varstr ne "") {
print("--\n");
printf("-- Environment : %s\n", $label);
show_vars();
print("--\n");
} else {
printf("++ Environment %s doesn't exists\n", $label);
}
untie(%envdb)|| die "++ can't untie $dbname!";
}
#
# tags()
#
sub tags ()
{
if (!defined($ENV{"pwre_env"})) {
print("++ Environment is not initialized!\n");
exit 1;
}
printf("--\n");
printf("-- Creating a CRiSP tag-file named ~/pwre/tags\n");
system("pwr_tags") && exit;
}
#
# _build()
#
sub _build () # args: branch, subbranch, flavour, phase
{
my($branch) = $_[0];
if (!defined($branch)) {
usage_build();
exit 1;
}
my($subbranch) = $_[1];
if (!defined($subbranch)) {
usage_build();
exit 1;
}
my($flavour) = $_[2];
shift(@_);
shift(@_);
shift(@_);
my($grepstr) = $ENV{"pwre_target"};
my($globstr) = $ENV{"pwre_sroot"} . "/$branch";
my(@dirs1) = glob($globstr);
my($dir1);
my(@dirs2);
my($dir2);
my(@mfiles);
my($globstr1);
my($globstr2);
my($globstr3);
foreach $dir1 (@dirs1) {
# $globstr = "$dir1" . "/$subbranch/$flavour/os_$os/hw_$hw";
# if ( ! -e $globstr ) {
# $globstr = "$dir1" . "/$subbranch/$flavour/os_$os/.hw_$hw";
# if ( ! -e $globstr ) {
# $globstr = "$dir1" . "/$subbranch/$flavour/.os_$os/.hw_$hw";
# }
# }
$globstr1 = "$dir1" . "/$subbranch/$flavour/os_$os/hw_$hw";
$globstr2 = "$dir1" . "/$subbranch/$flavour/os_$os/.hw_$hw";
$globstr3 = "$dir1" . "/$subbranch/$flavour/.os_$os/.hw_$hw";
@dirs2 = (glob($globstr1),glob($globstr2),glob($globstr3));
foreach $dir2 (@dirs2) {
if (-d $dir2) {
@mfiles = `find $dir2 -name makefile`;
foreach (@mfiles) {
chomp($_);
$_ =~ s#/makefile##;
print("\n$_\n");
chdir($_) || die "cannot cd to $_ ($!)";
$ENV{"PWD"} = $_;
system("gmake @_") && exit 1;
}
}
}
}
}
#
# merge()
#
sub merge ()
{
if (!defined($ENV{"pwre_env"})) {
print("++ Environment is not initialized!\n");
exit 1;
}
my($eroot) = $ENV{"pwre_broot"};
if (!defined($eroot)) {
printf("++\n++ No build root is defined\n");
exit 1;
}
my($file) = $_[0];
# if ($module eq "rt") {
# printf("++\n++ No merge for module rt needed\n");
# exit 1;
# }
$eroot .= "/" . $ENV{"pwre_os"};
$eroot .= "/" . $ENV{"pwre_hw"};
my($mroot) = $eroot;
$mroot .= "/" . $ENV{"pwre_module"};
$eroot .= "/exp";
printf("--\n");
printf("-- Merge %s %s\n", $module, $file);
my($cmd) = $ENV{pwre_bin} . "/pwre_merge.sh " . $mroot . " " . $eroot . " " . $file;
system("$cmd");
}
#
# _exists()
#
sub _exists ()
{
my($ret) = 1;
use DB_File;
tie(%envdb, "DB_File", $dbname, O_CREAT|O_RDWR, 0644) || die "++ can't tie $dbname!";
$label = $_[0];
if (defined($envdb{$label})) {
$ret = 0;
}
untie(%envdb)|| die "++ can't untie $dbname!";
exit $ret;
}
#
# _print()
#
sub _print ()
{
use DB_File;
tie(%envdb, "DB_File", $dbname, O_CREAT|O_RDWR, 0644) || die "++ can't tie $dbname!";
$label = $_[0];
read_vars();
if ($varstr ne "") {
foreach (@vars) {
if ($_ eq "") {
printf("\"\"\n");
} else {
printf("%s\n", $_);
}
}
} else {
printf("++ Environment %s doesn't exists\n", $label);
}
untie(%envdb)|| die "++ can't untie $dbname!";
}
sub _module()
{
my($modu) = $_[0];
my($sroot) = $ENV{"pwre_sroot"};
my($idx) = rindex($sroot,"/");
$sroot = substr($sroot, 0, $idx);
my($broot) = $ENV{"pwre_broot"} . "/" . $ENV{"pwre_os"} . "/" . $ENV{"pwre_hw"};
$ENV{"pwre_module"} = $modu;
$ENV{"pwre_bmodule"} = $modu;
if ( $modu eq "rt") {
# $ENV{"pwre_bmodule"} = "exp";
$ENV{"pwre_sroot"} = $sroot . "/src";
}
else {
$ENV{"pwre_sroot"} = $sroot . "/" . $modu;
}
$ENV{"pwr_exe"} = $broot . "/" . $ENV{"pwre_bmodule"} . "/exe";
$ENV{"pwr_inc"} = $broot . "/" . $ENV{"pwre_bmodule"} . "/inc";
$ENV{"pwr_load"} = $broot . "/" . $ENV{"pwre_bmodule"} . "/load";
$ENV{"pwr_lib"} = $broot . "/" . $ENV{"pwre_bmodule"} . "/lib";
$ENV{"pwr_lis"} = $broot . "/" . $ENV{"pwre_bmodule"} . "/lis";
$ENV{"pwr_obj"} = $broot . "/" . $ENV{"pwre_bmodule"} . "/obj";
$ENV{"pwr_doc"} = $broot . "/" . "exp" . "/doc";
}
#
# Misc. subroutines
#
sub create_base()
{
my($newdir) = $_[0];
create_dir($newdir);
create_dir($newdir . "/db");
create_dir($newdir . "/exe");
create_dir($newdir . "/exe/sv_se");
create_dir($newdir . "/exe/en_us");
create_dir($newdir . "/exe/de_de");
create_dir($newdir . "/inc");
create_dir($newdir . "/load");
create_dir($newdir . "/lib");
create_dir($newdir . "/lis");
create_dir($newdir . "/obj");
create_dir($newdir . "/src");
create_dir($newdir . "/cnf");
create_dir($newdir . "/doc");
create_dir($newdir . "/doc/dox");
create_dir($newdir . "/doc/prm");
create_dir($newdir . "/doc/sv_se");
create_dir($newdir . "/doc/en_us");
create_dir($newdir . "/doc/sv_se/orm");
create_dir($newdir . "/doc/en_us/orm");
create_dir($newdir . "/doc/sv_se/dsh");
create_dir($newdir . "/doc/en_us/dsh");
create_dir($newdir . "/doc/help");
}
sub create_dir()
{
my($dir) = $_[0];
if (!chdir($dir)) {
if (mkdir($dir, 0775)) {
printf("-- mkdir: %s\n", $dir);
} else {
printf("++\n++ Cannot mkdir %s, reason: %s\n", $dir, $!);
exit 1;
}
}
}
sub get_vars ()
{
printf( "Arg: %s\n", $_[1]);
if ($_[1] eq "") {
$sroot = get_var(" Source root [%s]? ", $sroot);
} else {
$sroot = $_[1];
}
if ($_[2] eq "") {
$vmsinc = get_var(" Import root [%s]? ", $vmsinc);
} else {
$vmsinc = $_[2];
}
if ($_[3] eq "") {
$broot = get_var(" Build root [%s]? ", $broot);
} else {
$broot = $_[3];
}
if ($_[4] eq "") {
$btype = get_var(" Build type [%s]? ", $btype);
} else {
$btype = $_[4];
}
if ($_[5] eq "") {
$os = get_var(" OS [%s]? ", $os);
} else {
$os = $_[5];
}
if ($_[6] eq "") {
$hw = get_var(" Hardware [%s]? ", $hw);
} else {
$hw = $_[6];
}
if ($_[7] eq "") {
$desc = get_var(" Description [%s]? ", $desc);
} else {
$desc = $_[7];
}
$varstr = join(";", ($sroot, $vmsinc, $broot, $btype, $os, $hw, $desc));
}
sub get_var()
{
my($tmp);
printf($_[0], $_[1]);
chomp($tmp = <STDIN>);
if ($tmp eq "") {
$tmp = $_[1];
}
return $tmp;
}
sub read_vars ()
{
$varstr = $envdb{$label};
($sroot, $vmsinc, $broot, $btype, $os, $hw, $desc) = split(/;/, $varstr);
@vars = ($sroot, $vmsinc, $broot, $btype, $os, $hw, $desc);
}
sub show_vars ()
{
my($module) = $ENV{"pwre_module"};
printf("-- Module.........: %s\n", $module);
printf("-- Source root....: %s\n", $sroot);
if ( $vmsinc ne "") {
printf("-- Import root....: %s\n", $vmsinc);
}
printf("-- Build root.....: %s\n", $broot);
printf("-- Build type.....: %s\n", $btype);
printf("-- OS.............: %s\n", $os);
printf("-- Hardware.......: %s\n", $hw);
printf("-- Description....: %s\n", $desc);
}
sub update_db ()
{
$envdb{$label} = $varstr;
}
sub usage_add ()
{
printf("++\n");
printf("++ add env : Adds an environment to the database\n");
}
sub usage_configure ()
{
printf("++\n");
printf("++ configure : Configures an environment\n");
}
sub usage_build ()
{
printf("++\n");
printf("++ build 'branch' 'subbranch' ['flavour']['phase']: Build, eg. pwre build exe rt* src all\n");
}
sub usage_build_all ()
{
printf("++\n");
printf("++ build_all : Builds all in current module\n");
}
sub usage_build_kernel ()
{
printf("++\n");
printf("++ build_kernel : Builds all in kernel modules (kernel, xtt, wb)\n");
}
sub usage_build_all_modules ()
{
printf("++\n");
printf("++ build_all_modules : Builds all in all modules\n");
}
sub usage_build_all_wbl ()
{
printf("++\n");
printf("++ build_all_wbl : Builds wbl in all modules\n");
}
sub usage_ebuild ()
{
printf("++\n");
printf("++ ebuild 'block' 'flavour' : Builds rt or op block\n");
}
sub usage_clean_exe_all ()
{
printf("++\n");
printf("++ clean_exe_all : Cleans all exe in all modules\n");
}
sub usage_method_build ()
{
printf("++\n");
printf("++ method_build : Rebuild method dependent programs\n");
}
sub usage_create_all_modules ()
{
printf("++\n");
printf("++ create_all_modules : Create build trees for all modules\n");
}
sub usage_copy ()
{
printf("++\n");
printf("++ copy : Copy Proview include files from the VMS host\n");
}
sub usage_create ()
{
printf("++\n");
printf("++ create : Creates the build directory tree\n");
}
sub usage_dele ()
{
printf("++\n");
printf("++ delete 'env' : Deletes an environment from the database\n");
}
sub usage_help ()
{
printf("++\n");
printf("++ help : Lists all command verbs\n");
}
sub usage_list ()
{
printf("++\n");
printf("++ list : Lists all environments in the database\n");
}
sub usage_init ()
{
printf("++\n");
printf("++ init 'env' : Inits an environment\n");
}
sub usage_import ()
{
printf("++\n");
printf("++ import 'block' ['flavour'] : Import files from import root, block dbs, rt, op, java, doc\n");
}
sub usage_module ()
{
printf("++\n");
printf("++ module 'module' : Set module\n");
}
sub usage_merge ()
{
printf("++\n");
printf("++ merge : Merge module base to exp base\n");
}
sub usage_modify ()
{
printf("++\n");
printf("++ modify 'env' : Modfies an existing environment\n");
}
sub usage_show ()
{
printf("++\n");
printf("++ show [env] : Shows current or given environment\n");
}
sub usage_tags ()
{
printf("++\n");
printf("++ tags : Creates a CRiSP tag-file named ~/pwre/tags\n");
}
#!/bin/bash
#
# pwre.source
#
# This script must be sourced
#
# Only the init verb is handled by this script, all the others
# is handled by pwre.perl
#
#
# Don't call pwre.perl if it is the init verb
#
env="$2"
local cmd
cmd="help"
if [ -z $1 ] || [ $1 = $cmd ] || [ ${cmd#$1} != $cmd ]; then
$pwre_bin/pwre.pl $@
return
fi
cmd="init"
if [ $1 = $cmd ]; then
echo "init..."
if [ "$env" = "" ]; then
echo "++ init what?"
else
export pwre_module=rt
export pwre_bmodule=rt
if $pwre_bin/pwre.pl _exists $2; then
set_env `$pwre_bin/pwre.pl _print $2`
else
echo "++ Environment $2 doesn't exist"
fi
source $pwre_bin/pwre_function
fi
return
fi
cmd="module"
if [ $1 = $cmd ]; then
echo "module..."
if [ -z $2 ]; then
export pwre_module="rt"
export pwre_bmodule="rt"
else
export pwre_module=$2
export pwre_bmodule=$2
fi
env=$pwre_env
set_env `$pwre_bin/pwre.pl _print $env`
return
fi
$pwre_bin/pwre.pl $@
#!/bin/bash
pwre_config_init()
{
d=`eval date +\"%F %X\"`
cat > $cfile <<EOF
#!/bin/bash
#
# pwre configuration file
#
# Generated by pwre_configure $d
# Do not edit this file
#
EOF
}
pwre_config_check_include()
{
let i=0
let found=0
let incfound=0
IFS=:
for file in $4
do
if test -e $file; then
echo "...Checking Yes $1"
echo "export PWRE_CONF_$2=1" >> $cfile
if test $3 == "1"; then
conf_cc_define=$conf_cc_define" -DPWRE_CONF_$2=1"
fi
incdir=${file%/*}
if test $incdir == "/usr/include"; then
incfound=1
else
while [ $i -lt $inc_cnt ]; do
if test ${inc_array[$i]} == $incdir; then
incfound=1
fi
i=$((i+1))
done
fi
if test $incfound -eq 0; then
inc_array[$inc_cnt]=$incdir
inc_cnt=$((inc_cnt+1))
fi
found=1
break
fi
done
if test $found -eq 0; then
echo "...Checking No $1"
fi
}
pwre_config_check_lib()
{
let i=0
let found=0
let libfound=0
IFS=:
for file in $6
do
if test -e $file; then
echo "...Checking Yes $1"
echo "export PWRE_CONF_$2=1" >> $cfile
if test $5 == "1"; then
conf_cc_define=$conf_cc_define" -DPWRE_CONF_$2=1"
fi
if test $3 == "lib"; then
libdir=${file%/*}
if test $libdir == "/usr/lib"; then
libfound=1
else
while [ $i -lt $lib_cnt ]; do
if test ${lib_array[$i]} == $libdir; then
libfound=1
fi
i=$((i+1))
done
fi
if test $libfound -eq 0; then
lib_array[$lib_cnt]=$libdir
lib_cnt=$((lib_cnt+1))
fi
lib=${file##/*/lib}
if test $4 == "gtk"; then
conf_libgtk=$conf_libgtk" -l${lib%.*}"
elif test $4 == "motif"; then
conf_libmotif=$conf_libmotif" -l${lib%.*}"
else
conf_lib=$conf_lib" -l${lib%.*}"
fi
elif test $3 == "gtk"; then
conf_libgtk=$conf_libgtk" \\\`pkg-config --libs gtk+-2.0\\\`"
conf_incdirgtk=$conf_incdirgtk" \\\`pkg-config --cflags gtk+-2.0\\\`"
else
echo "Unknown type"
fi
found=1
break
fi
done
if test $found -eq 0; then
echo "...Checking No $1"
echo "export PWRE_CONF_$2=0" >> $cfile
fi
}
pwre_create_blddir()
{
if test ! -e $pwre_croot/src/tools/bld/src/$pwre_os; then
cp -r $pwre_croot/src/tools/bld/src/os_templ $pwre_croot/src/tools/bld/src/$pwre_os
mv $pwre_croot/src/tools/bld/src/$pwre_os/hw_templ $pwre_croot/src/tools/bld/src/$pwre_os/$pwre_hw
elif test ! -e $pwre_croot/src/tools/bld/src/$pwre_os/$pwre_hw; then
cp -r $pwre_croot/src/tools/bld/src/os_templ/hw_templ $pwre_croot/src/tools/bld/src/$pwre_os/$pwre_hw
fi
}
pwre_create_makedir()
{
dirlist=`eval find $pwre_croot -name "os_templ"`
for dir in $dirlist; do
newdir=${dir%/*}/$pwre_os
if test ! -e $newdir; then
newdir=${dir%/*}/.$pwre_os
if test ! -e $newdir; then
echo "Creating $newdir"
cp -pr $dir $newdir
if test -e $newdir/hw_templ; then
mv $newdir/hw_templ $newdir/.$pwre_hw
fi
else
# os directory .os_ already exist
# Copy new and modified files
filelist=`eval ls $dir/`
for file in $filelist; do
if test ! -d $dir/$file; then
cp -p $dir/$file $newdir/
fi
done
if test -e $newdir/.$pwre_hw; then
cp -p $dir/hw_templ/* $newdir/.$pwre_hw/
elif test -e $dir/hw_templ; then
# Create hw dir
echo "Creating $newdir/$pwre_hw"
cp -pr $dir/hw_templ $newdir/.$pwre_hw
fi
fi
else
## os director os_ exist
if test ! -e $newdir/$pwre_hw; then
if test -e $newdir/.$pwre_hw; then
cp -p $dir/hw_templ/* $newdir/.$pwre_hw/
elif test -e $dir/hw_templ; then
# Create hw dir
echo "Creating $newdir/.$pwre_hw"
cp -pr $dir/hw_templ $newdir/.$pwre_hw
fi
fi
fi
done
}
#pwre_os="os_linux"
#pwre_hw="hw_x86"
cfile="$pwre_broot/pwre_${pwre_hw:3}_${pwre_os:3}.cnf"
dos=`eval echo ${pwre_os} | tr [:lower:] [:upper:]`
dhw=`eval echo ${pwre_hw} | tr [:lower:] [:upper:]`
conf_cc_define="-D$dos=1 -D$dhw=1 -DOS=${pwre_os:3} -DHW=${pwre_hw:3} -D_${dos:3}"
conf_lib=""
conf_libgtk=""
conf_libmotif=""
conf_libdir=""
conf_incdirgtk=""
let inc_cnt=0
let lib_cnt=0
let i=0
# Bash
if [ "$SHELL" != "/bin/bash" ] && [ "$SHELL" != "/usr/local/bin/bash" ]; then
echo "Config error: Default shell has to be bash"
exit
fi
echo "...Checking /bin/bash"
if test ! -e /bin/bash; then
if test -e /usr/local/bin/bash; then
echo "Config error: /bin/bash not found"
echo " Create link /bin/bash to /usr/local/bin/bash (ln -s /usr/local/bin/bash /bin/bash)"
else
echo "Config error: /bin/bash not found"
fi
exit
fi
if test "$pwre_broot" == ""; then
echo "Config error: pwre not initialized"
exit
fi
if test ! -w $pwre_broot; then
echo "Config error: pwre build root doesn't exist or is not writable"
exit
fi
if test ! -e $pwre_croot; then
echo "Config error: pwre source root doesn't exist"
exit
fi
pwre_create_blddir
pwre_create_makedir
pwre_config_init
#Gtk
pwre_config_check_lib gtk GTK gtk gtk 0 /usr/local/lib/libgtk-x11-2.0.so
pwre_config_check_lib libantlr LIBANTLR lib lib 0 /usr/local/lib/libantlr.a
pwre_config_check_lib librpcsvc LIBRPCSVC lib lib 0 /usr/lib/librpcsvc.so:/usr/lib/librpcsvc.a
pwre_config_check_lib libasound LIBASOUND lib lib 0 /usr/lib/libasound.so:/usr/lib/libasound.a
pwre_config_check_lib libpthread LIBPTHREAD lib lib 0 /usr/lib/libpthread.so:/usr/lib/libpthread.a
pwre_config_check_lib libm LIBM lib lib 0 /usr/lib/libm.so:/usr/lib/libm.a
pwre_config_check_lib libdb_cxx LIBDB_CXX lib lib 0 /usr/local/lib/libdb_cxx-4.8.so
pwre_config_check_lib libz LIBZ lib lib 0 /usr/lib/libz.so:/usr/lib/libz.a
pwre_config_check_lib libcrypt LIBCRYPT lib lib 0 /usr/lib/libcrypt.so:/usr/lib/libcrypt.a
pwre_config_check_lib mysql MYSQL lib lib 1 /usr/lib/libmysqlclient.so
pwre_config_check_lib mq MQ lib lib 1 /usr/lib/libdmq.so
pwre_config_check_lib libpnioif PNAK lib lib 1 /usr/lib/libpnioif.so:/usr/local/lib/libpnioif.a
pwre_config_check_lib libusb LIBUSB lib lib 1 /usr/lib/libusb-1.0.so
pwre_config_check_lib librt LIBRT lib lib 0 /usr/lib/librt.dylib:/usr/lib/librt.a
pwre_config_check_lib libiconv LIBICONV lib lib 0 /usr/local/lib/libiconv.so:usr/local/lib/libiconv.a
pwre_config_check_lib libfl LIBFL lib lib 0 /usr/lib/libfl.os:/usr/lib/libfl.a
#set -o xtrace
pwre_config_check_include antlr ANTLR 1 /usr/local/include/antlr/CommonAST.hpp
pwre_config_check_include gtk GTK 1 /usr/local/include/gtk-2.0/gtk/gtk.h
pwre_config_check_include jni JNI 1 /usr/local/jdk1.6.0/include/jni.h
pwre_config_check_include jni JNI 0 /usr/local/jdk1.6.0/include/freebsd/jni_md.h
pwre_config_check_include libdb_cxx LIBDB_CXX 0 /usr/local/include/db48/db_cxx.h
export pwre_conf_alsa=1
let i=0
while [ $i -lt $inc_cnt ]; do
conf_incdir=$conf_incdir" -I${inc_array[$i]}"
i=$((i+1))
done
let i=0
while [ $i -lt $lib_cnt ]; do
conf_libdir=$conf_libdir" -L${lib_array[$i]}"
i=$((i+1))
done
rm $pwre_croot/src/exe/rt_prio/src/.${pwre_os}/.${pwre_hw}/makefile
#rm $pwre_croot/otherio/exp/rt/src/.${pwre_os}/.${pwre_hw}/makefile
rm $pwre_croot/remote/exe/rs_remote_alcm/src/.${pwre_os}/.${pwre_hw}/makefile
#rm $pwre_croot/profibus/lib/rt/src/.${pwre_os}/.${pwre_hw}/makefile
echo "export PKG_CONFIG_PATH=/sw/fink/pkgconfig" >> $cfile
echo "export pwre_conf_cc_define=\"$conf_cc_define\"" >> $cfile
echo "export pwre_conf_libpwrco=\"-lpwr_co\"" >> $cfile
echo "export pwre_conf_libpwrrt=\"-lpwr_rt -lpwr_co -lpwr_statussrv -lpwr_msg_dummy\"" >> $cfile
echo "export pwre_conf_libpwrotherio=\"-lpwr_usbio_dummy -lpwr_usb_dummy\"" >> $cfile
echo "export pwre_conf_libpwrxtt=\"-lpwr_xtt -lpwr_ge -lpwr_cow -lpwr_flow -lpwr_glow\"" >> $cfile
echo "export pwre_conf_libpwrxttgtk=\" -lpwr_xtt_gtk -lpwr_ge_gtk -lpwr_cow_gtk -lpwr_flow_gtk -lpwr_glow_gtk\"" >> $cfile
echo "export pwre_conf_libpwrxttmotif=\"-lpwr_ge_motif -lpwr_cow_motif -lpwr_flow_motif -lpwr_glow_motif\"" >> $cfile
echo "export pwre_conf_libpwrwb=\"-lpwr_wb\"" >> $cfile
echo "export pwre_conf_libpwrwbgtk=\"-lpwr_wb_gtk\"" >> $cfile
echo "export pwre_conf_libpwrwbmotif=\"-lpwr_wb_motif\"" >> $cfile
echo "export pwre_conf_libpwropc=\"-lpwr_opc\"" >> $cfile
echo "export pwre_conf_libpwrremote=\"-lpwr_remote\"" >> $cfile
echo "export pwre_conf_libpwrnmps=\"-lpwr_nmps\"" >> $cfile
echo "export pwre_conf_libpwrtlog=\"-lpwr_tlog\"" >> $cfile
echo "export pwre_conf_libpwrsev=\"-lpwr_sev\"" >> $cfile
echo "export pwre_conf_lib=\"$conf_lib\"" >> $cfile
echo "export pwre_conf_libgtk=\"$conf_libgtk\"" >> $cfile
echo "export pwre_conf_libmotif=\"$conf_libmotif\"" >> $cfile
echo "export pwre_conf_libdir=\"$conf_libdir\"" >> $cfile
echo "export pwre_conf_incdir=\"$conf_incdir\"" >> $cfile
echo "export pwre_conf_incdirgtk=\"$conf_incdirgtk\"" >> $cfile
#
# Proview build environment setup
#
# Environment variables
#
# $pwre_croot Common source root, pwr
# $pwre_kroot Rt source root, pwr/src
# $pwre_sroot Module source root, eg. pwr/ssabox
# $pwre_broot Common build root
# $pwre_module Module name in source tree, eg. 'ssabox'
# $pwre_bmodule Module name in build tree, eg. 'ssabox'
# $pwre_os Operating system, eg. 'os_linux'
# $pwre_hw Hardware, eg. 'hw_x86'
# $pwr_exe Exe directory for module build root, eg. ssabox/exe
# $pwr_load Load directory for module build root
# $pwr_inc Inc directory for module build root
# $pwr_obj Obj directory for module build root
# $pwr_lib Lib directory for module build root
# $pwr_eexe Exe directory for common build root, ex. exp/exe
# $pwr_eload Load directory for common build root
# $pwr_einc Inc directory for common build root
# $pwr_eobj Obj directory for common build root
# $pwr_elib Lib directory for common build root
pwre()
{
if [ "$HOSTTYPE" = "alpha" ]; then
pwre_silent="-q"
else
pwre_silent="-s"
fi
export pwre_hosttype=$HOSTTYPE
local flags="$-"
if [ -e $pwre_broot/pwre_${pwre_hw:3}_${pwre_os:3}.cnf ]; then
source $pwre_broot/pwre_${pwre_hw:3}_${pwre_os:3}.cnf
fi
# Turn off filename globber
set -f
source $pwre_bin/pwre.source $@
if echo "$flags" | grep $pwre_silent -v f; then
set +f
fi
}
set_env()
{
if [ "$pwr_eexe" != "" ]; then
export PATH=${PATH%:$pwr_eexe}
export PATH=${PATH%:$pwr_exe}
fi
module=$pwre_module
if [ $module = "rt" ]; then
module=src
fi
sroot=${1%/*}
export pwre_croot=$sroot
export pwre_sroot=$sroot/$module
export pwre_kroot=$sroot/src
export pwre_env="$env"
export pwre_vmsinc="$2"
export pwre_broot="$3"
export pwre_btype="$4"
export pwre_os="os_$5"
export pwre_hw="hw_$6"
export pwre_target="$pwre_os/$pwre_hw"
export pwre_bin="$pwre_kroot/tools/pwre/src/$pwre_os"
export pwre_dir_symbols="$pwre_bin/dir_symbols.mk"
export pwr_exe="$pwre_broot/$pwre_os/$pwre_hw/$pwre_bmodule/exe"
export pwr_inc="$pwre_broot/$pwre_os/$pwre_hw/$pwre_bmodule/inc"
export pwr_load="$pwre_broot/$pwre_os/$pwre_hw/$pwre_bmodule/load"
export pwr_lib="$pwre_broot/$pwre_os/$pwre_hw/$pwre_bmodule/lib"
export pwr_lis="$pwre_broot/$pwre_os/$pwre_hw/$pwre_bmodule/lis"
export pwr_obj="$pwre_broot/$pwre_os/$pwre_hw/$pwre_bmodule/obj"
# Common doc
export pwr_doc="$pwre_broot/$pwre_os/$pwre_hw/exp/doc"
export pwr_eexe="$pwre_broot/$pwre_os/$pwre_hw/exp/exe"
export pwr_einc="$pwre_broot/$pwre_os/$pwre_hw/exp/inc"
export pwr_eload="$pwre_broot/$pwre_os/$pwre_hw/exp/load"
export pwr_elib="$pwre_broot/$pwre_os/$pwre_hw/exp/lib"
export pwr_elis="$pwre_broot/$pwre_os/$pwre_hw/exp/lis"
export pwr_eobj="$pwre_broot/$pwre_os/$pwre_hw/exp/obj"
export pwr_edoc="$pwre_broot/$pwre_os/$pwre_hw/exp/doc"
export pwrp_load="./"
export pwrp_pop="./"
export co_lib="$pwre_kroot/lib/co/src"
export op_lib="$pwre_kroot/lib/op/src"
export rt_lib="$pwre_kroot/lib/rt/src"
export wb_lib="$pwre_kroot/lib/wb/src"
export exe="$pwre_kroot/exe"
# PWR alias
alias pwr_root="cd $pwre_kroot"
alias pwr_exe="cd $pwr_exe"
alias pwr_inc="cd $pwr_inc"
alias pwr_load="cd $pwr_load"
alias pwr_lib="cd $pwr_lib"
alias pwr_lis="cd $pwr_lis"
alias pwr_obj="cd $pwr_obj"
alias co_lib="cd $pwre_kroot/lib/co/src"
alias op_lib="cd $pwre_kroot/lib/op/src"
alias rt_lib="cd $pwre_kroot/lib/rt/src"
alias wb_lib="cd $pwre_kroot/lib/wb/src"
alias db="cd $pwre_kroot/db"
alias exe="cd $pwre_kroot/exe"
alias exp="cd $pwre_kroot/exp"
alias inc="cd $pwre_kroot/exp/inc/src"
alias lib="cd $pwre_kroot/lib"
alias hlp="cd $pwre_kroot/hlp"
alias mmi="cd $pwre_kroot/mmi"
alias msg="cd $pwre_kroot/msg"
alias tools="cd $pwre_kroot/tools"
alias wbl="cd $pwre_kroot/wbl"
alias hw="cd $pwre_target"
alias bld="cd $pwre_broot/$pwre_target/bld"
alias co_bld="cd $pwre_broot/$pwre_target/bld/lib/co"
alias rt_bld="cd $pwre_broot/$pwre_target/bld/lib/rt"
alias exe_bld="cd $pwre_broot/$pwre_target/bld/exe"
alias tmp="cd $pwre_broot/$pwre_target/tmp"
pwre_get_variables
export PWRP_DB=$pwr_my_sqlserver":wb_template_"$pwr_dbversion
# export CLASSPATH=$pwre_broot/$pwre_os/$pwre_hw/bld/jpwr/rt:$pwre_broot/$pwre_os/$pwre_hw/bld/jpwr/jop:$pwre_broot/$pwre_os/$pwre_hw/bld/jpwr/beans
export CLASSPATH=$pwre_broot/$pwre_target/bld
export PATH=$PATH:$pwr_exe:$pwr_eexe
# Configure
# Dmq
if [ -e /usr/lib/libdmq.so ]; then
export pwre_conf_mq=1
else
export pwre_conf_mq=0
fi
# Mysql
if [ -e /usr/lib/libmysqlclient.so ] || [ -e /usr/lib/mysql/libmysqlclient.so ]; then
export pwre_conf_mysql=1
else
export pwre_conf_mysql=0
fi
# Gtk
if [ -e /usr/lib/libgtk-x11-2.0.so ]; then
export pwre_conf_gtk=1
else
export pwre_conf_gtk=0
fi
# libusb
if [ -e /usr/lib/libusb-1.0.so ]; then
export pwre_conf_libusb=1
else
export pwre_conf_libusb=0
fi
export pwre_conf_alsa=1
}
pwre_get_variables()
{
local socket
socket=`eval cat /etc/proview.cnf | grep "\bmysql_socket\b" | awk '{print $2}'`
if [ ! -z $socket ]; then
mysql_socket="--socket $socket"
fi
if [ -n $pwre_kroot ]; then
pwr_dbversion=`eval cat $pwre_kroot/exp/inc/src/pwr_version.h | grep "\bpwrv_cWbdbVersionShortStr\b" | awk '{print $3}'`
if [ -z $pwr_dbversion ]; then
echo "Unable to get pwr db version"
fi
export pwr_dbversion=${pwr_dbversion:1:3}
export pwre_dbversion=$pwr_dbversion
fi
}
#!/bin/bash
#
# Merge build tree for a module to common build tree
#
merge_dir_func()
{
local todir=$1
local fromdir=$2
local singlefile=$3
if [ "$singlefile" != "" ]; then
files=$singlefile
todir=$todir/${singlefile%/*}
else
files=`eval ls $fromdir 2>/dev/null`
fi
if [ ! -z "$files" ]; then
for file in $files; do
if [ ! -d $fromdir/$file ]; then
if [ -e $todir/$file ]; then
if [ $todir/$file -ot $fromdir/$file ]; then
echo "Copy $fromdir/$file"
cp $fromdir/$file $todir
fi
else
echo "Copy $fromdir/$file"
cp $fromdir/$file $todir
if [ ${file##*.} = "dbs" ]; then
# Change access on dbsfiles
chmod a+w $todir/$file
fi
fi
fi
done
fi
}
fromroot=$1
toroot=$2
file=$3
if [ "$file" != "" ]; then
# Merge only this file
merge_dir_func $toroot $fromroot $file
else
# Copy exe, load, obj and inc
merge_dir_func $toroot/exe $fromroot/exe
merge_dir_func $toroot/exe/sv_se $fromroot/exe/sv_se
merge_dir_func $toroot/exe/en_us $fromroot/exe/en_us
merge_dir_func $toroot/exe/de_de $fromroot/exe/de_de
merge_dir_func $toroot/inc $fromroot/inc
merge_dir_func $toroot/load $fromroot/load
merge_dir_func $toroot/obj $fromroot/obj
# Merge archives
cd ${toroot%/*}/tmp
libraries=`eval ls $fromroot/lib/* 2>/dev/null`
for lib in $libraries; do
arname=${lib##/*/}
if [ $arname = "libpwr_rt.a" ] || [ $arname = "libpwr_cow.a" ] || [ $arname = "libpwr_cow_motif.a" ] || [ $arname = "libpwr_cow_gtk.a" ] || [ $arname = "libpwr_wb.a" ] || [ $arname = "libpwr_wb_motif.a" ] || [ $arname = "libpwr_wb_gtk.a" ] || [ $arname = "libpwr_xtt.a" ] || [ $arname = "libpwr_xtt_motif.a" ] || [ $arname = "libpwr_xtt_gtk.a" ]; then
echo "Merge $lib"
modules=`eval ar -t $lib`
ar -x $lib
ar -rc $toroot/lib/$arname $modules
rm $modules
else
echo "Copy $lib"
cp $lib $toroot/lib/
fi
done
# Merge io methods
methodfile=$pwr_inc/rt_io_$pwre_module.meth
if [ -e $methodfile ]; then
echo "-- Merge io methods"
co_merge io_base $pwr_einc/rt_io_\*.meth $pwr_elib/libpwr_rt.a
fi
# Merge wb methods
methodfile=$pwr_inc/wb_$pwre_module.meth
if [ -e $methodfile ]; then
echo "-- Merge wb methods"
co_merge wb_base $pwr_einc/wb_\*.meth $pwr_elib/libpwr_wb.a
fi
# Merge xtt methods
methodfile=$pwr_inc/xtt_$pwre_module.meth
if [ -e $methodfile ]; then
echo "-- Merge xtt methods"
co_merge xtt_base $pwr_einc/xtt_\*.meth $pwr_elib/libpwr_xtt.a
fi
fi
#!/bin/bash
#
# Proview $Id: wb_admin.sh,v 1.1 2006-01-23 08:44:30 claes Exp $
# Copyright (C) 2005 SSAB Oxelsund AB.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with the program, if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
wb_adm_opendb_func ()
{
#
# Command is "opendb"
#
# Arguments 1: project
# 2: username
# 3: password
# 4: database
# 5: volume
local project=$1
local username=$2
local password=$3
local database=$4
local volume=$5
echo "args: $1 $2 $3 $4 $5"
source pwrp_env.sh set project $project
if [ "$database" != "dbdirectory" ]; then
source pwrp_env.sh setdb $database
fi
wb -q "$username" "$password" $volume &
}
wb_adm_create_func ()
{
local cmd
cmd="project"
if [ $1 = $cmd ] || [ ${cmd#$1} != $cmd ]; then
#
# Command is "create project"
#
# Arguments 2: project name
# 3: base name
# 4: project root
# 5: project hierarchy
# 6-: description
pname=$2
bname=$3
proot=$4
source pwrp_env.sh create $@
if [ $pwrc_status -ne 0 ]; then
return $pwrc_status
fi
#source pwrp_env.sh set project $pname
#if [ $pwrc_status -ne 0 ]; then
# return $pwrc_status
#fi
#wb_cmd create volume/name=\"directory\"/ident=254.254.254.253/class=\$DirectoryVolume
fi
}
wb_adm_parse ()
{
local cmd
cmd="opendb"
if [ -z $1 ] || [ $1 = $cmd ] || [ ${cmd#$1} != $cmd ]; then
shift
wb_adm_opendb_func $1 $2 $3 $4 $5
return
fi
cmd="create"
if [ -z $1 ] || [ $1 = $cmd ] || [ ${cmd#$1} != $cmd ]; then
shift
wb_adm_create_func $@
return
fi
echo "Unknown command"
}
#set -o xtrace
wb_adm_parse $@
#set +o xtrace
#!/bin/bash
#
# Proview $Id: wb_create_db.sh,v 1.1 2006-01-23 08:44:30 claes Exp $
# Copyright (C) 2005 SSAB Oxelösund AB.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with the program, if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#
# Create the database directory and copy en empty database to the
# directory.
#
db=$1
source pwrp_env.sh copy template $db noconfirm
if [ $? != 0 ]; then
return 1;
fi
#!/bin/bash
#
# Proview $Id: wb_distr_keepboot.sh,v 1.1 2006-01-23 08:44:30 claes Exp $
# Copyright (C) 2005 SSAB Oxelösund AB.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with the program, if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#
# Keep the old versions of bootfiles
#
new_file=$1
if [ -e $new_file ]; then
let version=30
while [ $version -ge 1 ]
do
old_file=$new_file.$version
old_file_ren=$new_file.$((version+1))
if [ -e $old_file ]; then
mv $old_file $old_file_ren
fi
let version=$version-1
done
old_file=$new_file.1
echo "-- Saving file $new_file -> $old_file"
mv $new_file $old_file
fi
#!/bin/bash
#
# Proview $Id: wb_gcg.sh,v 1.7 2008-06-02 14:58:42 claes Exp $
# Copyright (C) 2005 SSAB Oxelsund AB.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with the program, if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# wb_gcg.sh -- compile and link PLC code
#
# This compiles a file generated by wb_gcg
# and inserts it in the plc library
# It is called from the wb_gcg.c module.
#
let gcg__success=0
let gcg__compileerrors=1
let gcg__linkerrors=2
let gcg__archiveerror=3
let gcg__rsherror=4
#
# MyRsh returns the return status from the compile command, not from rsh
# It only works on remote unix systems, not VMS...
#
MyRsh()
{
hostname=
lflag=
nflag=
user=
case $1 in
-l)
;;
*)
hostname=$1
shift
esac
case $1 in
-l)
lflag=-l
user=$2
shift 2
esac
case $1 in
-n)
nflag=-n
shift
esac
case $hostname in
'')
hostname=$1
shift
esac
case $# in
0)
exec /usr/ucb/rlogin $lflag ${user+"$user"} "$hostname"
esac
AWK='
NR > 1 {
print prev;
prev = $0;
prev1 = $1;
prev2 = $2;
}
NR == 1 {
prev = $0;
prev1 = $1;
prev2 = $2;
}
END {
if (prev1 ~ /[0-9]*[0-9]0/)
exit(prev1 / 10);
if (prev1 == "0")
exit(prev2);
print prev;
exit(1);
}
'
exec 3>&1
if rsh "$hostname" $lflag ${user+"$user"} $nflag \
"(${*-:}); sh -c '"'echo "$0 $1" >&2'\'' $?0 "$status"' \
2>&1 >&3 3>&- | awk "$AWK" >&2 3>&-
then
gcg_status=0
else
gcg_status=1
fi
}
CompileProcess()
{
if $cc_cmd -o $pwrp_obj/${FileName}.o $pwrp_gc/${FileName}.gc
then
echo "-- Plc process compiled for $OsStr $say_debug $ObjectName"
gcg_status=$gcg__success
else
echo "** Plc process compiled with errors $OsStr $ObjectName"
gcg_status=$gcg__compileerrors
fi
if [ $Debug -eq 0 ]; then
rm $pwrp_gc/${FileName}.gc
fi
}
CompileProgram()
{
if $cc_cmd -o $pwrp_obj/plc_m${FileName}.o $pwrp_gc/plc_m${FileName}.gc
then
echo "-- Plc plcpgm compiled for $OsStr $say_debug $ObjectName"
gcg_status=$gcg__success
else
echo "** Plc plcpgm compiled with errors $OsStr $ObjectName"
gcg_status=$gcg__compileerrors
fi
if [ $Debug -eq 0 ]; then
rm $pwrp_gc/plc_m${FileName}.gc
fi
}
CompileWindow()
{
if $cc_cmd -o $pwrp_obj/plc_m${FileName}.o $pwrp_gc/plc_m${FileName}.gc
then
echo "-- Plc window compiled for $OsStr $say_debug $ObjectName"
gcg_status=$gcg__success
else
echo "** Plc window compiled with errors for $OsStr $ObjectName"
gcg_status=$gcg__compileerrors
fi
if [ $Debug -eq 0 ]; then
rm $pwrp_gc/plc_m${FileName}.gc
rm $pwrp_gc/plc_dec${FileName}.gc
rm $pwrp_gc/plc_r1r${FileName}.gc
rm $pwrp_gc/plc_r2r${FileName}.gc
rm $pwrp_gc/plc_ref${FileName}.gc
rm $pwrp_gc/plc_cod${FileName}.gc
fi
}
CompileRtNode()
{
#link option file exists and is not empty
if [ -s $pwrp_exe/$FileName.opt ]; then
ld_opt_tmp="`cat $pwrp_exe/$FileName.opt`"
ld_opt="`eval echo $ld_opt_tmp`"
else
ld_opt="`eval echo $pwr_obj/rt_io_user.o -lpwr_rt -lpwr_usbio_dummy`"
fi
if g++ $link_debug -L/lib/thread -L$pwrp_lib -L$pwrp_cmn/x86_linux/lib -L$pwr_lib \
-o $pwrp_exe/$OutFile \
$pwr_obj/rt_plc_process.o \
$pwrp_obj/${FileName}.o \
$Libs \
$ld_opt \
$pwr_obj/pwr_msg_rt.o $pwr_obj/pwr_msg_co.o \
-lpwr_remote -lpwr_nmps -lpwr_rt -lpwr_co -lrpcsvc -lpwr_msg_dummy -lpthread -lm
then
echo "-- Plc program linked for $OsStr $say_linkdebug node $FileName"
gcg_status=$gcg__success
else
echo "** Plc program link errors for $OsStr node $FileName"
gcg_status=$gcg__linkerrors
fi
if [ -n "$pwrp_exe_target" ]; then
cp $pwrp_exe/$OutFile $pwrp_exe_target
echo "-- Plc copied to $pwrp_exe_target"
fi
}
CompileLibrary()
{
echo "-- Building archive for volume: $VolumeId"
cd $pwrp_obj
if ar -rc $pwrp_lib/$PlcLib `ls plc_m${VolumeId}*.o`
then
echo "-- Archive built for volume: $VolumeId"
gcg_status=$gcg__success
else
echo "** Error builing archive for volume: $VolumeId"
gcg_status=$gcg__archiveerror
fi
}
OsMaskToOpSys ()
{
let BitM=$1
let Idx=0
let Val=1
while [ $Val -lt $BitM ]; do
let Val=$Val*2
let Idx=$Idx+1
done
let OpSys=Idx+1
}
#
#
#
# Main
#
#
#
# Arguments
#
let Debug="$1" # 1 if debug, 0 i nodebug
let FileType="$2" # the type of file: rtnode,
# plc or window module
FileName="$3" # the name of the file to be compiled,
VolumeId="$3" # VolumeId for objects to be inserted
let OsMask="$4" # pwr_mOpSys
OutFile="$5" # the name of the generated file
PlcLib="$5" # library for filetype Program and Windoow
Libs="$6" # link libraries
ObjectName="$6" # name of object
SystemName="$7" # name of system
ProjectRoot="$8" # project root
OsMaskToOpSys $OsMask # Convert Bitmask to index
#
# Local symbols
#
let OpSys__Low=0
let OpSys_CustomBuild=1
let OpSys_VAX_VMS=2
let OpSys_AXP_VMS=3
let OpSys_PPC_LYNX=4
let OpSys_X86_LYNX=5
let OpSys_PPC_LINUX=6
let OpSys_X86_LINUX=7
let OpSys_X86_64_LINUX=8
let OpSys_X86_64_MACOS=9
let OpSys_X86_64_FREEBSD=11
let OpSys__High=12
vOpSys="custombuild,vax_vms,axp_vms,ppc_lynx,x86_lynx,ppc_linux,x86_linux,x86_64_linux"
let FileType__Low=-1
let FileType_Process=0
let FileType_Program=1
let FileType_Window=2
let FileType_RtNode=3
let FileType_Library=4
let FileType__High=5
vFileType="Process,Program,Window,RtNode,Library"
local_setup="pwr_gcg_setup.sh"
if [ -e ${local_setup} ]; then
# echo "-- Local setup file used"
source ${local_setup} ${ProjectRoot} ${SystemName}
fi
if [ $Debug -eq 1 ]; then
cc_debug="-g"
link_debug="-g"
say_debug="with debug"
say_linkdebug="with debug"
else
cc_debug="-O3"
say_debug="optimized -O3"
say_linkdebug=""
fi
#
# Check OpSys
#
# Current opsys
unamestr=`eval uname`
machine=`eval uname -m`
if [ $unamestr == "Darwin" ]; then
CurrentOpSys=$OpSys_X86_64_MACOS
elif [ $unamestr == "FreeBSD" ]; then
CurrentOpSys=$OpSys_X86_64_FREEBSD
else
if [ $machine = "x86_64" ]; then
CurrentOpSys=$OpSys_X86_64_LINUX
else
CurrentOpSys=$OpSys_X86_LINUX
fi
fi
#
# Check FileType
#
if [ $FileType -le $FileType__Low ] || [ $FileType -ge $FileType__High ];
then
echo "Unknown file type: $FileType"
exit -1
fi
OsStr="`echo $vOpSys| cut -f $OpSys -d ,`"
let FileTypeIdx=$FileType+1
if [ $OpSys -eq $OpSys_PPC_LINUX ]; then
pwrp_gc="$pwrp_tmp"
# Suppress all warnings, -x
cc_cmd="gcc -c -x c -w $cc_debug -D_REENTRANT -DOS_LINUX -I$pwr_inc -I$pwrp_inc -I$pwrp_tmp $PWR_EXT_INC"
FileTypeStr="`echo $vFileType| cut -f $FileTypeIdx -d ,`"
# Execute build command
Compile$FileTypeStr
exit $gcg_status
elif [ $OpSys -eq $OpSys_X86_LINUX ]; then
pwrp_gc="$pwrp_tmp"
# Suppress all warnings, -x
if [ $CurrentOpSys -eq $OpSys ]; then
cc_cmd="gcc -c -x c -w $cc_debug -D_REENTRANT -DOS_LINUX -I$pwr_inc -I$pwrp_inc -I$pwrp_tmp $PWR_EXT_INC"
FileTypeStr="`echo $vFileType| cut -f $FileTypeIdx -d ,`"
# Execute build command
Compile$FileTypeStr
exit $gcg_status
elif [ $CurrentOpSys -eq $OpSys_X86_64_LINUX ]; then
echo "-- Not built for x86_linux"
fi
elif [ $OpSys -eq $OpSys_X86_64_LINUX ]; then
pwrp_gc="$pwrp_tmp"
# Suppress all warnings, -x
if [ $CurrentOpSys -eq $OpSys ]; then
cc_cmd="gcc -c -x c -w $cc_debug -D_REENTRANT -DOS_LINUX -I$pwr_inc -I$pwrp_inc -I$pwrp_tmp $PWR_EXT_INC"
FileTypeStr="`echo $vFileType| cut -f $FileTypeIdx -d ,`"
# Execute build command
Compile$FileTypeStr
exit $gcg_status
elif [ $CurrentOpSys -eq $OpSys_X86_LINUX ]; then
echo "-- Not built for x86_64_linux"
fi
elif [ $OpSys -eq $OpSys_X86_64_MACOS ]; then
pwrp_gc="$pwrp_tmp"
# Suppress all warnings, -x
if [ $CurrentOpSys -eq $OpSys ]; then
cc_cmd="gcc -c -x c -w $cc_debug -D_REENTRANT -DOS_MACOS -I$pwr_inc -I$pwrp_inc -I$pwrp_tmp $PWR_EXT_INC"
FileTypeStr="`echo $vFileType| cut -f $FileTypeIdx -d ,`"
# Execute build command
Compile$FileTypeStr
exit $gcg_status
fi
elif [ $OpSys -eq $OpSys_X86_64_FREEBSD ]; then
pwrp_gc="$pwrp_tmp"
# Suppress all warnings, -x
if [ $CurrentOpSys -eq $OpSys ]; then
cc_cmd="gcc -c -x c -w $cc_debug -D_REENTRANT -DOS_FREEBSD -I$pwr_inc -I$pwrp_inc -I$pwrp_tmp $PWR_EXT_INC"
FileTypeStr="`echo $vFileType| cut -f $FileTypeIdx -d ,`"
# Execute build command
Compile$FileTypeStr
exit $gcg_status
fi
elif [ $OpSys -eq $OpSys_AXP_VMS ]; then
rsh $pwr_build_host_axp_vms @pwr_exe:wb_gcg \"$1\" \"$2\" \"$3\" \"$4\" \"$5\" \"$6\" \"$7\" \"$pwrp_root\"
exit $?
elif [ $OpSys -eq $OpSys_VAX_VMS ]; then
rsh $pwr_build_host_vax_vms @pwr_exe:wb_gcg \"$1\" \"$2\" \"$3\" \"$4\" \"$5\" \"$6\" \"$7\" \"$pwrp_root\"
exit $?
elif [ $OpSys -eq $OpSys_X86_LYNX ]; then
MyRsh $pwr_build_host_x86_lynx '$pwr_exe/wb_gcg.sh' \"$1\" \"$2\" \"$3\" \"$4\" \"$5\" \"$6\" \"$7\" \"$pwrp_root\"
exit $gcg_status
elif [ $OpSys -eq $OpSys_CustomBuild ]; then
if [ -e $pwrp_exe/custom_build.sh ]; then
$pwrp_exe/custom_build.sh "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$pwrp_root"
exit $gcg_status
else
echo "Create \$pwrp_exe/custom_build.sh to build this volume"
exit $gcg_status
fi
else
echo "Unknown operating system: $OpSys"
exit -1
fi
#!/bin/bash
#
# Proview $Id: wb_gre_print.sh,v 1.1 2006-01-23 08:44:30 claes Exp $
# Copyright (C) 2005 SSAB Oxelösund AB.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with the program, if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#
if [ -z "$pwr_foe_gre_print" ]; then
echo "Printer is not defined in env 'pwr_foe_gre_print'"
fi
echo "Printing $1"
$pwr_foe_gre_print $1
#!/bin/bash
#
# Proview $Id: wb_open_db.sh,v 1.3 2008-10-09 08:31:42 claes Exp $
# Copyright (C) 2005 SSAB Oxelösund AB.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with the program, if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#
# Open a new terminal and start the navigator
# This procedure is started from the navigator 'Open db' method for
# DbConfig and DbTrace objects.
#
username=$1
password=$2
database=$3
title=$4
#set -o xtrace
if [ -z $database ]; then
echo "Database is missing"
return
fi
echo "-- Opening volume '$database'"
wb -q "$username" "$password" $database
#!/bin/bash
#
# Proview $Id: wb_pvd_pl.sh,v 1.2 2006-01-31 09:10:21 claes Exp $
# Copyright (C) 2005 SSAB Oxelsund AB.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with the program, if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#set -o xtrace
declare -ix pwrc_status=$pwrc__success
declare -i pwrc__success=0
declare -i pwrc__dbnotfound=1
declare -i pwrc__noproj=3
declare -i pwrc__rootexist=4
declare -i pwrc__notconfigured=5
declare -i pwrc__projlistfile=6
declare -i pwrc__projalrexist=7
declare -i pwrc__basealrexist=8
declare -i pwrc__nobase=9
declare -i pwrc__projlistfileacc=10
declare -i pwrc__syntax=11
declare -i pwrc__rootacc=12
declare -i pwrc__rootcreate=13
declare -i pwrc__rootdelete=14
declare -i pwrc__dbdelete=15
declare -i pwrc__baseexist=16
declare -i pwrc__move=17
declare -i pwrc__notmysqlsrv=18
declare -i pwrc__datadir=19
declare -i pwrc__nodb=20
declare -i pwrc__notemplatedb=21
declare -i pwrc__dbalrexist=22
declare -i pwrc__copy=23
declare -i pwrc__dbcreate=24
declare -i pwrc__projnotset=25
declare -i pwrc__projnameinv=26
declare -i pwrc__mysqldbcopy=27
declare -i pwrc__mysqldbrena=28
declare -i pwrc__mysql=29
declare -i pwrc__noroot=30
wb_pl_opendb_func ()
{
#
# Command is "opendb"
#
# Arguments 1: project
# 2: username
# 3: password
# 4: database
# 5: volume
local project=$1
local username=$2
local password=$3
local database=$4
local volume=$5
echo "args: $1 $2 $3 $4 $5"
source pwrp_env.sh set project $project
#if [ "$database" != "dbdirectory" ]; then
# source pwrp_env.sh setdb $database
#fi
wb -q "$username" "$password" $volume &
}
wb_pl_check_func ()
{
cmd="move"
if [ $1 = $cmd ] || [ ${cmd#$1} != $cmd ]; then
#
# Command is "check move"
#
# Arguments 2: source root
# 3: destination root
local srcroot=$2
local destroot=$3
local destdir=${destroot%/*}
if [ ! -e "$srcroot" ]; then
echo "Source root not found"
pwrc_status=$pwrc_noroot
fi
if [ -e "$destroot" ]; then
if [ ! -w "$destroot" ]; then
echo "No write access to project root"
pwrc_status=$pwrc__rootacc
return
else
if [ -e "$destroot/common" ]; then
echo "Error: destination root already exist"
pwrc_status=$pwrc__rootexist
return
fi
fi
else
if [ ! -e "$destdir" ]; then
echo "Can't create destination root"
pwrc_status=$pwrc__rootcreate
return
else
if [ ! -w "$destdir" ]; then
echo "No write access to project root"
pwrc_status=$pwrc__rootacc
return
fi
fi
fi
pwrc_status=$pwrc__success
return
fi
cmd="create"
if [ $1 = $cmd ] || [ ${cmd#$1} != $cmd ]; then
#
# Command is "check move"
#
# Arguments 2: destination root
local destroot=$2
local destdir=${destroot%/*}
if [ -e "$destroot" ]; then
if [ ! -w "$destroot" ]; then
echo "No write access to project root"
pwrc_status=$pwrc__rootacc
return
else
if [ -e "$destroot/common" ]; then
echo "Error: destination root already exist"
pwrc_status=$pwrc__rootexist
return
fi
fi
else
if [ ! -e "$destdir" ]; then
echo "Can't create destination root"
pwrc_status=$pwrc__rootcreate
return
else
if [ ! -w "$destdir" ]; then
echo "No write access to project root"
pwrc_status=$pwrc__rootacc
return
fi
fi
fi
pwrc_status=$pwrc__success
return
fi
}
wb_pl_create_func ()
{
local cmd
cmd="project"
if [ $1 = $cmd ] || [ ${cmd#$1} != $cmd ]; then
#
# Command is "create project"
#
# Arguments 2: project name
# 3: base name
# 4: project root
# 5: project hierarchy
# 6-: description
pname=$2
bname=$3
proot=$4
source pwrp_env.sh create $@
if [ $pwrc_status -ne 0 ]; then
return $pwrc_status
fi
#source pwrp_env.sh set project $pname
#if [ $pwrc_status -ne 0 ]; then
# return $pwrc_status
#fi
#wb_cmd create volume/name=\"directory\"/ident=254.254.254.253/class=\$DirectoryVolume
fi
}
wb_pl_parse ()
{
local cmd
cmd="opendb"
if [ -z $1 ] || [ $1 = $cmd ] || [ ${cmd#$1} != $cmd ]; then
shift
wb_pl_opendb_func $1 $2 $3 $4 $5
return
fi
cmd="create"
if [ -z $1 ] || [ $1 = $cmd ] || [ ${cmd#$1} != $cmd ]; then
shift
wb_pl_create_func $@
return
fi
cmd="check"
if [ -z $1 ] || [ $1 = $cmd ] || [ ${cmd#$1} != $cmd ]; then
shift
wb_pl_check_func $@
return $pwrc_status
fi
echo "Unknown command"
}
#set -o xtrace
wb_pl_parse $@
#set +o xtrace
#!/bin/bash
#
# Proview $Id: wb_start.sh,v 1.2 2007-05-28 14:50:48 claes Exp $
# Copyright (C) 2005 SSAB Oxelösund AB.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with the program, if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#
# Start the navigator
#
username=$1
password=$2
volume=$3
wb $username $password $volume $4 $5 $6 $7
#!/bin/bash
#
# Edit a base wb_load-file with classeditor
#
export pwr_exe=$pwr_eexe
export pwr_load=$pwr_eload
wb -c $1
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment