| 1 |
22 |
dgisselq |
################################################################################
|
| 2 |
|
|
##
|
| 3 |
|
|
## Filename: Makefile
|
| 4 |
|
|
##
|
| 5 |
|
|
## Project: CMod S6 System on a Chip, ZipCPU demonstration project
|
| 6 |
|
|
##
|
| 7 |
|
|
## Purpose: To coordinate the build of a small ZipOS.
|
| 8 |
|
|
##
|
| 9 |
|
|
## Creator: Dan Gisselquist, Ph.D.
|
| 10 |
|
|
## Gisselquist Technology, LLC
|
| 11 |
|
|
##
|
| 12 |
|
|
################################################################################
|
| 13 |
|
|
##
|
| 14 |
|
|
## Copyright (C) 2015-2016, Gisselquist Technology, LLC
|
| 15 |
|
|
##
|
| 16 |
|
|
## This program is free software (firmware): you can redistribute it and/or
|
| 17 |
|
|
## modify it under the terms of the GNU General Public License as published
|
| 18 |
|
|
## by the Free Software Foundation, either version 3 of the License, or (at
|
| 19 |
|
|
## your option) any later version.
|
| 20 |
|
|
##
|
| 21 |
|
|
## This program is distributed in the hope that it will be useful, but WITHOUT
|
| 22 |
|
|
## ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
|
| 23 |
|
|
## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
| 24 |
|
|
## for more details.
|
| 25 |
|
|
##
|
| 26 |
|
|
## You should have received a copy of the GNU General Public License along
|
| 27 |
|
|
## with this program. (It's in the $(ROOT)/doc directory, run make with no
|
| 28 |
|
|
## target there if the PDF file isn't present.) If not, see
|
| 29 |
|
|
## for a copy.
|
| 30 |
|
|
##
|
| 31 |
|
|
## License: GPL, v3, as defined and found on www.gnu.org,
|
| 32 |
|
|
## http://www.gnu.org/licenses/gpl.html
|
| 33 |
|
|
##
|
| 34 |
|
|
##
|
| 35 |
|
|
################################################################################
|
| 36 |
|
|
##
|
| 37 |
|
|
##
|
| 38 |
|
|
all:
|
| 39 |
|
|
|
| 40 |
|
|
CROSS := zip-
|
| 41 |
|
|
CC := $(CROSS)gcc
|
| 42 |
|
|
AS := $(CROSS)as
|
| 43 |
|
|
OBJDUMP := $(CROSS)objdump
|
| 44 |
|
|
OBJDIR := obj-zip
|
| 45 |
|
|
DEVSRCSR:= display.c keypad.c rtcsim.c
|
| 46 |
|
|
DEVSRCS := $(addprefix ../dev/,$(DEVSRCSR))
|
| 47 |
|
|
DEVOBJS := $(addprefix $(OBJDIR)/,$(subst .c,.o,$(DEVSRCSR)))
|
| 48 |
27 |
dgisselq |
SOURCES := bootloader.c kernel.c ksetup.c syspipe.c pipesetup.c taskp.c doorbell.c zipsys.c # ziplib.c
|
| 49 |
22 |
dgisselq |
OBJECTS := $(addprefix $(OBJDIR)/,$(subst .c,.o,$(SOURCES))) $(DEVOBJS) $(OBJDIR)/resetdump.o
|
| 50 |
|
|
HEADERS := $(wildcard *.h) $(subst .c,.h,$(DEVSRCS))
|
| 51 |
|
|
# CFLAGS := -O3 -fdump-tree-all -Wall -Wextra -nostdlib -fno-builtin
|
| 52 |
27 |
dgisselq |
# CFLAGS := -O3 -fdump-rtl-all -DZIPOS -Wall -Wextra -nostdlib -fno-builtin
|
| 53 |
22 |
dgisselq |
CFLAGS := -O3 -DZIPOS -Wall -Wextra -nostdlib -fno-builtin
|
| 54 |
|
|
# CFLAGS := -Wall -Wextra -nostdlib -fno-builtin
|
| 55 |
27 |
dgisselq |
LDFLAGS := -T cmodram.ld -Wl,-Map,$(OBJDIR)/doorbell.map
|
| 56 |
22 |
dgisselq |
|
| 57 |
|
|
all: $(OBJDIR)/ doorbell
|
| 58 |
|
|
$(OBJDIR)/:
|
| 59 |
|
|
@bash -c "if [ ! -e $(OBJDIR) ]; then mkdir -p $(OBJDIR); fi"
|
| 60 |
|
|
|
| 61 |
|
|
%.o: $(OBJDIR)/%.o
|
| 62 |
|
|
$(CC) $(CFLAGS) -c $< -o $@
|
| 63 |
|
|
|
| 64 |
|
|
$(OBJDIR)/%.o: %.c
|
| 65 |
|
|
$(CC) $(CFLAGS) -c $< -o $@
|
| 66 |
|
|
|
| 67 |
|
|
$(OBJDIR)/%.o: ../dev/%.c
|
| 68 |
|
|
$(CC) $(CFLAGS) -c $< -o $@
|
| 69 |
|
|
|
| 70 |
|
|
$(OBJDIR)/%.txt: $(OBJDIR)/%.o
|
| 71 |
|
|
$(OBJDUMP) -d $^ -o $@
|
| 72 |
|
|
|
| 73 |
|
|
$(OBJDIR)/%.s: %.c
|
| 74 |
|
|
$(CC) -S $(CFLAGS) -c $< -o $@
|
| 75 |
|
|
|
| 76 |
|
|
$(OBJDIR)/resetdump.o: resetdump.s
|
| 77 |
|
|
$(AS) $^ -o $@
|
| 78 |
|
|
|
| 79 |
27 |
dgisselq |
doorbell: $(OBJECTS) cmodram.ld
|
| 80 |
22 |
dgisselq |
$(CC) $(LDFLAGS) $(OBJECTS) -o $@
|
| 81 |
|
|
|
| 82 |
|
|
$(OBJDIR)/doorbell.txt: doorbell
|
| 83 |
|
|
$(OBJDUMP) -d $^ > $@
|
| 84 |
|
|
|
| 85 |
|
|
define build-depends
|
| 86 |
|
|
@echo "Building dependency file(s)"
|
| 87 |
|
|
@$(CC) $(CPPFLAGS) -MM $(SOURCES) $(DEVSRCS) > $(OBJDIR)/xdepends.txt
|
| 88 |
|
|
@sed -e 's/^.*.o: /$(OBJDIR)\/&/' < $(OBJDIR)/xdepends.txt > $(OBJDIR)/depends.txt
|
| 89 |
|
|
@rm $(OBJDIR)/xdepends.txt
|
| 90 |
|
|
endef
|
| 91 |
|
|
|
| 92 |
|
|
.PHONY: depends
|
| 93 |
|
|
depends: $(OBJDIR)/ tags
|
| 94 |
|
|
$(build-depends)
|
| 95 |
|
|
|
| 96 |
|
|
tags: $(SOURCES) $(HEADERS)
|
| 97 |
|
|
@echo "Generating tags"
|
| 98 |
|
|
@ctags $(SOURCES) $(DEVSRCS) $(HEADERS)
|
| 99 |
|
|
|
| 100 |
|
|
.PHONY: clean
|
| 101 |
|
|
clean:
|
| 102 |
|
|
rm -rf $(OBJDIR)/ doorbell
|
| 103 |
|
|
|
| 104 |
|
|
-include $(OBJDIR)/depends.txt
|