newlib-cygwin/winsup/cygwin/scripts/mkvers.sh

180 lines
4.6 KiB
Bash
Raw Normal View History

#!/bin/sh
2000-02-18 03:38:33 +08:00
# mkvers.sh - Make version information for cygwin DLL
#
# This file is part of Cygwin.
#
# This software is a copyrighted work licensed under the terms of the
# Cygwin license. Please consult the file "CYGWIN_LICENSE" for
# details.
exec 9> version.cc
#
# Arg 1 is the name of the version include file
#
ChangeLog: 2012-11-12 Christopher Faylor <me.cygwin2012@cgf.cx> * Makefile.common: Revamp for new configury. Add default compilation targets, include .E processing. Add magic for allowing "CFLAGS" to control optimization options in "CXXFLAGS". * configure.cygwin: New include for Cygwin configure.in's. * acinclude.m4: Delete old definitions. Implement AC_WINDOWS_HEADERS, AC_WINDOWS_LIBS, AC_CYGWIN_INCLUDES, target_builddir, winsup_srcdir. * aclocal.m4: Regenerate. * autogen.sh: New file. * ccwrap: New script. * c++wrap: New script. * config.guess: New script. * config.sub: New script. * configure: Regenerate. * configure.in: Eliminate LIB_AC_PROG_* calls in favor of standard. Delete ancient target test. * install-sh: New script. cygserver/ChangeLog: 2012-11-12 Christopher Faylor <me.cygwin2012@cgf.cx> * Makefile.in: Revamp for new configury. * configure.in: Revamp for new configury. * aclocal.m4: Regenerate. * configure: Ditto. * autogen.sh: New script. cygwin/ChangeLog: 2012-11-22 Christopher Faylor <me.cygwin2012@cgf.cx> * select.cc (select): Don't return -1 when we've timed out after looping. 2012-11-22 Christopher Faylor <me.cygwin2012@cgf.cx> * Makefile.in: Revamp for new configury. (datarootdir): Add variable setting. (winver_stamp): Accommodate changes to mkvers.sh setting. (libc.a): Fix race when libm.a might not have been built yet. * configure.in: Revamp for new configury. * aclocal.m4: Regenerate. * configure: Ditto. * autogen.sh: New script. * mkvers.sh: Find include directives via CFLAGS and friends rather than assuming that w32api lives nearby. utils/ChangeLog: 2012-11-12 Christopher Faylor <me.cygwin2012@cgf.cx> * aclocal.m4: Regenerate. * configure: Ditto. * autogen.sh: New script. * configure.in: Revamp for new configury. * Makefile.in: Revamp for new configury. Rename ALL_* to just *. Always use "VERBOSE" setting. (MINGW_CXX): Don't include CFLAGS in definition. (all): Define target first, before everything else so that it is the default. (ps.exe): Don't add useless -lcygwin. (ldh.exe): For consistency, add to existing MINGW_LDFLAGS rather than redefining them. (cygcheck.exe): Always include -lz for MINGW_LDFLAGS. Don't try to figure out where to find it. (dumper.exe): Simplify check. Assume libraries are installed rather than trying to retrieve from source tree. (install): Just use /bin/mkdir to create directories. (Makefile): Regenerate when standard dependencies change. * dump_setup.cc: Always include zlib.h. Remove accommodations for it possibly not existing. * parse_pe.cc: Add define which allows building with installed binutils package. * dumper.cc: Ditto.
2012-11-23 21:22:47 +08:00
incfile="$1"; shift
rcfile="$1"; shift
windres="$1"; shift
iflags=
# Find header file locations
while [ -n "$*" ]; do
case "$1" in
-I*)
iflags="$iflags $1"
;;
-idirafter)
ChangeLog: 2012-11-12 Christopher Faylor <me.cygwin2012@cgf.cx> * Makefile.common: Revamp for new configury. Add default compilation targets, include .E processing. Add magic for allowing "CFLAGS" to control optimization options in "CXXFLAGS". * configure.cygwin: New include for Cygwin configure.in's. * acinclude.m4: Delete old definitions. Implement AC_WINDOWS_HEADERS, AC_WINDOWS_LIBS, AC_CYGWIN_INCLUDES, target_builddir, winsup_srcdir. * aclocal.m4: Regenerate. * autogen.sh: New file. * ccwrap: New script. * c++wrap: New script. * config.guess: New script. * config.sub: New script. * configure: Regenerate. * configure.in: Eliminate LIB_AC_PROG_* calls in favor of standard. Delete ancient target test. * install-sh: New script. cygserver/ChangeLog: 2012-11-12 Christopher Faylor <me.cygwin2012@cgf.cx> * Makefile.in: Revamp for new configury. * configure.in: Revamp for new configury. * aclocal.m4: Regenerate. * configure: Ditto. * autogen.sh: New script. cygwin/ChangeLog: 2012-11-22 Christopher Faylor <me.cygwin2012@cgf.cx> * select.cc (select): Don't return -1 when we've timed out after looping. 2012-11-22 Christopher Faylor <me.cygwin2012@cgf.cx> * Makefile.in: Revamp for new configury. (datarootdir): Add variable setting. (winver_stamp): Accommodate changes to mkvers.sh setting. (libc.a): Fix race when libm.a might not have been built yet. * configure.in: Revamp for new configury. * aclocal.m4: Regenerate. * configure: Ditto. * autogen.sh: New script. * mkvers.sh: Find include directives via CFLAGS and friends rather than assuming that w32api lives nearby. utils/ChangeLog: 2012-11-12 Christopher Faylor <me.cygwin2012@cgf.cx> * aclocal.m4: Regenerate. * configure: Ditto. * autogen.sh: New script. * configure.in: Revamp for new configury. * Makefile.in: Revamp for new configury. Rename ALL_* to just *. Always use "VERBOSE" setting. (MINGW_CXX): Don't include CFLAGS in definition. (all): Define target first, before everything else so that it is the default. (ps.exe): Don't add useless -lcygwin. (ldh.exe): For consistency, add to existing MINGW_LDFLAGS rather than redefining them. (cygcheck.exe): Always include -lz for MINGW_LDFLAGS. Don't try to figure out where to find it. (dumper.exe): Simplify check. Assume libraries are installed rather than trying to retrieve from source tree. (install): Just use /bin/mkdir to create directories. (Makefile): Regenerate when standard dependencies change. * dump_setup.cc: Always include zlib.h. Remove accommodations for it possibly not existing. * parse_pe.cc: Add define which allows building with installed binutils package. * dumper.cc: Ditto.
2012-11-23 21:22:47 +08:00
shift
iflags="$iflags -I$1"
;;
esac
shift
ChangeLog: 2012-11-12 Christopher Faylor <me.cygwin2012@cgf.cx> * Makefile.common: Revamp for new configury. Add default compilation targets, include .E processing. Add magic for allowing "CFLAGS" to control optimization options in "CXXFLAGS". * configure.cygwin: New include for Cygwin configure.in's. * acinclude.m4: Delete old definitions. Implement AC_WINDOWS_HEADERS, AC_WINDOWS_LIBS, AC_CYGWIN_INCLUDES, target_builddir, winsup_srcdir. * aclocal.m4: Regenerate. * autogen.sh: New file. * ccwrap: New script. * c++wrap: New script. * config.guess: New script. * config.sub: New script. * configure: Regenerate. * configure.in: Eliminate LIB_AC_PROG_* calls in favor of standard. Delete ancient target test. * install-sh: New script. cygserver/ChangeLog: 2012-11-12 Christopher Faylor <me.cygwin2012@cgf.cx> * Makefile.in: Revamp for new configury. * configure.in: Revamp for new configury. * aclocal.m4: Regenerate. * configure: Ditto. * autogen.sh: New script. cygwin/ChangeLog: 2012-11-22 Christopher Faylor <me.cygwin2012@cgf.cx> * select.cc (select): Don't return -1 when we've timed out after looping. 2012-11-22 Christopher Faylor <me.cygwin2012@cgf.cx> * Makefile.in: Revamp for new configury. (datarootdir): Add variable setting. (winver_stamp): Accommodate changes to mkvers.sh setting. (libc.a): Fix race when libm.a might not have been built yet. * configure.in: Revamp for new configury. * aclocal.m4: Regenerate. * configure: Ditto. * autogen.sh: New script. * mkvers.sh: Find include directives via CFLAGS and friends rather than assuming that w32api lives nearby. utils/ChangeLog: 2012-11-12 Christopher Faylor <me.cygwin2012@cgf.cx> * aclocal.m4: Regenerate. * configure: Ditto. * autogen.sh: New script. * configure.in: Revamp for new configury. * Makefile.in: Revamp for new configury. Rename ALL_* to just *. Always use "VERBOSE" setting. (MINGW_CXX): Don't include CFLAGS in definition. (all): Define target first, before everything else so that it is the default. (ps.exe): Don't add useless -lcygwin. (ldh.exe): For consistency, add to existing MINGW_LDFLAGS rather than redefining them. (cygcheck.exe): Always include -lz for MINGW_LDFLAGS. Don't try to figure out where to find it. (dumper.exe): Simplify check. Assume libraries are installed rather than trying to retrieve from source tree. (install): Just use /bin/mkdir to create directories. (Makefile): Regenerate when standard dependencies change. * dump_setup.cc: Always include zlib.h. Remove accommodations for it possibly not existing. * parse_pe.cc: Add define which allows building with installed binutils package. * dumper.cc: Ditto.
2012-11-23 21:22:47 +08:00
done
2000-02-18 03:38:33 +08:00
[ -r $incfile ] || {
echo "**** Couldn't open file '$incfile'. Aborting."
2000-02-18 03:38:33 +08:00
}
parse_preproc_flags() {
# Since we're manually specifying the preprocessor, pass the default flags
# normally defined.
ccflags="--preprocessor=$1 --preprocessor-arg=-E \
--preprocessor-arg=-xc-header --define=RC_INVOKED "
shift
while [ -n "$*" ]; do
case "$1" in
# We need to be able to find the just-built cc1 binary.
-B*)
ccflags="$ccflags --preprocessor-arg=$1"
;;
esac
shift
done
}
parse_preproc_flags $CC
2000-02-18 03:38:33 +08:00
#
# Load the current date so we can work on individual fields
#
set -$- $(date -u +"%m %d %Y %H:%M")
m=$1 d=$2 y=$3 hhmm=$4
2000-02-18 03:38:33 +08:00
#
# Set date into YYYY-MM-DD HH:MM:SS format
#
builddate="$y-$m-$d $hhmm"
echo "$builddate"
2000-02-18 03:38:33 +08:00
set -$- ''
#
# Output the initial part of version.cc
#
cat <<EOF 1>&9
#include "config.h"
#include "cygwin_version.h"
2000-02-18 03:38:33 +08:00
#define strval(x) #x
#define str(x) strval(x)
#define shared_data_version str(CYGWIN_VERSION_SHARED_DATA)
const char *cygwin_version_strings =
"BEGIN_CYGWIN_VERSION_INFO\n"
EOF
#
# Split version file into dir and filename components
#
dir=$(dirname $incfile)
fn=$(basename $incfile)
2000-02-18 03:38:33 +08:00
#
# Look in the include file CVS directory for a CVS Tag file. This file,
# if it exists, will contain the name of the sticky tag associated with
# the current build. Save that for output later.
#
cvs_tag="$(sed -e '/dontuse/d' -e 's%^.\(.*\)%\1%' $dir/CVS/Tag 2>/dev/null)"
2000-02-18 03:38:33 +08:00
wv_cvs_tag="$cvs_tag"
2000-02-18 03:38:33 +08:00
[ -n "$cvs_tag" ] && cvs_tag=" CVS tag"'
'"$cvs_tag"
#
# Look in the source directory containing the include/cygwin/version.h
# and set dir accordingly.
dir=$(echo $dir | sed -e 's%/include/cygwin.*$%%' -e 's%include/cygwin.*$%.%')
2000-02-18 03:38:33 +08:00
#
# Scan the version.h file for strings that begin with CYGWIN_INFO or
# CYGWIN_VERSION. Perform crude parsing on the lines to get the values
# associated with these values and then pipe it into a while loop which
# outputs these values in C palatable format for inclusion in the DLL
# with a '%% ' identifier that will introduce "interesting" strings.
# These strings are strictly for use by a user to scan the DLL for
# interesting information.
#
(
sed -n -e 's%#define CYGWIN_INFO_\([A-Z_]*\)[ ][ ]*\([a-zA-Z0-9"][^/]*\).*%_\1\
\2%p' -e 's%#define CYGWIN_VERSION_\([A-Z_]*\)[ ][ ]*\([a-zA-Z0-9"][^/]*\).*%_\1\
\2%p' $incfile | sed -e 's/["\\]//g' -e '/^_/y/ABCDEFGHIJKLMNOPQRSTUVWXYZ_/abcdefghijklmnopqrstuvwxyz /';
echo ' build date'; echo $build_date;
[ -n "$cvs_tag" ] && echo "$cvs_tag";
2000-02-18 03:38:33 +08:00
) | while read var; do
read val
cat <<EOF
"%%% Cygwin $var: $val\n"
EOF
done | tee /tmp/mkvers.$$ 1>&9
trap "rm -f /tmp/mkvers.$$" 0 1 2 15
#
# Finally, output the shared ID and set up the cygwin_version structure
# for use by Cygwin itself.
#
cat <<EOF 1>&9
#ifdef DEBUGGING
"%%% Cygwin shared id: " CYGWIN_VERSION_DLL_IDENTIFIER "S" shared_data_version "-$builddate\n"
#else
"%%% Cygwin shared id: " CYGWIN_VERSION_DLL_IDENTIFIER "S" shared_data_version "\n"
#endif
"END_CYGWIN_VERSION_INFO\n\0";
cygwin_version_info cygwin_version =
{
CYGWIN_VERSION_API_MAJOR, CYGWIN_VERSION_API_MINOR,
CYGWIN_VERSION_DLL_MAJOR, CYGWIN_VERSION_DLL_MINOR,
CYGWIN_VERSION_SHARED_DATA,
CYGWIN_VERSION_MOUNT_REGISTRY,
"$builddate",
2000-02-18 03:38:33 +08:00
#ifdef DEBUGGING
CYGWIN_VERSION_DLL_IDENTIFIER "S" shared_data_version "-$builddate"
#else
CYGWIN_VERSION_DLL_IDENTIFIER "S" shared_data_version
#endif
};
EOF
#
# Generate winver.o using cygwin/version.h information.
# Turn the cygwin major number from some large number to something like 1.1.0.
#
eval $(sed -n 's/^.*dll \(m[ai][jn]or\): \([0-9]*\)[^0-9]*$/\1=\2/p' /tmp/mkvers.$$)
cygverhigh=$(expr $major / 1000)
cygverlow=$(expr $major % 1000)
2000-02-18 03:38:33 +08:00
cygwin_ver="$cygverhigh.$cygverlow.$minor"
if [ -n "$cvs_tag" ]
then
cvs_tag="$(echo $wv_cvs_tag | sed -e 's/-branch.*//')"
cygwin_ver="$cygwin_ver-$cvs_tag"
2000-02-18 03:38:33 +08:00
fi
echo "Version $cygwin_ver"
2000-02-18 03:38:33 +08:00
set -$- $builddate
$windres $iflags $ccflags \
--define CYGWIN_BUILD_DATE="$1" \
--define CYGWIN_BUILD_TIME="$2" \
--define CYGWIN_BUILD_YEAR=$y \
--define CYGWIN_VERSION='"'"$cygwin_ver"'"' \
$rcfile winver.o