ifndef CONTIKI
  $(error CONTIKI not defined! You must specify where CONTIKI resides!)
endif

ifeq ($(HOST_OS),Darwin)
  AROPTS = rc
endif

CONTIKI_TARGET_DIRS = . dev ctk
CONTIKI_TARGET_MAIN = ${addprefix $(OBJECTDIR)/,contiki-main.o}

CONTIKI_TARGET_SOURCEFILES = contiki-main.c clock.c leds.c leds-arch.c \
                button-sensor.c pir-sensor.c vib-sensor.c xmem.c \
                sensors.c irq.c cfs-posix.c cfs-posix-dir.c ctk-curses.c

ifeq ($(HOST_OS),Windows)
CONTIKI_TARGET_SOURCEFILES += wpcap-drv.c wpcap.c
TARGET_LIBFILES = /lib/w32api/libws2_32.a /lib/w32api/libiphlpapi.a
else
CONTIKI_TARGET_SOURCEFILES += tapdev-drv.c
#math
ifneq ($(CONTIKI_WITH_IPV6),1)
CONTIKI_TARGET_SOURCEFILES += tapdev.c
else
CONTIKI_TARGET_SOURCEFILES += tapdev6.c
endif
endif

CONTIKI_SOURCEFILES += $(CTK) ctk-conio.c $(CONTIKI_TARGET_SOURCEFILES)

.SUFFIXES:

### Define the CPU directory
CONTIKI_CPU=$(CONTIKI)/cpu/native
include $(CONTIKI)/cpu/native/Makefile.native

ifeq ($(HOST_OS),Windows)
CFLAGS += -I/usr/include/ncurses
endif

CURSES_LIBS ?= -lncurses

TARGET_LIBFILES += $(CURSES_LIBS)

MODULES+=core/net core/net/mac core/ctk core/net/llsec core/net/ip64-addr/