[OpenWrt-Devel] package libcoap for OpenWRT, Makefile

Baptiste Clenet bapclenet at gmail.com
Wed Aug 5 04:09:43 EDT 2015


Hi,

I'm trying to add a package for libcoap and then compile it with my
target Ralink MT7628.

Here is the Makefile:
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

include $(TOPDIR)/rules.mk

PKG_NAME:=libcoap
PKG_VERSION:=4.1.1
PKG_RELEASE:=1

PKG_SOURCE:=libcoap-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=@SF/libcoap
PKG_BUILD_DIR:=$(BUILD_DIR)/libcoap-$(PKG_VERSION)
PKG_INSTALL:=1

include $(INCLUDE_DIR)/package.mk

define Package/libcoap
  SECTION:=libs
  CATEGORY:=Libraries
  DEPENDS:=
  TITLE:=CoAP static library and example utilities
  URL:=http://libcoap.sourceforge.net/
endef

define Build/Compile
$(MAKE) -C $(PKG_BUILD_DIR) \
$(TARGET_CONFIGURE_OPTS) \
CFLAGS="$(TARGET_CFLAGS) -I$(PKG_BUILD_DIR)" \
CPPFLAGS="$(TARGET_CPPFLAGS) -I$(PKG_BUILD_DIR)" \
LDFLAGS="$(TARGET_LDFLAGS) -L$(PKG_BUILD_DIR) -lcoap"
endef

define Build/Install
endef

define Build/InstallDev
$(INSTALL_DIR) $(1)/usr/include
$(CP) $(PKG_BUILD_DIR)/coap.h $(1)/usr/include/
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_BUILD_DIR)/libcoap.a $(1)/usr/lib/
endef

define Package/libcoap/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/examples/coap-server $(1)/usr/bin/
$(INSTALL_BIN) $(PKG_BUILD_DIR)/examples/coap-client $(1)/usr/bin/
endef

$(eval $(call BuildPackage,libcoap))







I'm getting those errors with make V=s :


config.status: creating Makefile
config.status: creating doc/Makefile
config.status: creating doc/Doxyfile
config.status: creating examples/Makefile
config.status: creating tests/Makefile
config.status: creating config.h
configure: WARNING: unrecognized options: --disable-nls

// long make lines...

In file included from net.h:44:0,
                 from async.h:19,
                 from net.c:41:
address.h:134:19: error: unknown type name 'coap_address_t'
 coap_address_init(coap_address_t *addr) {
                   ^
address.h:149:1: error: unknown type name 'coap_address_t'
 coap_address_equals(const coap_address_t *a, const coap_address_t *b) {
 ^
address.h:149:1: error: unknown type name 'coap_address_t'
address.h:159:1: error: unknown type name 'coap_address_t'
 coap_is_mcast(const coap_address_t *a) {
 ^
In file included from net.h:47:0,
                 from async.h:19,
                 from net.c:41:
coap_time.h: In function 'coap_clock_init_impl':
coap_time.h:111:3: error: 'clock_offset' undeclared (first use in this function)
   clock_offset = time(NULL);
   ^
coap_time.h:111:3: note: each undeclared identifier is reported only
once for each function it appears in
coap_time.h: At top level:
coap_time.h:126:17: error: unknown type name 'coap_tick_t'
 coap_ticks_impl(coap_tick_t *t) {
                 ^
coap_time.h:144:18: error: unknown type name 'coap_tick_t'
 int coap_time_lt(coap_tick_t a, coap_tick_t b) {
                  ^
coap_time.h:144:33: error: unknown type name 'coap_tick_t'
 int coap_time_lt(coap_tick_t a, coap_tick_t b) {
                                 ^
coap_time.h:153:18: error: unknown type name 'coap_tick_t'
 int coap_time_le(coap_tick_t a, coap_tick_t b) {
                  ^
coap_time.h:153:33: error: unknown type name 'coap_tick_t'
 int coap_time_le(coap_tick_t a, coap_tick_t b) {
                                 ^
In file included from async.h:19:0,
                 from net.c:41:
net.h:54:3: error: unknown type name 'coap_tick_t'
   coap_tick_t t;         /**< when to send PDU for the next time */
   ^
net.h:58:3: error: unknown type name 'coap_address_t'
   coap_address_t local;  /**< local address */
   ^
net.h:59:3: error: unknown type name 'coap_address_t'
   coap_address_t remote; /**< remote address */
   ^
net.h:85:6: error: unknown type name 'coap_address_t'
      const coap_address_t *remote,
      ^
net.h:109:3: error: unknown type name 'coap_tick_t'
   coap_tick_t sendqueue_basetime;
   ^
In file included from async.h:19:0,
                 from net.c:41:
net.h:177:56: error: unknown type name 'coap_tick_t'
 unsigned int coap_adjust_basetime(coap_context_t *ctx, coap_tick_t now);
                                                        ^
net.h:186:1: error: unknown type name 'coap_address_t'
 coap_context_t *coap_new_context(const coap_address_t *listen_addr);
 ^
net.h:220:11: error: unknown type name 'coap_address_t'
           const coap_address_t *dst,
           ^
net.h:254:8: error: unknown type name 'coap_address_t'
        const coap_address_t *dst,
        ^
net.h:276:7: error: unknown type name 'coap_address_t'
       const coap_address_t *dst,
       ^
net.h:293:10: error: unknown type name 'coap_address_t'
          const coap_address_t *dst,
          ^
net.h:309:5: error: unknown type name 'coap_address_t'
     const coap_address_t *dst,
     ^
net.h:326:8: error: unknown type name 'coap_address_t'
        const coap_address_t *dst,
        ^
net.h:349:1: error: unknown type name 'coap_address_t'
 void coap_transaction_id(const coap_address_t *peer, const coap_pdu_t *pdu,
 ^
net.h:411:10: error: unknown type name 'coap_address_t'
          const coap_address_t *dst,
          ^
net.h:425:17: error: unknown type name 'coap_tick_t'
 void coap_ticks(coap_tick_t *);
                 ^
In file included from net.c:41:0:
async.h:40:3: error: unknown type name 'coap_tick_t'
   coap_tick_t created;
   ^
async.h:52:3: error: unknown type name 'coap_address_t'
   coap_address_t peer;  /**< the peer to notify */
   ^
async.h:88:46: error: unknown type name 'coap_address_t'
 coap_register_async(coap_context_t *context, coap_address_t *peer,
                                              ^
In file included from resource.h:42:0,
                 from net.c:42:
subscribe.h:43:3: error: unknown type name 'coap_address_t'
   coap_address_t subscriber;     /**< address and port of subscriber */
   ^
In file included from net.c:42:0:
resource.h:46:49: error: unknown type name 'coap_address_t'
   (coap_context_t  *, struct coap_resource_t *, coap_address_t *, coap_pdu_t *,
                                                 ^
resource.h:73:3: error: unknown type name 'coap_method_handler_t'
   coap_method_handler_t handler[4];
   ^
resource.h:228:31: error: unknown type name 'coap_method_handler_t'
         unsigned char method, coap_method_handler_t handler) {
                               ^
resource.h:275:12: error: unknown type name 'coap_address_t'
            const coap_address_t *observer,
            ^
resource.h:288:6: error: unknown type name 'coap_address_t'
      const coap_address_t *peer,
      ^
resource.h:300:5: error: unknown type name 'coap_address_t'
     const coap_address_t *observer,
     ^
resource.h:313:6: error: unknown type name 'coap_address_t'
      const coap_address_t *observer,
      ^
net.c:139:1: error: unknown type name 'coap_address_t'
 void coap_handle_failed_notify(coap_context_t *, const coap_address_t *,
 ^
net.c:143:43: error: unknown type name 'coap_tick_t'
 coap_adjust_basetime(coap_context_t *ctx, coap_tick_t now) {
                                           ^
net.c: In function 'coap_new_node':
net.c:239:8: warning: assignment makes pointer from integer without a
cast [enabled by default]
   node = coap_malloc_node();
        ^
net.c: At top level:
net.c:297:3: error: unknown type name 'coap_address_t'
   const coap_address_t *listen_addr) {
   ^
In file included from net.h:45:0,
                 from async.h:19,
                 from net.c:41:
net.c: In function 'coap_new_context':
net.c:321:42: error: 'clock_offset' undeclared (first use in this function)
   prng_init((unsigned long)listen_addr ^ clock_offset);
                                          ^
prng.h:80:48: note: in definition of macro 'prng_init'
 #define prng_init(Value) srand((unsigned long)(Value))
                                                ^
net.c:325:9: error: 'c' undeclared (first use in this function)
   if ( !c ) {
         ^
net.c: At top level:
net.c:498:1: error: unknown type name 'coap_address_t'
 coap_transaction_id(const coap_address_t *peer, const coap_pdu_t *pdu,
 ^
net.c:535:8: error: unknown type name 'coap_address_t'
        const coap_address_t *dst,
        ^
net.c:654:4: error: unknown type name 'coap_address_t'
    const coap_address_t *dst,
    ^
net.c:662:3: error: unknown type name 'coap_address_t'
   const coap_address_t *dst,
   ^
net.c:682:10: error: unknown type name 'coap_address_t'
          const coap_address_t *dst,
          ^
net.c:700:7: error: unknown type name 'coap_address_t'
       const coap_address_t *dst,
       ^
net.c: In function 'coap_send_confirmed':
net.c:703:3: error: unknown type name 'coap_tick_t'
   coap_tick_t now;
   ^
net.c:722:51: error: 'COAP_TICKS_PER_SECOND' undeclared (first use in
this function)
   node->timeout = COAP_DEFAULT_RESPONSE_TIMEOUT * COAP_TICKS_PER_SECOND +
                                                   ^
net.c:726:37: error: 'coap_address_t' undeclared (first use in this function)
   memcpy(&node->remote, dst, sizeof(coap_address_t));
                                     ^
net.c: In function 'coap_read':
net.c:840:3: error: unknown type name 'coap_address_t'
   coap_address_t src, dst;
   ^
net.c:852:23: error: 'buf' undeclared (first use in this function)
   pdu = (coap_hdr_t *)buf;
                       ^
net.c:910:37: error: 'coap_address_t' undeclared (first use in this function)
   memcpy(&node->local, &dst, sizeof(coap_address_t));
                                     ^
net.c:929:5: warning: passing argument 1 of 'coap_print_addr' from
incompatible pointer type [enabled by default]
     if (coap_print_addr(&src, addr, INET6_ADDRSTRLEN+8))
     ^
In file included from net.c:38:0:
debug.h:61:8: note: expected 'const struct coap_address_t *' but
argument is of type 'int *'
 size_t coap_print_addr(const struct coap_address_t *, unsigned char *, size_t);
        ^
net.c: At top level:
net.c:1002:1: error: unknown type name 'coap_address_t'
 coap_cancel_all_messages(coap_context_t *context, const coap_address_t *dst,
 ^
net.c: In function 'handle_request':
net.c:1284:3: error: unknown type name 'coap_method_handler_t'
   coap_method_handler_t h = NULL;
   ^
net.c:1337:40: error: 'coap_method_handler_t' undeclared (first use in
this function)
       sizeof(resource->handler)/sizeof(coap_method_handler_t))
                                        ^
net.c:1354:8: error: called object 'h' is not a function or function pointer
       h(context, resource, &node->remote,
        ^
net.c:1284:25: note: declared here
   coap_method_handler_t h = NULL;
                         ^
make[3]: *** [net.o] Error 1
make[3]: Leaving directory
`/home/xsoen/Documents/Developpement/OPENWRT/trunk-linux4.1/trunk/build_dir/target-mipsel_24kec+dsp_musl-1.1.10/libcoap-4.1.1'
make[2]: *** [/home/xsoen/Documents/Developpement/OPENWRT/trunk-linux4.1/trunk/build_dir/target-mipsel_24kec+dsp_musl-1.1.10/libcoap-4.1.1/.built]
Error 2
make[2]: Leaving directory
`/home/xsoen/Documents/Developpement/OPENWRT/trunk-linux4.1/trunk/package/libs/libcoap'
make[1]: *** [package/libs/libcoap/compile] Error 2
make[1]: Leaving directory
`/home/xsoen/Documents/Developpement/OPENWRT/trunk-linux4.1/trunk'
make: *** [package/libcoap/compile] Erreur 2


coap_address_t is defined in address.h inside some #ifdef (#ifdef
WITH_LWIP or #ifdef WITH_CONTIKI or #ifdef WITH_POSIX)

I don't know if WITH_POSIX is defined.

Regards,

-- 
Baptiste
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list