2006-06-17 22:41:10 +00:00
|
|
|
ifndef CONTIKI
|
2008-10-14 20:31:46 +00:00
|
|
|
${error CONTIKI not defined! You must specify where CONTIKI resides}
|
2006-06-17 22:41:10 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(TARGET),)
|
|
|
|
-include Makefile.target
|
|
|
|
ifeq ($(TARGET),)
|
2008-10-14 20:31:46 +00:00
|
|
|
${info TARGET not defined, using target 'native'}
|
|
|
|
TARGET=native
|
2006-06-17 22:41:10 +00:00
|
|
|
else
|
2007-12-24 15:24:15 +00:00
|
|
|
${info using saved target '$(TARGET)'}
|
2006-06-17 22:41:10 +00:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2007-12-24 15:24:15 +00:00
|
|
|
ifeq ($(DEFINES),)
|
|
|
|
-include Makefile.$(TARGET).defines
|
2008-01-04 21:01:37 +00:00
|
|
|
ifneq ($(DEFINES),)
|
|
|
|
${info using saved defines '$(DEFINES)'}
|
|
|
|
endif
|
2007-12-24 15:24:15 +00:00
|
|
|
endif
|
|
|
|
|
2006-06-17 22:41:10 +00:00
|
|
|
usage:
|
2006-08-31 09:36:29 +00:00
|
|
|
@echo "make MAKETARGETS... [TARGET=(TARGET)] [savetarget] [targets]"
|
|
|
|
|
|
|
|
targets:
|
|
|
|
@ls -1 $(CONTIKI)/platform | grep -v CVS
|
2006-06-17 22:41:10 +00:00
|
|
|
|
|
|
|
savetarget:
|
|
|
|
-@rm -f Makefile.target
|
2007-12-24 15:24:15 +00:00
|
|
|
@echo "saving Makefile.target"
|
2006-06-17 22:41:10 +00:00
|
|
|
@echo >Makefile.target "TARGET = $(TARGET)"
|
|
|
|
|
2007-12-24 15:24:15 +00:00
|
|
|
savedefines:
|
|
|
|
-@rm -f Makefile.$(TARGET).defines
|
|
|
|
@echo "saving Makefile.$(TARGET).defines"
|
|
|
|
@echo >Makefile.$(TARGET).defines "DEFINES = $(DEFINES)"
|
|
|
|
|
2008-11-14 21:37:45 +00:00
|
|
|
OBJECTDIR = obj_$(TARGET)
|
2006-06-17 22:41:10 +00:00
|
|
|
ifeq (${wildcard $(OBJECTDIR)},)
|
2008-11-14 22:06:53 +00:00
|
|
|
DUMMY := ${shell mkdir $(OBJECTDIR)}
|
2006-06-17 22:41:10 +00:00
|
|
|
endif
|
|
|
|
|
2008-11-15 11:13:19 +00:00
|
|
|
LOWERCASE = -abcdefghijklmnopqrstuvwxyz
|
|
|
|
UPPERCASE = _ABCDEFGHIJKLMNOPQRSTUVWXYZ
|
2008-11-14 21:37:45 +00:00
|
|
|
TARGET_UPPERCASE := ${shell echo $(TARGET) | sed 'y!$(LOWERCASE)!$(UPPERCASE)!'}
|
|
|
|
CFLAGS += -DCONTIKI_TARGET_$(TARGET_UPPERCASE)
|
|
|
|
|
2009-04-06 13:20:34 +00:00
|
|
|
include $(CONTIKI)/core/net/routing/Makefile.routing
|
2007-03-15 21:45:15 +00:00
|
|
|
include $(CONTIKI)/core/net/rime/Makefile.rime
|
2007-05-15 07:47:34 +00:00
|
|
|
include $(CONTIKI)/core/net/mac/Makefile.mac
|
2009-03-17 15:56:32 +00:00
|
|
|
SYSTEM = process.c procinit.c autostart.c elfloader.c profile.c \
|
|
|
|
timetable.c timetable-aggregate.c compower.c serial-line.c
|
2006-09-01 22:57:32 +00:00
|
|
|
THREADS = mt.c
|
2008-10-14 20:31:46 +00:00
|
|
|
LIBS = memb.c timer.c list.c etimer.c energest.c rtimer.c stimer.c \
|
2009-03-02 09:39:37 +00:00
|
|
|
print-stats.c ifft.c crc16.c random.c checkpoint.c ringbuf.c
|
2008-10-15 09:13:05 +00:00
|
|
|
|
2008-10-14 20:31:46 +00:00
|
|
|
ifdef UIP_CONF_IPV6
|
2008-11-14 22:06:53 +00:00
|
|
|
CFLAGS += -DUIP_CONF_IPV6
|
|
|
|
UIP = uip6.c tcpip.c psock.c uip-udp-packet.c uip-split.c \
|
2008-10-14 20:31:46 +00:00
|
|
|
uip-over-mesh.c resolv.c hc.c tcpdump.c uiplib.c
|
2008-11-14 22:06:53 +00:00
|
|
|
NET = $(UIP) uip-icmp6.c uip-nd6.c uip-nd6-io.c uip-netif.c sicslowpan.c
|
2008-10-14 20:31:46 +00:00
|
|
|
else # UIP_CONF_IPV6
|
2008-11-14 22:06:53 +00:00
|
|
|
UIP = uip.c uiplib.c resolv.c tcpip.c psock.c hc.c uip-split.c uip-fw.c \
|
2008-10-14 20:31:46 +00:00
|
|
|
uip-fw-drv.c uip_arp.c tcpdump.c uip-neighbor.c uip-udp-packet.c \
|
|
|
|
uip-over-mesh.c #rawpacket-udp.c
|
2008-11-14 22:06:53 +00:00
|
|
|
NET = $(UIP) uaodv.c uaodv-rt.c
|
2008-10-14 20:31:46 +00:00
|
|
|
endif # UIP_CONF_IPV6
|
2008-10-15 09:13:05 +00:00
|
|
|
|
2007-11-22 11:19:27 +00:00
|
|
|
CTK = ctk.c
|
|
|
|
CTKVNC = $(CTK) ctk-vncserver.c libconio.c vnc-server.c vnc-out.c ctk-vncfont.c
|
2006-06-17 22:41:10 +00:00
|
|
|
|
2008-10-14 19:06:51 +00:00
|
|
|
ifndef CONTIKI_NO_NET
|
2008-11-14 22:06:53 +00:00
|
|
|
CONTIKIFILES = $(SYSTEM) $(LIBS) $(NET) $(THREADS) $(DHCP)
|
2008-10-14 19:06:51 +00:00
|
|
|
else
|
2008-11-14 22:06:53 +00:00
|
|
|
CONTIKIFILES = $(SYSTEM) $(LIBS) $(THREADS) sicslowpan.c fakeuip.c
|
2008-10-14 19:06:51 +00:00
|
|
|
endif
|
2006-06-17 22:41:10 +00:00
|
|
|
|
|
|
|
CONTIKI_SOURCEFILES += $(CONTIKIFILES)
|
|
|
|
|
2009-04-06 13:20:34 +00:00
|
|
|
CONTIKIDIRS += ${addprefix $(CONTIKI)/core/,dev lib net net/mac net/rime \
|
|
|
|
net/routing sys cfs ctk lib/ctk loader . }
|
2006-06-17 22:41:10 +00:00
|
|
|
|
2007-04-21 15:13:14 +00:00
|
|
|
oname = ${patsubst %.c,%.o,${patsubst %.S,%.o,$(1)}}
|
2006-12-31 13:54:24 +00:00
|
|
|
|
2007-04-21 15:13:14 +00:00
|
|
|
CONTIKI_OBJECTFILES = ${addprefix $(OBJECTDIR)/,${call oname, $(CONTIKI_SOURCEFILES)}}
|
2007-04-21 14:56:52 +00:00
|
|
|
|
2007-04-21 15:13:14 +00:00
|
|
|
PROJECT_OBJECTFILES = ${addprefix $(OBJECTDIR)/,${call oname, $(PROJECT_SOURCEFILES)}}
|
2006-06-17 22:41:10 +00:00
|
|
|
|
2009-03-12 19:10:37 +00:00
|
|
|
### Include application makefiles
|
2009-07-02 22:36:04 +00:00
|
|
|
|
2009-03-12 19:10:37 +00:00
|
|
|
ifdef APPS
|
|
|
|
APPDIRS += ${wildcard ${addprefix $(CONTIKI)/apps/, $(APPS)} \
|
|
|
|
${addprefix $(CONTIKI)/platform/$(TARGET)/apps/, $(APPS)}}
|
|
|
|
APPINCLUDES = ${foreach APP, $(APPS), ${wildcard \
|
|
|
|
$(CONTIKI)/apps/$(APP)/Makefile.$(APP) \
|
|
|
|
$(CONTIKI)/platform/$(TARGET)/apps/$(APP)/Makefile.$(APP)}}
|
|
|
|
-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 20:08:56 +00:00
|
|
|
### Include target makefile (TODO Unsafe?)
|
2009-07-02 22:36:04 +00:00
|
|
|
|
2009-03-17 20:08:56 +00:00
|
|
|
target_makefile := $(wildcard $(CONTIKI)/platform/$(TARGET)/Makefile.$(TARGET))
|
|
|
|
|
|
|
|
# Check if the target makefile exists
|
|
|
|
ifeq ($(strip $(target_makefile)),)
|
|
|
|
${error The target platform "$(TARGET)" does not exist (maybe it was misspelled?)}
|
|
|
|
else
|
|
|
|
include $(CONTIKI)/platform/$(TARGET)/Makefile.$(TARGET)
|
|
|
|
endif
|
|
|
|
|
2007-12-21 10:16:45 +00:00
|
|
|
### Forward comma-separated list of arbitrary defines to the compiler
|
|
|
|
|
|
|
|
COMMA := ,
|
|
|
|
CFLAGS += ${addprefix -D,${subst $(COMMA), ,$(DEFINES)}}
|
|
|
|
|
2007-05-19 07:54:53 +00:00
|
|
|
### Setup directory search path for source and header files
|
2007-05-13 08:41:11 +00:00
|
|
|
|
|
|
|
CONTIKI_TARGET_DIRS_CONCAT = ${addprefix $(CONTIKI)/platform/$(TARGET)/, \
|
|
|
|
$(CONTIKI_TARGET_DIRS)}
|
|
|
|
CONTIKI_CPU_DIRS_CONCAT = ${addprefix $(CONTIKI_CPU)/, \
|
|
|
|
$(CONTIKI_CPU_DIRS)}
|
|
|
|
|
2009-02-11 09:03:52 +00:00
|
|
|
SOURCEDIRS = . $(PROJECTDIRS) $(CONTIKI_TARGET_DIRS_CONCAT) \
|
2007-05-13 08:41:11 +00:00
|
|
|
$(CONTIKI_CPU_DIRS_CONCAT) $(CONTIKIDIRS) $(APPDIRS)
|
|
|
|
|
|
|
|
vpath %.c $(SOURCEDIRS)
|
|
|
|
vpath %.S $(SOURCEDIRS)
|
|
|
|
|
2007-05-19 07:54:53 +00:00
|
|
|
CFLAGS += ${addprefix -I,$(SOURCEDIRS)}
|
|
|
|
|
2006-06-17 22:41:10 +00:00
|
|
|
### Automatic dependency generation
|
|
|
|
|
|
|
|
ifneq ($(MAKECMDGOALS),clean)
|
2007-04-14 18:37:06 +00:00
|
|
|
-include ${addprefix $(OBJECTDIR)/,$(CONTIKI_SOURCEFILES:.c=.d) \
|
|
|
|
$(PROJECT_SOURCEFILES:.c=.d)}
|
2006-06-17 22:41:10 +00:00
|
|
|
endif
|
|
|
|
|
2009-07-02 22:36:04 +00: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
|
|
|
|
|
2006-06-17 22:41:10 +00:00
|
|
|
clean:
|
2007-01-18 13:47:40 +00:00
|
|
|
rm -f *~ *core core *.srec \
|
2006-06-17 22:41:10 +00:00
|
|
|
*.lst *.map \
|
|
|
|
*.cprg *.bin *.data contiki*.a *.firmware core-labels.S *.ihex *.ini \
|
Support for z80(sdcc) port.
In order to support, some core modules are modified as follows:
core/sys/dsc.h
- If CTK_CONF_ICONS is diabled, the whole icon-related code is disabled.
- DSC_HEADER is changed to remove extra semicolon.
core/sys/process.h
- process_data_t is expressed by void* in signatures (known bug on sdcc).
core/sys/autostart.h
- autostart_processes is changed to remove extra semicolon.
core/sys/cc.h
- CC_CONF_ASSIGN_AGGREGATE is introduced.
- CC_CONF_INC_CAST_POINTER is introduced, a workaround of a kind
of sdcc bug for an increment.
core/net/hc.c
core/net/uip_arp.c
core/net/uaodv.c
- Aggregation assignments are changed to uip_ipaddr_copy.
core/net/psock.c
core/net/uipbuf.c
core/net/dhcpc.c
apps/shell/shell.c
core/ctk/vnc-server.c
core/ctk/vnc-out.c
- "register" keyword in a signature cannot be used in sdcc,
CC_REGISTER_ARG is used instead.
core/net/uip-over-mesh.c
- An extra semicolon is removed.
apps/dhcp/dhcp-dsc.c
apps/shell/shell-dsc.
apps/ftp/ftp-dsc.c
apps/process-list/process-list-dsc.c
apps/email/email-dsc.c
apps/webserver/webserver-dsc.c
apps/vnc/vnc-dsc.c
apps/vnc/vnc-viewer.h
apps/webbrowser/www-dsc.c
apps/about/about-dsc.c
apps/irc/irc-dsc.c
apps/telnet/telnet-dsc.c
apps/telnetd/telnetd-dsc.c
apps/netconf/netconf-dsc.c
apps/directory/directory-dsc.c
pps/calc/calc-dsc.c
- Modify an extern type to a real declaration, which is static
to prevent a compile error.
core/net/mac/xmac.c
- Variables cannot be defined in a head of block on sdcc.
core/ctk/ctk.h
core/ctk/ctk.c
apps/program-handler/program-handler.c
- If CTK_CONF_ICONS is diabled, the whole icon-related code is disabled.
Makefile.include
- Add a set of configuration for an assembler.
- $(CLEAN) variable is introduced for customized cleanup.
apps/process-list/process-list.c
- PROCESSLIST_CONF_HEIGHT is introduced to address smaller screen size.
core/lib/ctk-filedialog.c
- FILES_CONF_HEIGHT is introduced to address smaller screen size.
- "register" keyword in a signature cannot be used in sdcc,
CC_REGISTER_ARG is used instead.
apps/vnc/vnc-viewer.c
- A cast is added to prevent a compile error.
- "register" keyword in a signature cannot be used in sdcc,
CC_REGISTER_ARG is used instead.
apps/webbrowser/webclient.c
- CC_CONF_INC_CAST_POINTER is introduced, a workaround of a kind
of sdcc bug for an increment.
core/loader/elfloader.c
- A cast is added to prevent a compile error.
core/net/rime/rimeaddr.c
- An initialization is added to prevent a compile error.
core/net/rime/rudolph0.c
- NULL is changed to 0, because NULL causes a compile error.
core/net/rime/route-discovery.c
- Add an argument to match the definition of nf_callbacks.
cpu/z80/strcasecmp.h
cpu/z80/strcasecmp.c
cpu/z80/contiki-sdcc-conf.h
cpu/z80/mtarch.c
cpu/z80/mtarch.h
cpu/z80/Makefile.z80
- New files to make compilation availble on sdcc.
- Added support for multithreading.
2007-08-30 14:39:16 +00:00
|
|
|
*.ce *.co $(CLEAN)
|
2006-06-17 22:41:10 +00:00
|
|
|
-rm -rf $(OBJECTDIR)
|
|
|
|
|
2006-06-26 02:01:30 +00:00
|
|
|
ifndef CUSTOM_RULE_C_TO_CE
|
2006-06-17 22:41:10 +00:00
|
|
|
%.ce: %.c
|
|
|
|
$(CC) $(CFLAGS) -DAUTOSTART_ENABLE -c $< -o $@
|
|
|
|
$(STRIP) --strip-unneeded -g -x $@
|
2006-06-26 02:01:30 +00:00
|
|
|
endif
|
2006-06-17 22:41:10 +00:00
|
|
|
|
2006-06-26 02:01:30 +00:00
|
|
|
ifndef CUSTOM_RULE_C_TO_OBJECTDIR_O
|
2006-06-17 22:41:10 +00:00
|
|
|
$(OBJECTDIR)/%.o: %.c
|
2009-07-02 22:36:04 +00:00
|
|
|
$(CC) $(CFLAGS) -MMD -c $< -o $@
|
|
|
|
@$(FINALIZE_DEPENDENCY)
|
2006-06-26 02:01:30 +00:00
|
|
|
endif
|
2006-06-17 22:41:10 +00:00
|
|
|
|
2007-08-30 20:42:58 +00:00
|
|
|
ifndef CUSTOM_RULE_S_TO_OBJECTDIR_O
|
|
|
|
$(OBJECTDIR)/%.o: %.S
|
2007-09-06 01:09:53 +00:00
|
|
|
$(AS) $(ASFLAGS) -o $@ $<
|
2007-08-30 20:42:58 +00:00
|
|
|
endif
|
|
|
|
|
2006-06-26 02:01:30 +00:00
|
|
|
ifndef CUSTOM_RULE_C_TO_O
|
2006-06-17 22:41:10 +00:00
|
|
|
%.o: %.c
|
|
|
|
$(CC) $(CFLAGS) -c $< -o $@
|
2006-06-26 02:01:30 +00:00
|
|
|
endif
|
2006-06-17 22:41:10 +00:00
|
|
|
|
2006-06-26 02:01:30 +00:00
|
|
|
ifndef CUSTOM_RULE_C_TO_CO
|
2006-06-17 22:41:10 +00:00
|
|
|
%.co: %.c
|
|
|
|
$(CC) $(CFLAGS) -DAUTOSTART_ENABLE -c $< -o $@
|
2006-06-26 02:01:30 +00:00
|
|
|
endif
|
2006-06-17 22:41:10 +00:00
|
|
|
|
2006-06-26 02:01:30 +00:00
|
|
|
ifndef AROPTS
|
|
|
|
AROPTS = rcf
|
|
|
|
endif
|
2006-06-17 22:41:10 +00:00
|
|
|
|
2006-06-26 02:01:30 +00:00
|
|
|
ifndef CUSTOM_RULE_ALLOBJS_TO_TARGETLIB
|
2006-12-31 13:54:24 +00:00
|
|
|
contiki-$(TARGET).a: $(CONTIKI_OBJECTFILES)
|
2006-06-26 02:01:30 +00:00
|
|
|
$(AR) $(AROPTS) $@ $^
|
|
|
|
endif
|
2006-06-17 22:41:10 +00:00
|
|
|
|
2006-06-26 02:01:30 +00:00
|
|
|
ifndef LD
|
|
|
|
LD = $(CC)
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifndef CUSTOM_RULE_LINK
|
2007-04-18 22:38:44 +00:00
|
|
|
%.$(TARGET): %.co $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a
|
2007-04-14 18:37:06 +00:00
|
|
|
$(LD) $(LDFLAGS) $(TARGET_STARTFILES) ${filter-out %.a,$^} ${filter %.a,$^} $(TARGET_LIBFILES) -o $@
|
2006-06-26 02:01:30 +00:00
|
|
|
endif
|
2006-06-17 22:41:10 +00:00
|
|
|
|
2007-04-18 21:28:28 +00: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-17 22:41:10 +00:00
|
|
|
%: %.$(TARGET)
|
|
|
|
@
|