summaryrefslogtreecommitdiff
path: root/device/non-free/lib/pic14/libdev/mkall.sh
blob: 26a2c52041f2280172f4e8fde8b838f1091814b6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/bin/sh

# This script is supposed to recreate all device libraries and their
# accompanying header files from the gputils' header/*.inc files
# using sdcc/support/scripts/inc2h.pl.
#
# The devices to be created are listed in ./devices.txt, the output
# files will be located in ./build/, which is created before use.
#
# (c) 2007 by Raphael Neider <rneider @ web.de>
# This file is published under the terms of the GPLv2.

GPUTILS=$HOME/gputils.svn
SDCC=$HOME/sdcc/sdcc.svn

HEADERS=$SDCC/device/non-free/include/pic14

if [ ! -d "$GPUTILS" ]; then
    echo "gputils not found in '$GPUTILS' -- exiting.";
    exit 1;
fi;

if [ ! -d "$SDCC" ]; then
    echo "sdcc not found in '$SDCC' -- exiting.";
    exit 1;
fi;

mkdir build;
cd build;
cp ../pic14ports.txt .

if true; then
    sed -e 's/\s*#.*$//' ../devices.txt | grep -v '^\s*$' | while read PROC; do
        echo "### Generating files for $PROC ...";
        EMIT_LEGACY_NAMES=0;
        if grep -q 'NO_LEGACY_NAMES' "$HEADERS/pic${PROC}.h" >/dev/null 2>&1; then
            EMIT_LEGACY_NAMES=1;
        fi;
        $SDCC/support/scripts/inc2h.pl $PROC $GPUTILS $EMIT_LEGACY_NAMES;
    done;
fi;

for i in *.c; do
    newc=1;
    newh=1;
    differs=0;
    h="${i%.c}.h";
    echo "";
    echo "### Checking $i and $h ...";
    if [ -f "../$i" ]; then
        newc=0;
        if diff -wup "../$i" "$i"; then
            # identical
            :
        else
            differs=1;
        fi;
    fi;
    if [ -f "$HEADERS/$h" ]; then
        newh=0;
        if diff -wup "$HEADERS/$h" "$h"; then
            # identical
            :
        else
            differs=1;
        fi;
    fi;
    if [ "x$newc$newh" = "x11" ]; then
        # new device -- copy into place
        echo "Installing new files ...";
        mv -f "$i" ..;
        mv -f "$h" "$HEADERS/$h";
    elif [ "x$differs" = "x0" ]; then
        # identical files -- ignore
        echo "No change -- keeping files ...";
        rm -f "$i" "$h";
    else
        ok=no;
        while [ ! xyes = "x$ok" ]; do
            echo "Replace? [y/n]";
            read -n1 ans;
            case "$ans" in
                y|Y)
                    echo "Replacing ...";
                    mv -f "$i" ..;
                    mv -f "$h" "$HEADERS/$h";
                    ok=yes;
                    ;;
                n|N)
                    echo "Keeping ...";
                    rm -f "$i" "$h";
                    ok=yes;
                    ;;
                *)
                    ok=no;
                    ;;
            esac;
        done;
    fi;
done;

cd ..;