################################################################################
|
################################################################################
|
#
|
##
|
# Filename: Makefile
|
## Filename: Makefile
|
#
|
##
|
# Project: Zip CPU -- a small, lightweight, RISC CPU soft core
|
## Project: Zip CPU -- a small, lightweight, RISC CPU soft core
|
#
|
##
|
# Purpose: To direct and simplify the build of a variety of simple test
|
## Purpose: To direct and simplify the build of a variety of simple test
|
# programs which will use one (or both) of the ZipCPU simulators.
|
## programs which will use one (or both) of the ZipCPU simulators.
|
#
|
##
|
# Targets include:
|
## Targets include:
|
#
|
##
|
# helloworld
|
## helloworld
|
#
|
##
|
#
|
##
|
#
|
##
|
# Creator: Dan Gisselquist, Ph.D.
|
## Creator: Dan Gisselquist, Ph.D.
|
# Gisselquist Technology, LLC
|
## Gisselquist Technology, LLC
|
#
|
##
|
################################################################################
|
################################################################################
|
#
|
##
|
# Copyright (C) 2017, Gisselquist Technology, LLC
|
## Copyright (C) 2017-2019, Gisselquist Technology, LLC
|
#
|
##
|
# This program is free software (firmware): you can redistribute it and/or
|
## This program is free software (firmware): you can redistribute it and/or
|
# modify it under the terms of the GNU General Public License as published
|
## modify it under the terms of the GNU General Public License as published
|
# by the Free Software Foundation, either version 3 of the License, or (at
|
## by the Free Software Foundation, either version 3 of the License, or (at
|
# your option) any later version.
|
## your option) any later version.
|
#
|
##
|
# This program is distributed in the hope that it will be useful, but WITHOUT
|
## This program is distributed in the hope that it will be useful, but WITHOUT
|
# ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
|
## ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
|
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
# for more details.
|
## for more details.
|
#
|
##
|
# You should have received a copy of the GNU General Public License along
|
## You should have received a copy of the GNU General Public License along
|
# with this program. (It's in the $(ROOT)/doc directory. Run make with no
|
## with this program. (It's in the $(ROOT)/doc directory. Run make with no
|
# target there if the PDF file isn't present.) If not, see
|
## target there if the PDF file isn't present.) If not, see
|
# for a copy.
|
## for a copy.
|
#
|
##
|
# License: GPL, v3, as defined and found on www.gnu.org,
|
## License: GPL, v3, as defined and found on www.gnu.org,
|
# http://www.gnu.org/licenses/gpl.html
|
## http://www.gnu.org/licenses/gpl.html
|
#
|
##
|
#
|
##
|
################################################################################
|
################################################################################
|
#
|
##
|
|
##
|
.PHONY: all
|
.PHONY: all
|
all: helloworld
|
all: helloworld
|
|
|
CC := zip-gcc
|
CC := zip-gcc
|
OBJDUMP := zip-objdump
|
OBJDUMP := zip-objdump
|
OBJDIR := obj-zip
|
OBJDIR := obj-zip
|
CFLAGS := -O3
|
CFLAGS := -O3
|
LIBD := ../../sw/install/cross-tools/zip/lib
|
LIBD := ../../sw/install/cross-tools/zip/lib
|
LIBS := -L$(LIBD) -lzipbasic
|
LIBS := -L$(LIBD) -lzipbasic
|
SOURCES:= helloworld.c
|
SOURCES:= helloworld.c
|
LDSCRIPT:= ../zipsim.ld
|
LDSCRIPT:= ../zipsim.ld
|
|
|
$(OBJDIR)/%.o: %.c
|
$(OBJDIR)/%.o: %.c
|
$(CC) $(CFLAGS) -c $< -o $@
|
$(CC) $(CFLAGS) -c $< -o $@
|
|
|
helloworld: $(OBJDIR)/helloworld.o
|
helloworld: $(OBJDIR)/helloworld.o
|
$(CC) -T $(LDSCRIPT) $(CFLAGS) $(LIBD)/crt0.o $(LIBS) $< -o $@
|
$(CC) -T $(LDSCRIPT) $(CFLAGS) $(LIBD)/crt0.o $(LIBS) $< -o $@
|
|
|
helloworld.txt: helloworld
|
helloworld.txt: helloworld
|
$(OBJDUMP) -dr $< > $@
|
$(OBJDUMP) -dr $< > $@
|
|
|
define build-depends
|
define build-depends
|
$(CC) $(CFLAGS) -MM $(SOURCES) > $(OBJDIR)/xdepends.txt
|
$(CC) $(CFLAGS) -MM $(SOURCES) > $(OBJDIR)/xdepends.txt
|
sed -e 's/^.*.o: /$(OBJDIR)\/&/' < $(OBJDIR)/xdepends.txt > $(OBJDIR)/depends.txt
|
sed -e 's/^.*.o: /$(OBJDIR)\/&/' < $(OBJDIR)/xdepends.txt > $(OBJDIR)/depends.txt
|
@rm -f $(OBJDIR)/xdepends.txt
|
@rm -f $(OBJDIR)/xdepends.txt
|
endef
|
endef
|
|
|
tags: $(SOURCES)
|
tags: $(SOURCES)
|
@ctags $(SOURCES)
|
@ctags $(SOURCES)
|
|
|
.PHONY: depends
|
.PHONY: depends
|
depends: tags $(OBJDIR)/
|
depends: tags $(OBJDIR)/
|
$(build-depends)
|
$(build-depends)
|
|
|
$(OBJDIR)/:
|
$(OBJDIR)/:
|
@bash -c "if [[ ! -e $(OBJDIR) ]]; then mkdir -p $(OBJDIR)/; fi"
|
@bash -c "if [[ ! -e $(OBJDIR) ]]; then mkdir -p $(OBJDIR)/; fi"
|
|
|
.PHONY: clean
|
.PHONY: clean
|
clean:
|
clean:
|
rm -rf helloworld
|
rm -rf helloworld
|
|
|