summaryrefslogtreecommitdiff
path: root/device/non-free/lib/pic16/libdev/mkmk.sh
blob: 0f5aac8cb13ec73b0e47078d220048d4248327f9 (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
#!/bin/sh

#
# Consider using running 'sh update.sh' in '..' instead to
# also update the automake conditionals ENABLE_xxx!
#
# Script to generate Makefile.am,
# execute in device/lib/pic16/libdev/ with no arguments.
#
# For this to work, sdcc from PATH must already use the latest
# pic16fdevices.txt including to-be-added devices!
#
# Written by Raphael Neider <tecodev AT users sourceforge net>
#
# Released under the terms of the GPL v2.
#

cat <<HERE
## Makefile.am -- Process this file with automake to produce Makefile.in
## This file has been automatically generated using $0.

lib_LIBRARIES =

HERE

for f in ./pic1*.c; do
    p="${f##*/pic}";
    p="${p%.c}";
    arch="$p";
    ARCH=$(echo "$arch" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ);
    cat <<HERE
if ENABLE_${ARCH}
lib_LIBRARIES += libdev${arch}.a
endif ENABLE_${ARCH}
libdev${arch}_a_SOURCES = pic${arch}.c
HERE


    sdcc -mpic16 -p${arch} --nostdinc -I../../../../include/pic16 -I../../../include/pic16 -o pic${arch}.inc -E pic${arch}.c;
    if grep '\bEEADRH\b' pic${arch}.inc >/dev/null 2>&1; then
        # 16 bit EEPROM address space
        for i in get put; do
            for j in 1 2 3 4; do
                echo "libdev${arch}_a_SOURCES += gptr/eeprom16_gptr${i}${j}_dispatch.S";
            done;
        done;
    elif grep '\bEEADR\b' pic${arch}.inc >/dev/null 2>&1; then
        # 8 bit EEPROM address space
        for i in get put; do
            for j in 1 2 3 4; do
                echo "libdev${arch}_a_SOURCES += gptr/eeprom8_gptr${i}${j}_dispatch.S";
            done;
        done;
    else
        # No EEPROM
        echo "libdev${arch}_a_SOURCES += gptr/dispatch.S";
    fi;

    if ! grep '\bSSPBUF\b' pic${arch}.inc >/dev/null 2>&1; then
        echo "libdev${arch}_a_SOURCES += fake_sspbuf.c";
    fi;
    rm pic${arch}.inc;

    echo "libdev${arch}_a_CFLAGS = -p${arch} \$(AM_CFLAGS)";
    echo "";
done;

cat <<HERE
include \$(top_srcdir)/Makefile.common

HERE