2 # mkvers.sh - Make version information for cygwin DLL
4 # This file is part of Cygwin.
6 # This software is a copyrighted work licensed under the terms of the
7 # Cygwin license. Please consult the file "CYGWIN_LICENSE" for
13 # Arg 1 is the name of the version include file
19 # Find header file locations
34 echo "**** Couldn't open file '$incfile'. Aborting."
37 parse_preproc_flags
() {
38 # Since we're manually specifying the preprocessor, pass the default flags
40 ccflags
="--preprocessor=$1 --preprocessor-arg=-E \
41 --preprocessor-arg=-xc-header --define=RC_INVOKED "
45 # We need to be able to find the just-built cc1 binary.
47 ccflags
="$ccflags --preprocessor-arg=$1"
54 parse_preproc_flags
$CC
59 # Load the current date (or SOURCE_DATE_EPOCH) so we can work on individual fields
61 set -$
- $
(date ${SOURCE_DATE_EPOCH:+-d @}${SOURCE_DATE_EPOCH} -u +"%m %d %Y %H:%M")
62 m
=$1 d
=$2 y
=$3 hhmm
=$4
64 # Set date into YYYY-MM-DD HH:MM:SS format
66 builddate
="$y-$m-$d $hhmm"
72 # Output the initial part of version.cc
76 #include "cygwin_version.h"
79 #define str(x) strval(x)
80 #define shared_data_version str(CYGWIN_VERSION_SHARED_DATA)
82 const char *cygwin_version_strings =
83 "BEGIN_CYGWIN_VERSION_INFO\n"
87 # Split version file into dir and filename components
89 dir
=$
(dirname $incfile)
90 fn
=$
(basename $incfile)
93 # Look in the include file CVS directory for a CVS Tag file. This file,
94 # if it exists, will contain the name of the sticky tag associated with
95 # the current build. Save that for output later.
97 cvs_tag
="$(sed -e '/dontuse/d' -e 's%^.\(.*\)%\1%' $dir/CVS/Tag 2>/dev/null)"
100 [ -n "$cvs_tag" ] && cvs_tag
=" CVS tag"'
104 # Look in the source directory containing the include/cygwin/version.h
105 # and set dir accordingly.
106 dir
=$
(echo $dir |
sed -e 's%/include/cygwin.*$%%' -e 's%include/cygwin.*$%.%')
109 # Scan the version.h file for strings that begin with CYGWIN_INFO or
110 # CYGWIN_VERSION. Perform crude parsing on the lines to get the values
111 # associated with these values and then pipe it into a while loop which
112 # outputs these values in C palatable format for inclusion in the DLL
113 # with a '%% ' identifier that will introduce "interesting" strings.
114 # These strings are strictly for use by a user to scan the DLL for
115 # interesting information.
118 sed -n -e 's%#define CYGWIN_INFO_\([A-Z_]*\)[ ][ ]*\([a-zA-Z0-9"][^/]*\).*%_\1\
119 \2%p' -e 's%#define CYGWIN_VERSION_\([A-Z_]*\)[ ][ ]*\([a-zA-Z0-9"][^/]*\).*%_\1\
120 \2%p' $incfile |
sed -e 's/["\\]//g' -e '/^_/y/ABCDEFGHIJKLMNOPQRSTUVWXYZ_/abcdefghijklmnopqrstuvwxyz /';
121 echo ' build date'; echo $build_date;
122 [ -n "$cvs_tag" ] && echo "$cvs_tag";
123 ) |
while read var
; do
126 "%%% Cygwin $var: $val\n"
128 done |
tee /tmp
/mkvers.$$
1>&9
130 trap "rm -f /tmp/mkvers.$$" 0 1 2 15
133 # Finally, output the shared ID and set up the cygwin_version structure
134 # for use by Cygwin itself.
138 "%%% Cygwin shared id: " CYGWIN_VERSION_DLL_IDENTIFIER "S" shared_data_version "-$builddate\n"
140 "%%% Cygwin shared id: " CYGWIN_VERSION_DLL_IDENTIFIER "S" shared_data_version "\n"
142 "END_CYGWIN_VERSION_INFO\n\0";
143 cygwin_version_info cygwin_version =
145 CYGWIN_VERSION_API_MAJOR, CYGWIN_VERSION_API_MINOR,
146 CYGWIN_VERSION_DLL_MAJOR, CYGWIN_VERSION_DLL_MINOR,
147 CYGWIN_VERSION_SHARED_DATA,
148 CYGWIN_VERSION_MOUNT_REGISTRY,
151 CYGWIN_VERSION_DLL_IDENTIFIER "S" shared_data_version "-$builddate"
153 CYGWIN_VERSION_DLL_IDENTIFIER "S" shared_data_version
159 # Generate winver.o using cygwin/version.h information.
160 # Turn the cygwin major number from some large number to something like 1.1.0.
162 eval $
(sed -n 's/^.*dll \(m[ai][jn]or\): \([0-9]*\)[^0-9]*$/\1=\2/p' /tmp
/mkvers.$$
)
163 cygverhigh
=$
(expr $major / 1000)
164 cygverlow
=$
(expr $major % 1000)
165 cygwin_ver
="$cygverhigh.$cygverlow.$minor"
168 cvs_tag
="$(echo $wv_cvs_tag | sed -e 's/-branch.*//')"
169 cygwin_ver
="$cygwin_ver-$cvs_tag"
172 echo "Version $cygwin_ver"
174 $windres $iflags $ccflags \
175 --define CYGWIN_BUILD_DATE
="$1" \
176 --define CYGWIN_BUILD_TIME
="$2" \
177 --define CYGWIN_BUILD_YEAR
=$y \
178 --define CYGWIN_VERSION
='"'"$cygwin_ver"'"' \