#!/bin/ksh
# This script is used by Src/gdb/gdb/Makefile, to generate C
# statically-initialized declarations of wdb_version and sccs_id
# strings.
#
set -hu
CDPATH=; EDITOR=
typeset -r mybin=${0%%*([!/])}
export PATH=$mybin:/bin:/usr/bin:/usr/atria/bin

#set -o xtrace
#set -o verbose

typeset -r outfile=$1; shift
typeset -r host_alias=$1; shift

##### IA64 version numbers
# "1.3.00"	1st IPF release  May 2001
# "1.3.01"	for web release, set 06/21/01
# "1.3.02"	for web release, September 2001
# "1.3.04"      weekly TOT, 02 14 2002
# "1.3.05"	IC40, 02 28 2002
# "1.3.06"	weekly TOT, 03 19 2002
# "1.3.07"	IC43, 03 26 2002
# "1.4.00"	11.22 release
# "1.4.01"	wdb web release, 071202
# "1.4.02"	weekly TOT, 091802
# typeset -r wdb_version_nbr="1.4.02"
##### PA /main pre-merge numbers
# "3.0" 	AR1201 release made around September, 2001
# 3.0.03  - Patch to Intel
# 3.0.02  - Patch to Intel
# 3.0.01  - web release  12/01
# 3.0.01.01 - handed out early for a 3.0 problem"
# 3.0.03  - experimental version given to Fred Spraque - debug shared lib with
#		stripped main
# 3.0.04  - for Fred Spraque - debug shared lib with #		stripped main
# 3.0.05  - Update version string after giving one to Fred Sprague.
# 3.0.06  - Hardware watchpoint fix for Aries
# 3.1 	  - Update version string for AR0902 release
#########
# 3.3.00  - post-merge numbers ...


# Set the wdb version number
# 3.0.03  - Patch to Intel
# 3.0.02  - Patch to Intel
# 3.0.01  - web release  12/01
# 3.0.01.01 - handed out early for a 3.0 problem"
# 3.0.03  - experimental version given to Fred Spraque - debug shared lib with
#		stripped main
# 3.0.04  - for Fred Spraque - debug shared lib with #		stripped main
# 3.0.05  - Update version string after giving one to Fred Sprague.
# 3.0.06  - Hardware watchpoint fix for Aries
# 3.1 	  - Update version string for AR0902 release
# 3.1.01  - Patch for Intel;
# 3.1.02  - Patch for Intel;
# 3.1.1   - September Webrelease 2002
# 3.1.2   - Patch for telcordia
# 3.1.3   - Patch for Chapman,Callum - To debug cma core file with pid>2^16
# 3.1.4   - Patch for Michael Ehrig - JAGae57668 fortran +objdebug defect
# 3.1.4.1 - Patch for Fred - Command line calls in stripped a.out
# 3.1.5   - April Webrelease 2003
# 3.2     - Update version string for AR0903 release
# 3.2.3   - Update version string for JAGae78770 - Bits to Carl Burch.
# 3.2.4   - Update version string for bits to be sent to ModelTech
# 3.3     - October Webrelease 2003
# 3.3.1   - Patch for Gene Bradley - JAGae90956 corrupted DPs string for AR0903 release
# 3.4     - 11.23PI Release 2004
# 4.5     - Combined webrelease for PA & IPF June 2004 
# 5.0 	  - AR1204 - common PA/IA release on Web in Sept 2004 and AR in Dec 2004
# 5.1 	  - WR0205 - common PA/IA release on Web in Feb 2005

  typeset -r wdb_version_nbr="5.1.1"

if [[ "${host_alias}" = "hppa1.1-hp-hpux11.00" || "${host_alias}" = "hppa2.0w-hp-hpux11.00" ]]; then
  typeset -r wdb_primary_version="Hewlett-Packard Wildebeest ${wdb_version_nbr}"
else
  typeset -r wdb_primary_version="Hewlett-Packard Itanium Debugger Wildebeest ${wdb_version_nbr}"
  wdb_what="Itanium 11.23 11.22"
fi

# 4.0	 - May 14th - all CRT's for 11.23 release
# 4.0.01 - Aug 25 2003: First internal release towards 11.23 patch.
# 4.1    - Sep 05 2003: 11.23 patch release 
# 4.2 will be AR0304.
# 4.2.01 patch line version for Java unwind fix on top of 4.2
# 4.2.02 extra version number saved for possible further patch on top of 4.2
# 4.2.03 label move on 19 Feb 2004, and later ToT versions before 4.5.
# 4.5 will be a web release in Summer 2004 of common PA/IA sources
# 4.5.01 extra version number saved for possible further patch on top of 4.5
# 4.5.02 extra version number saved for possible further patch on top of 4.5.01
# 4.5.03 label move on 17 June 2004, and later ToT versions before 5.0.
# 5.0 is be AR1204 - common PA/IA sources
# 5.0.01 extra version number saved for possible further patch on top of 5.0
# 5.0.02 extra version number saved for possible further patch on top of 5.0.01
# 5.0.03 label move on 23 September 2004, and site-specific patch for Bloomberg.
# 5.0.04 label move on 30 September 2004, and later ToT versions after 5.0.03.
# 5.1 WR0205 - common PA/IA web release
# 5.1.1 WR0205 Patch release - label move on 11 March 2005 
# 6.0 will be 11.31  - common PA/IA sources

typeset -r current_date_time="$(date +%d-%b-%Y) $(date +%H:%M)"

WDB_PRODUCTION_BUILD=${WDB_PRODUCTION_BUILD:=}
wdb_version=${wdb_primary_version}
wdb_dated_version="${wdb_version} ${current_date_time}"

if [[ -z "${WDB_PRODUCTION_BUILD}" ]]; then
  wdb_version="${wdb_dated_version}"
fi

print >>$outfile
print "/* This string is used in top.c, in the startup banner. */" >>$outfile
print "char *  wdb_version = \"${wdb_version}\";" >>$outfile
print "char *  wdb_version_nbr = \"${wdb_version_nbr}\";" >>$outfile

print >>$outfile
print "/* This string is used by /bin/what, if the user does that. */" >>$outfile

if [[ ${host_alias} = "hppa1.1-hp-hpux11.00" || ${host_alias} = "hppa2.0w-hp-hpux11.00" ]]; then
  print "char sccs_id[] = \"@(#) ${wdb_dated_version} ${host_alias}\";" >>$outfile
else
   print "char sccs_id[] = \"@(#) ${wdb_dated_version} ${wdb_what}\";" >>$outfile
fi
