2 # mkvers.sh - Make version information for cygwin DLL
4 # Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2010 Red Hat, Inc.
6 # This file is part of Cygwin.
8 # This software is a copyrighted work licensed under the terms of the
9 # Cygwin license. Please consult the file "CYGWIN_LICENSE" for
15 # Arg 1 is the name of the version include file
22 echo "**** Couldn't open file '$incfile'. Aborting."
26 # Load the current date so we can work on individual fields
28 set -$- $(date +"%m %d %Y %H:%M")
29 m=$1 d=$2 y=$3 hhmm=$4
31 # Set date into YYYY-MM-DD HH:MM:SS format
33 builddate="$y-$m-$d $hhmm"
39 # Output the initial part of version.cc
43 #include "cygwin_version.h"
46 #define str(x) strval(x)
47 #define shared_data_version str(CYGWIN_VERSION_SHARED_DATA)
49 const char *cygwin_version_strings =
50 "BEGIN_CYGWIN_VERSION_INFO\n"
54 # Split version file into dir and filename components
56 dir=`dirname $incfile`
57 fn=`basename $incfile`
60 # Look in the include file CVS directory for a CVS Tag file. This file,
61 # if it exists, will contain the name of the sticky tag associated with
62 # the current build. Save that for output later.
64 cvs_tag="`sed -e '/dontuse/d' -e 's%^.\(.*\)%\1%' $dir/CVS/Tag 2>/dev/null`"
67 [ -n "$cvs_tag" ] && cvs_tag=" CVS tag"'
71 # Look in the source directory containing the include/cygwin/version.h
72 # and set dir accordingly.
73 dir=`echo $dir | sed -e 's%/include/cygwin.*$%%' -e 's%include/cygwin.*$%.%'`
75 # Look in $dir for a a ".snapshot-date" file. If one is found then this
76 # information will be saved for output to the DLL.
78 if [ -r "$dir/.snapshot-date" ]; then
79 read snapshotdate < "$dir/.snapshot-date"
80 snapshot="snapshot date
85 # Scan the version.h file for strings that begin with CYGWIN_INFO or
86 # CYGWIN_VERSION. Perform crude parsing on the lines to get the values
87 # associated with these values and then pipe it into a while loop which
88 # outputs these values in C palatable format for inclusion in the DLL
89 # with a '%% ' identifier that will introduce "interesting" strings.
90 # These strings are strictly for use by a user to scan the DLL for
91 # interesting information.
93 (sed -n -e 's%#define CYGWIN_INFO_\([A-Z_]*\)[ ][ ]*\([a-zA-Z0-9"][^/]*\).*%_\1\
94 \2%p' -e 's%#define CYGWIN_VERSION_\([A-Z_]*\)[ ][ ]*\([a-zA-Z0-9"][^/]*\).*%_\1\
95 \2%p' $incfile | sed -e 's/["\\]//g' -e '/^_/y/ABCDEFGHIJKLMNOPQRSTUVWXYZ_/abcdefghijklmnopqrstuvwxyz /';
96 echo ' build date'; echo $build_date; [ -n "$cvs_tag" ] && echo "$cvs_tag";\
97 [ -n "$snapshot" ] && echo "$snapshot"
98 ) | while read var; do
101 "%%% Cygwin $var: $val\n"
103 done | tee /tmp/mkvers.$$ 1>&9
105 trap "rm -f /tmp/mkvers.$$" 0 1 2 15
107 if [ -n "$snapshotdate" ]; then
108 usedate="`echo $snapshotdate | sed 's/-\\(..:..[^-]*\\).*$/ \1SNP/'`"
114 # Finally, output the shared ID and set up the cygwin_version structure
115 # for use by Cygwin itself.
119 "%%% Cygwin shared id: " CYGWIN_VERSION_DLL_IDENTIFIER "S" shared_data_version "-$builddate\n"
121 "%%% Cygwin shared id: " CYGWIN_VERSION_DLL_IDENTIFIER "S" shared_data_version "\n"
123 "END_CYGWIN_VERSION_INFO\n\0";
124 cygwin_version_info cygwin_version =
126 CYGWIN_VERSION_API_MAJOR, CYGWIN_VERSION_API_MINOR,
127 CYGWIN_VERSION_DLL_MAJOR, CYGWIN_VERSION_DLL_MINOR,
128 CYGWIN_VERSION_SHARED_DATA,
129 CYGWIN_VERSION_MOUNT_REGISTRY,
132 CYGWIN_VERSION_DLL_IDENTIFIER "S" shared_data_version "-$builddate"
134 CYGWIN_VERSION_DLL_IDENTIFIER "S" shared_data_version
140 # Generate winver.o using cygwin/version.h information.
141 # Turn the cygwin major number from some large number to something like 1.1.0.
143 eval `sed -n 's/^.*dll \(m[ai][jn]or\): \([0-9]*\)[^0-9]*$/\1=\2/p' /tmp/mkvers.$$`
144 cygverhigh=`expr $major / 1000`
145 cygverlow=`expr $major % 1000`
146 cygwin_ver="$cygverhigh.$cygverlow.$minor"
147 if [ -n "$cvs_tag" ]; then
148 cvs_tag="`echo $wv_cvs_tag | sed -e 's/-branch.*//'`"
149 cygwin_ver="$cygwin_ver-$cvs_tag"
152 echo "Version $cygwin_ver"
154 $windres --include-dir $dir/../w32api/include --include-dir $dir/include --define CYGWIN_BUILD_DATE="$1" --define CYGWIN_BUILD_TIME="$2" --define CYGWIN_VERSION='"'"$cygwin_ver"'"' $rcfile winver.o