diff --git a/Makefile.dep b/Makefile.dep index c1e1ba578..3ab7ee988 100644 --- a/Makefile.dep +++ b/Makefile.dep @@ -1,3 +1,9 @@ +ifneq (,$(filter libcoap,$(USEPKG))) + ifeq (,$(filter pnet,$(USEMODULE))) + USEMODULE += pnet + endif +endif + ifneq (,$(filter pnet,$(USEMODULE))) ifeq (,$(filter posix,$(USEMODULE))) USEMODULE += posix diff --git a/Makefile.modules b/Makefile.modules index c7380ba3a..30600b256 100644 --- a/Makefile.modules +++ b/Makefile.modules @@ -4,6 +4,7 @@ UNDEF += $(BINDIR)startup.o USEMODULE += cpu core sys INCLUDES += -I$(RIOTBASE)/core/include -I$(RIOTBASE)/drivers/include -I$(RIOTBASE)/sys/include ED = $(USEMODULE:%=-DMODULE_%) +ED += $(USEPKG:%=-DMODULE_%) EXTDEFINES = $(shell echo $(ED)|tr 'a-z' 'A-Z') BL=$(USEMODULE:%= $(BINDIR)%.a) diff --git a/pkg/libcoap/0001-Add-RIOT-Makefile.patch b/pkg/libcoap/0001-Add-RIOT-Makefile.patch new file mode 100644 index 000000000..9481c500c --- /dev/null +++ b/pkg/libcoap/0001-Add-RIOT-Makefile.patch @@ -0,0 +1,24 @@ +From b3ef68af33cb65f36666a416b71d7eb768715eca Mon Sep 17 00:00:00 2001 +From: Martin Lenders +Date: Thu, 31 Oct 2013 13:36:10 +0100 +Subject: [PATCH 1/4] Add RIOT Makefile + +--- + Makefile | 5 +++++ + 1 file changed, 5 insertions(+) + create mode 100644 Makefile + +diff --git a/Makefile b/Makefile +new file mode 100644 +index 0000000..f90baa1 +--- /dev/null ++++ b/Makefile +@@ -0,0 +1,5 @@ ++MODULE:=$(shell basename $(CURDIR)) ++INCLUDES += -I$(RIOTBASE) -I$(RIOTBASE)/sys/include -I$(RIOTBASE)/core/include -I$(RIOTBASE)/drivers/include -I$(RIOTBASE)/drivers/cc110x_ng/include -I$(RIOTBASE)/cpu/arm_common/include -I$(RIOTBASE)/sys/net/destiny/include -I$(RIOTBASE)/sys/net/sixlowpan/include/ -I$(RIOTBASE)/sys/net/ieee802154/include -I$(RIOTBASE)/sys/net/net_help -I$(RIOTBASE)/sys/posix/include -I$(RIOTBASE)/sys/posix/pnet/include ++CFLAGS += -DWITH_POSIX ++ ++include $(RIOTBASE)/Makefile.base +-- +1.8.3.2 + diff --git a/pkg/libcoap/0002-Add-config.h.patch b/pkg/libcoap/0002-Add-config.h.patch new file mode 100644 index 000000000..ac8c7a760 --- /dev/null +++ b/pkg/libcoap/0002-Add-config.h.patch @@ -0,0 +1,150 @@ +From 8be22676f13bd7d254378e2c04119e1632ed55d7 Mon Sep 17 00:00:00 2001 +From: Martin Lenders +Date: Thu, 31 Oct 2013 14:02:07 +0100 +Subject: [PATCH 2/4] Add config.h + +--- + config.h | 131 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 131 insertions(+) + create mode 100644 config.h + +diff --git a/config.h b/config.h +new file mode 100644 +index 0000000..8915dd3 +--- /dev/null ++++ b/config.h +@@ -0,0 +1,131 @@ ++/* config.h. Generated from config.h.in by configure. */ ++/* config.h.in. Generated from configure.in by autoheader. */ ++ ++/* Define if building universal (internal helper macro) */ ++/* #undef AC_APPLE_UNIVERSAL_BUILD */ ++ ++/* Define to 1 if you have the header file. */ ++#define HAVE_ARPA_INET_H 1 ++ ++/* Define to 1 if you have the header file. */ ++#define HAVE_ASSERT_H 1 ++ ++/* Define to 1 if you have the `getaddrinfo' function. */ ++/* #undef HAVE_GETADDRINFO */ ++ ++/* Define to 1 if you have the header file. */ ++#define HAVE_INTTYPES_H 1 ++ ++/* Define to 1 if you have the `coap' library (-lcoap). */ ++/* #undef HAVE_LIBCOAP */ ++ ++/* Define to 1 if you have the header file. */ ++/* #undef HAVE_LIMITS_H */ ++ ++/* Define to 1 if your system has a GNU libc compatible `malloc' function, and ++ to 0 otherwise. */ ++#define HAVE_MALLOC 0 ++ ++/* Define to 1 if you have the header file. */ ++/* #undef HAVE_MEMORY_H */ ++ ++/* Define to 1 if you have the `memset' function. */ ++#define HAVE_MEMSET 1 ++ ++/* Define to 1 if you have the header file. */ ++/* #undef HAVE_NETDB_H */ ++ ++/* Define to 1 if you have the header file. */ ++#define HAVE_NETINET_IN_H 1 ++ ++/* Define to 1 if you have the `select' function. */ ++/* #undef HAVE_SELECT */ ++ ++/* Define to 1 if you have the `socket' function. */ ++#define HAVE_SOCKET 1 ++ ++/* Define to 1 if you have the header file. */ ++#define HAVE_STDINT_H 1 ++ ++/* Define to 1 if you have the header file. */ ++#define HAVE_STDLIB_H 1 ++ ++/* Define to 1 if you have the `strcasecmp' function. */ ++#define HAVE_STRCASECMP 1 ++ ++/* Define to 1 if you have the header file. */ ++#define HAVE_STRINGS_H 1 ++ ++/* Define to 1 if you have the header file. */ ++#define HAVE_STRING_H 1 ++ ++/* Define to 1 if you have the `strnlen' function. */ ++#define HAVE_STRNLEN 1 ++ ++/* Define to 1 if you have the `strrchr' function. */ ++#define HAVE_STRRCHR 1 ++ ++/* Define to 1 if you have the header file. */ ++#define HAVE_SYS_SOCKET_H 1 ++ ++/* Define to 1 if you have the header file. */ ++/* #undef HAVE_SYS_STAT_H */ ++ ++/* Define to 1 if you have the header file. */ ++#define HAVE_SYS_TIME_H 1 ++ ++/* Define to 1 if you have the header file. */ ++#define HAVE_SYS_TYPES_H 1 ++ ++/* Define to 1 if you have the header file. */ ++#define HAVE_SYS_UNISTD_H 1 ++ ++/* Define to 1 if you have the header file. */ ++#define HAVE_TIME_H 1 ++ ++/* Define to 1 if you have the header file. */ ++#define HAVE_UNISTD_H 1 ++ ++/* Define to the address where bug reports for this package should be sent. */ ++#define PACKAGE_BUGREPORT "" ++ ++/* Define to the full name of this package. */ ++#define PACKAGE_NAME "libcoap" ++ ++/* Define to the full name and version of this package. */ ++#define PACKAGE_STRING "libcoap 4.1.1" ++ ++/* Define to the one symbol short name of this package. */ ++#define PACKAGE_TARNAME "libcoap" ++ ++/* Define to the home page for this package. */ ++#define PACKAGE_URL "" ++ ++/* Define to the version of this package. */ ++#define PACKAGE_VERSION "4.1.1" ++ ++/* Define to 1 if you have the ANSI C header files. */ ++#define STDC_HEADERS 1 ++ ++/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most ++ significant byte first (like Motorola and SPARC, unlike Intel). */ ++#if defined AC_APPLE_UNIVERSAL_BUILD ++# if defined __BIG_ENDIAN__ ++# define WORDS_BIGENDIAN 1 ++# endif ++#else ++# ifndef WORDS_BIGENDIAN ++/* # undef WORDS_BIGENDIAN */ ++# endif ++#endif ++ ++/* Define to rpl_malloc if the replacement function should be used. */ ++/* #undef malloc */ ++ ++/* Define to `unsigned int' if does not define. */ ++/* #undef size_t */ ++ ++/* Define to `int' if does not define. */ ++/* #undef ssize_t */ ++ ++#define WITH_POSIX 1 +-- +1.8.3.2 + diff --git a/pkg/libcoap/patch.txt b/pkg/libcoap/0003-Remove-two-example-programs-in-root.patch similarity index 75% rename from pkg/libcoap/patch.txt rename to pkg/libcoap/0003-Remove-two-example-programs-in-root.patch index 45e6b8a0c..08b5bd9b1 100644 --- a/pkg/libcoap/patch.txt +++ b/pkg/libcoap/0003-Remove-two-example-programs-in-root.patch @@ -1,13 +1,15 @@ -diff --git a/Makefile b/Makefile -new file mode 100644 -index 0000000..016d716 ---- /dev/null -+++ b/Makefile -@@ -0,0 +1,4 @@ -+MODULE:=$(shell basename $(CURDIR)) -+INCLUDES += -I$(RIOTBASE) -I$(RIOTBASE)/sys/include -I$(RIOTBASE)/core/include -I$(RIOTBASE)/drivers/include -I$(RIOTBASE)/drivers/cc110x_ng/include -I$(RIOTBASE)/cpu/arm_common/include -I$(RIOTBASE)/sys/net/destiny/include -I$(RIOTBASE)/sys/net/sixlowpan/include/ -I$(RIOTBASE)/sys/net/ieee802154/include -I$(RIOTBASE)/sys/net/net_help -I$(RIOTBASE)/sys/posix/include -I$(RIOTBASE)/sys/posix/pnet/include -+ -+include $(RIOTBASE)/Makefile.base +From 809b869b17623c8ec00c4ad421317037db30f3bf Mon Sep 17 00:00:00 2001 +From: Martin Lenders +Date: Thu, 31 Oct 2013 15:15:07 +0100 +Subject: [PATCH 3/4] Remove two example programs in root + +--- + coap-observer.c | 185 ----------------------------------------------- + coap-server.c | 220 -------------------------------------------------------- + 2 files changed, 405 deletions(-) + delete mode 100644 coap-observer.c + delete mode 100644 coap-server.c + diff --git a/coap-observer.c b/coap-observer.c deleted file mode 100644 index e4b2fe5..0000000 @@ -425,138 +427,6 @@ index 5dcdfcd..0000000 - PROCESS_END(); -} -/*---------------------------------------------------------------------------*/ -diff --git a/config.h b/config.h -new file mode 100644 -index 0000000..5d6ea39 ---- /dev/null -+++ b/config.h -@@ -0,0 +1,129 @@ -+/* config.h. Generated from config.h.in by configure. */ -+/* config.h.in. Generated from configure.in by autoheader. */ -+ -+/* Define if building universal (internal helper macro) */ -+/* #undef AC_APPLE_UNIVERSAL_BUILD */ -+ -+/* Define to 1 if you have the header file. */ -+#define HAVE_ARPA_INET_H 1 -+ -+/* Define to 1 if you have the header file. */ -+#define HAVE_ASSERT_H 1 -+ -+/* Define to 1 if you have the `getaddrinfo' function. */ -+/* #undef HAVE_GETADDRINFO */ -+ -+/* Define to 1 if you have the header file. */ -+#define HAVE_INTTYPES_H 1 -+ -+/* Define to 1 if you have the `coap' library (-lcoap). */ -+/* #undef HAVE_LIBCOAP */ -+ -+/* Define to 1 if you have the header file. */ -+/* #undef HAVE_LIMITS_H */ -+ -+/* Define to 1 if your system has a GNU libc compatible `malloc' function, and -+ to 0 otherwise. */ -+#define HAVE_MALLOC 0 -+ -+/* Define to 1 if you have the header file. */ -+/* #undef HAVE_MEMORY_H */ -+ -+/* Define to 1 if you have the `memset' function. */ -+#define HAVE_MEMSET 1 -+ -+/* Define to 1 if you have the header file. */ -+/* #undef HAVE_NETDB_H */ -+ -+/* Define to 1 if you have the header file. */ -+#define HAVE_NETINET_IN_H 1 -+ -+/* Define to 1 if you have the `select' function. */ -+/* #undef HAVE_SELECT */ -+ -+/* Define to 1 if you have the `socket' function. */ -+#define HAVE_SOCKET 1 -+ -+/* Define to 1 if you have the header file. */ -+#define HAVE_STDINT_H 1 -+ -+/* Define to 1 if you have the header file. */ -+#define HAVE_STDLIB_H 1 -+ -+/* Define to 1 if you have the `strcasecmp' function. */ -+#define HAVE_STRCASECMP 1 -+ -+/* Define to 1 if you have the header file. */ -+#define HAVE_STRINGS_H 1 -+ -+/* Define to 1 if you have the header file. */ -+#define HAVE_STRING_H 1 -+ -+/* Define to 1 if you have the `strnlen' function. */ -+#define HAVE_STRNLEN 1 -+ -+/* Define to 1 if you have the `strrchr' function. */ -+#define HAVE_STRRCHR 1 -+ -+/* Define to 1 if you have the header file. */ -+#define HAVE_SYS_SOCKET_H 1 -+ -+/* Define to 1 if you have the header file. */ -+/* #undef HAVE_SYS_STAT_H */ -+ -+/* Define to 1 if you have the header file. */ -+#define HAVE_SYS_TIME_H 1 -+ -+/* Define to 1 if you have the header file. */ -+#define HAVE_SYS_TYPES_H 1 -+ -+/* Define to 1 if you have the header file. */ -+#define HAVE_SYS_UNISTD_H 1 -+ -+/* Define to 1 if you have the header file. */ -+#define HAVE_TIME_H 1 -+ -+/* Define to 1 if you have the header file. */ -+#define HAVE_UNISTD_H 1 -+ -+/* Define to the address where bug reports for this package should be sent. */ -+#define PACKAGE_BUGREPORT "" -+ -+/* Define to the full name of this package. */ -+#define PACKAGE_NAME "libcoap" -+ -+/* Define to the full name and version of this package. */ -+#define PACKAGE_STRING "libcoap 4.0.3" -+ -+/* Define to the one symbol short name of this package. */ -+#define PACKAGE_TARNAME "libcoap" -+ -+/* Define to the home page for this package. */ -+#define PACKAGE_URL "" -+ -+/* Define to the version of this package. */ -+#define PACKAGE_VERSION "4.0.3" -+ -+/* Define to 1 if you have the ANSI C header files. */ -+#define STDC_HEADERS 1 -+ -+/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most -+ significant byte first (like Motorola and SPARC, unlike Intel). */ -+#if defined AC_APPLE_UNIVERSAL_BUILD -+# if defined __BIG_ENDIAN__ -+# define WORDS_BIGENDIAN 1 -+# endif -+#else -+# ifndef WORDS_BIGENDIAN -+/* # undef WORDS_BIGENDIAN */ -+# endif -+#endif -+ -+/* Define to rpl_malloc if the replacement function should be used. */ -+/* #undef malloc */ -+ -+/* Define to `unsigned int' if does not define. */ -+/* #undef size_t */ -+ -+/* Define to `int' if does not define. */ -+/* #undef ssize_t */ +-- +1.8.3.2 + diff --git a/pkg/libcoap/0004-Eliminate-some-compiler-warnings-and-errors.patch b/pkg/libcoap/0004-Eliminate-some-compiler-warnings-and-errors.patch new file mode 100644 index 000000000..9307d10c1 --- /dev/null +++ b/pkg/libcoap/0004-Eliminate-some-compiler-warnings-and-errors.patch @@ -0,0 +1,71 @@ +From 48906fde395dc05c18606ddf3abce5947ab6a1c6 Mon Sep 17 00:00:00 2001 +From: Martin Lenders +Date: Wed, 19 Feb 2014 02:24:50 +0100 +Subject: [PATCH 4/4] Eliminate some compiler warnings and errors + +--- + address.h | 4 ++++ + net.c | 4 ++++ + net.h | 8 +++++--- + 3 files changed, 13 insertions(+), 3 deletions(-) + +diff --git a/address.h b/address.h +index 403240e..0e715f1 100644 +--- a/address.h ++++ b/address.h +@@ -106,6 +106,10 @@ _coap_address_equals_impl(const coap_address_t *a, + return 0; + } + ++#ifndef IN_MULTICAST ++#define IN_MULTICAST(a) (1) ++#endif ++ + static inline int + _coap_is_mcast_impl(const coap_address_t *a) { + if (!a) +diff --git a/net.c b/net.c +index e90d49a..83097d1 100644 +--- a/net.c ++++ b/net.c +@@ -45,6 +45,10 @@ + #include "block.h" + #include "net.h" + ++#ifndef UINT_MAX ++#define UINT_MAX ((unsigned) -1ul) ++#endif ++ + #if defined(WITH_POSIX) + + time_t clock_offset; +diff --git a/net.h b/net.h +index f9afd48..59c7d59 100644 +--- a/net.h ++++ b/net.h +@@ -132,7 +132,7 @@ typedef struct coap_context_t { + * random value. A new message id can be created with + * coap_new_message_id(). + */ +- unsigned short message_id; ++ uint16_t message_id; + + /** + * The next value to be used for Observe. This field is global for +@@ -196,9 +196,11 @@ coap_context_t *coap_new_context(const coap_address_t *listen_addr); + static inline unsigned short + coap_new_message_id(coap_context_t *context) { + #ifndef WITH_CONTIKI +- return htons(++(context->message_id)); ++ context->message_id += 1; ++ return htons(context->message_id); + #else /* WITH_CONTIKI */ +- return uip_htons(++context->message_id); ++ context->message_id += 1; ++ return uip_htons(context->message_id); + #endif + } + +-- +1.8.3.2 + diff --git a/pkg/libcoap/Makefile b/pkg/libcoap/Makefile index 9a91f013b..1205f4f6d 100644 --- a/pkg/libcoap/Makefile +++ b/pkg/libcoap/Makefile @@ -1,6 +1,6 @@ PKG_NAME=libcoap PKG_URL=http://git.code.sf.net/p/libcoap/code -PKG_VERSION=89acaa6775ca3a4aedea510557e6b9c0c01fa5db +PKG_VERSION=ef41ce5d02d64cec0751882ae8fd95f6c32bc018 ifneq ($(RIOTBOARD),) include $(RIOTBOARD)/$(BOARD)/Makefile.include @@ -19,7 +19,7 @@ all: patch patch: $(CURDIR)/$(PKG_NAME)/Makefile $(CURDIR)/$(PKG_NAME)/Makefile: $(CURDIR)/$(PKG_NAME) - cd $< && git apply ../patch.txt + cd "$<" && git am --ignore-whitespace $(CURDIR)/*.patch || true $(CURDIR)/$(PKG_NAME)/: git clone $(PKG_URL) $@ && \