Line 44... |
Line 44... |
##
|
##
|
################################################################################
|
################################################################################
|
##
|
##
|
##
|
##
|
all:
|
all:
|
PROGRAMS := helloworld doorbell doorbell2 kptest
|
PROGRAMS := helloworld doorbell doorbell2 kptest blinky
|
all: $(OBJDIR)/ $(PROGRAMS)
|
all: $(OBJDIR)/ $(PROGRAMS)
|
|
|
|
|
OBJDIR := obj-zip
|
OBJDIR := obj-zip
|
CROSS := zip
|
CROSS := zip
|
Line 58... |
Line 58... |
SED := sed
|
SED := sed
|
OBJDUMP := $(CROSS)-objdump
|
OBJDUMP := $(CROSS)-objdump
|
|
|
# Not for build, for for building tags and dependency files, we need to know
|
# Not for build, for for building tags and dependency files, we need to know
|
# what the sources and headers are
|
# what the sources and headers are
|
DEVDRVR:= keypad.c display.c rtcsim.c
|
DEVDRVR:= keypad.c display.c rtcsim.c txfns.c
|
SOURCES:= helloworld.c doorbell.c doorbell2.c kptest.c $(DEVDRVR)
|
SOURCES:= helloworld.c doorbell.c doorbell2.c kptest.c $(DEVDRVR)
|
HEADERS:= board.h
|
HEADERS:= board.h
|
# OBJECTS:= $(addprefix $(OBJDIR)/,$(subst .cpp,.o,$(SOURCES)))
|
|
OBJDRVR := $(addprefix $(OBJDIR)/,$(subst .c,.o,$(DEVDRVR)))
|
OBJDRVR := $(addprefix $(OBJDIR)/,$(subst .c,.o,$(DEVDRVR)))
|
|
|
|
|
CPPFLAGS := -I../zipos -I.
|
CPPFLAGS := -I../zipos -I.
|
CFLAGS := -O3 -Wall -Wextra -nostdlib -fno-builtin
|
DUMPFLAGS := # -fdump-rtl-all
|
|
CFLAGS := $(CPPFLAGS) $(DUMPFLAGS) -O3 -Wall -Wextra -nostdlib -fno-builtin -Wa,-nocis
|
LDFLAGS = -T cmod.ld -Wl,-Map,$(OBJDIR)/$@.map -Wl,--unresolved-symbols=report-all -nostdlib
|
LDFLAGS = -T cmod.ld -Wl,-Map,$(OBJDIR)/$@.map -Wl,--unresolved-symbols=report-all -nostdlib
|
|
|
$(OBJDIR)/:
|
$(OBJDIR)/:
|
@bash -c "if [ ! -e $(OBJDIR) ]; then mkdir -p $(OBJDIR); fi"
|
$(mk-objdir)
|
|
|
%.o: $(OBJDIR)/%.o
|
%.o: $(OBJDIR)/%.o
|
|
|
$(OBJDIR)/%.o: %.c
|
$(OBJDIR)/%.o: %.c
|
|
$(mk-objdir)
|
|
$(CC) $(CFLAGS) -c $< -o $@
|
|
$(OBJDIR)/%.o: ../zipos/%.c
|
|
$(mk-objdir)
|
$(CC) $(CFLAGS) -c $< -o $@
|
$(CC) $(CFLAGS) -c $< -o $@
|
|
|
$(OBJDIR)/%.s: %.c
|
$(OBJDIR)/%.s: %.c
|
|
$(mk-objdir)
|
$(CC) -S $(CFLAGS) -c $< -o $@
|
$(CC) -S $(CFLAGS) -c $< -o $@
|
|
|
$(OBJDIR)/%.txt: $(OBJDIR)/%.o
|
$(OBJDIR)/%.txt: $(OBJDIR)/%.o
|
|
$(mk-objdir)
|
$(OBJDUMP) -dr $^ > $@
|
$(OBJDUMP) -dr $^ > $@
|
|
%.txt: %
|
|
$(OBJDUMP) -Dr $< > $@
|
|
|
|
|
helloworld: $(OBJDIR)/ $(OBJDIR)/helloworld.o cmod.ld
|
helloworld: $(OBJDIR)/helloworld.o cmod.ld
|
$(CC) $(LDFLAGS) $(OBJDIR)/helloworld.o -o $@
|
$(CC) $(LDFLAGS) $(OBJDIR)/helloworld.o -o $@
|
$(OBJDIR)/helloworld.txt: helloworld
|
$(OBJDIR)/helloworld.txt: helloworld
|
$(OBJDUMP) -dr $^ > $@
|
$(OBJDUMP) -dr $^ > $@
|
|
|
doorbell2: $(OBJDIR)/ $(OBJDIR)/doorbell2.o $(OBJDRVR) cmod.ld
|
doorbell: $(OBJDIR)/doorbell.o cmod.ld
|
$(CC) $(LDFLAGS) $(OBJDIR)/doorbell2.o $(OBJDRVR) -o $@
|
$(CC) $(LDFLAGS) $(OBJDIR)/doorbell.o -o $@
|
|
|
|
doorbell2: $(OBJDIR)/doorbell2.o $(OBJDRVR) $(OBJDIR)/string.o cmod.ld
|
|
$(CC) $(LDFLAGS) $(OBJDIR)/doorbell2.o $(OBJDRVR) $(OBJDIR)/string.o -o $@
|
$(OBJDIR)/doorbell2.txt: doorbell2
|
$(OBJDIR)/doorbell2.txt: doorbell2
|
$(OBJDUMP) -dr $^ > $@
|
$(OBJDUMP) -dr $^ > $@
|
|
|
kptest: $(OBJDIR)/ $(OBJDIR)/kptest.o $(OBJDRVR) cmod.ld
|
KPSRCS := kptest.c keypad.c txfns.c
|
$(CC) $(LDFLAGS) $(OBJDIR)/kptest.o $(OBJDRVR) -o $@
|
KPOBJS := $(addprefix $(OBJDIR)/,$(subst .c,.o,$(KPSRCS)))
|
|
kptest: $(KPOBJS) cmod.ld
|
|
$(CC) $(LDFLAGS) $(KPOBJS) -o $@
|
$(OBJDIR)/kptest.txt: kptest
|
$(OBJDIR)/kptest.txt: kptest
|
$(OBJDUMP) -dr $^ > $@
|
$(OBJDUMP) -dr $^ > $@
|
|
|
|
blinky: $(OBJDIR)/blinky.o cmod.ld
|
|
$(CC) $(LDFLAGS) $(OBJDIR)/blinky.o -o $@
|
|
|
|
define mk-objdir
|
|
@bash -c "if [ ! -e $(OBJDIR) ]; then mkdir -p $(OBJDIR); fi"
|
|
endef
|
|
|
define build-depends
|
define build-depends
|
@echo "Building dependency file(s)"
|
@echo "Building dependency file(s)"
|
$(CC) $(CPPFLAGS) -MM $(SOURCES) > $(OBJDIR)/xdep.txt
|
$(CC) $(CPPFLAGS) -MM $(SOURCES) > $(OBJDIR)/xdep.txt
|
$(SED) -e 's/^.*.o: /$(OBJDIR)\/&/' < $(OBJDIR)/xdep.txt > $(OBJDIR)/depends.txt
|
$(SED) -e 's/^.*.o: /$(OBJDIR)\/&/' < $(OBJDIR)/xdep.txt > $(OBJDIR)/depends.txt
|
@rm $(OBJDIR)/xdep.txt
|
@rm $(OBJDIR)/xdep.txt
|