| 1 |
111 |
dgisselq |
################################################################################
|
| 2 |
|
|
#
|
| 3 |
|
|
# Filename: Makefile
|
| 4 |
|
|
#
|
| 5 |
|
|
# Project: Zip CPU -- a small, lightweight, RISC CPU soft core
|
| 6 |
|
|
#
|
| 7 |
|
|
# Purpose: This makefile attempts to build the ZipCPU toolchain. This
|
| 8 |
|
|
# includes binutils and GCC. (Eventually, it will include the
|
| 9 |
202 |
dgisselq |
# standard library as well ...) Configuration options for binutils, GCC,
|
| 10 |
|
|
# and newlib can be found (and set) in the gas-script.sh, gcc-script.sh,
|
| 11 |
|
|
# and nlib-script.sh files respectively.
|
| 12 |
111 |
dgisselq |
#
|
| 13 |
|
|
# Targets:
|
| 14 |
|
|
#
|
| 15 |
|
|
# make all:
|
| 16 |
202 |
dgisselq |
# Includes the install target, but also the pdf documentation
|
| 17 |
|
|
# files that come with binutils and gcc. Building this target
|
| 18 |
|
|
# will require a LaTeX distribution in addition to the needs of
|
| 19 |
|
|
# the other targets. Since the PDFs can be found on line,
|
| 20 |
|
|
# building them is not really necessary, but may be quite useful.
|
| 21 |
111 |
dgisselq |
#
|
| 22 |
202 |
dgisselq |
# make install
|
| 23 |
|
|
# Attempts to build binutils, gcc, and newlib, and to install
|
| 24 |
|
|
# them into the local install directory.
|
| 25 |
|
|
#
|
| 26 |
|
|
# This is the default target
|
| 27 |
|
|
#
|
| 28 |
|
|
# make binutils
|
| 29 |
|
|
# make gcc
|
| 30 |
|
|
# make newlib
|
| 31 |
|
|
# Builds the respective packages
|
| 32 |
|
|
#
|
| 33 |
|
|
# make binutils-install
|
| 34 |
|
|
# make gcc-install
|
| 35 |
|
|
# make newlib-install
|
| 36 |
|
|
# Installs the respective packages into the install directory,
|
| 37 |
|
|
# building them first if necessary.
|
| 38 |
|
|
#
|
| 39 |
111 |
dgisselq |
# make clean
|
| 40 |
202 |
dgisselq |
# Removes all build products--to include the source directories
|
| 41 |
|
|
# that are built from patched tarballs.
|
| 42 |
111 |
dgisselq |
#
|
| 43 |
|
|
#
|
| 44 |
|
|
# Creator: Dan Gisselquist, Ph.D.
|
| 45 |
|
|
# Gisselquist Technology, LLC
|
| 46 |
|
|
#
|
| 47 |
|
|
################################################################################
|
| 48 |
|
|
#
|
| 49 |
202 |
dgisselq |
# Copyright (C) 2015-2017, Gisselquist Technology, LLC
|
| 50 |
111 |
dgisselq |
#
|
| 51 |
|
|
# This program is free software (firmware): you can redistribute it and/or
|
| 52 |
|
|
# modify it under the terms of the GNU General Public License as published
|
| 53 |
|
|
# by the Free Software Foundation, either version 3 of the License, or (at
|
| 54 |
|
|
# your option) any later version.
|
| 55 |
|
|
#
|
| 56 |
|
|
# This program is distributed in the hope that it will be useful, but WITHOUT
|
| 57 |
|
|
# ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
|
| 58 |
|
|
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
| 59 |
|
|
# for more details.
|
| 60 |
|
|
#
|
| 61 |
|
|
# License: GPL, v3, as defined and found on www.gnu.org,
|
| 62 |
|
|
# http://www.gnu.org/licenses/gpl.html
|
| 63 |
|
|
#
|
| 64 |
|
|
#
|
| 65 |
|
|
################################################################################
|
| 66 |
|
|
#
|
| 67 |
202 |
dgisselq |
.PHONY: all basic-install install build
|
| 68 |
|
|
install: basic-install
|
| 69 |
111 |
dgisselq |
all: basic-install binutils-pdf-install gcc-pdf-install
|
| 70 |
202 |
dgisselq |
basic-install: gas-install gcc-install newlib-install
|
| 71 |
|
|
build: gas gcc-all nlib
|
| 72 |
|
|
CC: gcc
|
| 73 |
94 |
dgisselq |
|
| 74 |
202 |
dgisselq |
BINUTILSD=binutils-2.27
|
| 75 |
|
|
GCCD=gcc-6.2.0
|
| 76 |
|
|
NLIBD=newlib-2.5.0
|
| 77 |
111 |
dgisselq |
INSTALL=`pwd`/install
|
| 78 |
|
|
PDFD=$(INSTALL)/usr/doc
|
| 79 |
94 |
dgisselq |
ZASMD=zasm
|
| 80 |
202 |
dgisselq |
BUILDGASD=build-gas
|
| 81 |
|
|
BUILDGCCD=build-gcc
|
| 82 |
|
|
BUILDNLIB=build-nlib
|
| 83 |
|
|
SUBMAKE=$(MAKE) --no-print-directory
|
| 84 |
|
|
ZIPINCD=$(INSTALL)/cross-tools/zip/include
|
| 85 |
94 |
dgisselq |
|
| 86 |
202 |
dgisselq |
$(BINUTILSD)-zip/nonce.txt: $(BINUTILSD).tar.bz2 gas-zippatch.patch
|
| 87 |
|
|
rm -rf $(BINUTILSD)-zip/
|
| 88 |
|
|
tar -xjf ./$(BINUTILSD).tar.bz2 --transform s,$(BINUTILSD),$(BINUTILSD)-zip,
|
| 89 |
|
|
-bash -c "cd $(BINUTILSD)-zip; patch -p1 <../gas-zippatch.patch"
|
| 90 |
111 |
dgisselq |
rm -rf $(BUILDGASD)
|
| 91 |
202 |
dgisselq |
touch $(BINUTILSD)-zip/nonce.txt
|
| 92 |
111 |
dgisselq |
|
| 93 |
202 |
dgisselq |
$(BUILDGASD)/nonce.txt: $(BINUTILSD)-zip/nonce.txt
|
| 94 |
114 |
dgisselq |
bash -c "if [ ! -e build-gas ]; then bash gas-script.sh; fi"
|
| 95 |
202 |
dgisselq |
touch $(BUILDGASD)/nonce.txt
|
| 96 |
94 |
dgisselq |
|
| 97 |
202 |
dgisselq |
.PHONY: binutils
|
| 98 |
|
|
binutils: $(BUILDGASD)/nonce.txt
|
| 99 |
|
|
$(SUBMAKE) --directory=$(BUILDGASD)
|
| 100 |
|
|
|
| 101 |
111 |
dgisselq |
.PHONY: binutils-install
|
| 102 |
|
|
binutils-install: binutils
|
| 103 |
202 |
dgisselq |
$(SUBMAKE) --directory=$(BUILDGASD) install
|
| 104 |
|
|
cp ../bench/zipsim.ld install/cross-tools/zip/lib/ldscripts
|
| 105 |
94 |
dgisselq |
|
| 106 |
111 |
dgisselq |
.PHONY: binutils-pdf
|
| 107 |
|
|
binutils-pdf: binutils
|
| 108 |
202 |
dgisselq |
$(SUBMAKE) --directory=$(BUILDGASD) pdf
|
| 109 |
111 |
dgisselq |
|
| 110 |
202 |
dgisselq |
$(PDFD)/:
|
| 111 |
|
|
bash -c "if [[ ! -d $(PDFD) ]]; then mkdir -p $(PDFD); fi"
|
| 112 |
|
|
|
| 113 |
|
|
.PHONY:
|
| 114 |
|
|
pdfd: $(PDFD)/
|
| 115 |
|
|
|
| 116 |
111 |
dgisselq |
.PHONY: binutils-pdf-install
|
| 117 |
202 |
dgisselq |
binutils-pdf-install: binutils-pdf $(PDFD)/
|
| 118 |
111 |
dgisselq |
find $(BUILDGASD) -name "*.pdf" -exec cp \{\} $(PDFD)/ \;
|
| 119 |
|
|
|
| 120 |
202 |
dgisselq |
.PHONY: gas
|
| 121 |
|
|
gas: binutils
|
| 122 |
111 |
dgisselq |
|
| 123 |
202 |
dgisselq |
.PHONY: gas-install
|
| 124 |
|
|
gas-install: binutils-install
|
| 125 |
|
|
|
| 126 |
|
|
# We can also set the environment variable DEJAGNU to point to our site .exp
|
| 127 |
|
|
# file.
|
| 128 |
|
|
gas-check: binutils-install
|
| 129 |
|
|
+$(SUBMAKE) --directory=$(BUILDGASD) check RUNTESTFLAGS="--target_board=zip-sim"
|
| 130 |
111 |
dgisselq |
#
|
| 131 |
|
|
#
|
| 132 |
|
|
# Now let's try the same thing for GCC
|
| 133 |
|
|
#
|
| 134 |
|
|
#
|
| 135 |
202 |
dgisselq |
$(GCCD)-zip/nonce.txt: $(GCCD).tar.bz2 gcc-zippatch.patch
|
| 136 |
|
|
rm -rf $(GCCD)-zip/
|
| 137 |
|
|
tar -xjf ./$(GCCD).tar.bz2 --transform s,$(GCCD),$(GCCD)-zip,
|
| 138 |
|
|
-bash -c "cd $(GCCD)-zip; patch -p1 <../gcc-zippatch.patch"
|
| 139 |
111 |
dgisselq |
rm -rf $(BUILDGCCD)
|
| 140 |
202 |
dgisselq |
touch $(GCCD)-zip/nonce.txt
|
| 141 |
|
|
|
| 142 |
|
|
$(GCCD)-zip/gcc/config/zip/genzipops.c: $(GCCD)-zip/nonce.txt
|
| 143 |
|
|
genzipops: $(GCCD)-zip/gcc/config/zip/genzipops.c $(GCCD)-zip/nonce.txt
|
| 144 |
|
|
$(CC) $< -o $@
|
| 145 |
|
|
$(GCCD)-zip/gcc/config/zip/zip-ops.md: genzipops
|
| 146 |
|
|
./genzipops $@
|
| 147 |
|
|
|
| 148 |
|
|
$(BUILDGCCD)/nonce.txt: $(GCCD)-zip/nonce.txt $(GCCD)-zip/gcc/config/zip/zip-ops.md gas-install
|
| 149 |
113 |
dgisselq |
bash -c "if [[ ! -e $(BUILDGCCD) ]]; then bash gcc-script.sh; fi"
|
| 150 |
202 |
dgisselq |
touch $(BUILDGCCD)/nonce.txt
|
| 151 |
111 |
dgisselq |
|
| 152 |
202 |
dgisselq |
#
|
| 153 |
|
|
#
|
| 154 |
|
|
# GCC must be done in two parts: The host files first, which don't depend
|
| 155 |
|
|
# upon a built compiler, and then all the libraries that depend upon the
|
| 156 |
|
|
# built compiler.
|
| 157 |
|
|
#
|
| 158 |
|
|
#
|
| 159 |
|
|
gcc-host: $(BUILDGCCD)/nonce.txt
|
| 160 |
|
|
+$(SUBMAKE) --directory=$(BUILDGCCD) all-host
|
| 161 |
|
|
.PHONY: zip-gcc
|
| 162 |
|
|
zip-gcc: gcc-host
|
| 163 |
|
|
|
| 164 |
|
|
gcc-install-host: $(BUILDGCCD)/nonce.txt gcc-host
|
| 165 |
|
|
+$(SUBMAKE) --directory=$(BUILDGCCD) install-host
|
| 166 |
|
|
|
| 167 |
|
|
.PHONY: zip-gcc-install
|
| 168 |
|
|
zip-gcc-install: gcc-install-host
|
| 169 |
|
|
|
| 170 |
|
|
$(INSTALL)/cross-tools/bin/zip-gcc: zip-gcc-install
|
| 171 |
|
|
|
| 172 |
|
|
$(INSTALL)/cross-tools/bin/zip-cc: zip-gcc-install
|
| 173 |
|
|
bash -c "cd $(INSTALL)/cross-tools/bin; if [[ ! -e zip-cc ]]; then ln -s zip-gcc zip-cc; fi"
|
| 174 |
|
|
|
| 175 |
|
|
.PHONY: gcc-pdf-install
|
| 176 |
|
|
#
|
| 177 |
|
|
#
|
| 178 |
|
|
# Now for the second part of GCC. This part depends upon newlib as well as
|
| 179 |
|
|
# GCC proper.
|
| 180 |
|
|
#
|
| 181 |
|
|
#
|
| 182 |
|
|
.PHONY: gcc
|
| 183 |
|
|
gcc: $(BUILDGCCD)/nonce.txt gas-install newlib-install
|
| 184 |
|
|
+$(SUBMAKE) --directory=$(BUILDGCCD)
|
| 185 |
|
|
|
| 186 |
111 |
dgisselq |
.PHONY: gcc-install
|
| 187 |
|
|
gcc-install: gcc
|
| 188 |
202 |
dgisselq |
+$(SUBMAKE) --directory=$(BUILDGCCD) install
|
| 189 |
111 |
dgisselq |
|
| 190 |
|
|
.PHONY: gcc-pdf
|
| 191 |
202 |
dgisselq |
gcc-pdf: $(BUILDGCCD)/nonce.txt
|
| 192 |
|
|
+$(SUBMAKE) --directory=$(BUILDGCCD) pdf
|
| 193 |
111 |
dgisselq |
|
| 194 |
202 |
dgisselq |
gcc-pdf-install: gcc-pdf $(PDFD)/
|
| 195 |
111 |
dgisselq |
find $(BUILDGCCD) -name "*.pdf" -exec cp \{\} $(PDFD)/ \;
|
| 196 |
|
|
|
| 197 |
|
|
#
|
| 198 |
|
|
#
|
| 199 |
202 |
dgisselq |
# And repeat for newlib
|
| 200 |
|
|
#
|
| 201 |
|
|
#
|
| 202 |
|
|
$(NLIBD)-zip/nonce.txt: $(NLIBD).tar.gz nlib-zippatch.patch
|
| 203 |
|
|
rm -rf $(NLIBD)-zip/
|
| 204 |
|
|
tar -xzf ./$(NLIBD).tar.gz --transform s,$(NLIBD),$(NLIBD)-zip,
|
| 205 |
|
|
-bash -c "cd $(NLIBD)-zip; patch -p1 <../nlib-zippatch.patch"
|
| 206 |
|
|
rm -rf $(BUILDNLIB)
|
| 207 |
|
|
touch $(NLIBD)-zip/nonce.txt
|
| 208 |
|
|
|
| 209 |
|
|
$(BUILDNLIB)/nonce.txt: $(NLIBD)-zip/nonce.txt $(BUILDGASD)/nonce.txt
|
| 210 |
|
|
bash nlib-script.sh
|
| 211 |
|
|
touch $(BUILDNLIB)/nonce.txt
|
| 212 |
|
|
|
| 213 |
|
|
.PHONY: newlib
|
| 214 |
|
|
newlib: $(BUILDNLIB)/nonce.txt zip-gcc-install
|
| 215 |
|
|
newlib: $(INSTALL)/cross-tools/bin/zip-cc
|
| 216 |
|
|
+$(SUBMAKE) --directory=$(BUILDNLIB)
|
| 217 |
|
|
|
| 218 |
|
|
.PHONY: newlib-install
|
| 219 |
|
|
newlib-install: newlib
|
| 220 |
|
|
+$(SUBMAKE) --directory=$(BUILDNLIB) install
|
| 221 |
|
|
|
| 222 |
|
|
|
| 223 |
|
|
# Some abbreviations for targets
|
| 224 |
|
|
.PHONY: nlib nlib-install
|
| 225 |
|
|
nlib: newlib
|
| 226 |
|
|
nlib-install: newlib-install
|
| 227 |
|
|
|
| 228 |
|
|
#
|
| 229 |
|
|
#
|
| 230 |
111 |
dgisselq |
# Finally, can we build and install zasm?
|
| 231 |
|
|
#
|
| 232 |
|
|
#
|
| 233 |
202 |
dgisselq |
# zasm:
|
| 234 |
|
|
# $(SUBMAKE) --directory=$(ZASMD) all
|
| 235 |
111 |
dgisselq |
|
| 236 |
202 |
dgisselq |
# zasm-install: zasm
|
| 237 |
|
|
# $(SUBMAKE) --directory=$(ZASMD) install
|
| 238 |
111 |
dgisselq |
|
| 239 |
|
|
#
|
| 240 |
|
|
#
|
| 241 |
|
|
# The clean target
|
| 242 |
|
|
#
|
| 243 |
|
|
#
|
| 244 |
|
|
.PHONY: clean
|
| 245 |
|
|
clean:
|
| 246 |
|
|
rm -rf $(INSTALL)
|
| 247 |
202 |
dgisselq |
rm -rf $(BINUTILSD)-zip/ $(GCCD)-zip/ $(NLIBD)-zip/
|
| 248 |
|
|
rm -rf $(BUILDGASD) $(BUILDGCCD) $(BUILDNLIB)
|
| 249 |
|
|
# $(SUBMAKE) --no-print-directory --directory=$(ZASMD) clean
|
| 250 |
111 |
dgisselq |
|