Line 1... |
Line 1... |
################################################################################
|
################################################################################
|
#
|
##
|
# 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: This makefile attempts to build the ZipCPU toolchain. This
|
## Purpose: This makefile attempts to build the ZipCPU toolchain. This
|
# includes binutils and GCC. (Eventually, it will include the
|
## includes binutils and GCC. (Eventually, it will include the
|
# standard library as well ...) Configuration options for binutils, GCC,
|
## standard library as well ...) Configuration options for binutils, GCC,
|
# and newlib can be found (and set) in the gas-script.sh, gcc-script.sh,
|
## and newlib can be found (and set) in the gas-script.sh, gcc-script.sh,
|
# and nlib-script.sh files respectively.
|
## and nlib-script.sh files respectively.
|
#
|
##
|
# Targets:
|
## Targets:
|
#
|
##
|
# make all:
|
## make all:
|
# Includes the install target, but also the pdf documentation
|
## Includes the install target, but also the pdf documentation
|
# files that come with binutils and gcc. Building this target
|
## files that come with binutils and gcc. Building this target
|
# will require a LaTeX distribution in addition to the needs of
|
## will require a LaTeX distribution in addition to the needs of
|
# the other targets. Since the PDFs can be found on line,
|
## the other targets. Since the PDFs can be found on line,
|
# building them is not really necessary, but may be quite useful.
|
## building them is not really necessary, but may be quite useful.
|
#
|
##
|
# make install
|
## make install
|
# Attempts to build binutils, gcc, and newlib, and to install
|
## Attempts to build binutils, gcc, and newlib, and to install
|
# them into the local install directory.
|
## them into the local install directory.
|
#
|
##
|
# This is the default target
|
## This is the default target
|
#
|
##
|
# make binutils
|
## make binutils
|
# make gcc
|
## make gcc
|
# make newlib
|
## make newlib
|
# Builds the respective packages
|
## Builds the respective packages
|
#
|
##
|
# make binutils-install
|
## make binutils-install
|
# make gcc-install
|
## make gcc-install
|
# make newlib-install
|
## make newlib-install
|
# Installs the respective packages into the install directory,
|
## Installs the respective packages into the install directory,
|
# building them first if necessary.
|
## building them first if necessary.
|
#
|
##
|
# make clean
|
## make clean
|
# Removes all build products--to include the source directories
|
## Removes all build products--to include the source directories
|
# that are built from patched tarballs.
|
## that are built from patched tarballs.
|
#
|
##
|
#
|
##
|
# Creator: Dan Gisselquist, Ph.D.
|
## Creator: Dan Gisselquist, Ph.D.
|
# Gisselquist Technology, LLC
|
## Gisselquist Technology, LLC
|
#
|
##
|
################################################################################
|
################################################################################
|
#
|
##
|
# Copyright (C) 2015-2017, Gisselquist Technology, LLC
|
## Copyright (C) 2015-2017, 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.
|
#
|
##
|
# License: GPL, v3, as defined and found on www.gnu.org,
|
## You should have received a copy of the GNU General Public License along
|
# http://www.gnu.org/licenses/gpl.html
|
## 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
|
#
|
## for a copy.
|
|
##
|
|
## License: GPL, v3, as defined and found on www.gnu.org,
|
|
## http://www.gnu.org/licenses/gpl.html
|
|
##
|
|
##
|
################################################################################
|
################################################################################
|
#
|
##
|
|
##
|
.PHONY: all basic-install install build
|
.PHONY: all basic-install install build
|
install: basic-install
|
install: basic-install
|
all: basic-install binutils-pdf-install gcc-pdf-install
|
all: basic-install binutils-pdf-install gcc-pdf-install
|
basic-install: gas-install gcc-install newlib-install
|
basic-install: gas-install gcc-install newlib-install
|
build: gas gcc-all nlib
|
build: gas gcc-all nlib
|
CC: gcc
|
CC: gcc
|
|
|
BINUTILSD=binutils-2.27
|
BINUTILSD:=binutils-2.27
|
GCCD=gcc-6.2.0
|
GCCD:=gcc-6.2.0
|
NLIBD=newlib-2.5.0
|
NLIBD:=newlib-2.5.0
|
INSTALL=`pwd`/install
|
export INSTALLD:=$(shell pwd)/install
|
PDFD=$(INSTALL)/usr/doc
|
export PATH:=$(PATH):$(INSTALLD)/cross-tools/bin
|
|
PDFD=$(INSTALLD)/usr/doc
|
ZASMD=zasm
|
ZASMD=zasm
|
BUILDGASD=build-gas
|
BUILDGASD:=build-gas
|
BUILDGCCD=build-gcc
|
BUILDGCCD:=build-gcc
|
BUILDNLIB=build-nlib
|
BUILDNLIB:=build-nlib
|
SUBMAKE=$(MAKE) --no-print-directory
|
TARGETGCC:=$(INSTALL)/cross-tools/bin/zip-gcc
|
ZIPINCD=$(INSTALL)/cross-tools/zip/include
|
SUBMAKE:=$(MAKE) --no-print-directory
|
|
ZIPINCD=$(INSTALLD)/cross-tools/zip/include
|
|
|
$(BINUTILSD)-zip/nonce.txt: $(BINUTILSD).tar.bz2 gas-zippatch.patch
|
$(BINUTILSD)-zip/nonce.txt: $(BINUTILSD).tar.bz2 gas-zippatch.patch
|
rm -rf $(BINUTILSD)-zip/
|
rm -rf $(BINUTILSD)-zip/
|
tar -xjf ./$(BINUTILSD).tar.bz2 --transform s,$(BINUTILSD),$(BINUTILSD)-zip,
|
tar -xjf ./$(BINUTILSD).tar.bz2 --transform s,$(BINUTILSD),$(BINUTILSD)-zip,
|
-bash -c "cd $(BINUTILSD)-zip; patch -p1 <../gas-zippatch.patch"
|
-bash -c "cd $(BINUTILSD)-zip; patch -p1 <../gas-zippatch.patch"
|
Line 95... |
Line 103... |
touch $(BUILDGASD)/nonce.txt
|
touch $(BUILDGASD)/nonce.txt
|
|
|
.PHONY: binutils
|
.PHONY: binutils
|
binutils: $(BUILDGASD)/nonce.txt
|
binutils: $(BUILDGASD)/nonce.txt
|
$(SUBMAKE) --directory=$(BUILDGASD)
|
$(SUBMAKE) --directory=$(BUILDGASD)
|
|
@echo "Binutils package build complete"
|
|
|
.PHONY: binutils-install
|
.PHONY: binutils-install
|
binutils-install: binutils
|
binutils-install: binutils
|
$(SUBMAKE) --directory=$(BUILDGASD) install
|
$(SUBMAKE) --directory=$(BUILDGASD) install
|
cp ../bench/zipsim.ld install/cross-tools/zip/lib/ldscripts
|
cp ../bench/zipsim.ld install/cross-tools/zip/lib/ldscripts
|
|
bash -c "if [[ ! -f $(BUILDGASD)/install-nonce.txt ]]; then touch $(BUILDGASD)/install-nonce.txt; fi"
|
|
@echo "Binutils installed"
|
|
|
.PHONY: binutils-pdf
|
.PHONY: binutils-pdf
|
binutils-pdf: binutils
|
binutils-pdf: binutils
|
$(SUBMAKE) --directory=$(BUILDGASD) pdf
|
$(SUBMAKE) --directory=$(BUILDGASD) pdf
|
|
@echo "Binutils pdfs made"
|
|
|
$(PDFD)/:
|
.PHONY: pdfd
|
bash -c "if [[ ! -d $(PDFD) ]]; then mkdir -p $(PDFD); fi"
|
pdfd:
|
|
$(mk-pdfd)
|
.PHONY:
|
|
pdfd: $(PDFD)/
|
define mk-pdfd
|
|
@bash -c "if [[ ! -d $(PDFD) ]]; then mkdir -p $(PDFD); fi"
|
|
endef
|
|
|
.PHONY: binutils-pdf-install
|
.PHONY: binutils-pdf-install
|
binutils-pdf-install: binutils-pdf $(PDFD)/
|
binutils-pdf-install: binutils-pdf pdfd
|
find $(BUILDGASD) -name "*.pdf" -exec cp \{\} $(PDFD)/ \;
|
find $(BUILDGASD) -name "*.pdf" -exec cp \{\} $(PDFD)/ \;
|
|
@echo "Binutils pdfs installed"
|
|
|
.PHONY: gas
|
.PHONY: gas
|
gas: binutils
|
gas: binutils
|
|
|
.PHONY: gas-install
|
.PHONY: gas-install
|
gas-install: binutils-install
|
gas-install: binutils-install
|
|
|
|
$(BUILDGASD)/install-nonce.txt: binutils-install
|
|
|
|
|
# We can also set the environment variable DEJAGNU to point to our site .exp
|
# We can also set the environment variable DEJAGNU to point to our site .exp
|
# file.
|
# file.
|
gas-check: binutils-install
|
gas-check: binutils-install
|
+$(SUBMAKE) --directory=$(BUILDGASD) check RUNTESTFLAGS="--target_board=zip-sim"
|
+$(SUBMAKE) --directory=$(BUILDGASD) check RUNTESTFLAGS="--target_board=zip-sim"
|
#
|
#
|
#
|
#
|
# Now let's try the same thing for GCC
|
# Now let's try the same thing for GCC
|
#
|
#
|
#
|
#
|
|
$(GCCD)-zip/nonce.txt: $(BUILDGASD)/install-nonce.txt
|
$(GCCD)-zip/nonce.txt: $(GCCD).tar.bz2 gcc-zippatch.patch
|
$(GCCD)-zip/nonce.txt: $(GCCD).tar.bz2 gcc-zippatch.patch
|
rm -rf $(GCCD)-zip/
|
rm -rf $(GCCD)-zip/
|
tar -xjf ./$(GCCD).tar.bz2 --transform s,$(GCCD),$(GCCD)-zip,
|
tar -xjf ./$(GCCD).tar.bz2 --transform s,$(GCCD),$(GCCD)-zip,
|
-bash -c "cd $(GCCD)-zip; patch -p1 <../gcc-zippatch.patch"
|
-bash -c "cd $(GCCD)-zip; patch -p1 <../gcc-zippatch.patch"
|
rm -rf $(BUILDGCCD)
|
rm -rf $(BUILDGCCD)
|
Line 143... |
Line 162... |
genzipops: $(GCCD)-zip/gcc/config/zip/genzipops.c $(GCCD)-zip/nonce.txt
|
genzipops: $(GCCD)-zip/gcc/config/zip/genzipops.c $(GCCD)-zip/nonce.txt
|
$(CC) $< -o $@
|
$(CC) $< -o $@
|
$(GCCD)-zip/gcc/config/zip/zip-ops.md: genzipops
|
$(GCCD)-zip/gcc/config/zip/zip-ops.md: genzipops
|
./genzipops $@
|
./genzipops $@
|
|
|
$(BUILDGCCD)/nonce.txt: $(GCCD)-zip/nonce.txt $(GCCD)-zip/gcc/config/zip/zip-ops.md gas-install
|
$(BUILDGCCD)/nonce.txt: $(BUILDGASD)/install-nonce.txt
|
|
$(BUILDGCCD)/nonce.txt: $(GCCD)-zip/nonce.txt $(GCCD)-zip/gcc/config/zip/zip-ops.md
|
bash -c "if [[ ! -e $(BUILDGCCD) ]]; then bash gcc-script.sh; fi"
|
bash -c "if [[ ! -e $(BUILDGCCD) ]]; then bash gcc-script.sh; fi"
|
touch $(BUILDGCCD)/nonce.txt
|
touch $(BUILDGCCD)/nonce.txt
|
|
|
#
|
#
|
#
|
#
|
Line 156... |
Line 176... |
# built compiler.
|
# built compiler.
|
#
|
#
|
#
|
#
|
gcc-host: $(BUILDGCCD)/nonce.txt
|
gcc-host: $(BUILDGCCD)/nonce.txt
|
+$(SUBMAKE) --directory=$(BUILDGCCD) all-host
|
+$(SUBMAKE) --directory=$(BUILDGCCD) all-host
|
|
@echo "GCC package build complete"
|
.PHONY: zip-gcc
|
.PHONY: zip-gcc
|
zip-gcc: gcc-host
|
zip-gcc: gcc-host
|
|
|
gcc-install-host: $(BUILDGCCD)/nonce.txt gcc-host
|
gcc-install-host: $(BUILDGCCD)/nonce.txt gcc-host
|
+$(SUBMAKE) --directory=$(BUILDGCCD) install-host
|
+$(SUBMAKE) --directory=$(BUILDGCCD) install-host
|
|
@bash -c "if [[ ! -f $(BUILDGCCD)/install-nonce.txt ]]; then touch $(BUILDGCCD)/install-nonce.txt; fi"
|
|
@echo "GCC package installed"
|
|
|
.PHONY: zip-gcc-install
|
.PHONY: zip-gcc-install
|
zip-gcc-install: gcc-install-host
|
zip-gcc-install: gcc-install-host
|
|
|
$(INSTALL)/cross-tools/bin/zip-gcc: zip-gcc-install
|
$(INSTALLD)/cross-tools/bin/zip-gcc: zip-gcc-install
|
|
$(BUILDGCCD)/install-nonce.txt: zip-gcc-install
|
|
|
$(INSTALL)/cross-tools/bin/zip-cc: zip-gcc-install
|
$(INSTALLD)/cross-tools/bin/zip-cc: zip-gcc-install
|
bash -c "cd $(INSTALL)/cross-tools/bin; if [[ ! -e zip-cc ]]; then ln -s zip-gcc zip-cc; fi"
|
bash -c "cd $(INSTALLD)/cross-tools/bin; if [[ ! -e zip-cc ]]; then ln -s zip-gcc zip-cc; fi"
|
|
|
.PHONY: gcc-pdf-install
|
.PHONY: gcc-pdf-install
|
#
|
#
|
#
|
#
|
# Now for the second part of GCC. This part depends upon newlib as well as
|
# Now for the second part of GCC. This part depends upon newlib as well as
|
# GCC proper.
|
# GCC proper.
|
#
|
#
|
#
|
#
|
.PHONY: gcc
|
.PHONY: gcc
|
gcc: $(BUILDGCCD)/nonce.txt gas-install newlib-install
|
gcc: $(BUILDGASD)/install-nonce.txt
|
|
gcc: $(BUILDNLIB)/install-nonce.txt
|
|
gcc: $(BUILDGCCD)/nonce.txt
|
+$(SUBMAKE) --directory=$(BUILDGCCD)
|
+$(SUBMAKE) --directory=$(BUILDGCCD)
|
|
|
.PHONY: gcc-install
|
.PHONY: gcc-install
|
gcc-install: gcc
|
gcc-install: gcc
|
+$(SUBMAKE) --directory=$(BUILDGCCD) install
|
+$(SUBMAKE) --directory=$(BUILDGCCD) install
|
|
@echo "GCC installed"
|
|
|
.PHONY: gcc-pdf
|
.PHONY: gcc-pdf
|
gcc-pdf: $(BUILDGCCD)/nonce.txt
|
gcc-pdf: $(BUILDGCCD)/nonce.txt
|
+$(SUBMAKE) --directory=$(BUILDGCCD) pdf
|
+$(SUBMAKE) --directory=$(BUILDGCCD) pdf
|
|
@echo "GCC documentation built"
|
|
|
gcc-pdf-install: gcc-pdf $(PDFD)/
|
gcc-pdf-install: gcc-pdf $(PDFD)/
|
find $(BUILDGCCD) -name "*.pdf" -exec cp \{\} $(PDFD)/ \;
|
find $(BUILDGCCD) -name "*.pdf" -exec cp \{\} $(PDFD)/ \;
|
|
@echo "GCC documentation/pdfs installed"
|
|
|
#
|
#
|
#
|
#
|
# And repeat for newlib
|
# And repeat for newlib
|
#
|
#
|
#
|
#
|
|
$(NLIBD)-zip/nonce.txt: $(BUILDGCCD)/install-nonce.txt
|
$(NLIBD)-zip/nonce.txt: $(NLIBD).tar.gz nlib-zippatch.patch
|
$(NLIBD)-zip/nonce.txt: $(NLIBD).tar.gz nlib-zippatch.patch
|
rm -rf $(NLIBD)-zip/
|
rm -rf $(NLIBD)-zip/
|
tar -xzf ./$(NLIBD).tar.gz --transform s,$(NLIBD),$(NLIBD)-zip,
|
tar -xzf ./$(NLIBD).tar.gz --transform s,$(NLIBD),$(NLIBD)-zip,
|
-bash -c "cd $(NLIBD)-zip; patch -p1 <../nlib-zippatch.patch"
|
-bash -c "cd $(NLIBD)-zip; patch -p1 <../nlib-zippatch.patch"
|
rm -rf $(BUILDNLIB)
|
rm -rf $(BUILDNLIB)
|
Line 209... |
Line 239... |
$(BUILDNLIB)/nonce.txt: $(NLIBD)-zip/nonce.txt $(BUILDGASD)/nonce.txt
|
$(BUILDNLIB)/nonce.txt: $(NLIBD)-zip/nonce.txt $(BUILDGASD)/nonce.txt
|
bash nlib-script.sh
|
bash nlib-script.sh
|
touch $(BUILDNLIB)/nonce.txt
|
touch $(BUILDNLIB)/nonce.txt
|
|
|
.PHONY: newlib
|
.PHONY: newlib
|
newlib: $(BUILDNLIB)/nonce.txt zip-gcc-install
|
newlib: $(BUILDGCCD)/install-nonce.txt
|
newlib: $(INSTALL)/cross-tools/bin/zip-cc
|
newlib: $(BUILDNLIB)/nonce.txt
|
|
newlib: $(INSTALLD)/cross-tools/bin/zip-cc
|
+$(SUBMAKE) --directory=$(BUILDNLIB)
|
+$(SUBMAKE) --directory=$(BUILDNLIB)
|
|
@echo "Newlib build complete"
|
|
|
.PHONY: newlib-install
|
.PHONY: newlib-install
|
newlib-install: newlib
|
newlib-install: newlib
|
+$(SUBMAKE) --directory=$(BUILDNLIB) install
|
+$(SUBMAKE) --directory=$(BUILDNLIB) install
|
|
@bash -c "if [[ ! -f $(BUILDNLIB)/install-nonce.txt ]]; then touch $(BUILDNLIB)/install-nonce.txt; fi"
|
|
@echo "Newlib installed"
|
|
|
|
|
# Some abbreviations for targets
|
# Some abbreviations for targets
|
.PHONY: nlib nlib-install
|
.PHONY: nlib nlib-install
|
nlib: newlib
|
nlib: newlib
|
nlib-install: newlib-install
|
nlib-install: newlib-install
|
|
$(BUILDNLIB)/install-nonce.txt: newlib-install
|
|
|
#
|
#
|
#
|
#
|
# Finally, can we build and install zasm?
|
# Finally, can we build and install zasm?
|
#
|
#
|
Line 241... |
Line 276... |
# The clean target
|
# The clean target
|
#
|
#
|
#
|
#
|
.PHONY: clean
|
.PHONY: clean
|
clean:
|
clean:
|
rm -rf $(INSTALL)
|
rm -rf $(INSTALLD)/cros-tools/bin/zip-*
|
rm -rf $(BINUTILSD)-zip/ $(GCCD)-zip/ $(NLIBD)-zip/
|
rm -rf $(BINUTILSD)-zip/ $(GCCD)-zip/ $(NLIBD)-zip/
|
rm -rf $(BUILDGASD) $(BUILDGCCD) $(BUILDNLIB)
|
rm -rf $(BUILDGASD) $(BUILDGCCD) $(BUILDNLIB)
|
# $(SUBMAKE) --no-print-directory --directory=$(ZASMD) clean
|
# $(SUBMAKE) --no-print-directory --directory=$(ZASMD) clean
|
|
|