From 0f062e557eb9c368e939a15f0d7c8af3d3de1c18 Mon Sep 17 00:00:00 2001 From: Olaf Bergmann Date: Tue, 16 Feb 2016 14:19:11 +0100 Subject: [PATCH] Makefile: fixed build infrastructure for Contiki examples The new structure of libcoap allows to clone Contiki in a subdirectory. The example build now uses Makefile to first clone Contiki and then invoke Makefile.contiki for the actual build. The TARGET is set to minimal-net by default but can be changed to any other (tested) target. --- examples/contiki/Makefile | 30 ++++++-------------------- examples/contiki/Makefile.common | 36 ------------------------------- examples/contiki/Makefile.contiki | 36 +++++++------------------------ 3 files changed, 15 insertions(+), 87 deletions(-) delete mode 100644 examples/contiki/Makefile.common diff --git a/examples/contiki/Makefile b/examples/contiki/Makefile index 7dc0b3c8..dac5de6a 100644 --- a/examples/contiki/Makefile +++ b/examples/contiki/Makefile @@ -1,27 +1,11 @@ -NODE_ADDR?=0x1000 +CONTIKI=contiki +TARGET?=minimal-net all: server -contiki: - git clone https://github.com/contiki-os/contiki.git +$(CONTIKI): + git clone https://github.com/contiki-os/contiki.git $@ + cd $(CONTIKI)/apps && ln -s ../../../.. libcoap -# contiki and coap opts -CONTIKI=contiki - -CFLAGS += -I. - -# contiki library - -PLATFORM_VPATH = $(CONTIKI)/cpu/native $(CONTIKI)/cpu/native/net $(CONTIKI)/platform/minimal-net -#PLATFORM_CPPFLAGS = -PLATFORM_CFLAGS = -I$(CONTIKI)/cpu/native/ -I$(CONTIKI)/platform/minimal-net -PLATFORM_OBJS = contiki-main.o tapdev6.o tapdev-drv.o clock.o serial-line.o - -CONTIKIOBJS = $(PLATFORM_OBJS) ringbuf.o autostart.o list.o memb.o uiplib.o uip-nd6.o uip-neighbor.o uip-ds6.o uip-ds6-nbr.o linkaddr.o uip.o uip-udp-packet.o random.o ctimer.o timer.o etimer.o stimer.o procinit.o process.o udp-socket.o uip-icmp6.o tcpip.o uip-packetqueue.o uip-ds6-route.o nbr-table.o uip6.o uip.o uip-debug.o packetbuf.o -vpath %.c $(CONTIKI)/core $(CONTIKI)/core/lib $(CONTIKI)/core/sys $(CONTIKI)/core/dev $(CONTIKI)/core/net $(CONTIKI)/core/net/ip $(CONTIKI)/core/net/ipv4 $(CONTIKI)/core/net/ipv6 $(CONTIKI)/core/loader $(CONTIKI)/core/cfs $(PLATFORM_VPATH) - -CFLAGS += -DCONTIKI_TARGET_MINIMAL_NET=1 -DWITH_UIP6=1 -DUIP6_CONF_IPV6=1 -DNETSTACK_CONF_WITH_IPV6=1 -DUIP_CONF_IPV6_RPL=0 -URPL_BORDER_ROUTER -DAUTOSTART_ENABLE -DNODE_ADDR=$(NODE_ADDR) - -CFLAGS += -g3 -Wall -pedantic -O0 - -include Makefile.common +server: $(CONTIKI) + $(MAKE) -f Makefile.contiki V=1 CONTIKI=$(CONTIKI) TARGET=$(TARGET) NODE_ADDR=0x1000 server diff --git a/examples/contiki/Makefile.common b/examples/contiki/Makefile.common deleted file mode 100644 index e8d3fa24..00000000 --- a/examples/contiki/Makefile.common +++ /dev/null @@ -1,36 +0,0 @@ -top_srcdir ?= ../.. - -# coap library - -CFLAGS += -std=gnu99 - -CFLAGS += -I$(top_srcdir)/include/coap -DCOAP_RESOURCES_NOHASH - -vpath %.c $(top_srcdir)/src - -COAPOBJS = net.o debug.o option.o resource.o hashkey.o pdu.o encode.o subscribe.o coap_io.o block.o uri.o mem.o - -CFLAGS += -I$(CONTIKI)/core/ -I$(CONTIKI)/core/sys/ -I$(CONTIKI)/core/net/ip/ -I$(CONTIKI)/core/lib/ $(PLATFORM_CFLAGS) -CPPFLAGS += $(PLATFORM_CPPFLAGS) - -# making an executable out of all of it - -OBJS = server.o ${CONTIKIOBJS} ${COAPOBJS} - -server: ${OBJS} - -symbols.h: $(CONTIKI)/tools/empty-symbols.h - cp -p $< $@ - -symbols.c: $(CONTIKI)/tools/empty-symbols.c - cp -p $< $@ - -symbols.o: symbols.c symbols.h - -clean: - rm -f core server ${OBJS} symbols.c symbols.h - -distclean: clean - rm -rf *~ *.o contiki - -.PHONY: clean distclean contiki diff --git a/examples/contiki/Makefile.contiki b/examples/contiki/Makefile.contiki index 67e02bdd..5189a729 100644 --- a/examples/contiki/Makefile.contiki +++ b/examples/contiki/Makefile.contiki @@ -1,15 +1,13 @@ -NODE_ADDR?=0x1000 - ######################################################################## # platform-specific options ifeq ($(TARGET), econotag) CONTIKI_WITH_RPL=0 -CFLAGS += -DUIP_CONF_TCP=0 +CFLAGS += -DUIP_CONF_TCP=0 -DCOAP_MAX_BLOCK_SZX=1 endif ifeq ($(TARGET), mbxxx) -CFLAGS += -DUIP_CONF_TCP=0 -DHAVE_ASSERT_H -DHAVE_LIMITS_H +CFLAGS += -DUIP_CONF_TCP=0 -DCOAP_MAX_BLOCK_SZX=1 -DHAVE_ASSERT_H -DHAVE_LIMITS_H STM32W_CPUREV=CC #STM32W_CPUREV=xB endif @@ -17,32 +15,14 @@ endif # usually, you should not need changing anything beyond this line ######################################################################## +CONTIKI?=../../../.. + +ifneq ($(NODE_ADDR),) + CFLAGS += -DNODE_ADDR=$(NODE_ADDR) +endif + all: server -CONTIKI=../../../.. -#CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\" - -CFLAGS += -DNODE_ADDR=$(NODE_ADDR) -DCOAP_MAX_BLOCK_SZX=1 - -#ifeq ($(UIP_CONF_IPV6_RPL),0) -#CFLAGS += -DUIP_CONF_IPV6_RPL=0 -DRPL_BORDER_ROUTER=0 -DUIP_CONF_ROUTER=0 -#endif - -#WITH_UIP6=1 -#UIP_CONF_IPV6=1 - -# ifeq ($(TARGET), minimal-net) -# CFLAGS += -DHAVE_ASSERT_H -DWITH_UIP6=1 -# ifneq ($(ROLE),client) -# UIP_LLADDR="{0x00,0x06,0x98,0x00,0x02,0x32}" -# CFLAGS+= -DUIP_CONF_LLADDR=$(UIP_LLADDR) -# else -# UIP_LLADDR="{0x00,0x06,0x98,0x00,0x02,0x30}" -# CFLAGS+= -DUDP_CONNECTION_ADDR="fe80::206:98ff:fe00:232" \ -# -DUIP_CONF_LLADDR=$(UIP_LLADDR) -# endif -# endif - CFLAGS += -ffunction-sections LDFLAGS += -Wl,--gc-sections,--undefined=_reset_vector__,--undefined=InterruptVectors,--undefined=_copy_data_init__,--undefined=_clear_bss_init__,--undefined=_end_of_init__