4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-01-21 05:49:19 +08:00
Corinna Vinschen 007e23d639 Cygwin: Reorganize cygwin source dir
Create subdirs and move files accordingly:

- DevDocs:  doc files
- fhandler: fhandler sources, split fhandler.cc into base.cc and null.cc
- local_includes: local include files
- scripts:  scripts called during build
- sec:      security sources

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-05 12:02:11 +02:00

44 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
# cygmagic - Generate "magic numbers" from a structure.
#
# 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.
set -e
shopt -s -o pipefail
shopt -s inherit_errexit
file_magic=$1; shift
gcc=$1; shift
file=$1; shift
tmpfile=/tmp/$$.magic
trap "rm -f /tmp/$$.magic" 0 1 2 15
cat <<EOF > $tmpfile
/* autogenerated - do not edit */
#include "$file"
EOF
sumit() {
cksum $*
}
while [ -n "$1" ]; do
define=$1; shift
struct=$1; shift
sum=`$gcc -D__CYGMAGIC__ -E -P $file | sed -n "/^$struct/,/^};/p" | sed -e 's/[ ]//g' -e '/^$/d' | sumit | awk '{printf "0x%xU", $1}'`
echo "#define $define $sum"
curr=`sed -n "s/^#[ ]*define CURR_$define[ ][ ]*\([^ ][^ ]*\)/\1/p" $file`
[ "$curr" != "$sum" ] && echo "*** WARNING WARNING WARNING WARNING WARNING ***
*** $file: magic number for $define changed old $curr != new $sum
*** WARNING WARNING WARNING WARNING WARNING ***" 1>&2
done >> $tmpfile
mv $tmpfile $file_magic
exit 0