2006-06-17 22:41:10 +00:00
|
|
|
ifndef CONTIKI
|
|
|
|
$(error CONTIKI not defined! You must specify where CONTIKI resides!)
|
|
|
|
endif
|
|
|
|
|
|
|
|
OBJECTDIR = obj_$(TARGET)
|
2006-10-09 10:09:10 +00:00
|
|
|
CFLAGS += -DCONTIKI_TARGET=$(TARGET)
|
2006-06-17 22:41:10 +00:00
|
|
|
|
|
|
|
ifeq ($(TARGET),)
|
|
|
|
-include Makefile.target
|
|
|
|
ifeq ($(TARGET),)
|
2006-08-31 09:36:29 +00:00
|
|
|
$(warning TARGET not defined, using native target)
|
|
|
|
TARGET=native
|
2006-06-17 22:41:10 +00:00
|
|
|
else
|
|
|
|
$(warning using saved target '$(TARGET)')
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
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
|
|
|
|
@echo >Makefile.target "TARGET = $(TARGET)"
|
|
|
|
|
|
|
|
ifeq (${wildcard $(OBJECTDIR)},)
|
|
|
|
DUMMY := ${shell mkdir $(OBJECTDIR)}
|
|
|
|
endif
|
|
|
|
|
2007-03-15 21:45:15 +00:00
|
|
|
include $(CONTIKI)/core/net/rime/Makefile.rime
|
2007-03-22 23:54:16 +00:00
|
|
|
SYSTEM = process.c procinit.c service.c autostart.c elfloader.c
|
2006-09-01 22:57:32 +00:00
|
|
|
THREADS = mt.c
|
2007-04-03 19:08:06 +00:00
|
|
|
LIBS = memb.c timer.c list.c etimer.c energest.c rtimer.c
|
2006-06-17 22:41:10 +00:00
|
|
|
CFS = cfs.c cfs-ram.c
|
|
|
|
CTK = ctk.c
|
|
|
|
UIP = uip.c uiplib.c resolv.c tcpip.c psock.c hc.c uip-split.c \
|
|
|
|
uip-fw.c uip-fw-service.c uipbuf.c uip_arp.c uiplib.c tcpdump.c \
|
2007-03-22 19:02:42 +00:00
|
|
|
uip-neighbor.c uip-udp-packet.c rawpacket-udp.c uip-over-mesh.c
|
2006-06-17 22:41:10 +00: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-04-03 00:46:18 +00:00
|
|
|
CONTIKIFILES = $(SYSTEM) $(THREADS) $(CFS) $(LIBS) $(NET) $(DHCP)
|
2006-06-17 22:41:10 +00:00
|
|
|
|
|
|
|
CONTIKI_SOURCEFILES += $(CONTIKIFILES)
|
|
|
|
|
2007-03-15 21:45:15 +00:00
|
|
|
CONTIKIDIRS = ${addprefix $(CONTIKI)/core/,dev lib net net/rime sys \
|
2006-06-17 22:41:10 +00:00
|
|
|
cfs ctk lib/ctk loader . }
|
|
|
|
|
2006-12-31 13:54:24 +00:00
|
|
|
CONTIKI_OBJECTFILES = ${addprefix $(OBJECTDIR)/,$(CONTIKI_SOURCEFILES:.c=.o)}
|
|
|
|
|
2006-06-17 22:41:10 +00:00
|
|
|
PROJECT_OBJECTFILES = ${addprefix $(OBJECTDIR)/,$(PROJECT_SOURCEFILES:.c=.o)}
|
|
|
|
|
|
|
|
### Include application makefiles
|
|
|
|
|
|
|
|
ifdef APPS
|
|
|
|
APPDIRS += $(addprefix $(CONTIKI)/apps/, $(APPS))
|
|
|
|
APPINCLUDES = $(foreach APP, $(APPS), $(CONTIKI)/apps/$(APP)/Makefile.$(APP))
|
|
|
|
-include $(APPINCLUDES)
|
|
|
|
CONTIKI_SOURCEFILES += $(APP_SOURCES) $(DSC_SOURCES)
|
|
|
|
endif
|
|
|
|
|
|
|
|
### Include target makefile (TODO Unsafe?)
|
|
|
|
include $(CONTIKI)/platform/$(TARGET)/Makefile.$(TARGET)
|
|
|
|
|
|
|
|
### Automatic dependency generation
|
|
|
|
|
|
|
|
ifneq ($(MAKECMDGOALS),clean)
|
|
|
|
-include $(addprefix $(OBJECTDIR)/,$(CONTIKI_SOURCEFILES:.c=.d) \
|
|
|
|
$(PROJECT_SOURCEFILES:.c=.d))
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
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 \
|
|
|
|
*.ce *.co
|
|
|
|
-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
|
|
|
|
$(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_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
|
|
|
|
|
|
|
ifndef CCDEP
|
|
|
|
CCDEP = $(CC)
|
|
|
|
endif
|
|
|
|
ifndef CDEPFLAGS
|
|
|
|
CDEPFLAGS = $(CFLAGS)
|
|
|
|
endif
|
|
|
|
|
2006-12-31 14:16:32 +00:00
|
|
|
ifndef CUSTOM_RULE_C_TO_OBJECTDIR_D
|
2006-06-17 22:41:10 +00:00
|
|
|
$(OBJECTDIR)/%.d: %.c
|
2007-03-31 18:40:52 +00:00
|
|
|
@echo Making dependencies for $<; set -e; rm -f $@; \
|
2006-06-17 22:41:10 +00:00
|
|
|
$(CCDEP) -MM $(CDEPFLAGS) $< > $@.$$$$; \
|
|
|
|
sed 's,\($*\)\.o[ :]*,$(OBJECTDIR)/\1.o $@ : ,g' < $@.$$$$ > $@; \
|
|
|
|
rm -f $@.$$$$
|
2006-12-31 14:16:32 +00:00
|
|
|
endif
|
2006-06-17 22:41:10 +00:00
|
|
|
|
|
|
|
# The line below is needed so that GNU make does not remove the
|
|
|
|
# generated file.
|
|
|
|
.PRECIOUS: %.$(TARGET)
|
|
|
|
|
2006-06-26 02:01:30 +00:00
|
|
|
ifndef LD
|
|
|
|
LD = $(CC)
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifndef CUSTOM_RULE_LINK
|
2007-03-16 06:56:58 +00:00
|
|
|
%.$(TARGET): %.co $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a
|
2006-12-31 13:34:59 +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
|
|
|
|
|
|
|
# The target below looks weird, but I had to add the @ to avoid complaints
|
|
|
|
# from GNU make about "*** No rule to make target `XXX'. Stop."
|
|
|
|
%: %.$(TARGET)
|
|
|
|
@
|