OpenCores
URL https://opencores.org/ocsvn/zipcpu/zipcpu/trunk

Subversion Repositories zipcpu

[/] [zipcpu/] [trunk/] [sw/] [Makefile] - Blame information for rev 209

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 111 dgisselq
################################################################################
2 209 dgisselq
##
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
##      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
##
13
## Targets:
14
##
15
##      make all:
16
##              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
##
22
##      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
##      make clean
40
##              Removes all build products--to include the source directories
41
##              that are built from patched tarballs.
42
##
43
##
44
## Creator:     Dan Gisselquist, Ph.D.
45
##              Gisselquist Technology, LLC
46
##
47 111 dgisselq
################################################################################
48 209 dgisselq
##
49
## Copyright (C) 2015-2017, Gisselquist Technology, LLC
50
##
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
## You should have received a copy of the GNU General Public License along
62
## with this program.  (It's in the $(ROOT)/doc directory.  Run make with no
63
## target there if the PDF file isn't present.)  If not, see
64
##  for a copy.
65
##
66
## License:     GPL, v3, as defined and found on www.gnu.org,
67
##              http://www.gnu.org/licenses/gpl.html
68
##
69
##
70 111 dgisselq
################################################################################
71 209 dgisselq
##
72
##
73 202 dgisselq
.PHONY: all basic-install install build
74
install: basic-install
75 111 dgisselq
all: basic-install binutils-pdf-install gcc-pdf-install
76 202 dgisselq
basic-install: gas-install gcc-install newlib-install
77
build: gas gcc-all nlib
78
CC: gcc
79 94 dgisselq
 
80 209 dgisselq
BINUTILSD:=binutils-2.27
81
GCCD:=gcc-6.2.0
82
NLIBD:=newlib-2.5.0
83
export INSTALLD:=$(shell pwd)/install
84
export PATH:=$(PATH):$(INSTALLD)/cross-tools/bin
85
PDFD=$(INSTALLD)/usr/doc
86 94 dgisselq
ZASMD=zasm
87 209 dgisselq
BUILDGASD:=build-gas
88
BUILDGCCD:=build-gcc
89
BUILDNLIB:=build-nlib
90
TARGETGCC:=$(INSTALL)/cross-tools/bin/zip-gcc
91
SUBMAKE:=$(MAKE) --no-print-directory
92
ZIPINCD=$(INSTALLD)/cross-tools/zip/include
93 94 dgisselq
 
94 202 dgisselq
$(BINUTILSD)-zip/nonce.txt: $(BINUTILSD).tar.bz2 gas-zippatch.patch
95
        rm -rf $(BINUTILSD)-zip/
96
        tar -xjf ./$(BINUTILSD).tar.bz2 --transform s,$(BINUTILSD),$(BINUTILSD)-zip,
97
        -bash -c "cd $(BINUTILSD)-zip; patch -p1 <../gas-zippatch.patch"
98 111 dgisselq
        rm -rf $(BUILDGASD)
99 202 dgisselq
        touch $(BINUTILSD)-zip/nonce.txt
100 111 dgisselq
 
101 202 dgisselq
$(BUILDGASD)/nonce.txt: $(BINUTILSD)-zip/nonce.txt
102 114 dgisselq
        bash -c "if [ ! -e build-gas ]; then bash gas-script.sh; fi"
103 202 dgisselq
        touch $(BUILDGASD)/nonce.txt
104 94 dgisselq
 
105 202 dgisselq
.PHONY: binutils
106
binutils: $(BUILDGASD)/nonce.txt
107
        $(SUBMAKE) --directory=$(BUILDGASD)
108 209 dgisselq
        @echo "Binutils package build complete"
109 202 dgisselq
 
110 111 dgisselq
.PHONY: binutils-install
111
binutils-install: binutils
112 202 dgisselq
        $(SUBMAKE) --directory=$(BUILDGASD) install
113
        cp ../bench/zipsim.ld install/cross-tools/zip/lib/ldscripts
114 209 dgisselq
        bash -c "if [[ ! -f $(BUILDGASD)/install-nonce.txt ]]; then touch $(BUILDGASD)/install-nonce.txt; fi"
115
        @echo "Binutils installed"
116 94 dgisselq
 
117 111 dgisselq
.PHONY: binutils-pdf
118
binutils-pdf: binutils
119 202 dgisselq
        $(SUBMAKE) --directory=$(BUILDGASD) pdf
120 209 dgisselq
        @echo "Binutils pdfs made"
121 111 dgisselq
 
122 209 dgisselq
.PHONY: pdfd
123
pdfd:
124
        $(mk-pdfd)
125 202 dgisselq
 
126 209 dgisselq
define mk-pdfd
127
        @bash -c "if [[ ! -d $(PDFD) ]]; then mkdir -p $(PDFD); fi"
128
endef
129 202 dgisselq
 
130 111 dgisselq
.PHONY: binutils-pdf-install
131 209 dgisselq
binutils-pdf-install: binutils-pdf pdfd
132 111 dgisselq
        find $(BUILDGASD) -name "*.pdf" -exec cp \{\} $(PDFD)/ \;
133 209 dgisselq
        @echo "Binutils pdfs installed"
134 111 dgisselq
 
135 202 dgisselq
.PHONY: gas
136
gas: binutils
137 111 dgisselq
 
138 202 dgisselq
.PHONY: gas-install
139
gas-install: binutils-install
140
 
141 209 dgisselq
$(BUILDGASD)/install-nonce.txt: binutils-install
142
 
143
 
144 202 dgisselq
# We can also set the environment variable DEJAGNU to point to our site .exp
145
# file.
146
gas-check: binutils-install
147
        +$(SUBMAKE) --directory=$(BUILDGASD) check RUNTESTFLAGS="--target_board=zip-sim"
148 111 dgisselq
#
149
#
150
# Now let's try the same thing for GCC
151
#
152
#
153 209 dgisselq
$(GCCD)-zip/nonce.txt: $(BUILDGASD)/install-nonce.txt
154 202 dgisselq
$(GCCD)-zip/nonce.txt: $(GCCD).tar.bz2 gcc-zippatch.patch
155
        rm -rf $(GCCD)-zip/
156
        tar -xjf ./$(GCCD).tar.bz2 --transform s,$(GCCD),$(GCCD)-zip,
157
        -bash -c "cd $(GCCD)-zip; patch -p1 <../gcc-zippatch.patch"
158 111 dgisselq
        rm -rf $(BUILDGCCD)
159 202 dgisselq
        touch $(GCCD)-zip/nonce.txt
160
 
161
$(GCCD)-zip/gcc/config/zip/genzipops.c: $(GCCD)-zip/nonce.txt
162
genzipops: $(GCCD)-zip/gcc/config/zip/genzipops.c $(GCCD)-zip/nonce.txt
163
        $(CC) $< -o $@
164
$(GCCD)-zip/gcc/config/zip/zip-ops.md: genzipops
165
        ./genzipops $@
166
 
167 209 dgisselq
$(BUILDGCCD)/nonce.txt: $(BUILDGASD)/install-nonce.txt
168
$(BUILDGCCD)/nonce.txt: $(GCCD)-zip/nonce.txt $(GCCD)-zip/gcc/config/zip/zip-ops.md
169 113 dgisselq
        bash -c "if [[ ! -e $(BUILDGCCD) ]]; then bash gcc-script.sh; fi"
170 202 dgisselq
        touch $(BUILDGCCD)/nonce.txt
171 111 dgisselq
 
172 202 dgisselq
#
173
#
174
# GCC must be done in two parts: The host files first, which don't depend
175
# upon a built compiler, and then all the libraries that depend upon the
176
# built compiler.
177
#
178
#
179
gcc-host: $(BUILDGCCD)/nonce.txt
180
        +$(SUBMAKE) --directory=$(BUILDGCCD) all-host
181 209 dgisselq
        @echo "GCC package build complete"
182 202 dgisselq
.PHONY: zip-gcc
183
zip-gcc: gcc-host
184
 
185
gcc-install-host: $(BUILDGCCD)/nonce.txt gcc-host
186
        +$(SUBMAKE) --directory=$(BUILDGCCD) install-host
187 209 dgisselq
        @bash -c "if [[ ! -f $(BUILDGCCD)/install-nonce.txt ]]; then touch $(BUILDGCCD)/install-nonce.txt; fi"
188
        @echo "GCC package installed"
189 202 dgisselq
 
190
.PHONY: zip-gcc-install
191
zip-gcc-install: gcc-install-host
192
 
193 209 dgisselq
$(INSTALLD)/cross-tools/bin/zip-gcc: zip-gcc-install
194
$(BUILDGCCD)/install-nonce.txt: zip-gcc-install
195 202 dgisselq
 
196 209 dgisselq
$(INSTALLD)/cross-tools/bin/zip-cc: zip-gcc-install
197
        bash -c "cd $(INSTALLD)/cross-tools/bin; if [[ ! -e zip-cc ]]; then ln -s zip-gcc zip-cc; fi"
198 202 dgisselq
 
199
.PHONY: gcc-pdf-install
200
#
201
#
202
# Now for the second part of GCC.  This part depends upon newlib as well as
203
# GCC proper.
204
#
205
#
206
.PHONY: gcc
207 209 dgisselq
gcc: $(BUILDGASD)/install-nonce.txt
208
gcc: $(BUILDNLIB)/install-nonce.txt
209
gcc: $(BUILDGCCD)/nonce.txt
210 202 dgisselq
        +$(SUBMAKE) --directory=$(BUILDGCCD)
211
 
212 111 dgisselq
.PHONY: gcc-install
213
gcc-install: gcc
214 202 dgisselq
        +$(SUBMAKE) --directory=$(BUILDGCCD) install
215 209 dgisselq
        @echo "GCC installed"
216 111 dgisselq
 
217
.PHONY: gcc-pdf
218 202 dgisselq
gcc-pdf: $(BUILDGCCD)/nonce.txt
219
        +$(SUBMAKE) --directory=$(BUILDGCCD) pdf
220 209 dgisselq
        @echo "GCC documentation built"
221 111 dgisselq
 
222 202 dgisselq
gcc-pdf-install: gcc-pdf $(PDFD)/
223 111 dgisselq
        find $(BUILDGCCD) -name "*.pdf" -exec cp \{\} $(PDFD)/ \;
224 209 dgisselq
        @echo "GCC documentation/pdfs installed"
225 111 dgisselq
 
226
#
227
#
228 202 dgisselq
# And repeat for newlib
229
#
230
#
231 209 dgisselq
$(NLIBD)-zip/nonce.txt: $(BUILDGCCD)/install-nonce.txt
232 202 dgisselq
$(NLIBD)-zip/nonce.txt: $(NLIBD).tar.gz nlib-zippatch.patch
233
        rm -rf $(NLIBD)-zip/
234
        tar -xzf ./$(NLIBD).tar.gz --transform s,$(NLIBD),$(NLIBD)-zip,
235
        -bash -c "cd $(NLIBD)-zip; patch -p1 <../nlib-zippatch.patch"
236
        rm -rf $(BUILDNLIB)
237
        touch $(NLIBD)-zip/nonce.txt
238
 
239
$(BUILDNLIB)/nonce.txt: $(NLIBD)-zip/nonce.txt $(BUILDGASD)/nonce.txt
240
        bash nlib-script.sh
241
        touch $(BUILDNLIB)/nonce.txt
242
 
243
.PHONY: newlib
244 209 dgisselq
newlib: $(BUILDGCCD)/install-nonce.txt
245
newlib: $(BUILDNLIB)/nonce.txt
246
newlib: $(INSTALLD)/cross-tools/bin/zip-cc
247 202 dgisselq
        +$(SUBMAKE) --directory=$(BUILDNLIB)
248 209 dgisselq
        @echo "Newlib build complete"
249 202 dgisselq
 
250
.PHONY: newlib-install
251
newlib-install: newlib
252
        +$(SUBMAKE) --directory=$(BUILDNLIB) install
253 209 dgisselq
        @bash -c "if [[ ! -f $(BUILDNLIB)/install-nonce.txt ]]; then touch $(BUILDNLIB)/install-nonce.txt; fi"
254
        @echo "Newlib installed"
255 202 dgisselq
 
256
 
257
# Some abbreviations for targets
258
.PHONY: nlib nlib-install
259
nlib: newlib
260
nlib-install: newlib-install
261 209 dgisselq
$(BUILDNLIB)/install-nonce.txt: newlib-install
262 202 dgisselq
 
263
#
264
#
265 111 dgisselq
# Finally, can we build and install zasm?
266
#
267
#
268 202 dgisselq
# zasm:
269
#       $(SUBMAKE) --directory=$(ZASMD) all
270 111 dgisselq
 
271 202 dgisselq
# zasm-install: zasm
272
#       $(SUBMAKE) --directory=$(ZASMD) install
273 111 dgisselq
 
274
#
275
#
276
# The clean target
277
#
278
#
279
.PHONY: clean
280
clean:
281 209 dgisselq
        rm -rf $(INSTALLD)/cros-tools/bin/zip-*
282 202 dgisselq
        rm -rf $(BINUTILSD)-zip/ $(GCCD)-zip/ $(NLIBD)-zip/
283
        rm -rf $(BUILDGASD) $(BUILDGCCD) $(BUILDNLIB)
284
        # $(SUBMAKE) --no-print-directory --directory=$(ZASMD) clean
285 111 dgisselq
 

powered by: WebSVN 2.1.0

© copyright 1999-2021 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.