430 lines
10 KiB
Bash
430 lines
10 KiB
Bash
#!/bin/sh
|
|
#
|
|
# Shell script to configure TC for MinGW and create the Inno setup script.
|
|
#
|
|
# License: TinyCOBOL is covered by GNU General Public License
|
|
# Copyright (C) 2001-2004 David Essex
|
|
#
|
|
# cmd: tconfig.mingw.sh [options]
|
|
# options:
|
|
# -h Display this information
|
|
# -d 'YYYY/MM/DD' Set release date (default is current date)
|
|
# -i 'directory' Set make file install directory (default='C:/TinyCOBOL')
|
|
# -l language Set language (en/es/fr/it/pt_BR/ default=en)
|
|
# -m Set MF compatability option on (default=off)
|
|
# -r build Set release build (default=1)
|
|
# -v 'major.minor.patch' Set release version (default is parsed from configure.in)
|
|
#
|
|
#
|
|
e0a="invalid number of parms..."
|
|
e0b="invalid option(s) "
|
|
e0c="TC configure and Inno setup script for MinGW"
|
|
e0d="usage: tconfig.mingw.sh [ options ]\nOptions:\n\
|
|
-h Display this information\n\
|
|
-d 'YYYY/MM/DD' Set release date (default is current date)\n\
|
|
-i 'directory' Set make file install directory (default='C:/TinyCOBOL')\n\
|
|
-l language Set language (en/es/fr/it/pt_BR/ default=en)\n\
|
|
-m Set MF compatability option on (default=off)\n\
|
|
-r build Set release build (default=1)\n\
|
|
-v 'major.minor.patch' Set release version (default is parsed from configure.in)\
|
|
"
|
|
#
|
|
p_print1 ()
|
|
{
|
|
for arg in "$@"
|
|
do
|
|
# echo $arg >&2
|
|
printf "$arg\n" >&2
|
|
done
|
|
}
|
|
#
|
|
TCOB_MAJOR_VERSION=''
|
|
TCOB_MINOR_VERSION=''
|
|
TCOB_PATCH_LEVEL=''
|
|
TCOB_RELEASE_VERSION=1
|
|
TCOB_VERSION=''
|
|
TCOB_RELEASE_DATE=''
|
|
tcob_version=$TCOB_VERSION
|
|
tcob_rdate=$TCOB_RELEASE_DATE
|
|
tcob_release=$TCOB_RELEASE_VERSION
|
|
#
|
|
TCOBPP_MAJOR_VERSION=''
|
|
TCOBPP_MINOR_VERSION=''
|
|
TCOBPP_PATCH_LEVEL=''
|
|
TCOBPP_VERSION=''
|
|
TCOBPP_RELEASE_DATE=''
|
|
tcobpp_version=$TCOBPP_VERSION
|
|
tcobpp_rdate=$TCOBPP_RELEASE_DATE
|
|
#
|
|
with_lang=''
|
|
tcob_lang=en
|
|
tcob_install_dir='C:/TinyCOBOL'
|
|
host_os=MinGW
|
|
#
|
|
#/* #undef USE_MF_COMPATABILITY */
|
|
tcob_mfopt='0'
|
|
tcob_mfopt1='\/\* \#undef USE_MF_COMPATABILITY \*\/'
|
|
tcob_mfopt2='\#define USE_MF_COMPATABILITY 1'
|
|
#
|
|
errf1=0
|
|
#
|
|
# Get information from configure.in file
|
|
#
|
|
p_set_version ()
|
|
{
|
|
#
|
|
if [ -z "$tcob_version" ]
|
|
then
|
|
TCOB_MAJOR_VERSION=`grep '^TCOB_MAJOR_VERSION' version.txt | cut -f2 -d'='`
|
|
TCOB_MINOR_VERSION=`grep '^TCOB_MINOR_VERSION' version.txt | cut -f2 -d'='`
|
|
TCOB_PATCH_LEVEL=`grep '^TCOB_PATCH_LEVEL' version.txt | cut -f2 -d'='`
|
|
TCOB_VERSION=$TCOB_MAJOR_VERSION.$TCOB_MINOR_VERSION.$TCOB_PATCH_LEVEL
|
|
tcob_version=$TCOB_VERSION
|
|
else
|
|
str1=`echo "$tcob_version" | sed 's|[0-9]*\.[0-9]*\.[0-9]*||g'`
|
|
# echo "debug: str1=$str1;"
|
|
if [ -z "$str1" ]
|
|
then
|
|
TCOB_MAJOR_VERSION=`echo "$tcob_version" | cut -f1 -d'.'`
|
|
TCOB_MINOR_VERSION=`echo "$tcob_version" | cut -f2 -d'.'`
|
|
TCOB_PATCH_LEVEL=`echo "$tcob_version" | cut -f3 -d'.'`
|
|
TCOB_VERSION=$TCOB_MAJOR_VERSION.$TCOB_MINOR_VERSION.$TCOB_PATCH_LEVEL
|
|
tcob_version=$TCOB_VERSION
|
|
else
|
|
e00="error: version=$tcob_version is invalid ...aborting"
|
|
p_print1 "$e00"
|
|
exit 1
|
|
fi
|
|
fi
|
|
}
|
|
#
|
|
p_set_release_date ()
|
|
{
|
|
#
|
|
if [ -z "$tcob_rdate" ]
|
|
then
|
|
# TCOB_RELEASE_DATE=`date +%Y\\/%m\\/%d | sed 's.\/.\\\/.g'`
|
|
TCOB_RELEASE_DATE=`date +%Y/%m/%d`
|
|
tcob_rdate=$TCOB_RELEASE_DATE
|
|
else
|
|
str1=`echo "$tcob_rdate" | sed 's|[12][0-9]\{3\}\/[0-9]\{1,2\}\/[0-9]\{1,2\}||g'`
|
|
if [ -z "$str1" ]
|
|
then
|
|
# TCOB_RELEASE_DATE=`echo "$tcob_rdate" | sed 's.\/.\\\/.g'`
|
|
TCOB_RELEASE_DATE="$tcob_rdate"
|
|
tcob_rdate=$TCOB_RELEASE_DATE
|
|
else
|
|
e00="error: release date=$tcob_rdate is invalid ...aborting"
|
|
p_print1 "$e00"
|
|
exit 1
|
|
fi
|
|
fi
|
|
}
|
|
#
|
|
p_set_cobpp_version ()
|
|
{
|
|
TCOBPP_MAJOR_VERSION=`cat configure.in | grep '^TCOBPP_MAJOR_VERSION' | cut -f2 -d'='`
|
|
TCOBPP_MINOR_VERSION=`cat configure.in | grep '^TCOBPP_MINOR_VERSION' | cut -f2 -d'='`
|
|
TCOBPP_PATCH_LEVEL=`cat configure.in | grep '^TCOBPP_PATCH_LEVEL' | cut -f2 -d'='`
|
|
TCOBPP_VERSION=$TCOBPP_MAJOR_VERSION.$TCOBPP_MINOR_VERSION.$TCOBPP_PATCH_LEVEL
|
|
TCOBPP_RELEASE_DATE=`cat configure.in | grep '^TCOBPP_RELEASE_DATE' | cut -f2 -d'=' | sed 's.\/.\\\/.g'`
|
|
tcobpp_version=$TCOBPP_VERSION
|
|
tcobpp_rdate=$TCOBPP_RELEASE_DATE
|
|
#
|
|
# echo "debug: TCOB_RELEASE_DATE=$TCOB_RELEASE_DATE, $tcob_rdate"
|
|
# echo "debug: TCOBPP_RELEASE_DATE=$TCOBPP_RELEASE_DATE, $tcobpp_rdate"
|
|
}
|
|
#
|
|
#
|
|
# Check and set language option
|
|
#
|
|
p_check_lang_otion ()
|
|
{
|
|
#
|
|
case "x$with_lang" in
|
|
x) tcob_lang='en' ;;
|
|
xen) tcob_lang='en' ;;
|
|
xes) tcob_lang='es' ;;
|
|
xfr) tcob_lang='fr' ;;
|
|
xit) tcob_lang='it' ;;
|
|
xpt_BR) tcob_lang='pt_BR' ;;
|
|
*) echo "Language option '$with_lang' not available, defaulting to language=en (English)"
|
|
tcob_lang='en';;
|
|
esac
|
|
}
|
|
#
|
|
# Create PP version and command line help files
|
|
#
|
|
p_cobpp ()
|
|
{
|
|
#
|
|
p_check_file_exists cobpp/tcppversion.h
|
|
if [ $errf1 -eq 0 ]
|
|
then
|
|
cat cobpp/tcppversion.h.in | \
|
|
sed \
|
|
-e "s|@TCOBPP_MAJOR_VERSION@|$TCOBPP_MAJOR_VERSION|g" \
|
|
-e "s|@TCOBPP_MINOR_VERSION@|$TCOBPP_MINOR_VERSION|g" \
|
|
-e "s|@TCOBPP_PATCH_LEVEL@|$TCOBPP_PATCH_LEVEL|g" \
|
|
-e "s|@TCOBPP_VERSION@|$tcobpp_version|g" \
|
|
-e "s|@TCOBPP_RELEASE_DATE@|$tcobpp_rdate|g" \
|
|
-e "s|@host_os@|$host_os|g" \
|
|
> cobpp/tcppversion.h
|
|
fi
|
|
#
|
|
# cat cobpp/tcpphelp.h.in |
|
|
# sed
|
|
# -e "s|@tcob_lang@|$tcob_lang|g"
|
|
# > cobpp/tcpphelp.h
|
|
}
|
|
#
|
|
# Create main compiler version and command line help files
|
|
#
|
|
p_cob ()
|
|
{
|
|
p_check_file_exists compiler/htversion.h
|
|
if [ $errf1 -eq 0 ]
|
|
then
|
|
cat compiler/htversion.h.in | \
|
|
sed \
|
|
-e "s|@TCOB_MAJOR_VERSION@|$TCOB_MAJOR_VERSION|g" \
|
|
-e "s|@TCOB_MINOR_VERSION@|$TCOB_MINOR_VERSION|g" \
|
|
-e "s|@TCOB_PATCH_LEVEL@|$TCOB_PATCH_LEVEL|g" \
|
|
-e "s|@TCOB_VERSION@|$tcob_version|g" \
|
|
-e "s|@TCOB_RELEASE_DATE@|$tcob_rdate|g" \
|
|
-e "s|@host_os@|$host_os|g" \
|
|
> compiler/htversion.h
|
|
fi
|
|
#
|
|
}
|
|
#
|
|
#
|
|
# Create config
|
|
#
|
|
p_config ()
|
|
{
|
|
#
|
|
p_check_file_exists htconfig.h
|
|
if [ $errf1 -eq 0 ]
|
|
then
|
|
if [ $tcob_mfopt = "0" ]
|
|
then
|
|
cat htconfig.mingw.h | \
|
|
sed \
|
|
-e "s|@tcob_lang@|$tcob_lang|g" \
|
|
-e "s|@tcobpp_lang@|$tcob_lang|g" \
|
|
-e "s|@install_dir@|$tcob_install_dir|g" \
|
|
> htconfig.h
|
|
else
|
|
cat htconfig.mingw.h | \
|
|
sed \
|
|
-e "s|@tcob_lang@|$tcob_lang|g" \
|
|
-e "s|@tcobpp_lang@|$tcob_lang|g" \
|
|
-e "s|@install_dir@|$tcob_install_dir|g" \
|
|
-e "s|$tcob_mfopt1|$tcob_mfopt2|" \
|
|
> htconfig.h
|
|
fi
|
|
fi
|
|
#
|
|
}
|
|
#
|
|
# Create make and WIN32 resource files
|
|
#
|
|
p_main ()
|
|
{
|
|
#
|
|
p_check_file_exists Makefile
|
|
if [ $errf1 -eq 0 ]
|
|
then
|
|
cp -f Makefile.mingw Makefile
|
|
fi
|
|
#
|
|
p_check_file_exists cobpp/Makefile
|
|
if [ $errf1 -eq 0 ]
|
|
then
|
|
# cp -i cobpp/Makefile.mingw cobpp/Makefile
|
|
cat cobpp/Makefile.mingw | \
|
|
sed \
|
|
-e "s|@install_dir@|$tcob_install_dir|g" \
|
|
> cobpp/Makefile
|
|
fi
|
|
#
|
|
p_check_file_exists compiler/Makefile
|
|
if [ $errf1 -eq 0 ]
|
|
then
|
|
# cp -i compiler/Makefile.mingw compiler/Makefile
|
|
cat compiler/Makefile.mingw | \
|
|
sed \
|
|
-e "s|@install_dir@|$tcob_install_dir|g" \
|
|
> compiler/Makefile
|
|
fi
|
|
#
|
|
p_check_file_exists lib/Makefile
|
|
if [ $errf1 -eq 0 ]
|
|
then
|
|
# cp -i lib/Makefile.mingw lib/Makefile
|
|
cat lib/Makefile.mingw | \
|
|
sed \
|
|
-e "s|@tcob_version@|$TCOB_VERSION|g" \
|
|
-e "s|@install_dir@|$tcob_install_dir|g" \
|
|
> lib/Makefile
|
|
fi
|
|
#
|
|
p_check_file_exists cobroutines/Makefile
|
|
if [ $errf1 -eq 0 ]
|
|
then
|
|
# cp -i lib/Makefile.mingw lib/Makefile
|
|
cat cobroutines/Makefile.mingw | \
|
|
sed \
|
|
-e "s|@tcob_version@|$TCOB_VERSION|g" \
|
|
-e "s|@install_dir@|$tcob_install_dir|g" \
|
|
> cobroutines/Makefile
|
|
fi
|
|
#
|
|
p_check_file_exists compiler/htcobolrc
|
|
if [ $errf1 -eq 0 ]
|
|
then
|
|
cp -f compiler/htcobolrc.mingw compiler/htcobolrc
|
|
fi
|
|
#
|
|
p_check_file_exists lib/htcobolrt.rc
|
|
if [ $errf1 -eq 0 ]
|
|
then
|
|
cat lib/htcobolrt.rc.in | \
|
|
sed \
|
|
-e "s|@TCOB_MAJOR_VERSION@|$TCOB_MAJOR_VERSION|g" \
|
|
-e "s|@TCOB_MINOR_VERSION@|$TCOB_MINOR_VERSION|g" \
|
|
-e "s|@TCOB_PATCH_LEVEL@|$TCOB_PATCH_LEVEL|g" \
|
|
-e "s|@TCOB_VERSION@|$tcob_version|g" \
|
|
-e "s|@TCOB_RELEASE_DATE@|$tcob_rdate|g" \
|
|
> lib/htcobolrt.rc
|
|
fi
|
|
#
|
|
p_check_file_exists cobrun/Makefile
|
|
if [ $errf1 -eq 0 ]
|
|
then
|
|
# cp -i cobrun/Makefile.mingw cobrun/Makefile
|
|
cp -f cobrun/Makefile.mingw cobrun/Makefile
|
|
cat cobrun/Makefile.mingw | \
|
|
sed \
|
|
-e "s|@tcob_version@|$TCOB_VERSION|g" \
|
|
-e "s|@install_dir@|$tcob_install_dir|g" \
|
|
> cobrun/Makefile
|
|
fi
|
|
#
|
|
}
|
|
#
|
|
#
|
|
# Create the Inno setup script from template
|
|
#
|
|
p_isetup ()
|
|
{
|
|
p_check_file_exists tcobol.iss
|
|
if [ $errf1 -eq 0 ]
|
|
then
|
|
t1=`echo ' ' | tr ' ' '\15'`
|
|
# -e "s|$|$t1|"
|
|
# sed -c
|
|
cat info/isetup/tcobol.iss.in | \
|
|
sed \
|
|
-e "s|@TCOB_VERSION@|$TCOB_MAJOR_VERSION.$TCOB_MINOR_VERSION|g" \
|
|
-e "s|@TCOB_RELEASE_VERSION@|$tcob_release|g" \
|
|
-e "s|$|$t1|" \
|
|
> tcobol.iss
|
|
fi
|
|
}
|
|
#
|
|
#
|
|
# Check if make files install directory exists
|
|
#
|
|
p_check_install_dir ()
|
|
{
|
|
#
|
|
if [ -d "$tcob_install_dir" ]
|
|
then
|
|
e22="WARNING: \n\
|
|
Install directory '$tcob_install_dir' exists.\n\
|
|
Directory contents will be over-written during installation process. \n"
|
|
#
|
|
printf "$e22"
|
|
fi
|
|
}
|
|
#
|
|
#
|
|
# Check if make files install directory exists
|
|
#
|
|
p_check_file_exists ()
|
|
{
|
|
#
|
|
errf1=0
|
|
if [ -f "$1" ]
|
|
then
|
|
e22="file exists, overwrite '$1' ? y/n[n]:"
|
|
printf "$e22"
|
|
read reply
|
|
if [ "$reply" != "y" ]
|
|
then
|
|
errf1=5
|
|
fi
|
|
fi
|
|
}
|
|
#
|
|
while getopts hd:i:l:mr:v: opt
|
|
do
|
|
case "$opt"
|
|
in
|
|
h)
|
|
p_print1 "$e0c" "$e0d"
|
|
exit 1
|
|
;;
|
|
d)
|
|
tcob_rdate=$OPTARG
|
|
;;
|
|
i)
|
|
# tcob_install_dir=$OPTARG
|
|
# sed 's.\/.\\\/.g'
|
|
# tcob_install_dir0=`echo "$OPTARG" | sed "s|'\'|'\\\'|g"`
|
|
# tcob_install_dir0=`echo "$OPTARG" | sed 's|\\|\\\/|g'`
|
|
# echo "OPTARG=$OPTARG, tcob_install_dir=$tcob_install_dir;"
|
|
# exit 1
|
|
tcob_install_dir=`echo "$OPTARG" | tr '\134' '\57'`
|
|
;;
|
|
l)
|
|
with_lang=$OPTARG
|
|
p_check_lang_otion
|
|
;;
|
|
m)
|
|
tcob_mfopt='1'
|
|
;;
|
|
r)
|
|
tcob_release=$OPTARG
|
|
;;
|
|
v)
|
|
tcob_version=$OPTARG
|
|
;;
|
|
\?)
|
|
# e1="$e0b$opt ..."
|
|
p_print1 "$e0c" "$e0d"
|
|
exit 1
|
|
;;
|
|
esac
|
|
done
|
|
#
|
|
p_check_install_dir
|
|
#
|
|
p_set_release_date
|
|
p_set_version
|
|
p_set_cobpp_version
|
|
#
|
|
p_main
|
|
#
|
|
p_config
|
|
#
|
|
p_cobpp
|
|
#
|
|
p_cob
|
|
#
|
|
p_isetup
|
|
#
|
|
|