osd-contiki/cpu/z80/Makefile.z80
oliverschmidt 7a228fea41 Replaced classic approach of generating dependency files via rule with generating them as side effect of generating object files. The issue with "No rule to make target ..." is solved as suggested in http://make.paulandlesley.org/autodep.html.
At least with gcc (and cc65) the dependency files are generated without an additional run of the C compiler. This is especially beneficial on Cygwin because of the fork() performance issue.
2009-07-02 22:36:04 +00:00

81 lines
2.3 KiB
Makefile

#
# Makefile for z80/SDCC
# @author Takahide Matsutsuka <markn@markn.org>
#
# $Id: Makefile.z80,v 1.12 2009/07/02 22:36:35 oliverschmidt Exp $
#
### Compiler definitions
CC = sdcc
LD = link-z80
AS = as-z80
AR = sdcclib
OBJCOPY = objcopy
STRIP = strip
### Custom rules
CUSTOM_RULE_ALLOBJS_TO_TARGETLIB=1
CUSTOM_RULE_LINK=1
### Default flags
CFLAGS += --std-c99 --vc -mz80
# --peep-file $(CONTIKI_CPU)/z80peephole.def
ASFLAGS +=
LDFLAGS += -mz80 --out-fmt-ihx --no-std-crt0
AROPTS = -a
### CPU-dependent cleanup files
CLEAN += *.lnk *.sym *.lib contiki.ihx
### CPU-dependent directories
CONTIKI_CPU_DIRS = . dev lib loader
### CPU-dependent source files
CONTIKI_SOURCEFILES += strcasecmp.c mtarch.c uip_arch.c \
libconio_z80.c log-conio.c rs232.c \
mef.c
CONTIKI_ASMFILES += uip_arch-asm.S crt0.S
#crt-prg.S
CONTIKI_ASMOBJECTFILES = ${addprefix $(OBJECTDIR)/,$(CONTIKI_ASMFILES:.S=.o)}
CONTIKI_CASMOBJECTFILES = ${addprefix $(OBJECTDIR)/,$(CONTIKI_CASMFILES:.cS=.o)}
CONTIKI_PLATFORM_DIRS = $(PLATFORM_APPDIRS) \
${addprefix $(CONTIKI)/platform/$(TARGET)/, $(CONTIKI_TARGET_DIRS)}
#".cS" suffix means assembler file with #include directive
#so that a developer can use definitions of C-style include file
#in assembler file. Make sure the header file contains only compiler
#directives. (i.e. #define, etc.)
vpath %.cS $(CONTIKI_PLATFORM_DIRS)
ifndef CUSTOM_RULE_CS_TO_OBJECTDIR_O
$(OBJECTDIR)/%.o: %.cS
cp $< $(OBJECTDIR)/$*.c
$(CC) $(CFLAGS) -E $(OBJECTDIR)/$*.c > $(OBJECTDIR)/tmp
perl -pe "s/^#(.*)/;$$1/" $(OBJECTDIR)/tmp > $(OBJECTDIR)/$*.S
$(AS) $(ASFLAGS) -o $@ $(OBJECTDIR)/$*.S
rm -f $(OBJECTDIR)/tmp
endif
#CUSTOM_RULE_ALLOBJS_TO_TARGETLIB
contiki-$(TARGET).lib: $(CONTIKI_OBJECTFILES) $(PROJECT_OBJECTFILES) $(CONTIKI_ASMOBJECTFILES) $(CONTIKI_CASMOBJECTFILES)
rm -f $@
for target in $^; do echo $$target >> $@; done
#CUSTOM_RULE_LINK
contiki.ihx: contiki-$(TARGET).lib $(OBJECTDIR)/crt0.o
$(CC) $(LDFLAGS) -o $@ $(OBJECTDIR)/crt0.o -lcontiki-$(TARGET).lib
$(LD) -nf contiki
LDPFLAGS = -mz80 --out-fmt-ihx --no-std-crt0 --code-loc 0 --data-loc 0
test.ihx: contiki-$(TARGET).lib $(OBJECTDIR)/crt-prg.o
$(CC) $(LDPFLAGS) -o $@ $(OBJECTDIR)/crt-prg.o -lcontiki-$(TARGET).lib
$(LD) -nf test
%.ihx: contiki-$(TARGET).lib $(OBJECTDIR)/%*.o
$(CC) $(LDPFLAGS) -o $@ $(OBJECTDIR)/$*.o -lcontiki-$(TARGET).lib
$(LD) -nf $*