summaryrefslogtreecommitdiff
path: root/recipes-bsp/multitech/mts-io.inc
blob: d6384a450cfdeb02b584eed1fc9cb5059b2cf496 (plain)
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
DESCRIPTION = "mts-io controller and sysfs wrapper"
HOMEPAGE = "http://www.multitech.net/"
SECTION = "base"
PRIORITY = "optional"
LICENSE = "GPLv2"
LIC_FILES_CHKSUM = "file://io-module/COPYING;md5=94d55d512a9ba36caa9b7df079bae19f \
                    file://io-tool/COPYING;md5=94d55d512a9ba36caa9b7df079bae19f \
"
DEPENDS = "virtual/kernel"
INC_PR = "r0"

SRCREV = "${PV}"

SRC_URI = " \
    git://git.multitech.net/mts-io.git;protocol=git \
    file://led-status_heartbeat_trigger \
    file://lora-led-updater \
    file://mts-io.init \
    file://mts-io.mtcap.init \
    file://radio-reset.init \
    file://radio-reset.default \
    file://mts-io.conf \
"
S = "${WORKDIR}/git"

inherit module
inherit update-rc.d
inherit autotools

# add this since we aren't using module.bbclass
addtask make_scripts after do_patch before do_compile
do_make_scripts[lockfiles] = "${TMPDIR}/kernel-scripts.lock"
do_make_scripts[deptask] = "do_populate_sysroot"

EXTRA_OEMAKE = " -C ${STAGING_KERNEL_DIR} \
                KBUILD_VERBOSE=1 \
                M=${S}/io-module \
                modules \
                "

do_compile () {
    bbnote make   "$@"
    make   "$@"
    unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS
    oe_runmake
}


# Note that the opkg post install does not work if the radio-reset package is
# named mts-io-radio-reset.  It may be too long for the opkg name to handle.
PACKAGES = "${PN}-noarch kernel-module-${PN} ${PN}-util ${PN}-util-dbg ${PN}-dev ${PN}-radio"

FILES_kernel-module-${PN} = "${base_libdir}/modules/${KERNEL_VERSION}/extra/mts_io.ko"

FILES_${PN}-noarch = "${sysconfdir}/init.d/mts-io \
                        ${sysconfdir}/rc5.d/S95led-status_heartbeat_trigger \
                        ${sysconfdir}/default/mts-io  \
                        ${sysconfdir}/init.d/led-status_heartbeat_trigger"
                        
                        
FILES_${PN}-noarch += "${libdir}/mts-io-sysfs*"
FILES_${PN}-noarch += "${sbindir}/mts-io-sysfs"
FILES_${PN}-noarch_append_mtcap += "${sbindir}/lora-led-updater"
FILES_${PN}-util += "${sbindir}/mts-util-lora2-reset"
FILES_${PN}-util-dbg += "/usr/src /usr/sbin/.debug"
FILES_${PN}-dev += "/usr/include/linux/mts_eeprom.h"
FILES_${PN}-radio = "${sysconfdir}/init.d/radio-reset \
                           ${sysconfdir}/default/radio-reset"
RRECOMMENDS_${PN}-radio = "update-rc.d"


INITSCRIPT_NAME = "mts-io"
INITSCRIPT_PARAMS = "start 39 S ."

PARALLEL_MAKE = ""

fakeroot do_install () {
    make DESTDIR=${D} install
    install -m 0755 -d ${D}${base_libdir}/modules/${KERNEL_VERSION}/extra
    # use cp instead of install so the driver doesn't get stripped
    cp ${S}/io-module/mts_io.ko ${D}${base_libdir}/modules/${KERNEL_VERSION}/extra
    cp ${S}/io-module/mts_io.h ${STAGING_KERNEL_DIR}/include/linux/
    cp ${S}/io-module/mts_io.h ${STAGING_INCDIR}/linux/
    install -m0644 ${S}/io-module/mts_eeprom.h ${STAGING_KERNEL_DIR}/include/linux/
    install -d ${D}/usr/include/linux/
    install -m 0644 ${S}/io-module/mts_eeprom.h ${D}/usr/include/linux/

    install -d ${D}${sysconfdir}/init.d
    install -m 0755 ${WORKDIR}/mts-io.init ${D}${sysconfdir}/init.d/mts-io
    install -m 0755 ${WORKDIR}/radio-reset.init ${D}${sysconfdir}/init.d/radio-reset
    install -m 0755 ${WORKDIR}/led-status_heartbeat_trigger ${D}/${sysconfdir}/init.d/
    install -d ${D}${sysconfdir}/default
    install -m 0755 ${WORKDIR}/mts-io.conf ${D}${sysconfdir}/default/mts-io

    # blink status LED after booted
    install -d ${D}${sysconfdir}/rc5.d
    ln -sf ${sysconfdir}/init.d/led-status_heartbeat_trigger ${D}/${sysconfdir}/rc5.d/S95led-status_heartbeat_trigger

    install -m 0755 -d ${D}${sbindir}
    install -d ${D}${libdir}/mts-io-sysfs
    install -m 0755 ${S}/io-tool/mts-io-sysfs-inc.sh ${D}${libdir}/mts-io-sysfs
    install -m 0755 ${S}/io-tool/mts-io-sysfs ${D}${sbindir}/mts-io-sysfs

    install -d ${D}${sysconfdir}/default
    install -m 0644 ${WORKDIR}/radio-reset.default ${D}${sysconfdir}/default/radio-reset
}

fakeroot do_install_append_mtcap() {
    # install MTCAP mts-io init script
    install -m 0755 ${WORKDIR}/mts-io.mtcap.init ${D}${sysconfdir}/init.d/mts-io
    install -m 0755 ${WORKDIR}/lora-led-updater ${D}${sbindir}/lora-led-updater
}

# Radio-reset is on boot and shutdown for AEP/mlinux
fakeroot do_install_append_mtcdt() {
    # install MTCAP mts-io init script
    sed -i 's/STOP="no"/STOP="yes"/' ${D}${sysconfdir}/default/radio-reset
}

# Install the radio reset.  Not allowed two init script in one recipe.
pkg_postinst_${PN}-radio() {
#!/bin/sh
# Begin section update-rc.d
logger -t opkg.install.radio -p daemon.info 'radio preinstall'
if type update-rc.d >/dev/null 2>/dev/null; then
        if [ -n "$D" ]; then
                OPT="-r $D"
        else
                OPT="-s"
        fi
        update-rc.d $OPT radio-reset start 39 S .
fi
# End section update-rc.d
}

pkg_preinst_${PN}-radio() {
    #!/bin/bash
    if type update-rc.d >/dev/null 2>/dev/null; then
        if [ -n "$D" ]; then
            OPT="-f -r $D"
        else
            OPT="-f"
        fi
        update-rc.d $OPT radio-reset remove
    fi
}

pkg_prerm_${PN}-radio() {
    #!/bin/bash
    if [ -z "$D" ] ; then
        logger -t opkg.remove.radio -p daemon.info 'Removing radio-reset'
    fi
}


pkg_postrm_${PN}-radio() {
    #!/bin/bash
    if type update-rc.d >/dev/null 2>/dev/null; then
        if [ -n "$D" ]; then
            OPT="-f -r $D"
        else
            OPT="-f"
        fi
        update-rc.d $OPT radio-reset remove
    fi
}