#!/bin/sh
#
# Install evaluate_parameters and friends.
# You should run this procedure while logged in as root.
#
# Stephen.O.Lidie@CDC1.CC.Lehigh.EDU, 91/06/24.
#
# Works on VX/VE 5.2.3 L765XA.

INC=/usr/local/include
BIN=/usr/local/bin
LIB=/usr/local/lib

rm ${BIN}/generate_pdt

echo "Installing evap.h in ${INC} ..."
cp evap.h ${INC}/evap.h
chmod 755 ${INC}/evap.h

echo "Compiling evaluate_parameters ..."
cc -DP_EVAP_MM_PATH=\"${LIB}/libevapmm.a\" -O -c \
      -I${INC} evap.c

echo "Creating evap library ..."
echo "Installing libevap.a in ${LIB} ..."
ar rcv ${LIB}/libevap.a evap.o
#ranlib ${LIB}/libevap.a
chmod 755 ${LIB}/libevap.a

echo "Compiling generate_pdt ..."
cc -O -o ${BIN}/genpdt -I${INC} -Wl,-L${LIB} genpdt.c -levap
cp ${BIN}/genpdt ${BIN}/generate_pdt
chmod 755 ${BIN}/genpdt
chmod 755 ${BIN}/generate_pdt

echo "Generating display_command_information's PDT ..."
${BIN}/generate_pdt -i pdt/disci_pdt -o pdt/disci_pdt_out

echo "Compiling display_command_information ..."
cc disci.c -o ${BIN}/disci -O -I${INC} -Wl,-L${LIB} -levap
cp ${BIN}/disci  ${BIN}/display_command_information
chmod 755 ${BIN}/disci
chmod 755 ${BIN}/display_command_information

echo "Generating add_message_modules' PDT ..."
cat > pdt/addmm_pdt << end_of_addmm_pdt
PDT (addmm.mm) add_message_modules, add_message_module, addmm
  message_module_library, mml: file = D_ADDMM_MML, ${LIB}/libevapmm.a
PDTEND required_file_list
end_of_addmm_pdt
${BIN}/generate_pdt -i pdt/addmm_pdt -o pdt/addmm_pdt_out

echo "Compiling add_message_modules ..."
cc addmm.c -o ${BIN}/addmm -O -I${INC} -Wl,-L${LIB} -levap
cp ${BIN}/addmm ${BIN}/add_message_modules
cp ${BIN}/addmm ${BIN}/add_message_module
chmod 755 ${BIN}/addmm
chmod 755 ${BIN}/add_message_modules
chmod 755 ${BIN}/add_message_module

echo "Saving previous message module archive file as libevapmm.a_old ..."
cp ${LIB}/libevapmm.a ${LIB}/libevapmm.a_old
rm ${LIB}/libevapmm.a

echo "Generating message modules for generate_pdt, ..."
echo "      display_command_information, and ..."
echo "      add_message_modules."

${BIN}/add_message_modules message_module/*.mm
chmod 755 ${LIB}/libevapmm.a

echo
echo "Installation of evaluate_parameters and friends is complete."
