newlib/winsup/cygwin/mkvers.sh

177 lines
4.6 KiB
Bash
Raw Normal View History

2000-02-17 20:38:33 +01:00
#!/bin/sh
# mkvers.sh - Make version information for cygwin DLL
#
# Copyright 1998, 1999, 2000 Cygnus Solutions.
#
# 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
trap "rm -f /tmp/version.cc" 1 2 15
#
# Arg 1 is the name of the version include file
#
incfile="$1"
rcfile="$2"
windres="$3"
[ -r $incfile ] || {
echo "**** Couldn't open file '$incfile'. Aborting."
}
#
# Load the current date so we can work on individual fields
#
build_date=`date`
set -$- $build_date
#
# Translate the month into a number
#
case "$2" in
Jan) m=01 ;;
Feb) m=02 ;;
Mar) m=03 ;;
Apr) m=04 ;;
May) m=05 ;;
Jun) m=06 ;;
Jul) m=07 ;;
Aug) m=08 ;;
Sep) m=09 ;;
Oct) m=10 ;;
Nov) m=11 ;;
Dec) m=12 ;;
esac
if [ "$3" -le 10 ]; then
d=0$3
else
d=$3
fi
hhmm="`echo $4 | sed 's/:..$//'`"
2000-02-17 20:38:33 +01:00
#
# Set date into YYYY-MM-DD HH:MM:SS format
#
builddate="${6-$5}-$m-$d $hhmm"
2000-02-17 20:38:33 +01:00
set -$- ''
#
# Output the initial part of version.cc
#
cat <<EOF 1>&9
#include <winsup.h>
#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`
#
# 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 's%^.\(.*\)%\1%' $dir/CVS/Tag 2>/dev/null`"
wv_cvs_tag="$cvs_tag"
2000-02-17 20:38:33 +01:00
[ -n "$cvs_tag" ] && cvs_tag=" CVS tag"'
'"$cvs_tag"
#
# Look in the source directory containing the include/cygwin/version.h
# file for a ".snapshot-date" file. If one is found then this information
# will be saved for output to the DLL.
#
dir=`echo $dir | sed -e 's%/include/cygwin.*$%%' -e 's%include/cygwin.*$%.%'`
if [ -r "$dir/.snapshot-date" ]; then
read snapshotdate < "$dir/.snapshot-date"
2000-02-17 20:38:33 +01:00
snapshot="snapshot date
$snapshotdate"
2000-02-17 20:38:33 +01:00
fi
#
# 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 /';
2000-02-17 20:38:33 +01:00
echo ' build date'; echo $build_date; [ -n "$cvs_tag" ] && echo "$cvs_tag";\
[ -n "$snapshot" ] && echo "$snapshot"
) | 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
if [ -n "$snapshotdate" ]; then
usedate="`echo $snapshotdate | sed 's/-\\(..:..[^-]*\\).*$/ \1SNP/'`"
else
usedate="$builddate"
fi
2000-02-17 20:38:33 +01:00
#
# 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,
"$usedate",
2000-02-17 20:38:33 +01: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`
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-17 20:38:33 +01:00
fi
echo "Version $cygwin_ver"
2000-02-17 20:38:33 +01:00
set -$- $builddate
* include/cygwin/version.h: Bump DLL minor version number to 5 due to all of the changes below. Redefine process structure to avoid a fixed size table. Redefine pinfo/_pinfo classes. Use these throughout. * dcrt0.cc (dll_crt0_1): Accomodate set_myself argument change. (__api_fatal): Accomodate _pinfo::record_death argument change. * exceptions.cc (really_exit): Ditto. (sig_handle_tty_stop): Use pinfo constructor to access process info. (events_init): Don't create pinfo_mutex since it is no longer required. * external.cc (fillout_pinfo): Use winpids class to iterate over all system pids. (cygwin_internal): lock_pinfo_for_update and unlock_pinfo are now noops. * fhandler_termios.cc (fhandler_termios::set_ctty): Use pinfo constructor to access process info. * fork.cc (fork): Reorganize to initialize child info after the child has started since that is when we know the child's winpid, which is necessary to allocate the pinfo shared memory. * mmap.cc (recreate_mmaps_after_fork): Change arg type to _pinfo. * pinfo.cc: Rename pinfo methods to _pinfo throughout. Eliminate pinfo_list stuff. (set_myself): Accept a pid argument now. Call pinfo initializer to initialize myself. Detect when this is an "execed" process and create an "indirect" pid block. (pinfo_init): Accomodate set_myself arg change. (procinfo): Remove. (pinfo::lock_pinfo): Remove. (pinfo::unlock_pinfo): Remove. (pinfo::init): New method. Allocates shared memory space for process pinfo structure. (pinfo::record_death): Don't call locking functions. (cygwin_winpid_to_pid): Simplify by using new pinfo constructor. (EnumProcessesW95): New function for iterating over processes on Windows 95. (winpids::winpids): New constructor for winpids class. Sets up a list of process ids. (enum_init): Initialize w95/wnt pid enumerators. * shared.cc (shared-info::initialize): Remove pid initialization. * shared.h: Move pinfo stuff into pinfo.h. (class shared_info): Remove pinfo_list element. * signal.cc (kill_worker): Use pinfo constructor to access process info. (kill_pgrp): Ditto. Use winpids methods to access list of processes. * sigproc.cc: Throughout, modify to use _pinfo where appropriate. (proc_exists (pid_t)): New function. Determines if a process exists based on the pid. (proc_exists (_pinfo *p): Use new proc_exists function above. (proc_subproc): Copy pinfo stuff around rather than _pinfo pointers. Try to be careful about releasing shared memory when we don't need it anymore. Remove pinfo locks. (remove_zombies): Remove pinfo memory when zombie is going away. * sigproc.h: Reflect _pinfo/pinfo changes in sigproc.cc. * spawn.cc (spawn_guts): Eliminate pinfo *child argument. Reorganize to only initialize child pinfo after process has been started and we know the windows pid. (_spawnve): Reflect spawn_guts changes. * syscalls.cc (setpgid): Use pinfo constructor to access process info. (getpgid): Ditto. (internal_getlogin): Use _pinfo. * winsup.h: Eliminate pinfo_mutex. Eliminate spawn_guts declaration since it is static now. Reflect set_myself argument change. * include/sys/cygwin.h: Add some PID_* enums to accomodate new pinfo stuff. * include/cygwin/version.h: Update minor version for cygdrive changes below.
2000-07-29 18:24:59 +02:00
set -x
2000-06-21 07:04:56 +02:00
exec $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