1#!/usr/bin/env sh
2
3# Copyright (c) 1995-2009, 2014-2015, 2018, 2020 Paul Mattes.
4# Copyright (c) 2005, Don Russell.
5# All rights reserved.
6#
7# Redistribution and use in source and binary forms, with or without
8# modification, are permitted provided that the following conditions
9# are met:
10#     * Redistributions of source code must retain the above copyright
11#       notice, this list of conditions and the following disclaimer.
12#     * Redistributions in binary form must reproduce the above copyright
13#       notice, this list of conditions and the following disclaimer in the
14#       documentation and/or other materials provided with the distribution.
15#     * Neither the names of Paul Mattes, Don Russell nor their contributors
16#       may be used to endorse or promote products derived from this software
17#       without specific prior written permission.
18#
19# THIS SOFTWARE IS PROVIDED BY PAUL MATTES AND DON RUSSELL "AS IS"
20# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PAUL MATTES OR DON RUSSELL
23# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
24# OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
29# THE POSSIBILITY OF SUCH DAMAGE.
30
31# Create version.c from version.txt
32#  mkversion [program [path-to-version.txt]]
33#set -x
34
35# Ensure that 'date' emits 7-bit U.S. ASCII.
36LANG=C
37LC_ALL=C
38export LANG LC_ALL
39
40set -e
41
42. ${2-./version.txt}
43date="date -u"
44[ -n "$SOURCE_DATE_EPOCH" ] && date="$date -d@$SOURCE_DATE_EPOCH"
45builddate=`$date`
46sccsdate=`$date +%Y/%m/%d`
47user=${LOGNAME-$USER}
48
49# Create an all numeric timestamp for rpqnames.
50# rpq.c will return this string of numbers in bcd format
51# It is OK to change the length (+ or -), but use
52# decimal (0-9) digits only. Length must be even number of digits.
53rpq_timestamp=`$date +%Y%m%d%H%M%S`
54
55app=${1-x3270}
56cat <<EOF
57const char *app = "$app";
58const char *build = "$app v$version $builddate $user";
59const char *app_defaults_version = "$adversion";
60const char *cyear = "$cyear";
61const char sccsid[] = "@(#)$app v$version $sccsdate $user";
62
63const char *build_rpq_timestamp = "$rpq_timestamp";
64const char *build_rpq_version = "$version";
65EOF
66