2010-11-10 14:11:43 +01:00
|
|
|
# $Id: Makefile.cooja,v 1.42 2010/11/10 13:11:43 fros4943 Exp $
|
2006-08-21 14:11:16 +02:00
|
|
|
|
2006-09-06 14:20:12 +02:00
|
|
|
## The COOJA Simulator Contiki platform Makefile
|
|
|
|
##
|
|
|
|
## This makefile should normally never be called directly, but
|
|
|
|
## rather from inside the COOJA simulator.
|
|
|
|
## The purpose of this file is to compile a shared library that
|
|
|
|
## can be loaded into the Java part of COOJA.
|
2006-08-21 14:11:16 +02:00
|
|
|
|
2009-03-10 22:23:38 +01:00
|
|
|
ifndef CONTIKI
|
|
|
|
$(error CONTIKI not defined!)
|
|
|
|
endif
|
|
|
|
|
|
|
|
### Assuming simulator quickstart if no JNI library name set from Cooja
|
|
|
|
ifndef LIBNAME
|
2007-04-02 12:28:52 +02:00
|
|
|
QUICKSTART=1
|
|
|
|
endif
|
|
|
|
|
2007-03-25 20:22:41 +02:00
|
|
|
### Quickstart simulator
|
2007-04-02 12:28:52 +02:00
|
|
|
ifdef QUICKSTART
|
|
|
|
|
|
|
|
# Create COOJA JAR rule
|
2007-04-02 11:07:30 +02:00
|
|
|
$(CONTIKI)/tools/cooja/dist/cooja.jar:
|
2007-04-02 12:28:52 +02:00
|
|
|
@echo "Creating COOJA Java archive..."
|
2007-04-02 11:07:30 +02:00
|
|
|
(cd $(CONTIKI)/tools/cooja && ant jar)
|
2007-04-02 12:28:52 +02:00
|
|
|
|
|
|
|
# Quickstart rule
|
2011-10-24 17:04:45 +02:00
|
|
|
ifneq ($(MAKECMDGOALS),clean)
|
2009-03-12 18:48:23 +01:00
|
|
|
.PHONY: $(MAKECMDGOALS)
|
2009-03-12 16:12:50 +01:00
|
|
|
.PRECIOUS: $(MAKECMDGOALS)
|
2007-04-02 12:28:52 +02:00
|
|
|
$(MAKECMDGOALS): $(CONTIKI)/tools/cooja/dist/cooja.jar
|
2009-10-28 14:39:15 +01:00
|
|
|
java -mx512m -jar $< -quickstart='$(firstword $(MAKECMDGOALS))' -contiki='$(CONTIKI)'
|
2011-10-24 17:04:45 +02:00
|
|
|
endif
|
2007-04-02 12:28:52 +02:00
|
|
|
|
|
|
|
endif ## QUICKSTART
|
2006-08-21 14:11:16 +02:00
|
|
|
|
2010-06-11 17:17:26 +02:00
|
|
|
#MAIN_SRC = $(OBJECTDIR)/$(LIBNAME).c
|
|
|
|
MAIN_OBJ = $(OBJECTDIR)/$(LIBNAME).o
|
|
|
|
ARCHIVE = $(OBJECTDIR)/$(LIBNAME).a
|
|
|
|
JNILIB = $(OBJECTDIR)/$(LIBNAME).cooja
|
2009-03-11 09:40:37 +01:00
|
|
|
CONTIKI_APP_OBJ = $(CONTIKI_APP).co
|
2006-08-21 14:11:16 +02:00
|
|
|
|
2009-03-10 22:23:38 +01:00
|
|
|
### COOJA platform sources
|
2006-08-21 14:11:16 +02:00
|
|
|
COOJA = $(CONTIKI)/platform/$(TARGET)
|
2007-05-18 15:51:04 +02:00
|
|
|
CONTIKI_TARGET_DIRS = . dev lib sys cfs net
|
2006-08-21 14:11:16 +02:00
|
|
|
|
2010-11-10 14:11:43 +01:00
|
|
|
# (COOJA_SOURCEDIRS contains additional sources dirs set from simulator)
|
|
|
|
vpath %.c $(COOJA_SOURCEDIRS)
|
|
|
|
|
2013-08-15 11:56:12 +02:00
|
|
|
COOJA_BASE = simEnvChange.c cooja_mt.c cooja_mtarch.c rtimer-arch.c slip.c watchdog.c rimestats.c
|
2006-08-21 14:11:16 +02:00
|
|
|
|
2006-09-29 16:32:15 +02:00
|
|
|
COOJA_INTFS = beep.c button-sensor.c ip.c leds-arch.c moteid.c \
|
2007-05-18 15:51:04 +02:00
|
|
|
pir-sensor.c rs232.c vib-sensor.c \
|
2010-03-09 09:12:15 +01:00
|
|
|
clock.c log.c cfs-cooja.c cooja-radio.c
|
2006-08-21 14:11:16 +02:00
|
|
|
|
2009-03-17 16:56:32 +01:00
|
|
|
COOJA_CORE = random.c sensors.c leds.c symbols.c
|
2006-09-06 14:20:12 +02:00
|
|
|
|
2010-03-10 13:15:52 +01:00
|
|
|
COOJA_NET = uip-driver.c
|
|
|
|
|
2009-03-10 22:23:38 +01:00
|
|
|
# (COOJA_SOURCEFILES contains additional sources set from simulator)
|
2006-08-21 14:11:16 +02:00
|
|
|
CONTIKI_TARGET_SOURCEFILES = \
|
2010-03-10 13:15:52 +01:00
|
|
|
$(COOJA_BASE) $(COOJA_INTFS) $(COOJA_CORE) $(COOJA_NET) $(COOJA_SOURCEFILES)
|
2009-03-26 17:22:36 +01:00
|
|
|
|
2006-08-21 14:11:16 +02:00
|
|
|
CONTIKI_SOURCEFILES += $(CONTIKI_TARGET_SOURCEFILES)
|
|
|
|
|
|
|
|
.SUFFIXES:
|
|
|
|
|
|
|
|
### Define the CPU directory
|
|
|
|
CONTIKI_CPU=$(CONTIKI)/cpu/x86
|
|
|
|
|
2006-09-06 14:20:12 +02:00
|
|
|
### Compiler arguments
|
2010-06-11 17:17:26 +02:00
|
|
|
#CC = gcc
|
2010-03-15 12:03:17 +01:00
|
|
|
CFLAGSNO = $(EXTRA_CC_ARGS) -Wall -g -I/usr/local/include -DCLASSNAME=$(CLASSNAME)
|
2012-12-09 21:24:03 +01:00
|
|
|
CFLAGS += $(CFLAGSNO)
|
2006-08-21 14:11:16 +02:00
|
|
|
|
2012-05-17 17:27:50 +02:00
|
|
|
ifeq ($(UIP_CONF_IPV6),1)
|
2010-03-10 13:15:52 +01:00
|
|
|
CFLAGS += -DWITH_UIP6=1
|
|
|
|
endif
|
|
|
|
ifdef WITH_UIP
|
|
|
|
CFLAGS += -DWITH_UIP=1
|
|
|
|
endif
|
|
|
|
|
2012-01-31 14:53:52 +01:00
|
|
|
## Copied from Makefile.include, since Cooja overrides CFLAGS et al
|
2012-05-17 17:27:50 +02:00
|
|
|
ifeq ($(UIP_CONF_IPV6),1)
|
2012-01-31 14:53:52 +01:00
|
|
|
CFLAGS += -DUIP_CONF_IPV6=1
|
|
|
|
ifneq ($(UIP_CONF_RPL),0)
|
|
|
|
CFLAGS += -DUIP_CONF_IPV6_RPL=1
|
|
|
|
endif # UIP_CONF_RPL
|
|
|
|
endif # UIP_CONF_IPV6
|
|
|
|
|
2009-03-10 22:23:38 +01:00
|
|
|
REDEF_PRINTF=1 # Redefine functions to enable printf()s inside Cooja
|
|
|
|
|
2006-09-06 14:20:12 +02:00
|
|
|
### Define custom targets
|
2013-06-21 00:45:41 +02:00
|
|
|
|
|
|
|
# NB: Assumes ARCHIVE was not overridden and is in $(OBJECTDIR)
|
|
|
|
$(ARCHIVE): ${addprefix $(OBJECTDIR)/, $(CONTIKI_SOURCEFILES:.c=.o)} | $(OBJECTDIR)
|
2009-03-10 22:23:38 +01:00
|
|
|
$(AR_COMMAND_1) $^ $(AR_COMMAND_2)
|
|
|
|
|
2013-06-21 00:45:41 +02:00
|
|
|
# NB: Assumes JNILIB was not overridden and is in $(OBJECTDIR)
|
|
|
|
$(JNILIB): $(CONTIKI_APP_OBJ) $(MAIN_OBJ) $(PROJECT_OBJECTFILES) $(ARCHIVE) | $(OBJECTDIR)
|
2006-11-06 19:03:34 +01:00
|
|
|
ifdef SYMBOLS
|
2008-10-05 17:43:09 +02:00
|
|
|
@echo Generating symbols
|
2007-01-09 10:13:36 +01:00
|
|
|
# Recreate symbols file and relink with final memory layout (twice)
|
2009-03-10 22:23:38 +01:00
|
|
|
${CONTIKI}/tools/make-symbols-nm $(JNILIB)
|
2010-06-11 17:17:26 +02:00
|
|
|
$(CC) $(CFLAGS) -c symbols.c -o $(OBJECTDIR)/symbols.o
|
2007-09-05 16:00:59 +02:00
|
|
|
$(LINK_COMMAND_1) $^ $(LINK_COMMAND_2)
|
2009-03-10 22:23:38 +01:00
|
|
|
${CONTIKI}/tools/make-symbols-nm $(JNILIB)
|
2010-06-11 17:17:26 +02:00
|
|
|
$(CC) $(CFLAGS) -c symbols.c -o $(OBJECTDIR)/symbols.o
|
2008-10-05 17:43:09 +02:00
|
|
|
endif ## SYMBOLS
|
|
|
|
ifdef REDEF_PRINTF
|
|
|
|
@echo Redefining printf
|
2012-03-09 14:57:21 +01:00
|
|
|
-$(foreach OBJ,$^, $(OBJCOPY) --redefine-sym printf=log_printf $(OBJ); )
|
|
|
|
-$(foreach OBJ,$^, $(OBJCOPY) --redefine-sym puts=log_puts $(OBJ); )
|
|
|
|
-$(foreach OBJ,$^, $(OBJCOPY) --redefine-sym putchar=log_putchar $(OBJ); )
|
2008-10-05 17:43:09 +02:00
|
|
|
endif ## REDEF_PRINTF
|
2007-09-05 16:00:59 +02:00
|
|
|
$(LINK_COMMAND_1) $^ $(LINK_COMMAND_2)
|
2006-08-21 14:11:16 +02:00
|
|
|
|
2009-03-12 14:04:10 +01:00
|
|
|
.PHONY: $(CONTIKI_APP).cooja
|
2009-03-10 22:23:38 +01:00
|
|
|
$(CONTIKI_APP).cooja: $(JNILIB)
|
|
|
|
cp $(JNILIB) $@
|
2009-03-11 09:40:37 +01:00
|
|
|
rm $(CONTIKI_APP_OBJ)
|
2007-01-09 10:13:36 +01:00
|
|
|
|
2013-06-21 00:45:41 +02:00
|
|
|
# Trickiness: GNU make matches this against the file base name.
|
|
|
|
# Assume that the directory part is the standard location.
|
|
|
|
mtype%.o: contiki-cooja-main.o | $(OBJECTDIR)
|
2010-03-15 12:03:17 +01:00
|
|
|
mv contiki-cooja-main.o $@
|
|
|
|
|
2007-01-09 10:13:36 +01:00
|
|
|
symbols.c:
|
|
|
|
# Create initial symbol files if not existing
|
2011-04-03 13:24:58 +02:00
|
|
|
cp ${CONTIKI}/tools/empty-symbols.c symbols.c
|
|
|
|
cp ${CONTIKI}/tools/empty-symbols.h symbols.h
|