OSDN Git Service

gas/opcodes: blackfin: move dsp mac func defines to common header
[pf3gnuchains/sourceware.git] / winsup / cygwin / mkvers.sh
1 #!/bin/sh
2 # mkvers.sh - Make version information for cygwin DLL
3 #
4 #   Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2010 Red Hat, Inc.
5 #
6 # This file is part of Cygwin.
7 #
8 # This software is a copyrighted work licensed under the terms of the
9 # Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
10 # details.
11
12 exec 9> version.cc
13
14 #
15 # Arg 1 is the name of the version include file
16 #
17 incfile="$1"
18 rcfile="$2"
19 windres="$3"
20
21 [ -r $incfile ] || {
22     echo "**** Couldn't open file '$incfile'.  Aborting."
23 }
24
25 #
26 # Load the current date so we can work on individual fields
27 #
28 set -$- $(date +"%m %d %Y %H:%M")
29 m=$1 d=$2 y=$3 hhmm=$4
30 #
31 # Set date into YYYY-MM-DD HH:MM:SS format
32 #
33 builddate="$y-$m-$d $hhmm"
34 echo "$builddate"
35
36 set -$- ''
37
38 #
39 # Output the initial part of version.cc
40 #
41 cat <<EOF 1>&9
42 #include "config.h"
43 #include "cygwin_version.h"
44
45 #define strval(x) #x
46 #define str(x) strval(x)
47 #define shared_data_version str(CYGWIN_VERSION_SHARED_DATA)
48
49 const char *cygwin_version_strings =
50   "BEGIN_CYGWIN_VERSION_INFO\n"
51 EOF
52
53 #
54 # Split version file into dir and filename components
55 #
56 dir=`dirname $incfile`
57 fn=`basename $incfile`
58
59 #
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.
63 #
64 cvs_tag="`sed -e '/dontuse/d' -e 's%^.\(.*\)%\1%' $dir/CVS/Tag 2>/dev/null`"
65
66 wv_cvs_tag="$cvs_tag"
67 [ -n "$cvs_tag" ] && cvs_tag=" CVS tag"'
68 '"$cvs_tag"
69
70 #
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.*$%.%'`
74
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.
77 #
78 if [ -r "$dir/.snapshot-date" ]; then
79     read snapshotdate < "$dir/.snapshot-date"
80     snapshot="snapshot date
81 $snapshotdate"
82 fi
83
84 #
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.
92 #
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
99     read val
100 cat <<EOF
101   "%%% Cygwin $var: $val\n"
102 EOF
103 done | tee /tmp/mkvers.$$ 1>&9
104
105 trap "rm -f /tmp/mkvers.$$" 0 1 2 15
106
107 if [ -n "$snapshotdate" ]; then
108   usedate="`echo $snapshotdate | sed 's/-\\(..:..[^-]*\\).*$/ \1SNP/'`"
109 else
110   usedate="$builddate"
111 fi
112
113 #
114 # Finally, output the shared ID and set up the cygwin_version structure
115 # for use by Cygwin itself.
116 #
117 cat <<EOF 1>&9
118 #ifdef DEBUGGING
119   "%%% Cygwin shared id: " CYGWIN_VERSION_DLL_IDENTIFIER "S" shared_data_version "-$builddate\n"
120 #else
121   "%%% Cygwin shared id: " CYGWIN_VERSION_DLL_IDENTIFIER "S" shared_data_version "\n"
122 #endif
123   "END_CYGWIN_VERSION_INFO\n\0";
124 cygwin_version_info cygwin_version =
125 {
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,
130   "$usedate",
131 #ifdef DEBUGGING
132   CYGWIN_VERSION_DLL_IDENTIFIER "S" shared_data_version "-$builddate"
133 #else
134   CYGWIN_VERSION_DLL_IDENTIFIER "S" shared_data_version
135 #endif
136 };
137 EOF
138
139 #
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.
142 #
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"
150 fi
151
152 echo "Version $cygwin_ver"
153 set -$- $builddate
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