added rule for .cooja target.

compiling for cooja is now similar to other platforms, for example:
make hello-world.cooja TARGET=cooja
This commit is contained in:
fros4943 2009-03-10 21:23:38 +00:00
parent 42a7eb3c86
commit 0bc10750bc

View file

@ -1,4 +1,4 @@
# $Id: Makefile.cooja,v 1.23 2008/10/05 15:43:09 fros4943 Exp $ # $Id: Makefile.cooja,v 1.24 2009/03/10 21:23:38 fros4943 Exp $
## The COOJA Simulator Contiki platform Makefile ## The COOJA Simulator Contiki platform Makefile
## ##
@ -7,6 +7,10 @@
## The purpose of this file is to compile a shared library that ## The purpose of this file is to compile a shared library that
## can be loaded into the Java part of COOJA. ## can be loaded into the Java part of COOJA.
ifndef CONTIKI
$(error CONTIKI not defined!)
endif
ifndef WINDIR ifndef WINDIR
ifdef OS ifdef OS
ifneq (,$(findstring Windows,$(OS))) ifneq (,$(findstring Windows,$(OS)))
@ -15,14 +19,8 @@ ifndef WINDIR
endif endif
endif endif
### Check input COOJA parameters ### Assuming simulator quickstart if no JNI library name set from Cooja
ifndef LIBNAME
ifndef CONTIKI
$(error CONTIKI not defined!)
endif
### Assuming quickstart if no type ID set
ifndef TYPEID
QUICKSTART=1 QUICKSTART=1
endif endif
@ -46,13 +44,12 @@ $(MAKECMDGOALS): $(CONTIKI)/tools/cooja/dist/cooja.jar
endif ## QUICKSTART endif ## QUICKSTART
OUTPUT_DIR = obj_cooja #MAIN_SRC = obj_cooja/$(LIBNAME).c
LIBFILE = $(OUTPUT_DIR)/$(TYPEID).library MAIN_OBJ = obj_cooja/$(LIBNAME).o
ARFILE = $(OUTPUT_DIR)/$(TYPEID).a ARCHIVE = obj_cooja/$(LIBNAME).a
MAPFILE = $(OUTPUT_DIR)/$(TYPEID).map JNILIB = obj_cooja/$(LIBNAME).cooja
MAINFILE = $(OUTPUT_DIR)/$(TYPEID).co
### Define COOJA core interfaces ### COOJA platform sources
COOJA = $(CONTIKI)/platform/$(TARGET) COOJA = $(CONTIKI)/platform/$(TARGET)
CONTIKI_TARGET_DIRS = . dev lib sys cfs net CONTIKI_TARGET_DIRS = . dev lib sys cfs net
@ -62,10 +59,11 @@ COOJA_INTFS = beep.c button-sensor.c ip.c leds-arch.c moteid.c \
pir-sensor.c rs232.c vib-sensor.c \ pir-sensor.c rs232.c vib-sensor.c \
clock.c log.c radio-sensor.c cfs-cooja.c clock.c log.c radio-sensor.c cfs-cooja.c
CORE_FILES = random.c sensors.c leds.c serial.c symbols.c COOJA_CORE = random.c sensors.c leds.c serial.c symbols.c
# (COOJA_SOURCEFILES contains additional sources set from simulator)
CONTIKI_TARGET_SOURCEFILES = \ CONTIKI_TARGET_SOURCEFILES = \
$(COOJA_BASE) $(COOJA_INTFS) $(CORE_FILES) $(PROJECT_SOURCEFILES) $(COOJA_BASE) $(COOJA_INTFS) $(COOJA_CORE) $(COOJA_SOURCEFILES)
CONTIKI_SOURCEFILES += $(CONTIKI_TARGET_SOURCEFILES) CONTIKI_SOURCEFILES += $(CONTIKI_TARGET_SOURCEFILES)
@ -78,30 +76,33 @@ CONTIKI_CPU=$(CONTIKI)/cpu/x86
CFLAGSNO = $(EXTRA_CC_ARGS) -Wall -g -I/usr/local/include CFLAGSNO = $(EXTRA_CC_ARGS) -Wall -g -I/usr/local/include
CFLAGS = $(CFLAGSNO) CFLAGS = $(CFLAGSNO)
REDEF_PRINTF=1 # Redefine functions to enable printf()s inside Cooja
### Define custom targets ### Define custom targets
REDEF_PRINTF=1 $(ARCHIVE): ${addprefix obj_cooja/, $(CONTIKI_SOURCEFILES:.c=.o)}
$(LIBFILE): $(MAINFILE) $(PROJECT_OBJECTFILES) $(ARFILE) $(AR_COMMAND_1) $^ $(AR_COMMAND_2)
$(JNILIB): $(CONTIKI_APP).co $(MAIN_OBJ) $(PROJECT_OBJECTFILES) $(ARCHIVE)
ifdef SYMBOLS ifdef SYMBOLS
@echo Generating symbols @echo Generating symbols
# Recreate symbols file and relink with final memory layout (twice) # Recreate symbols file and relink with final memory layout (twice)
${CONTIKI}/tools/make-symbols-nm $(LIBFILE) ${CONTIKI}/tools/make-symbols-nm $(JNILIB)
$(CC) $(CFLAGS) -c symbols.c -o $(OBJECTDIR)/symbols.o $(CC) $(CFLAGS) -c symbols.c -o obj_cooja/symbols.o
$(LINK_COMMAND_1) $^ $(LINK_COMMAND_2) $(LINK_COMMAND_1) $^ $(LINK_COMMAND_2)
${CONTIKI}/tools/make-symbols-nm $(LIBFILE) ${CONTIKI}/tools/make-symbols-nm $(JNILIB)
$(CC) $(CFLAGS) -c symbols.c -o $(OBJECTDIR)/symbols.o $(CC) $(CFLAGS) -c symbols.c -o obj_cooja/symbols.o
endif ## SYMBOLS endif ## SYMBOLS
ifdef REDEF_PRINTF ifdef REDEF_PRINTF
@echo Redefining printf @echo Redefining printf
-$(foreach OBJ,$^, objcopy --redefine-sym printf=log_printf $(OBJ); ) -$(foreach OBJ,$^, objcopy --redefine-sym printf=log_printf $(OBJ); )
-$(foreach OBJ,$^, objcopy --redefine-sym puts=log_puts $(OBJ); ) -$(foreach OBJ,$^, objcopy --redefine-sym puts=log_puts $(OBJ); )
-$(foreach OBJ,$^, objcopy --redefine-sym putchar=log_putchar $(OBJ); ) -$(foreach OBJ,$^, objcopy --redefine-sym putchar=log_putchar $(OBJ); )
endif ## REDEF_PRINTF endif ## REDEF_PRINTF
$(LINK_COMMAND_1) $^ $(LINK_COMMAND_2) $(LINK_COMMAND_1) $^ $(LINK_COMMAND_2)
$(ARFILE): ${addprefix $(OBJECTDIR)/, $(CONTIKI_SOURCEFILES:.c=.o)} $(CONTIKI_APP).cooja: $(JNILIB)
$(AR_COMMAND_1) $^ $(AR_COMMAND_2) cp $(JNILIB) $@
rm $(CONTIKI_APP).co
symbols.c: symbols.c:
# Create initial symbol files if not existing # Create initial symbol files if not existing