OpenWrt Forum Archive

Topic: How to compile a package for openwrt?

The content of this topic has been archived on 3 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hello!
Just sorry for my English, my native language is Russian. I try to write correctly and use an interpreter, but errors may occur.

I need to compile the source code in the IPK package for OpenWRT 15.05.

I have a control relay MP709 (http://www.olimp-z.ru/mp709)
Source code for Linux: http://www.olimp-z.ru/products/MP709/mp709_adriver.tar
My OS: Debian 8.
My router: TP-Link TL-MR3220 (ver. 1.2)

Here are the contents of the README:

requirements:
libusb 1.0

1. cd hidapi/linux
make
../../
make

2. Add udev rule like this:
ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="05df", MODE="0660", GROUP="masterkit"

Add user who works with mp709 to group "masterkit"

3. enjoy your new mp709
   mp709 on
   mp709 off

As I understand it, that first I need to compile hidapi, and then compile the relay control program mp709.
But due to lack of experience, I can not figure out how to compile this code for my router architecture.

I have read articles on the wiki.openwrt.org and on the Internet how to add a package OpenWRT and write makefile. But I get an error and I do not know how to fix them. I ask for help from the community.


I made these commands:

# git clone git://git.openwrt.org/15.05/openwrt.git
# cd openwrt
# ./scripts/feeds update -a && ./scripts/feeds install -a
# make prereq

At this stage there were errors due to a missing packet, but I found them all and installed.

Then I in openwrt/package folder created folder mp709. In it, I create a folder src to put the source code. And next to the folder src I created Makefile file.

Makefile

root@pc:/home/user/openwrt/package/mp709# cat Makefile

include $(TOPDIR)/rules.mk

    PKG_NAME:=mp709
    PKG_VERSION:=1
    PKG_RELEASE:=1
    PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)

include $(INCLUDE_DIR)/package.mk



define Package/mp709
        SECTION:=utils
        CATEGORY:=Utilities
        DEFAULT:=n
        TITLE:=MP709 relay control utilities
        DEPENDS:=+libusb-1.0
endef



define Package/mp709/description
        MP709 relay control
endef



define Build/Prepare
        mkdir -p $(PKG_BUILD_DIR)
        $(CP) ./src/* $(PKG_BUILD_DIR)/
endef



define Build/Configure
        $(call Build/Configure/Default,--with-linux-headers=$(LINUX_DIR))
endef


define Build/Compile
        $(TARGET_CC) $(TARGET_CFLAGS) -Ihidapi/hidapi -Wall -g -c `pkg-config libusb-1.0 --cflags` -fpermissive  -o $(PKG_BUILD_DIR)/mp709
endef



define Package/mp709/install
        $(INSTALL_DIR) $(1)/bin
        $(INSTALL_BIN) $(PKG_BUILD_DIR)/mp709 $(1)/bin/
endef

$(eval $(call BuildPackage,mp709))
root@pc:/home/user/openwrt/package# ls mp709
Makefile  src
root@pc:/home/user/openwrt/package/mp709# ls src
hidapi  Makefile  mp709.c  mp709.o  README

An error occurred while launching compile the package:

root@pc:/home/user/openwrt# make /package/mp709/compile V=99
make[1]: Entering directory '/home/user/openwrt'
make[1]: *** No rule to make target '/package/mp709/compile'.  Stop.
make[1]: Leaving directory '/home/user/openwrt'
/home/user/openwrt/include/toplevel.mk:181: ошибка выполнения рецепта для цели «/package/mp709/compile»
make: *** [/package/mp709/compile] Error 2

Please tell me what is my mistake. Thank you!

instead of

make /package/mp709/compile

try

make package/mp709/compile 

New error:

root@pc:/home/user/openwrt# make package/mp709/compile V=99
make[1]: Entering directory '/home/user/openwrt'
make[2]: Entering directory '/home/user/openwrt/package/libs/toolchain'
cp -fpR /home/user/openwrt/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/lib/libuClibc-*.so /home/user/openwrt/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/lib/libcrypt-*.so /home/user/openwrt/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/lib/libm-*.so /home/user/openwrt/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/lib/libpthread-*.so /home/user/openwrt/build_dir/target-mips_34kc_uClibc-0.9.33.2/toolchain/
cp: cannot stat '/home/user/openwrt/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/lib/libuClibc-*.so': No such file or directory
cp: cannot stat '/home/user/openwrt/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/lib/libcrypt-*.so': No such file or directory
cp: cannot stat '/home/user/openwrt/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/lib/libm-*.so': No such file or directory
cp: cannot stat '/home/user/openwrt/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/lib/libpthread-*.so': No such file or directory
Makefile:636: recipe for target '/home/user/openwrt/build_dir/target-mips_34kc_uClibc-0.9.33.2/toolchain/.built' failed
make[2]: *** [/home/user/openwrt/build_dir/target-mips_34kc_uClibc-0.9.33.2/toolchain/.built] Error 1
make[2]: Leaving directory '/home/user/openwrt/package/libs/toolchain'
package/Makefile:191: recipe for target 'package/libs/toolchain/compile' failed
make[1]: *** [package/libs/toolchain/compile] Error 2
make[1]: Leaving directory '/home/user/openwrt'
/home/user/openwrt/include/toplevel.mk:181: ошибка выполнения рецепта для цели «package/mp709/compile»
make: *** [package/mp709/compile] Ошибка 2

first

make tools/install
make toolchain/install

then build dependencies

make package/libusb1.0/compile
make package/libusb1.0/install

then build package

make package/mp709/compile
make package/mp709/install
make package/index

After

make package/index

I have some errors

root@pc:/home/user/openwrt# make package/index -j1 V=s
make[1]: Entering directory '/home/user/openwrt'
Generating package index...
Generating index for package ./jshn_2015-11-08-10429bccd0dc5d204635e110a7a8fae7b80d16cb_ar71xx.ipk
Generating index for package ./libblobmsg-json_2015-11-08-10429bccd0dc5d204635e110a7a8fae7b80d16cb_ar71xx.ipk
Generating index for package ./libgcc_4.8-linaro-1_ar71xx.ipk
Generating index for package ./libjson-c_0.12-1_ar71xx.ipk
Generating index for package ./libjson-script_2015-11-08-10429bccd0dc5d204635e110a7a8fae7b80d16cb_ar71xx.ipk
Generating index for package ./libubox_2015-11-08-10429bccd0dc5d204635e110a7a8fae7b80d16cb_ar71xx.ipk
Generating index for package ./usign_2015-05-08-cf8dcdb8a4e874c77f3e9a8e9b643e8c17b19131_ar71xx.ipk
Signing package index...
bash: line 3: /home/user/openwrt/staging_dir/host/bin/usign: No such file or directory
bash: line 3: /home/user/openwrt/staging_dir/host/bin/usign: No such file or directory
bash: line 3: /home/user/openwrt/staging_dir/host/bin/usign: No such file or directory
bash: line 3: /home/user/openwrt/staging_dir/host/bin/usign: No such file or directory
bash: line 3: /home/user/openwrt/staging_dir/host/bin/usign: No such file or directory
bash: line 3: /home/user/openwrt/staging_dir/host/bin/usign: No such file or directory
package/Makefile:147: recipe for target 'package/index' failed
make[1]: *** [package/index] Error 127
make[1]: Leaving directory '/home/user/openwrt'
/home/user/openwrt/include/toplevel.mk:181: ошибка выполнения рецепта для цели «package/index»
make: *** [package/index] Ошибка 2

(Last edited by energoblock on 30 May 2016, 18:52)

The discussion might have continued from here.