introduced optional Makefile.customrules-$(TARGET), to contain custom platform make rules

This commit is contained in:
Fredrik Osterlind 2013-12-09 14:56:45 +01:00 committed by Adam Dunkels
parent 112e0d6855
commit cf32063c0b
3 changed files with 53 additions and 42 deletions

View File

@ -220,6 +220,8 @@ clean:
distclean: clean distclean: clean
-rm -rf $(CONTIKI_PROJECT).$(TARGET) -rm -rf $(CONTIKI_PROJECT).$(TARGET)
-include $(CONTIKI)/platform/$(TARGET)/Makefile.customrules-$(TARGET)
ifndef CUSTOM_RULE_C_TO_CE ifndef CUSTOM_RULE_C_TO_CE
%.ce: %.c %.ce: %.c
$(TRACE_CC) $(TRACE_CC)

View File

@ -60,7 +60,7 @@ COOJA_NET = uip-driver.c
# (COOJA_SOURCEFILES contains additional sources set from simulator) # (COOJA_SOURCEFILES contains additional sources set from simulator)
CONTIKI_TARGET_SOURCEFILES = \ CONTIKI_TARGET_SOURCEFILES = \
$(COOJA_BASE) $(COOJA_INTFS) $(COOJA_CORE) $(COOJA_NET) $(COOJA_SOURCEFILES) $(COOJA_BASE) $(COOJA_INTFS) $(COOJA_CORE) $(COOJA_NET) $(COOJA_SOURCEFILES)
CONTIKI_SOURCEFILES += $(CONTIKI_TARGET_SOURCEFILES) CONTIKI_SOURCEFILES += $(CONTIKI_TARGET_SOURCEFILES)
.SUFFIXES: .SUFFIXES:
@ -88,44 +88,4 @@ ifeq ($(UIP_CONF_IPV6),1)
endif # UIP_CONF_RPL endif # UIP_CONF_RPL
endif # UIP_CONF_IPV6 endif # UIP_CONF_IPV6
REDEF_PRINTF=1 # Redefine functions to enable printf()s inside Cooja MODULES += core/net/ipv6 core/net/mac core/net/rime core/net/mac/contikimac
### Define custom targets
# NB: Assumes ARCHIVE was not overridden and is in $(OBJECTDIR)
$(ARCHIVE): ${addprefix $(OBJECTDIR)/, $(CONTIKI_SOURCEFILES:.c=.o)} | $(OBJECTDIR)
$(AR_COMMAND_1) $^ $(AR_COMMAND_2)
# NB: Assumes JNILIB was not overridden and is in $(OBJECTDIR)
$(JNILIB): $(CONTIKI_APP_OBJ) $(MAIN_OBJ) $(PROJECT_OBJECTFILES) $(ARCHIVE) | $(OBJECTDIR)
ifdef SYMBOLS
@echo Generating symbols
# Recreate symbols file and relink with final memory layout (twice)
${CONTIKI}/tools/make-symbols-nm $(JNILIB)
$(CC) $(CFLAGS) -c symbols.c -o $(OBJECTDIR)/symbols.o
$(LINK_COMMAND_1) $^ $(LINK_COMMAND_2)
${CONTIKI}/tools/make-symbols-nm $(JNILIB)
$(CC) $(CFLAGS) -c symbols.c -o $(OBJECTDIR)/symbols.o
endif ## SYMBOLS
ifdef REDEF_PRINTF
@echo Redefining printf
-$(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); )
endif ## REDEF_PRINTF
$(LINK_COMMAND_1) $^ $(LINK_COMMAND_2)
.PHONY: $(CONTIKI_APP).cooja
$(CONTIKI_APP).cooja: $(JNILIB)
cp $(JNILIB) $@
rm $(CONTIKI_APP_OBJ)
# 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)
mv contiki-cooja-main.o $@
symbols.c:
# Create initial symbol files if not existing
cp ${CONTIKI}/tools/empty-symbols.c symbols.c
cp ${CONTIKI}/tools/empty-symbols.h symbols.h

View File

@ -0,0 +1,49 @@
### Define custom targets
CUSTOM_RULE_C_TO_CE=1
#CUSTOM_RULE_C_TO_OBJECTDIR_O=1
CUSTOM_RULE_S_TO_OBJECTDIR_O=1
#CUSTOM_RULE_C_TO_O=1
#CUSTOM_RULE_C_TO_CO=1
CUSTOM_RULE_ALLOBJS_TO_TARGETLIB=1
CUSTOM_RULE_LINK=1
REDEF_PRINTF=1 # Redefine functions to enable printf()s inside Cooja
# NB: Assumes ARCHIVE was not overridden and is in $(OBJECTDIR)
$(ARCHIVE): $(CONTIKI_OBJECTFILES) | $(OBJECTDIR)
$(AR_COMMAND_1) $^ $(AR_COMMAND_2)
# NB: Assumes JNILIB was not overridden and is in $(OBJECTDIR)
$(JNILIB): $(CONTIKI_APP_OBJ) $(MAIN_OBJ) $(PROJECT_OBJECTFILES) $(ARCHIVE) | $(OBJECTDIR)
ifdef SYMBOLS
@echo Generating symbols
# Recreate symbols file and relink with final memory layout (twice)
${CONTIKI}/tools/make-symbols-nm $(JNILIB)
$(CC) $(CFLAGS) -c symbols.c -o $(OBJECTDIR)/symbols.o
$(LINK_COMMAND_1) $^ $(LINK_COMMAND_2)
${CONTIKI}/tools/make-symbols-nm $(JNILIB)
$(CC) $(CFLAGS) -c symbols.c -o $(OBJECTDIR)/symbols.o
endif ## SYMBOLS
ifdef REDEF_PRINTF
@echo Redefining printf
-$(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); )
endif ## REDEF_PRINTF
$(LINK_COMMAND_1) $^ $(LINK_COMMAND_2)
.PHONY: $(CONTIKI_APP).cooja
$(CONTIKI_APP).cooja: $(JNILIB)
cp $(JNILIB) $@
rm $(CONTIKI_APP_OBJ)
# 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)
mv contiki-cooja-main.o $@
symbols.c:
# Create initial symbol files if not existing
cp ${CONTIKI}/tools/empty-symbols.c symbols.c
cp ${CONTIKI}/tools/empty-symbols.h symbols.h