Makefile 15 KB
Newer Older
1 2
-include ../../config.mk
-include ../../tools/kconfig/.config
3

Marcin Hagmajer's avatar
Marcin Hagmajer committed
4
OS:=$(shell uname)
5 6 7 8 9 10
CC:=$(CROSS_COMPILE)gcc
LD:=$(CROSS_COMPILE)ld
AR:=$(CROSS_COMPILE)ar
RANLIB:=$(CROSS_COMPILE)ranlib
SIZE:=$(CROSS_COMPILE)size
STRIP_BIN:=$(CROSS_COMPILE)strip
Maxime Vincent's avatar
Maxime Vincent committed
11
TEST_LDFLAGS=-pthread  $(PREFIX)/modules/*.o $(PREFIX)/lib/*.o -lvdeplug
12
UNIT_LDFLAGS=-lcheck -lm -pthread -lrt
13
ifneq ("$(wildcard /etc/debian-release)","")
14 15
     UNIT_LDFLAGS+=-lsubunit
endif
16 17
UNIT_CFLAGS= $(CFLAGS) -Wno-missing-braces

18 19
LIBNAME:="libpicotcp.a"

Daniele Lacamera's avatar
Daniele Lacamera committed
20
PREFIX?=$(PWD)/build
21
DEBUG?=1
22 23
PROFILE?=0
PERF?=0
24 25 26
ENDIAN?=little
STRIP?=0
RTOS?=0
27 28
GENERIC?=0
PTHREAD?=0
29
ADDRESS_SANITIZER?=1
30
GCOV?=0
31 32

# Default compiled-in protocols
33
#
34 35 36 37
TCP?=1
UDP?=1
ETH?=1
IPV4?=1
38 39
IPV4FRAG?=1
IPV6FRAG?=0
40 41 42 43 44 45 46 47
NAT?=1
ICMP4?=1
MCAST?=1
DEVLOOP?=1
PING?=1
DHCP_CLIENT?=1
DHCP_SERVER?=1
DNS_CLIENT?=1
48
MDNS?=1
49
DNS_SD?=1
50
SNTP_CLIENT?=1
51
IPFILTER?=1
Bart Volkaerts's avatar
Bart Volkaerts committed
52
CRC?=1
53
OLSR?=0
54
SLAACV4?=1
55
TFTP?=1
56
AODV?=1
57 58
MEMORY_MANAGER?=0
MEMORY_MANAGER_PROFILING?=0
59
TUN?=0
Daniele Lacamera's avatar
Daniele Lacamera committed
60
TAP?=0
61
PCAP?=0
62
PPP?=1
63 64
6LOWPAN?=0
IEEE802154?=0
65
IPC?=0
66
CYASSL?=0
67
WOLFSSL?=0
68
POLARSSL?=0
69
TICKLESS?=0
70 71 72 73

#IPv6 related
IPV6?=1

74 75 76 77 78 79
TEST?=0
ifeq ($(TEST),1)
	6LOWPAN=1
	IEEE802154=1
endif

80 81 82 83 84 85 86
UNITS?=0
ifeq ($(UNITS),1)
	6LOWPAN=1
	IEEE802154=1
	ARCH=faulty
endif

87 88 89 90 91 92 93
UNITS_MM?=0
ifeq ($(UNITS_MM),1)
	6LOWPAN=1
	IEEE802154=1
	MEMORY_MANAGER=1
endif

94
EXTRA_CFLAGS+=-DPICO_COMPILE_TIME=`date +%s`
95
EXTRA_CFLAGS+=$(PLATFORM_CFLAGS)
96

Toon Stegen's avatar
Toon Stegen committed
97 98 99 100 101
CFLAGS=-I$(PREFIX)/include -Iinclude -Imodules  $(EXTRA_CFLAGS)
# options for adding warnings
CFLAGS+= -Wall -W -Wextra -Wshadow -Wcast-qual -Wwrite-strings -Wundef -Wdeclaration-after-statement
CFLAGS+= -Wconversion -Wcast-align -Wmissing-prototypes
# options for supressing warnings
102
CFLAGS+= -Wno-missing-field-initializers
Daniele Lacamera's avatar
Daniele Lacamera committed
103

104 105 106 107
ifeq ($(CC),clang)
CFLAGS+= -Wunreachable-code-break -Wpointer-bool-conversion -Wmissing-variable-declarations
endif

Marcin Hagmajer's avatar
Marcin Hagmajer committed
108 109 110 111 112 113 114 115 116 117 118 119
ifeq ($(OS),Darwin)
  LIBSIZE=stat -f%z
  ifeq ($(SIZE),size)
    SUMSIZE=$(SIZE)
  else
    SUMSIZE=$(SIZE) -t
  endif
else
  LIBSIZE=du -b
  SUMSIZE=$(SIZE) -t
endif

120 121
ifeq ($(DEBUG),1)
  CFLAGS+=-ggdb
122
else
Douwe De Bock's avatar
Douwe De Bock committed
123 124 125 126 127
  ifeq ($(PERF), 1)
    CFLAGS+=-O3
  else
    CFLAGS+=-Os
  endif
128 129
endif

130 131 132 133
ifeq ($(PROFILE),1)
  CFLAGS+=-pg
endif

134
ifeq ($(TFTP),1)
135
  MOD_OBJ+=$(LIBBASE)modules/pico_strings.o $(LIBBASE)modules/pico_tftp.o
136
  OPTIONS+=-DPICO_SUPPORT_TFTP
137 138
endif

139
ifeq ($(AODV),1)
140
  MOD_OBJ+=$(LIBBASE)modules/pico_aodv.o
141 142 143
  OPTIONS+=-DPICO_SUPPORT_AODV
endif

144 145 146
ifeq ($(GENERIC),1)
  CFLAGS+=-DGENERIC
endif
147

148 149
ifeq ($(PTHREAD),1)
  CFLAGS+=-DPICO_SUPPORT_PTHREAD
150 151
endif

152

153 154
ifneq ($(ENDIAN),little)
  CFLAGS+=-DPICO_BIGENDIAN
155 156
endif

157
ifneq ($(RTOS),0)
158
  OPTIONS+=-DPICO_SUPPORT_RTOS
159 160
endif

161 162 163 164 165 166
ifeq ($(ARCH),cortexm4-hardfloat)
  CFLAGS+=-DCORTEX_M4_HARDFLOAT -mcpu=cortex-m4 -mthumb -mlittle-endian -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb-interwork -fsingle-precision-constant
endif

ifeq ($(ARCH),cortexm4-softfloat)
  CFLAGS+=-DCORTEX_M4_SOFTFLOAT -mcpu=cortex-m4 -mthumb -mlittle-endian -mfloat-abi=soft -mthumb-interwork
167 168
endif

169
ifeq ($(ARCH),cortexm3)
170
  CFLAGS+=-DCORTEX_M3 -mcpu=cortex-m3 -mthumb -mlittle-endian -mthumb-interwork
171 172
endif

173 174 175 176
ifeq ($(ARCH),cortexm0plus)
  CFLAGS+=-DCORTEX_M0PLUS -mcpu=cortex-m0plus -mthumb -mlittle-endian -mthumb-interwork
endif

177 178
ifeq ($(ARCH),arm9)
  CFLAGS+=-DARM9 -mcpu=arm9e -march=armv5te -gdwarf-2 -Wall -marm -mthumb-interwork -fpack-struct
179 180
endif

181
ifeq ($(ADDRESS_SANITIZER),1)
Maxime Vincent's avatar
Maxime Vincent committed
182
  TEST_LDFLAGS+=-fsanitize=address -fno-omit-frame-pointer
183 184
endif

185 186 187 188 189
ifeq ($(GCOV),1)
  TEST_LDFLAGS+=-lgcov --coverage
  CFLAGS+=-fprofile-arcs -ftest-coverage
endif

190 191
ifeq ($(ARCH),faulty)
  CFLAGS+=-DFAULTY -DUNIT_TEST
192 193 194 195
  ifeq ($(ADDRESS_SANITIZER),1)
    CFLAGS+=-fsanitize=address
  endif
  CFLAGS+=-fno-omit-frame-pointer
196 197
  UNITS_OBJ+=test/pico_faulty.o
  TEST_OBJ+=test/pico_faulty.o
198
  DUMMY_EXTRA+=test/pico_faulty.o
199 200 201 202 203 204
endif

ifeq ($(ARCH),msp430)
  CFLAGS+=-DMSP430
endif

205
ifeq ($(ARCH),esp8266)
206
  CFLAGS+=-DESP8266 -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals
207 208
endif

209 210 211 212
ifeq ($(ARCH),mt7681)
  CFLAGS+=-DMT7681 -fno-builtin -ffunction-sections -fno-strict-aliasing -m16bit -mabi=2 -mbaseline=V2 -mcpu=n9 -mno-div -mel -mmw-count=8 -mno-ext-mac -mno-dx-regs
endif

213 214 215 216 217
ifeq ($(ARCH),pic24)
  CFLAGS+=-DPIC24 -c -mcpu=24FJ256GA106  -MMD -MF -g -omf=elf \
  -mlarge-code -mlarge-data -msmart-io=1 -msfr-warn=off
endif

218 219 220 221
ifeq ($(ARCH),pic32)
  CFLAGS+=-DPIC32
endif

222
ifeq ($(ARCH),atmega128)
Douwe De Bock's avatar
Douwe De Bock committed
223
  CFLAGS+=-Wall -mmcu=atmega128 -DAVR
224 225
endif

226 227 228 229
ifeq ($(ARCH),none)
  CFLAGS+=-DARCHNONE
endif

230 231 232 233
ifeq ($(ARCH),shared)
  CFLAGS+=-fPIC
endif

234
%.o:%.c deps
235
	$(CC) -c $(CFLAGS) -o $@ $<
236 237 238 239 240 241

CORE_OBJ= stack/pico_stack.o \
          stack/pico_frame.o \
          stack/pico_device.o \
          stack/pico_protocol.o \
          stack/pico_socket.o \
Douwe De Bock's avatar
Douwe De Bock committed
242
          stack/pico_socket_multicast.o \
243
          stack/pico_tree.o \
244 245
          stack/pico_md5.o \
		  stack/pico_jobs.o
246

Douwe De Bock's avatar
Douwe De Bock committed
247 248
POSIX_OBJ+= modules/pico_dev_vde.o \
            modules/pico_dev_tun.o \
249
            modules/pico_dev_ipc.o \
Douwe De Bock's avatar
Douwe De Bock committed
250
            modules/pico_dev_tap.o \
251
            modules/pico_dev_mock.o
252

253
include rules/debug.mk
254 255 256 257 258 259 260

ifneq ($(ETH),0)
  include rules/eth.mk
endif
ifneq ($(IPV4),0)
  include rules/ipv4.mk
endif
261 262
ifneq ($(IPV4FRAG),0)
  include rules/ipv4frag.mk
263 264 265 266 267 268 269 270 271 272 273 274 275
endif
ifneq ($(ICMP4),0)
  include rules/icmp4.mk
endif
ifneq ($(TCP),0)
  include rules/tcp.mk
endif
ifneq ($(UDP),0)
  include rules/udp.mk
endif
ifneq ($(MCAST),0)
  include rules/mcast.mk
  include rules/igmp.mk
roel0's avatar
roel0 committed
276
  include rules/mld.mk
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292
endif
ifneq ($(NAT),0)
  include rules/nat.mk
endif
ifneq ($(DEVLOOP),0)
  include rules/devloop.mk
endif
ifneq ($(DHCP_CLIENT),0)
  include rules/dhcp_client.mk
endif
ifneq ($(DHCP_SERVER),0)
  include rules/dhcp_server.mk
endif
ifneq ($(DNS_CLIENT),0)
  include rules/dns_client.mk
endif
293 294 295
ifneq ($(MDNS),0)
  include rules/mdns.mk
endif
296 297 298
ifneq ($(DNS_SD),0)
  include rules/dns_sd.mk
endif
299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319
ifneq ($(IPFILTER),0)
  include rules/ipfilter.mk
endif
ifneq ($(CRC),0)
  include rules/crc.mk
endif
ifneq ($(OLSR),0)
  include rules/olsr.mk
endif
ifneq ($(SLAACV4),0)
  include rules/slaacv4.mk
endif
ifneq ($(IPV6),0)
  include rules/ipv6.mk
endif
ifneq ($(MEMORY_MANAGER),0)
  include rules/memory_manager.mk
endif
ifneq ($(MEMORY_MANAGER_PROFILING),0)
  OPTIONS+=-DPICO_SUPPORT_MM_PROFILING
endif
320 321
ifneq ($(SNTP_CLIENT),0)
  include rules/sntp_client.mk
322
endif
323 324 325
ifneq ($(TUN),0)
  include rules/tun.mk
endif
Daniele Lacamera's avatar
Daniele Lacamera committed
326 327 328
ifneq ($(TAP),0)
  include rules/tap.mk
endif
329 330 331
ifneq ($(PCAP),0)
  include rules/pcap.mk
endif
Daniele Lacamera's avatar
Daniele Lacamera committed
332 333 334
ifneq ($(PPP),0)
  include rules/ppp.mk
endif
335 336
ifneq ($(6LOWPAN), 0)
  include rules/6lowpan.mk
337
endif
338 339 340
ifneq ($(IPC),0)
  include rules/ipc.mk
endif
341 342 343
ifneq ($(CYASSL),0)
  include rules/cyassl.mk
endif
344 345 346
ifneq ($(WOLFSSL),0)
  include rules/wolfssl.mk
endif
347 348 349
ifneq ($(POLARSSL),0)
  include rules/polarssl.mk
endif
350 351 352
ifneq ($(TICKLESS),0)
  include rules/tickless.mk
endif
353

354 355
all: mod core lib

356
core: $(CORE_OBJ)
357 358 359
	@mkdir -p $(PREFIX)/lib
	@mv stack/*.o $(PREFIX)/lib

360
mod: $(MOD_OBJ)
361 362 363 364 365 366 367 368 369 370
	@mkdir -p $(PREFIX)/modules
	@mv modules/*.o $(PREFIX)/modules || echo

posix: all $(POSIX_OBJ)
	@mv modules/*.o $(PREFIX)/modules || echo


TEST_ELF= test/picoapp.elf
TEST6_ELF= test/picoapp6.elf

Daniele Lacamera's avatar
Daniele Lacamera committed
371

372
test: posix
373
	@if [ $(TEST) -eq 0 ]; then \
374
	echo "\n\nsmoke tests should be compiled with TEST=1 from now on!"; \
375 376
	exit 1; \
	fi
377
	@mkdir -p $(PREFIX)/test/
Daniele Lacamera's avatar
Daniele Lacamera committed
378 379
	@make -C test/examples PREFIX=$(PREFIX)
	@echo -e "\t[CC] picoapp.o"
380
	@$(CC) -c -o $(PREFIX)/examples/picoapp.o test/picoapp.c $(CFLAGS) -Itest/examples
Daniele Lacamera's avatar
Daniele Lacamera committed
381
	@echo -e "\t[LD] $@"
382
	@$(CC) -g -o $(TEST_ELF) -I include -I modules -I $(PREFIX)/include -Wl,--start-group $(TEST_LDFLAGS) $(TEST_OBJ) $(PREFIX)/examples/*.o -Wl,--end-group
383 384
	@mv test/*.elf $(PREFIX)/test
	@install $(PREFIX)/$(TEST_ELF) $(PREFIX)/$(TEST6_ELF)
385

386 387
tst: test

388
$(PREFIX)/include/pico_defines.h:
389 390
	@mkdir -p $(PREFIX)/lib
	@mkdir -p $(PREFIX)/include
danielinux's avatar
danielinux committed
391
	bash ./mkdeps.sh $(PREFIX) $(OPTIONS)
392 393 394 395 396 397 398


deps: $(PREFIX)/include/pico_defines.h



lib: mod core
399 400 401 402 403
	@cp -f include/*.h $(PREFIX)/include
	@cp -fa include/arch $(PREFIX)/include
	@cp -f modules/*.h $(PREFIX)/include
	@echo -e "\t[AR] $(PREFIX)/lib/$(LIBNAME)"
	@$(AR) cru $(PREFIX)/lib/$(LIBNAME) $(PREFIX)/modules/*.o $(PREFIX)/lib/*.o \
404
	  || $(AR) cru $(PREFIX)/lib/$(LIBNAME) $(PREFIX)/lib/*.o
405 406 407 408
	@echo -e "\t[RANLIB] $(PREFIX)/lib/$(LIBNAME)"
	@$(RANLIB) $(PREFIX)/lib/$(LIBNAME)
	@test $(STRIP) -eq 1 && (echo -e "\t[STRIP] $(PREFIX)/lib/$(LIBNAME)" \
     && $(STRIP_BIN) $(PREFIX)/lib/$(LIBNAME)) \
409
     || echo -e "\t[KEEP SYMBOLS] $(PREFIX)/lib/$(LIBNAME)"
Marcin Hagmajer's avatar
Marcin Hagmajer committed
410 411
	@echo -e "\t[LIBSIZE] `$(LIBSIZE) $(PREFIX)/lib/$(LIBNAME)`"
	@echo -e "`$(SUMSIZE) $(PREFIX)/lib/$(LIBNAME)`"
412 413 414 415 416 417

loop: mod core
	mkdir -p $(PREFIX)/test
	@$(CC) -c -o $(PREFIX)/modules/pico_dev_loop.o modules/pico_dev_loop.c $(CFLAGS)
	@$(CC) -c -o $(PREFIX)/loop_ping.o test/loop_ping.c $(CFLAGS) -ggdb

418
units: mod core lib $(UNITS_OBJ) $(MOD_OBJ)
419
	@if [ $(UNITS) -eq 0 ]; then \
420
	echo "\n\nunit tests should be compiled with UNITS=1 from now on!"; \
421 422
	exit 1; \
	fi
423 424 425
	@echo -e "\n\t[UNIT TESTS SUITE]"
	@mkdir -p $(PREFIX)/test
	@echo -e "\t[CC] units.o"
426
	@$(CC) -g -c -o $(PREFIX)/test/units.o test/units.c $(UNIT_CFLAGS) -I stack -I modules -I includes -I test/unit -DUNIT_TEST
427
	@echo -e "\t[LD] $(PREFIX)/test/units"
428
	@$(CC) -o $(PREFIX)/test/units $(UNIT_CFLAGS) $(PREFIX)/test/units.o $(UNIT_LDFLAGS) \
429 430
	   $(UNITS_OBJ) $(PREFIX)/modules/pico_aodv.o \
	   $(PREFIX)/modules/pico_fragments.o
431 432 433 434 435 436 437 438 439 440
	@$(CC) -o $(PREFIX)/test/modunit_pico_protocol.elf $(UNIT_CFLAGS) -I. test/unit/modunit_pico_protocol.c stack/pico_tree.c $(UNIT_LDFLAGS) $(UNITS_OBJ)
	@$(CC) -o $(PREFIX)/test/modunit_pico_frame.elf $(UNIT_CFLAGS) -I. test/unit/modunit_pico_frame.c stack/pico_tree.c $(UNIT_LDFLAGS) $(UNITS_OBJ)
	@$(CC) -o $(PREFIX)/test/modunit_seq.elf $(UNIT_CFLAGS) -I. test/unit/modunit_seq.c $(UNIT_LDFLAGS) $(UNITS_OBJ) $(PREFIX)/lib/libpicotcp.a
	@$(CC) -o $(PREFIX)/test/modunit_tcp.elf $(UNIT_CFLAGS) -I. test/unit/modunit_pico_tcp.c $(UNIT_LDFLAGS) $(UNITS_OBJ) $(PREFIX)/lib/libpicotcp.a
	@$(CC) -o $(PREFIX)/test/modunit_dns_client.elf $(UNIT_CFLAGS) -I. test/unit/modunit_pico_dns_client.c $(UNIT_LDFLAGS) $(UNITS_OBJ) $(PREFIX)/lib/libpicotcp.a
	@$(CC) -o $(PREFIX)/test/modunit_dns_common.elf $(UNIT_CFLAGS) -I. test/unit/modunit_pico_dns_common.c $(UNIT_LDFLAGS) $(UNITS_OBJ) $(PREFIX)/lib/libpicotcp.a
	@$(CC) -o $(PREFIX)/test/modunit_mdns.elf $(UNIT_CFLAGS) -I. test/unit/modunit_pico_mdns.c $(UNIT_LDFLAGS) $(UNITS_OBJ) $(PREFIX)/lib/libpicotcp.a
	@$(CC) -o $(PREFIX)/test/modunit_dns_sd.elf $(UNIT_CFLAGS) -I. test/unit/modunit_pico_dns_sd.c $(UNIT_LDFLAGS) $(UNITS_OBJ) $(PREFIX)/lib/libpicotcp.a
	@$(CC) -o $(PREFIX)/test/modunit_dev_loop.elf $(UNIT_CFLAGS) -I. test/unit/modunit_pico_dev_loop.c $(UNIT_LDFLAGS) $(UNITS_OBJ)
	@$(CC) -o $(PREFIX)/test/modunit_ipv6_nd.elf $(UNIT_CFLAGS) -I. test/unit/modunit_pico_ipv6_nd.c $(UNIT_LDFLAGS) $(UNITS_OBJ) $(PREFIX)/lib/libpicotcp.a
Milan Platisa's avatar
Milan Platisa committed
441
	@$(CC) -o $(PREFIX)/test/modunit_ipv6_pmtu.elf $(UNIT_CFLAGS) -I. test/unit/modunit_pico_ipv6_pmtu.c $(UNIT_LDFLAGS) $(UNITS_OBJ) $(PREFIX)/lib/libpicotcp.a
442 443 444 445 446 447 448 449 450 451 452 453 454 455 456
	@$(CC) -o $(PREFIX)/test/modunit_ethernet.elf $(UNIT_CFLAGS) -I. test/unit/modunit_pico_ethernet.c $(UNIT_LDFLAGS) $(UNITS_OBJ) $(PREFIX)/lib/libpicotcp.a
	@$(CC) -o $(PREFIX)/test/modunit_pico_stack.elf $(UNIT_CFLAGS) -I. test/unit/modunit_pico_stack.c $(UNIT_LDFLAGS) $(UNITS_OBJ) $(PREFIX)/lib/libpicotcp.a
	@$(CC) -o $(PREFIX)/test/modunit_tftp.elf $(UNIT_CFLAGS) -I. test/unit/modunit_pico_tftp.c  $(UNIT_LDFLAGS) $(UNITS_OBJ) $(PREFIX)/lib/libpicotcp.a
	@$(CC) -o $(PREFIX)/test/modunit_sntp_client.elf $(UNIT_CFLAGS) -I. test/unit/modunit_pico_sntp_client.c $(UNIT_LDFLAGS) $(UNITS_OBJ)
	@$(CC) -o $(PREFIX)/test/modunit_ipfilter.elf $(UNIT_CFLAGS) -I. test/unit/modunit_pico_ipfilter.c stack/pico_tree.c $(UNIT_LDFLAGS) $(UNITS_OBJ)
	@$(CC) -o $(PREFIX)/test/modunit_aodv.elf $(UNIT_CFLAGS) -I. test/unit/modunit_pico_aodv.c  $(UNIT_LDFLAGS) $(UNITS_OBJ) $(PREFIX)/lib/libpicotcp.a
	@$(CC) -o $(PREFIX)/test/modunit_fragments.elf $(UNIT_CFLAGS) -I. test/unit/modunit_pico_fragments.c  $(UNIT_LDFLAGS) $(UNITS_OBJ) $(PREFIX)/lib/libpicotcp.a
	@$(CC) -o $(PREFIX)/test/modunit_queue.elf $(UNIT_CFLAGS) -I. test/unit/modunit_queue.c  $(UNIT_LDFLAGS) $(UNITS_OBJ)
	@$(CC) -o $(PREFIX)/test/modunit_dev_ppp.elf $(UNIT_CFLAGS) -I. test/unit/modunit_pico_dev_ppp.c  $(UNIT_LDFLAGS) $(UNITS_OBJ) $(PREFIX)/lib/libpicotcp.a
	@$(CC) -o $(PREFIX)/test/modunit_mld.elf $(UNIT_CFLAGS) -I. test/unit/modunit_pico_mld.c  $(UNIT_LDFLAGS) $(UNITS_OBJ) $(PREFIX)/lib/libpicotcp.a
	@$(CC) -o $(PREFIX)/test/modunit_igmp.elf $(UNIT_CFLAGS) -I. test/unit/modunit_pico_igmp.c  $(UNIT_LDFLAGS) $(UNITS_OBJ) $(PREFIX)/lib/libpicotcp.a
	@$(CC) -o $(PREFIX)/test/modunit_hotplug_detection.elf $(UNIT_CFLAGS) -I. test/unit/modunit_pico_hotplug_detection.c  $(UNIT_LDFLAGS) $(UNITS_OBJ) $(PREFIX)/lib/libpicotcp.a
	@$(CC) -o $(PREFIX)/test/modunit_802154.elf $(UNIT_CFLAGS) -I. test/unit/modunit_pico_802154.c  $(UNIT_LDFLAGS) $(UNITS_OBJ) $(PREFIX)/lib/libpicotcp.a
	@$(CC) -o $(PREFIX)/test/modunit_6lowpan.elf $(UNIT_CFLAGS) -I. -I test/examples test/unit/modunit_pico_6lowpan.c  $(UNIT_LDFLAGS) $(UNITS_OBJ) $(PREFIX)/lib/libpicotcp.a
	@$(CC) -o $(PREFIX)/test/modunit_strings.elf $(UNIT_CFLAGS) -I. test/unit/modunit_pico_strings.c $(UNIT_LDFLAGS) $(UNITS_OBJ) $(PREFIX)/lib/libpicotcp.a
457 458 459 460 461 462 463 464 465 466 467

devunits: mod core lib
	@echo -e "\n\t[UNIT TESTS SUITE: device drivers]"
	@mkdir -p $(PREFIX)/test/unit/device/
	@echo -e "\t[CC] picotcp_mock.o"
	@$(CC) -c -o $(PREFIX)/test/unit/device/picotcp_mock.o $(CFLAGS) -I stack -I modules -I includes -I test/unit test/unit/device/picotcp_mock.c
	@$(CC) -c -o $(PREFIX)/test/unit/device/unit_dev_vde.o $(CFLAGS) -I stack -I modules -I includes -I test/unit test/unit/device/unit_dev_vde.c
	@echo -e "\t[LD] $(PREFIX)/test/devunits"
	@$(CC) -o $(PREFIX)/test/devunits $(CFLAGS) -I stack $(PREFIX)/test/unit/device/*.o -lcheck -lm -pthread -lrt

units_mm: mod core lib
468
	@if [ $(UNITS_MM) -eq 0 ]; then \
469
	echo "\n\nMM unit tests should be compiled with UNITS_MM=1 from now on!"; \
470 471
	exit 1; \
	fi
472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489
	@echo -e "\n\t[UNIT TESTS SUITE]"
	@mkdir -p $(PREFIX)/test
	@echo -e "\t[CC] units_mm.o"
	@$(CC) -c -o $(PREFIX)/test/units_mm.o test/unit/unit_mem_manager.c $(CFLAGS) -I stack -I modules -I includes -I test/unit
	@echo -e "\t[LD] $(PREFIX)/test/units"
	@$(CC) -o $(PREFIX)/test/units_mm $(CFLAGS) $(PREFIX)/test/units_mm.o -lcheck -lm -pthread -lrt


clean:
	@echo -e "\t[CLEAN] $(PREFIX)/"
	@rm -rf $(PREFIX) tags

mbed:
	@echo -e "\t[Creating PicoTCP.zip]"
	@rm -f PicoTCP.zip
	@cp include/pico_socket.h include/socket.tmp
	@echo "#define MBED\n" > include/mbed.tmp
	@cat include/mbed.tmp include/socket.tmp > include/pico_socket.h
490
	@zip -0 PicoTCP.zip -r include modules stack -x include/arch/ include/arch/* include/pico_config.h include/*.tmp modules/pico_dev_*
491 492 493 494 495
	@rm include/pico_socket.h include/mbed.tmp
	@mv include/socket.tmp include/pico_socket.h


style:
496 497
	@find . -iname "*.[c|h]" | xargs -x uncrustify --replace -l C -c uncrustify.cfg || true
	@find . -iname "*unc-backup*" |xargs -x rm || true
498

499
dummy: mod core lib $(DUMMY_EXTRA)
500 501
	@echo testing configuration...
	@$(CC) -c -o test/dummy.o test/dummy.c $(CFLAGS)
502
	@$(CC) -o dummy test/dummy.o $(DUMMY_EXTRA) $(PREFIX)/lib/libpicotcp.a $(LDFLAGS) $(CFLAGS)
503
	@echo done.
504
	@rm -f test/dummy.o dummy
505

Daniele Lacamera's avatar
Daniele Lacamera committed
506
ppptest: test/ppp.c lib
507 508
	gcc -ggdb -c -o ppp.o test/ppp.c -I $(PREFIX)/include/ -I $(PREFIX)/modules/ $(CFLAGS)
	gcc -o ppp ppp.o $(PREFIX)/lib/libpicotcp.a $(LDFLAGS) $(CFLAGS)
Daniele Lacamera's avatar
Daniele Lacamera committed
509
	rm -f ppp.o
510 511 512


FORCE: