nes-proj/Makefile.include

156 lines
4.0 KiB
Makefile
Raw Normal View History

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)
ifeq ($(TARGET),)
-include Makefile.target
ifeq ($(TARGET),)
${warning TARGET not defined, using native target}
TARGET=native
else
${warning using saved target '$(TARGET)'}
endif
endif
usage:
@echo "make MAKETARGETS... [TARGET=(TARGET)] [savetarget] [targets]"
targets:
@ls -1 $(CONTIKI)/platform | grep -v CVS
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
THREADS = mt.c
2007-04-03 19:08:06 +00:00
LIBS = memb.c timer.c list.c etimer.c energest.c rtimer.c
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
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
CONTIKIFILES = $(SYSTEM) $(THREADS) $(CFS) $(LIBS) $(NET) $(DHCP)
CONTIKI_SOURCEFILES += $(CONTIKIFILES)
2007-03-15 21:45:15 +00:00
CONTIKIDIRS = ${addprefix $(CONTIKI)/core/,dev lib net net/rime sys \
cfs ctk lib/ctk loader . }
CONTIKI_OBJECTFILES = ${addprefix $(OBJECTDIR)/,$(CONTIKI_SOURCEFILES:.c=.o)}
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)
APP_SOURCES = ${foreach APP, $(APPS), $($(APP)_src)}
DSC_SOURCES = ${foreach APP, $(APPS), $($(APP)_dsc)}
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:
rm -f *~ *core core *.srec \
*.lst *.map \
*.cprg *.bin *.data contiki*.a *.firmware core-labels.S *.ihex *.ini \
*.ce *.co
-rm -rf $(OBJECTDIR)
ifndef CUSTOM_RULE_C_TO_CE
%.ce: %.c
$(CC) $(CFLAGS) -DAUTOSTART_ENABLE -c $< -o $@
$(STRIP) --strip-unneeded -g -x $@
endif
ifndef CUSTOM_RULE_C_TO_OBJECTDIR_O
$(OBJECTDIR)/%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
endif
ifndef CUSTOM_RULE_C_TO_O
%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
endif
ifndef CUSTOM_RULE_C_TO_CO
%.co: %.c
$(CC) $(CFLAGS) -DAUTOSTART_ENABLE -c $< -o $@
endif
ifndef AROPTS
AROPTS = rcf
endif
ifndef CUSTOM_RULE_ALLOBJS_TO_TARGETLIB
contiki-$(TARGET).a: $(CONTIKI_OBJECTFILES)
$(AR) $(AROPTS) $@ $^
endif
ifndef CCDEP
CCDEP = $(CC)
endif
ifndef CDEPFLAGS
CDEPFLAGS = $(CFLAGS)
endif
ifndef CUSTOM_RULE_C_TO_OBJECTDIR_D
$(OBJECTDIR)/%.d: %.c
@echo Making dependencies for $<; set -e; rm -f $@; \
$(CCDEP) -MM $(CDEPFLAGS) $< > $@.$$$$; \
sed 's,\($*\)\.o[ :]*,$(OBJECTDIR)/\1.o $@ : ,g' < $@.$$$$ > $@; \
rm -f $@.$$$$
endif
ifndef LD
LD = $(CC)
endif
ifndef CUSTOM_RULE_LINK
%.$(TARGET): %.co $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a
$(LD) $(LDFLAGS) $(TARGET_STARTFILES) ${filter-out %.a,$^} ${filter %.a,$^} $(TARGET_LIBFILES) -o $@
endif
# 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.
%: %.$(TARGET)
@