struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / device / non-free / lib / pic14 / libdev / mkall.sh
blob26a2c52041f2280172f4e8fde8b838f1091814b6
1 #!/bin/sh
3 # This script is supposed to recreate all device libraries and their
4 # accompanying header files from the gputils' header/*.inc files
5 # using sdcc/support/scripts/inc2h.pl.
7 # The devices to be created are listed in ./devices.txt, the output
8 # files will be located in ./build/, which is created before use.
10 # (c) 2007 by Raphael Neider <rneider @ web.de>
11 # This file is published under the terms of the GPLv2.
13 GPUTILS=$HOME/gputils.svn
14 SDCC=$HOME/sdcc/sdcc.svn
16 HEADERS=$SDCC/device/non-free/include/pic14
18 if [ ! -d "$GPUTILS" ]; then
19 echo "gputils not found in '$GPUTILS' -- exiting.";
20 exit 1;
21 fi;
23 if [ ! -d "$SDCC" ]; then
24 echo "sdcc not found in '$SDCC' -- exiting.";
25 exit 1;
26 fi;
28 mkdir build;
29 cd build;
30 cp ../pic14ports.txt .
32 if true; then
33 sed -e 's/\s*#.*$//' ../devices.txt | grep -v '^\s*$' | while read PROC; do
34 echo "### Generating files for $PROC ...";
35 EMIT_LEGACY_NAMES=0;
36 if grep -q 'NO_LEGACY_NAMES' "$HEADERS/pic${PROC}.h" >/dev/null 2>&1; then
37 EMIT_LEGACY_NAMES=1;
38 fi;
39 $SDCC/support/scripts/inc2h.pl $PROC $GPUTILS $EMIT_LEGACY_NAMES;
40 done;
41 fi;
43 for i in *.c; do
44 newc=1;
45 newh=1;
46 differs=0;
47 h="${i%.c}.h";
48 echo "";
49 echo "### Checking $i and $h ...";
50 if [ -f "../$i" ]; then
51 newc=0;
52 if diff -wup "../$i" "$i"; then
53 # identical
55 else
56 differs=1;
57 fi;
58 fi;
59 if [ -f "$HEADERS/$h" ]; then
60 newh=0;
61 if diff -wup "$HEADERS/$h" "$h"; then
62 # identical
64 else
65 differs=1;
66 fi;
67 fi;
68 if [ "x$newc$newh" = "x11" ]; then
69 # new device -- copy into place
70 echo "Installing new files ...";
71 mv -f "$i" ..;
72 mv -f "$h" "$HEADERS/$h";
73 elif [ "x$differs" = "x0" ]; then
74 # identical files -- ignore
75 echo "No change -- keeping files ...";
76 rm -f "$i" "$h";
77 else
78 ok=no;
79 while [ ! xyes = "x$ok" ]; do
80 echo "Replace? [y/n]";
81 read -n1 ans;
82 case "$ans" in
83 y|Y)
84 echo "Replacing ...";
85 mv -f "$i" ..;
86 mv -f "$h" "$HEADERS/$h";
87 ok=yes;
89 n|N)
90 echo "Keeping ...";
91 rm -f "$i" "$h";
92 ok=yes;
95 ok=no;
97 esac;
98 done;
99 fi;
100 done;
102 cd ..;