]>
Commit | Line | Data |
---|---|---|
77f4a250 | 1 | #!/bin/sh |
33ad2bf9 CF |
2 | # cygmagic - Generate "magic numbers" from a structure. |
3 | # | |
bc837d22 | 4 | # Copyright 2001, 2002, 2005 Red Hat, Inc. |
33ad2bf9 CF |
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 | ||
77f4a250 CF |
12 | file_magic=$1; shift |
13 | gcc=$1; shift | |
14 | file=$1; shift | |
15 | trap "rm -f /tmp/$$.magic" 0 1 2 15 | |
16 | cat <<EOF > $file_magic | |
17 | /* autogenerated - do not edit */ | |
18 | #include "$file" | |
19 | EOF | |
6d8bd861 CF |
20 | sumit() { |
21 | cksum $* | |
22 | } | |
f3647dd7 | 23 | |
77f4a250 CF |
24 | while [ -n "$1" ]; do |
25 | define=$1; shift | |
26 | struct=$1; shift | |
44055eca | 27 | sum=`$gcc -E $file | sed -n "/^$struct/,/^};/p" | sed -e 's/[ ]//g' -e '/^$/d' | sumit | awk '{printf "0x%xU", $1}'` |
77f4a250 CF |
28 | echo "#define $define $sum" |
29 | curr=`sed -n "s/^#[ ]*define CURR_$define[ ][ ]*\([^ ][^ ]*\)/\1/p" $file` | |
acf05df7 | 30 | [ "$curr" != "$sum" ] && echo "*** WARNING WARNING WARNING WARNING WARNING *** |
aaf219f0 | 31 | *** $file: magic number for $define changed old $curr != new $sum |
77f4a250 CF |
32 | *** WARNING WARNING WARNING WARNING WARNING ***" 1>&2 |
33 | done >> $file_magic | |
34 | exit 0 |