1top_srcdir = ../.. 2include_dir = $(top_srcdir)/include 3 4LIBCOAP_API_VERSION = $(shell sed -ne 's/^LIBCOAP_API_VERSION=\([0-9]\+\).*$$/\1/p' $(top_srcdir)/configure.ac) 5 6coap_include_dir = $(include_dir)/coap$(LIBCOAP_API_VERSION) 7 8WITH_LWIP_BRANCH=STABLE-2_0_3_RELEASE 9WITH_LWIP_CONTRIB_BRANCH=STABLE-2_0_1_RELEASE 10 11# Need to determine which library clock_gettime() resides in (as found by ./autogen.sh) 12LDLIBS := $(shell if [ ../../config.log ] ; then grep ac_cv_search_clock_gettime=- ../../config.log|cut -d= -f2 ; fi) 13 14all: server 15 16lwip: 17 git clone --depth 1 git://git.savannah.nongnu.org/lwip.git -b $(WITH_LWIP_BRANCH) 18 (cd lwip ; git checkout $(WITH_LWIP_BRANCH)) 19 $(MAKE) 20 21lwip-contrib: 22 git clone --depth 1 git://git.savannah.nongnu.org/lwip/lwip-contrib.git -b $(WITH_LWIP_CONTRIB_BRANCH) 23 (cd lwip-contrib ; git checkout $(WITH_LWIP_CONTRIB_BRANCH)) 24 $(MAKE) 25 26# lwip and coap opts (include early to shadow the lwip-contrib/ports/unix/proj/minimal/ file and any ../../config.h) 27CFLAGS += -DWITH_LWIP -iquote. 28 29# lwip library 30 31LWIPOBJS = def.o init.o tapif.o etharp.o netif.o timeouts.o stats.o mem.o memp.o udp.o tcp.o pbuf.o ip4_addr.o ip4.o inet_chksum.o tcp_in.o tcp_out.o icmp.o raw.o ip4_frag.o sys_arch.o ethernet.o ip.o 32vpath %.c lwip/src/core/ lwip-contrib/ports/unix/proj/minimal/ lwip/src/netif/ lwip/src/core/ipv4/ lwip-contrib/ports/unix/port/ lwip-contrib/ports/unix/port/netif/ 33# CFLAGS += -DLWIP_UNIX_LINUX 34 35# if ipv6 is used 36vpath %.c lwip/src/core/ipv6/ 37LWIPOBJS += mld6.o ip6.o icmp6.o ethip6.o nd6.o ip6_addr.o ip6_frag.o 38 39# coap library 40 41CFLAGS += -std=gnu99 42 43# set path to coap_include_dir for lwippools.h 44CFLAGS += -I$(top_srcdir)/include -I$(coap_include_dir) 45 46vpath %.c $(top_srcdir)/src 47 48COAPOBJS = net.o coap_cache.o coap_debug.o option.o resource.o pdu.o encode.o subscribe.o coap_io_lwip.o block.o uri.o str.o coap_session.o coap_notls.o coap_hashkey.o address.o coap_tcp.o async.o 49 50CFLAGS += -g3 -Wall -Wextra -pedantic -O0 51# not sorted out yet 52CFLAGS += -Wno-unused-parameter 53 54CFLAGS += -Ilwip/src/include/ -Ilwip/src/include/ipv4/ -Ilwip-contrib/ports/unix/port/include/ -Ilwip-contrib/ports/unix/proj/minimal/ 55 56OBJS = server.o server-coap.o ${LWIPOBJS} ${COAPOBJS} 57 58$(coap_include_dir)/coap.h: 59 @echo "Error: $@ not present. Run the autotools chain (\`./autogen.sh && ./configure\`) in the project root directory to build the required coap.h file." 60 @exit 1 61 62${OBJS}: lwip lwip-contrib $(coap_include_dir)/coap.h 63 64server: ${OBJS} 65 66clean: 67 rm -f ${OBJS} 68 69.PHONY: clean 70