2012-02-10 17:51:35 +01:00
|
|
|
# -*- makefile -*-
|
|
|
|
|
2006-06-18 00:41:10 +02:00
|
|
|
ifndef CONTIKI
|
2013-02-11 00:28:31 +01:00
|
|
|
${error CONTIKI not defined! You must specify where Contiki resides}
|
2006-06-18 00:41:10 +02:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(TARGET),)
|
|
|
|
-include Makefile.target
|
|
|
|
ifeq ($(TARGET),)
|
2008-10-14 22:31:46 +02:00
|
|
|
${info TARGET not defined, using target 'native'}
|
|
|
|
TARGET=native
|
2006-06-18 00:41:10 +02:00
|
|
|
else
|
2007-12-24 16:24:15 +01:00
|
|
|
${info using saved target '$(TARGET)'}
|
2006-06-18 00:41:10 +02:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2007-12-24 16:24:15 +01:00
|
|
|
ifeq ($(DEFINES),)
|
|
|
|
-include Makefile.$(TARGET).defines
|
2008-01-04 22:01:37 +01:00
|
|
|
ifneq ($(DEFINES),)
|
|
|
|
${info using saved defines '$(DEFINES)'}
|
|
|
|
endif
|
2007-12-24 16:24:15 +01:00
|
|
|
endif
|
|
|
|
|
2012-02-22 00:57:22 +01:00
|
|
|
ifndef HOST_OS
|
|
|
|
ifeq ($(OS),Windows_NT)
|
2012-02-24 11:21:48 +01:00
|
|
|
## TODO: detect more specific Windows set-ups,
|
|
|
|
## e.g. CygWin, MingW, VisualC, Watcom, Interix
|
2012-02-22 00:57:22 +01:00
|
|
|
HOST_OS := Windows
|
|
|
|
else
|
|
|
|
HOST_OS := $(shell uname)
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2006-06-18 00:41:10 +02:00
|
|
|
usage:
|
2006-08-31 11:36:29 +02:00
|
|
|
@echo "make MAKETARGETS... [TARGET=(TARGET)] [savetarget] [targets]"
|
|
|
|
|
|
|
|
targets:
|
2012-02-17 17:54:06 +01:00
|
|
|
@ls -1 $(CONTIKI)/platform $(TARGETDIRS) | grep -v CVS
|
2006-06-18 00:41:10 +02:00
|
|
|
|
|
|
|
savetarget:
|
|
|
|
-@rm -f Makefile.target
|
2007-12-24 16:24:15 +01:00
|
|
|
@echo "saving Makefile.target"
|
2006-06-18 00:41:10 +02:00
|
|
|
@echo >Makefile.target "TARGET = $(TARGET)"
|
|
|
|
|
2007-12-24 16:24:15 +01:00
|
|
|
savedefines:
|
|
|
|
-@rm -f Makefile.$(TARGET).defines
|
|
|
|
@echo "saving Makefile.$(TARGET).defines"
|
|
|
|
@echo >Makefile.$(TARGET).defines "DEFINES = $(DEFINES)"
|
|
|
|
|
2008-11-14 22:37:45 +01:00
|
|
|
OBJECTDIR = obj_$(TARGET)
|
2006-06-18 00:41:10 +02:00
|
|
|
|
2008-11-15 12:13:19 +01:00
|
|
|
LOWERCASE = -abcdefghijklmnopqrstuvwxyz
|
|
|
|
UPPERCASE = _ABCDEFGHIJKLMNOPQRSTUVWXYZ
|
2012-05-17 17:27:50 +02:00
|
|
|
TARGET_UPPERCASE := ${strip ${shell echo $(TARGET) | sed 'y!$(LOWERCASE)!$(UPPERCASE)!'}}
|
2010-10-25 00:31:17 +02:00
|
|
|
CFLAGS += -DCONTIKI=1 -DCONTIKI_TARGET_$(TARGET_UPPERCASE)=1
|
2008-11-14 22:37:45 +01:00
|
|
|
|
2007-03-15 22:45:15 +01:00
|
|
|
include $(CONTIKI)/core/net/rime/Makefile.rime
|
2007-05-15 09:47:34 +02:00
|
|
|
include $(CONTIKI)/core/net/mac/Makefile.mac
|
2009-03-17 16:56:32 +01:00
|
|
|
SYSTEM = process.c procinit.c autostart.c elfloader.c profile.c \
|
|
|
|
timetable.c timetable-aggregate.c compower.c serial-line.c
|
2006-09-02 00:57:32 +02:00
|
|
|
THREADS = mt.c
|
2010-06-14 09:34:36 +02:00
|
|
|
LIBS = memb.c mmem.c timer.c list.c etimer.c ctimer.c energest.c rtimer.c stimer.c \
|
2009-03-02 10:39:37 +01:00
|
|
|
print-stats.c ifft.c crc16.c random.c checkpoint.c ringbuf.c
|
2010-02-23 19:18:53 +01:00
|
|
|
DEV = nullradio.c
|
2010-06-14 21:19:16 +02:00
|
|
|
NET = netstack.c uip-debug.c packetbuf.c queuebuf.c packetqueue.c
|
2010-02-19 00:15:26 +01:00
|
|
|
|
2012-05-17 17:27:50 +02:00
|
|
|
ifeq ($(UIP_CONF_IPV6),1)
|
2010-04-30 15:43:53 +02:00
|
|
|
CFLAGS += -DUIP_CONF_IPV6=1
|
2008-11-14 23:06:53 +01:00
|
|
|
UIP = uip6.c tcpip.c psock.c uip-udp-packet.c uip-split.c \
|
2011-08-29 21:30:44 +02:00
|
|
|
resolv.c tcpdump.c uiplib.c simple-udp.c
|
2010-10-28 17:43:29 +02:00
|
|
|
NET += $(UIP) uip-icmp6.c uip-nd6.c uip-packetqueue.c \
|
2012-11-26 20:11:14 +01:00
|
|
|
sicslowpan.c neighbor-attr.c neighbor-info.c uip-ds6.c uip-ds6-route.c
|
2011-12-19 13:50:50 +01:00
|
|
|
ifneq ($(UIP_CONF_RPL),0)
|
|
|
|
CFLAGS += -DUIP_CONF_IPV6_RPL=1
|
|
|
|
include $(CONTIKI)/core/net/rpl/Makefile.rpl
|
|
|
|
endif # UIP_CONF_RPL
|
2008-10-14 22:31:46 +02:00
|
|
|
else # UIP_CONF_IPV6
|
2008-11-14 23:06:53 +01:00
|
|
|
UIP = uip.c uiplib.c resolv.c tcpip.c psock.c hc.c uip-split.c uip-fw.c \
|
2008-10-14 22:31:46 +02:00
|
|
|
uip-fw-drv.c uip_arp.c tcpdump.c uip-neighbor.c uip-udp-packet.c \
|
2012-01-25 15:34:47 +01:00
|
|
|
uip-over-mesh.c dhcpc.c simple-udp.c
|
2010-02-19 00:15:26 +01:00
|
|
|
NET += $(UIP) uaodv.c uaodv-rt.c
|
2008-10-14 22:31:46 +02:00
|
|
|
endif # UIP_CONF_IPV6
|
2008-10-15 11:13:05 +02:00
|
|
|
|
2007-11-22 12:19:27 +01:00
|
|
|
CTK = ctk.c
|
|
|
|
CTKVNC = $(CTK) ctk-vncserver.c libconio.c vnc-server.c vnc-out.c ctk-vncfont.c
|
2006-06-18 00:41:10 +02:00
|
|
|
|
2008-10-14 21:06:51 +02:00
|
|
|
ifndef CONTIKI_NO_NET
|
2010-02-23 19:18:53 +01:00
|
|
|
CONTIKIFILES = $(SYSTEM) $(LIBS) $(NET) $(THREADS) $(DHCP) $(DEV)
|
2008-10-14 21:06:51 +02:00
|
|
|
else
|
2010-02-23 19:18:53 +01:00
|
|
|
CONTIKIFILES = $(SYSTEM) $(LIBS) $(THREADS) $(DEV) sicslowpan.c fakeuip.c
|
2008-10-14 21:06:51 +02:00
|
|
|
endif
|
2006-06-18 00:41:10 +02:00
|
|
|
|
|
|
|
CONTIKI_SOURCEFILES += $(CONTIKIFILES)
|
|
|
|
|
2009-04-06 15:20:34 +02:00
|
|
|
CONTIKIDIRS += ${addprefix $(CONTIKI)/core/,dev lib net net/mac net/rime \
|
2010-04-30 15:43:53 +02:00
|
|
|
net/rpl sys cfs ctk lib/ctk loader . }
|
2006-06-18 00:41:10 +02:00
|
|
|
|
2007-04-21 17:13:14 +02:00
|
|
|
oname = ${patsubst %.c,%.o,${patsubst %.S,%.o,$(1)}}
|
2006-12-31 14:54:24 +01:00
|
|
|
|
2007-04-21 17:13:14 +02:00
|
|
|
CONTIKI_OBJECTFILES = ${addprefix $(OBJECTDIR)/,${call oname, $(CONTIKI_SOURCEFILES)}}
|
2007-04-21 16:56:52 +02:00
|
|
|
|
2007-04-21 17:13:14 +02:00
|
|
|
PROJECT_OBJECTFILES = ${addprefix $(OBJECTDIR)/,${call oname, $(PROJECT_SOURCEFILES)}}
|
2006-06-18 00:41:10 +02:00
|
|
|
|
2009-03-12 20:10:37 +01:00
|
|
|
### Include application makefiles
|
2009-07-03 00:36:04 +02:00
|
|
|
|
2009-03-12 20:10:37 +01:00
|
|
|
ifdef APPS
|
|
|
|
APPDIRS += ${wildcard ${addprefix $(CONTIKI)/apps/, $(APPS)} \
|
2013-02-11 00:28:31 +01:00
|
|
|
${addprefix $(CONTIKI)/platform/$(TARGET)/apps/, $(APPS)} \
|
|
|
|
$(APPS)}
|
2012-03-11 01:42:45 +01:00
|
|
|
APPINCLUDES = ${foreach APP, $(APPS), ${wildcard ${foreach DIR, $(APPDIRS), $(DIR)/Makefile.$(APP)}}}
|
2009-03-12 20:10:37 +01:00
|
|
|
-include $(APPINCLUDES)
|
|
|
|
APP_SOURCES = ${foreach APP, $(APPS), $($(APP)_src)}
|
|
|
|
DSC_SOURCES = ${foreach APP, $(APPS), $($(APP)_dsc)}
|
|
|
|
CONTIKI_SOURCEFILES += $(APP_SOURCES) $(DSC_SOURCES)
|
|
|
|
endif
|
|
|
|
|
2009-03-17 21:08:56 +01:00
|
|
|
### Include target makefile (TODO Unsafe?)
|
2009-07-03 00:36:04 +02:00
|
|
|
|
2012-02-17 17:51:56 +01:00
|
|
|
target_makefile := $(wildcard $(CONTIKI)/platform/$(TARGET)/Makefile.$(TARGET) ${foreach TDIR, $(TARGETDIRS), $(TDIR)/$(TARGET)/Makefile.$(TARGET)})
|
2009-03-17 21:08:56 +01:00
|
|
|
|
2011-03-10 20:59:21 +01:00
|
|
|
# Check if the target makefile exists, and create the object directory if necessary.
|
2009-03-17 21:08:56 +01:00
|
|
|
ifeq ($(strip $(target_makefile)),)
|
|
|
|
${error The target platform "$(TARGET)" does not exist (maybe it was misspelled?)}
|
|
|
|
else
|
2011-03-10 20:59:21 +01:00
|
|
|
ifeq (${wildcard $(OBJECTDIR)},)
|
|
|
|
DUMMY := ${shell mkdir $(OBJECTDIR)}
|
|
|
|
endif
|
2012-02-10 16:57:37 +01:00
|
|
|
ifneq (1, ${words $(target_makefile)})
|
|
|
|
${error More than one TARGET Makefile found: $(target_makefile)}
|
|
|
|
endif
|
|
|
|
include $(target_makefile)
|
2009-03-17 21:08:56 +01:00
|
|
|
endif
|
|
|
|
|
2007-12-21 11:16:45 +01:00
|
|
|
### Forward comma-separated list of arbitrary defines to the compiler
|
|
|
|
|
|
|
|
COMMA := ,
|
|
|
|
CFLAGS += ${addprefix -D,${subst $(COMMA), ,$(DEFINES)}}
|
|
|
|
|
2007-05-19 09:54:53 +02:00
|
|
|
### Setup directory search path for source and header files
|
2007-05-13 10:41:11 +02:00
|
|
|
|
2012-02-10 16:57:37 +01:00
|
|
|
CONTIKI_TARGET_DIRS_CONCAT = ${addprefix ${dir $(target_makefile)}, \
|
2007-05-13 10:41:11 +02:00
|
|
|
$(CONTIKI_TARGET_DIRS)}
|
|
|
|
CONTIKI_CPU_DIRS_CONCAT = ${addprefix $(CONTIKI_CPU)/, \
|
|
|
|
$(CONTIKI_CPU_DIRS)}
|
|
|
|
|
2009-02-11 10:03:52 +01:00
|
|
|
SOURCEDIRS = . $(PROJECTDIRS) $(CONTIKI_TARGET_DIRS_CONCAT) \
|
2012-02-10 16:57:37 +01:00
|
|
|
$(CONTIKI_CPU_DIRS_CONCAT) $(CONTIKIDIRS) $(APPDIRS) ${dir $(target_makefile)}
|
2007-05-13 10:41:11 +02:00
|
|
|
|
|
|
|
vpath %.c $(SOURCEDIRS)
|
|
|
|
vpath %.S $(SOURCEDIRS)
|
|
|
|
|
2007-05-19 09:54:53 +02:00
|
|
|
CFLAGS += ${addprefix -I,$(SOURCEDIRS)}
|
|
|
|
|
2011-07-16 14:53:44 +02:00
|
|
|
### Check for a git repo and pass version if found
|
|
|
|
### git.exe in Windows cmd shells may require no stderr redirection
|
|
|
|
#RELSTR=${shell git describe --tags}
|
|
|
|
RELSTR=${shell git describe --tags 2>/dev/null}
|
|
|
|
ifneq ($(RELSTR),)
|
|
|
|
CFLAGS += -DCONTIKI_VERSION_STRING=\"Contiki-$(RELSTR)\"
|
|
|
|
endif
|
|
|
|
|
2006-06-18 00:41:10 +02:00
|
|
|
### Automatic dependency generation
|
|
|
|
|
|
|
|
ifneq ($(MAKECMDGOALS),clean)
|
2007-04-14 20:37:06 +02:00
|
|
|
-include ${addprefix $(OBJECTDIR)/,$(CONTIKI_SOURCEFILES:.c=.d) \
|
2013-02-11 00:28:31 +01:00
|
|
|
$(PROJECT_SOURCEFILES:.c=.d)}
|
2006-06-18 00:41:10 +02:00
|
|
|
endif
|
|
|
|
|
2009-07-03 00:36:04 +02:00
|
|
|
### See http://make.paulandlesley.org/autodep.html#advanced
|
|
|
|
|
|
|
|
define FINALIZE_DEPENDENCY
|
|
|
|
cp $(@:.o=.d) $(@:.o=.$$$$); \
|
|
|
|
sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
|
|
|
|
-e '/^$$/ d' -e 's/$$/ :/' < $(@:.o=.$$$$) >> $(@:.o=.d); \
|
|
|
|
rm -f $(@:.o=.$$$$)
|
|
|
|
endef
|
|
|
|
|
2011-07-16 14:53:44 +02:00
|
|
|
clean:
|
2007-01-18 14:47:40 +01:00
|
|
|
rm -f *~ *core core *.srec \
|
2006-06-18 00:41:10 +02:00
|
|
|
*.lst *.map \
|
2013-02-11 00:28:31 +01:00
|
|
|
*.cprg *.bin *.data contiki*.a *.firmware core-labels.S *.ihex *.ini \
|
|
|
|
*.ce *.co $(CLEAN)
|
2006-06-18 00:41:10 +02:00
|
|
|
-rm -rf $(OBJECTDIR)
|
|
|
|
|
2006-06-26 04:01:30 +02:00
|
|
|
ifndef CUSTOM_RULE_C_TO_CE
|
2006-06-18 00:41:10 +02:00
|
|
|
%.ce: %.c
|
|
|
|
$(CC) $(CFLAGS) -DAUTOSTART_ENABLE -c $< -o $@
|
|
|
|
$(STRIP) --strip-unneeded -g -x $@
|
2006-06-26 04:01:30 +02:00
|
|
|
endif
|
2006-06-18 00:41:10 +02:00
|
|
|
|
2006-06-26 04:01:30 +02:00
|
|
|
ifndef CUSTOM_RULE_C_TO_OBJECTDIR_O
|
2006-06-18 00:41:10 +02:00
|
|
|
$(OBJECTDIR)/%.o: %.c
|
2009-07-03 00:36:04 +02:00
|
|
|
$(CC) $(CFLAGS) -MMD -c $< -o $@
|
|
|
|
@$(FINALIZE_DEPENDENCY)
|
2006-06-26 04:01:30 +02:00
|
|
|
endif
|
2006-06-18 00:41:10 +02:00
|
|
|
|
2007-08-30 22:42:58 +02:00
|
|
|
ifndef CUSTOM_RULE_S_TO_OBJECTDIR_O
|
|
|
|
$(OBJECTDIR)/%.o: %.S
|
2007-09-06 03:09:53 +02:00
|
|
|
$(AS) $(ASFLAGS) -o $@ $<
|
2007-08-30 22:42:58 +02:00
|
|
|
endif
|
|
|
|
|
2006-06-26 04:01:30 +02:00
|
|
|
ifndef CUSTOM_RULE_C_TO_O
|
2006-06-18 00:41:10 +02:00
|
|
|
%.o: %.c
|
|
|
|
$(CC) $(CFLAGS) -c $< -o $@
|
2006-06-26 04:01:30 +02:00
|
|
|
endif
|
2006-06-18 00:41:10 +02:00
|
|
|
|
2006-06-26 04:01:30 +02:00
|
|
|
ifndef CUSTOM_RULE_C_TO_CO
|
2006-06-18 00:41:10 +02:00
|
|
|
%.co: %.c
|
|
|
|
$(CC) $(CFLAGS) -DAUTOSTART_ENABLE -c $< -o $@
|
2006-06-26 04:01:30 +02:00
|
|
|
endif
|
2006-06-18 00:41:10 +02:00
|
|
|
|
2006-06-26 04:01:30 +02:00
|
|
|
ifndef AROPTS
|
|
|
|
AROPTS = rcf
|
|
|
|
endif
|
2006-06-18 00:41:10 +02:00
|
|
|
|
2006-06-26 04:01:30 +02:00
|
|
|
ifndef CUSTOM_RULE_ALLOBJS_TO_TARGETLIB
|
2006-12-31 14:54:24 +01:00
|
|
|
contiki-$(TARGET).a: $(CONTIKI_OBJECTFILES)
|
2006-06-26 04:01:30 +02:00
|
|
|
$(AR) $(AROPTS) $@ $^
|
|
|
|
endif
|
2006-06-18 00:41:10 +02:00
|
|
|
|
2006-06-26 04:01:30 +02:00
|
|
|
ifndef LD
|
|
|
|
LD = $(CC)
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifndef CUSTOM_RULE_LINK
|
2007-04-19 00:38:44 +02:00
|
|
|
%.$(TARGET): %.co $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a
|
2007-04-14 20:37:06 +02:00
|
|
|
$(LD) $(LDFLAGS) $(TARGET_STARTFILES) ${filter-out %.a,$^} ${filter %.a,$^} $(TARGET_LIBFILES) -o $@
|
2006-06-26 04:01:30 +02:00
|
|
|
endif
|
2006-06-18 00:41:10 +02:00
|
|
|
|
2012-03-26 22:55:57 +02:00
|
|
|
%.ramprof: %.$(TARGET)
|
2012-07-11 01:02:59 +02:00
|
|
|
$(NM) -S -td --size-sort $< | grep -i " [abdrw] " | cut -d' ' -f2,4
|
2012-03-26 22:55:57 +02:00
|
|
|
|
|
|
|
%.flashprof: %.$(TARGET)
|
2012-07-11 01:02:59 +02:00
|
|
|
$(NM) -S -td --size-sort $< | grep -i " [t] " | cut -d' ' -f2,4
|
2012-03-26 22:55:57 +02:00
|
|
|
|
2007-04-18 23:28:28 +02:00
|
|
|
# Don't treat %.$(TARGET) as an intermediate file because it is
|
|
|
|
# in fact the primary target.
|
|
|
|
.PRECIOUS: %.$(TARGET)
|
|
|
|
|
|
|
|
# Cancel the predefined implict rule for compiling and linking
|
|
|
|
# a single C source into a binary to force GNU make to consider
|
|
|
|
# the match-anything rule below instead.
|
|
|
|
%: %.c
|
|
|
|
|
|
|
|
# Match-anything pattern rule to allow the project makefiles to
|
|
|
|
# abstract from the actual binary name. It needs to contain some
|
|
|
|
# command in order to be a rule, not just a prerequisite.
|
2006-06-18 00:41:10 +02:00
|
|
|
%: %.$(TARGET)
|
|
|
|
@
|