1c87c5fbaSopenharmony_ciCONTIKI=contiki-ng
2c87c5fbaSopenharmony_ciTARGET?=native
3c87c5fbaSopenharmony_ci
4c87c5fbaSopenharmony_ciWITH_CONTIKI_NG_BRANCH=release/v4.9
5c87c5fbaSopenharmony_ci
6c87c5fbaSopenharmony_ciall: $(CONTIKI) check-version server
7c87c5fbaSopenharmony_ci
8c87c5fbaSopenharmony_ci$(CONTIKI):
9c87c5fbaSopenharmony_ci	git clone --depth 1 https://github.com/contiki-ng/contiki-ng.git $@
10c87c5fbaSopenharmony_ci	echo "Updating $(CONTIKI) to ${WITH_CONTIKI_NG_BRANCH}"
11c87c5fbaSopenharmony_ci	(cd ${CONTIKI} ; git pull --tags 2> /dev/null ; git checkout ${WITH_CONTIKI_NG_BRANCH})
12c87c5fbaSopenharmony_ci	cd $(CONTIKI)/os/net/app-layer && rm -rf libcoap && ln -s ../../../../../.. libcoap
13c87c5fbaSopenharmony_ci
14c87c5fbaSopenharmony_cicheck-version:
15c87c5fbaSopenharmony_ci	@(if [ -d $(CONTIKI) ] ; then \
16c87c5fbaSopenharmony_ci		cd $(CONTIKI) ; \
17c87c5fbaSopenharmony_ci		TAG=`git describe --tags --all`; \
18c87c5fbaSopenharmony_ci		if [ "$$TAG" != ${WITH_CONTIKI_NG_BRANCH} ] ; then \
19c87c5fbaSopenharmony_ci			if [ "$$TAG" != "tags/${WITH_CONTIKI_NG_BRANCH}" ] ; then \
20c87c5fbaSopenharmony_ci				git pull --tags 2> /dev/null ; \
21c87c5fbaSopenharmony_ci				echo "Updating $(CONTIKI) to ${WITH_CONTIKI_NG_BRANCH}" ; \
22c87c5fbaSopenharmony_ci				git checkout ${WITH_CONTIKI_NG_BRANCH} ; \
23c87c5fbaSopenharmony_ci				cd os/net/app-layer && rm -rf libcoap && ln -s ../../../../../.. libcoap ; \
24c87c5fbaSopenharmony_ci			fi ; \
25c87c5fbaSopenharmony_ci		fi ; \
26c87c5fbaSopenharmony_ci	fi)
27c87c5fbaSopenharmony_ci
28c87c5fbaSopenharmony_ciserver:	$(CONTIKI)
29c87c5fbaSopenharmony_ci	$(MAKE) -f Makefile.contiki CONTIKI=$(CONTIKI) TARGET=$(TARGET) server
30c87c5fbaSopenharmony_ci
31c87c5fbaSopenharmony_ciclean:
32c87c5fbaSopenharmony_ci	$(MAKE) -f Makefile.contiki CONTIKI=$(CONTIKI) TARGET=$(TARGET) clean
33c87c5fbaSopenharmony_ci	rm -rf build
34