2006-06-18 00:41:10 +02:00
|
|
|
ifndef CONTIKI
|
2007-04-14 20:37:06 +02:00
|
|
|
${error CONTIKI not defined! You must specify where CONTIKI resides!}
|
2006-06-18 00:41:10 +02:00
|
|
|
endif
|
|
|
|
|
|
|
|
OBJECTDIR = obj_$(TARGET)
|
2006-10-09 12:09:10 +02:00
|
|
|
CFLAGS += -DCONTIKI_TARGET=$(TARGET)
|
2006-06-18 00:41:10 +02:00
|
|
|
|
|
|
|
ifeq ($(TARGET),)
|
|
|
|
-include Makefile.target
|
|
|
|
ifeq ($(TARGET),)
|
2007-04-14 20:37:06 +02:00
|
|
|
${warning TARGET not defined, using native target}
|
2006-08-31 11:36:29 +02:00
|
|
|
TARGET=native
|
2006-06-18 00:41:10 +02:00
|
|
|
else
|
2007-04-14 20:37:06 +02:00
|
|
|
${warning using saved target '$(TARGET)'}
|
2006-06-18 00:41:10 +02:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
usage:
|
2006-08-31 11:36:29 +02:00
|
|
|
@echo "make MAKETARGETS... [TARGET=(TARGET)] [savetarget] [targets]"
|
|
|
|
|
|
|
|
targets:
|
|
|
|
@ls -1 $(CONTIKI)/platform | grep -v CVS
|
2006-06-18 00:41:10 +02:00
|
|
|
|
|
|
|
savetarget:
|
|
|
|
-@rm -f Makefile.target
|
|
|
|
@echo >Makefile.target "TARGET = $(TARGET)"
|
|
|
|
|
|
|
|
ifeq (${wildcard $(OBJECTDIR)},)
|
|
|
|
DUMMY := ${shell mkdir $(OBJECTDIR)}
|
|
|
|
endif
|
|
|
|
|
2007-03-15 22:45:15 +01:00
|
|
|
include $(CONTIKI)/core/net/rime/Makefile.rime
|
2007-05-15 09:47:34 +02:00
|
|
|
ifdef CHAMELEON
|
|
|
|
include $(CONTIKI)/core/net/chameleon/Makefile.chameleon
|
|
|
|
endif
|
|
|
|
include $(CONTIKI)/core/net/mac/Makefile.mac
|
2007-03-23 00:54:16 +01:00
|
|
|
SYSTEM = process.c procinit.c service.c autostart.c elfloader.c
|
2006-09-02 00:57:32 +02:00
|
|
|
THREADS = mt.c
|
2007-05-15 09:47:34 +02:00
|
|
|
LIBS = memb.c timer.c list.c etimer.c energest.c rtimer.c
|
2006-06-18 00:41:10 +02:00
|
|
|
CTK = ctk.c
|
|
|
|
UIP = uip.c uiplib.c resolv.c tcpip.c psock.c hc.c uip-split.c \
|
2007-05-20 23:29:39 +02:00
|
|
|
uip-fw.c uip-fw-drv.c uipbuf.c uip_arp.c uiplib.c tcpdump.c \
|
2007-03-22 20:02:42 +01:00
|
|
|
uip-neighbor.c uip-udp-packet.c rawpacket-udp.c uip-over-mesh.c
|
2006-06-18 00:41:10 +02:00
|
|
|
NET = $(UIP) uaodv.c uaodv-rt.c
|
|
|
|
|
|
|
|
CTKVNC = $(CTK) ctk-vncserver.c libconio.c vnc-server.c vnc-out.c \
|
|
|
|
ctk-vncfont.c
|
|
|
|
CTKTERM = $(CTK) libconio.c ctk-term.c ctk-term-in.c ctk-term-out.c \
|
|
|
|
ctk-termtelnet.c
|
|
|
|
|
2007-05-19 23:05:48 +02:00
|
|
|
CONTIKIFILES = $(SYSTEM) $(LIBS) $(NET) $(DHCP) $(THREADS)
|
2006-06-18 00:41:10 +02:00
|
|
|
|
|
|
|
CONTIKI_SOURCEFILES += $(CONTIKIFILES)
|
|
|
|
|
2007-05-15 09:47:34 +02:00
|
|
|
CONTIKIDIRS += ${addprefix $(CONTIKI)/core/,dev lib net net/mac net/rime sys \
|
2006-06-18 00:41:10 +02:00
|
|
|
cfs ctk lib/ctk loader . }
|
|
|
|
|
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
|
|
|
|
|
|
|
### Include application makefiles
|
|
|
|
|
|
|
|
ifdef APPS
|
2007-04-14 20:37:06 +02:00
|
|
|
APPDIRS += ${addprefix $(CONTIKI)/apps/, $(APPS)}
|
|
|
|
APPINCLUDES = ${foreach APP, $(APPS), $(CONTIKI)/apps/$(APP)/Makefile.$(APP)}
|
2006-06-18 00:41:10 +02:00
|
|
|
-include $(APPINCLUDES)
|
2007-04-14 20:37:06 +02:00
|
|
|
APP_SOURCES = ${foreach APP, $(APPS), $($(APP)_src)}
|
|
|
|
DSC_SOURCES = ${foreach APP, $(APPS), $($(APP)_dsc)}
|
2006-06-18 00:41:10 +02:00
|
|
|
CONTIKI_SOURCEFILES += $(APP_SOURCES) $(DSC_SOURCES)
|
|
|
|
endif
|
|
|
|
|
|
|
|
### Include target makefile (TODO Unsafe?)
|
2007-05-13 10:41:11 +02:00
|
|
|
|
2006-06-18 00:41:10 +02:00
|
|
|
include $(CONTIKI)/platform/$(TARGET)/Makefile.$(TARGET)
|
|
|
|
|
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
|
|
|
|
|
|
|
CONTIKI_TARGET_DIRS_CONCAT = ${addprefix $(CONTIKI)/platform/$(TARGET)/, \
|
|
|
|
$(CONTIKI_TARGET_DIRS)}
|
|
|
|
CONTIKI_CPU_DIRS_CONCAT = ${addprefix $(CONTIKI_CPU)/, \
|
|
|
|
$(CONTIKI_CPU_DIRS)}
|
|
|
|
|
|
|
|
SOURCEDIRS = $(PROJECTDIRS) $(CONTIKI_TARGET_DIRS_CONCAT) \
|
|
|
|
$(CONTIKI_CPU_DIRS_CONCAT) $(CONTIKIDIRS) $(APPDIRS)
|
|
|
|
|
|
|
|
vpath %.c $(SOURCEDIRS)
|
|
|
|
vpath %.S $(SOURCEDIRS)
|
|
|
|
|
2007-05-19 09:54:53 +02:00
|
|
|
CFLAGS += ${addprefix -I,$(SOURCEDIRS)}
|
|
|
|
|
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) \
|
|
|
|
$(PROJECT_SOURCEFILES:.c=.d)}
|
2006-06-18 00:41:10 +02:00
|
|
|
endif
|
|
|
|
|
|
|
|
clean:
|
2007-01-18 14:47:40 +01:00
|
|
|
rm -f *~ *core core *.srec \
|
2006-06-18 00:41:10 +02:00
|
|
|
*.lst *.map \
|
|
|
|
*.cprg *.bin *.data contiki*.a *.firmware core-labels.S *.ihex *.ini \
|
|
|
|
*.ce *.co
|
|
|
|
-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
|
|
|
|
$(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_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
|
|
|
|
|
|
|
ifndef CCDEP
|
|
|
|
CCDEP = $(CC)
|
|
|
|
endif
|
|
|
|
ifndef CDEPFLAGS
|
|
|
|
CDEPFLAGS = $(CFLAGS)
|
|
|
|
endif
|
|
|
|
|
2006-12-31 15:16:32 +01:00
|
|
|
ifndef CUSTOM_RULE_C_TO_OBJECTDIR_D
|
2006-06-18 00:41:10 +02:00
|
|
|
$(OBJECTDIR)/%.d: %.c
|
2007-03-31 20:40:52 +02:00
|
|
|
@echo Making dependencies for $<; set -e; rm -f $@; \
|
2006-06-18 00:41:10 +02:00
|
|
|
$(CCDEP) -MM $(CDEPFLAGS) $< > $@.$$$$; \
|
|
|
|
sed 's,\($*\)\.o[ :]*,$(OBJECTDIR)/\1.o $@ : ,g' < $@.$$$$ > $@; \
|
|
|
|
rm -f $@.$$$$
|
2006-12-31 15:16:32 +01:00
|
|
|
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
|
|
|
|
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)
|
|
|
|
@
|