forked from z88dk/z88dk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
272 lines (216 loc) · 8.12 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
#
#
# The impromptu compilation makefile for z88dk
#
# $Id: Makefile,v 1.57 2016-09-09 09:06:07 dom Exp $
#
# ---> Configurable parameters are below his point
# EXESUFFIX is passed when cross-compiling Win32 on Linux
ifeq ($(OS),Windows_NT)
EXESUFFIX := .exe
else
EXESUFFIX ?=
endif
PREFIX ?= /usr/local
prefix_share = $(PREFIX)/share/z88dk
bin_dir = $(PREFIX)/bin
git_rev ?= $(shell git rev-parse --short HEAD)
git_count ?= $(shell git rev-list --count HEAD)
version ?= $(shell date +%Y%m%d)
INSTALL ?= install
CFLAGS ?= -O2
CC ?= gcc
# Prefix for executables (eg z88dk-, hence z88dk-z80asm, z88dk-copt etc)
CROSS ?= 0
OCC := $(CC)
ifneq (, $(shell which ccache))
CC := ccache $(CC)
endif
Z88DK_PATH = $(shell pwd)
SDCC_PATH = $(Z88DK_PATH)/src/sdcc-build
SDCC_VERSION = 13131
ifdef BUILD_SDCC
ifdef BUILD_SDCC_HTTP
SDCC_DEPS = zsdcc_r$(SDCC_VERSION)_src.tar.gz
endif
endif
# --> End of Configurable Options
export CC INSTALL CFLAGS CROSS
BINS = bin/z88dk-appmake$(EXESUFFIX) bin/z88dk-copt$(EXESUFFIX) \
bin/z88dk-ucpp$(EXESUFFIX) bin/z88dk-sccz80$(EXESUFFIX) bin/z88dk-z80asm$(EXESUFFIX) \
bin/zcc$(EXESUFFIX) bin/z88dk-zpragma$(EXESUFFIX) bin/z88dk-zx7$(EXESUFFIX) \
bin/z88dk-z80nm$(EXESUFFIX) bin/z88dk-zobjcopy$(EXESUFFIX) \
bin/z88dk-ticks$(EXESUFFIX) bin/z88dk-z80svg$(EXESUFFIX) \
bin/z88dk-font2pv1000$(EXESUFFIX) bin/z88dk-basck$(EXESUFFIX) \
bin/z88dk-lib$(EXESUFFIX) bin/z88dk-zx0$(EXESUFFIX)
ALL = $(BINS) testsuite
ALL_EXT = bin/z88dk-zsdcc$(EXESUFFIX)
.PHONY: all
all: $(ALL) $(ALL_EXT)
src/config.h:
$(shell if [ "${git_count}" != "" ]; then \
echo '#define PREFIX "${prefix_share}"' > src/config.h; \
echo '#define BINDIR "${bin_dir}"' >> src/config.h; \
echo '#define UNIX 1' >> src/config.h; \
echo '#define Z88DK_VERSION "${git_count}-${git_rev}-${version}"' >> src/config.h; \
fi)
$(shell if [ ! -f src/config.h ]; then \
echo '#define PREFIX "${prefix_share}"' > src/config.h; \
echo '#define BINDIR "${bin_dir}"' >> src/config.h; \
echo '#define UNIX 1' >> src/config.h; \
echo '#define Z88DK_VERSION "unknown-unknown-${version}"' >> src/config.h; \
fi)
@mkdir -p bin
$(SDCC_PATH)/configure: $(SDCC_DEPS)
ifdef BUILD_SDCC
ifdef BUILD_SDCC_HTTP
tar xzf $^
touch $@
else
svn checkout -r $(SDCC_VERSION) https://svn.code.sf.net/p/sdcc/code/trunk/sdcc -q $(SDCC_PATH)
patch -d $(SDCC_PATH) -p0 < $(Z88DK_PATH)/src/zsdcc/sdcc-z88dk.patch
endif
endif
zsdcc_r$(SDCC_VERSION)_src.tar.gz:
curl http://nightly.z88dk.org/zsdcc/zsdcc_r$(SDCC_VERSION)_src.tar.gz -o zsdcc_r$(SDCC_VERSION)_src.tar.gz
# Helper rule to build the zsdcc tarball for ci builds
zsdcc-tarball: $(SDCC_PATH)/configure
@mkdir -p dist
tar --exclude=.svn -cvzf dist/zsdcc_r$(SDCC_VERSION)_src.tar.gz src/sdcc-build
$(SDCC_PATH)/Makefile: $(SDCC_PATH)/configure
ifdef BUILD_SDCC
cd $(SDCC_PATH) && CC=$(OCC) ./configure \
--disable-ds390-port --disable-ds400-port \
--disable-hc08-port --disable-s08-port --disable-mcs51-port \
--disable-pic-port --disable-pic14-port --disable-pic16-port \
--disable-tlcs90-port --disable-xa51-port --disable-stm8-port \
--disable-pdk13-port --disable-pdk14-port \
--disable-pdk15-port --disable-pdk16-port \
--disable-mos6502-port --disable-mos65c02-port \
--disable-r2k-port \
--disable-ucsim --disable-device-lib --disable-packihx
endif
$(SDCC_PATH)/bin/sdcc$(EXESUFFIX): $(SDCC_PATH)/Makefile
ifdef BUILD_SDCC
$(MAKE) -C $(SDCC_PATH)
endif
bin/z88dk-zsdcc$(EXESUFFIX): $(SDCC_PATH)/bin/sdcc$(EXESUFFIX)
ifdef BUILD_SDCC
cp $(SDCC_PATH)/bin/sdcc$(EXESUFFIX) $(Z88DK_PATH)/bin/z88dk-zsdcc$(EXESUFFIX)
cp $(SDCC_PATH)/bin/sdcpp$(EXESUFFIX) $(Z88DK_PATH)/bin/z88dk-zsdcpp$(EXESUFFIX)
endif
bin/z88dk-appmake$(EXESUFFIX): src/config.h
$(MAKE) -C src/appmake PREFIX=`pwd` install
bin/z88dk-copt$(EXESUFFIX): src/config.h
$(MAKE) -C src/copt PREFIX=`pwd` install
bin/z88dk-ucpp$(EXESUFFIX): src/config.h
$(MAKE) -C src/ucpp PREFIX=`pwd` install
bin/z88dk-sccz80$(EXESUFFIX): src/config.h
$(MAKE) -C src/sccz80 PREFIX=`pwd` install
bin/z88dk-z80asm$(EXESUFFIX): src/config.h
$(MAKE) -C src/z80asm PREFIX=`pwd` PREFIX_SHARE=`pwd` install
bin/zcc$(EXESUFFIX): src/config.h
$(MAKE) -C src/zcc PREFIX=`pwd` install
bin/z88dk-zpragma$(EXESUFFIX): src/config.h
$(MAKE) -C src/zpragma PREFIX=`pwd` install
bin/z88dk-zx7$(EXESUFFIX): src/config.h
$(MAKE) -C src/zx7 PREFIX=`pwd` install
bin/z88dk-zx0$(EXESUFFIX): src/config.h
$(MAKE) -C src/zx0 PREFIX=`pwd` install
bin/z88dk-z80nm$(EXESUFFIX): src/config.h
$(MAKE) -C src/z80nm PREFIX=`pwd` install
bin/z88dk-zobjcopy$(EXESUFFIX): src/config.h
$(MAKE) -C src/zobjcopy PREFIX=`pwd` install
bin/z88dk-z80svg$(EXESUFFIX): src/config.h
$(MAKE) -C support/graphics PREFIX=`pwd` install
bin/z88dk-basck$(EXESUFFIX): src/config.h
$(MAKE) -C support/basck PREFIX=`pwd` install
bin/z88dk-font2pv1000$(EXESUFFIX): src/config.h
$(MAKE) -C support/pv1000 PREFIX=`pwd` install
bin/z88dk-ticks$(EXESUFFIX): src/config.h
$(MAKE) -C src/ticks PREFIX=`pwd` install
bin/z88dk-lib$(EXESUFFIX): src/config.h
$(MAKE) -C src/z88dk-lib PREFIX=`pwd` install
libs: $(BINS)
$(MAKE) -C libsrc
$(MAKE) -C libsrc install
install: install-clean
mkdir -p $(DESTDIR)$(PREFIX)/bin $(DESTDIR)$(prefix_share)/lib $(DESTDIR)$(prefix_share)/src
$(MAKE) -C src/appmake PREFIX=$(DESTDIR)$(PREFIX) install
$(MAKE) -C src/copt PREFIX=$(DESTDIR)$(PREFIX) install
$(MAKE) -C src/ucpp PREFIX=$(DESTDIR)$(PREFIX) install
$(MAKE) -C src/sccz80 PREFIX=$(DESTDIR)$(PREFIX) install
$(MAKE) -C src/z80asm PREFIX=$(DESTDIR)$(PREFIX) PREFIX_SHARE=$(DESTDIR)$(prefix_share) install
$(MAKE) -C src/zcc PREFIX=$(DESTDIR)$(PREFIX) install
$(MAKE) -C src/zpragma PREFIX=$(DESTDIR)$(PREFIX) install
$(MAKE) -C src/zx7 PREFIX=$(DESTDIR)$(PREFIX) install
$(MAKE) -C src/zx0 PREFIX=$(DESTDIR)$(PREFIX) install
$(MAKE) -C src/z80nm PREFIX=$(DESTDIR)$(PREFIX) install
$(MAKE) -C src/zobjcopy PREFIX=$(DESTDIR)$(PREFIX) install
$(MAKE) -C src/ticks PREFIX=$(DESTDIR)$(PREFIX) install
$(MAKE) -C src/z88dk-lib PREFIX=$(DESTDIR)$(PREFIX) install
$(MAKE) -C support/graphics PREFIX=$(DESTDIR)$(PREFIX) install
$(MAKE) -C support/basck PREFIX=$(DESTDIR)$(PREFIX) install
$(MAKE) -C support/pv1000 PREFIX=$(DESTDIR)$(PREFIX) install
cp -r support/cmake $(DESTDIR)$(prefix_share)/
if [ -f bin/z88dk-zsdcpp$(EXESUFFIX) ]; then cp bin/z88dk-zsdcpp$(EXESUFFIX) $(DESTDIR)$(PREFIX)/bin/; fi
if [ -f bin/z88dk-zsdcc$(EXESUFFIX) ]; then cp bin/z88dk-zsdcc$(EXESUFFIX) $(DESTDIR)$(PREFIX)/bin/; fi
cp -r include $(DESTDIR)$(prefix_share)/
cp -r lib $(DESTDIR)$(prefix_share)/
cp -r libsrc $(DESTDIR)$(prefix_share)/
cp -r src/m4 $(DESTDIR)$(prefix_share)/src/
install-clean:
$(MAKE) -C libsrc install-clean
$(RM) lib/z80asm*.lib
# BSD install syntax below
#find include -type d -exec $(INSTALL) -d -m 755 {,$(prefix_share)/}{} \;
#find include -type f -exec $(INSTALL) -m 664 {,$(prefix_share)/}{} \;
#find lib -type d -exec $(INSTALL) -d -m 755 {,$(prefix_share)/}{} \;
#find lib -type f -exec $(INSTALL) -m 664 {,$(prefix_share)/}{} \;
#find libsrc -type d -exec $(INSTALL) -d -m 755 {,$(prefix_share)/}{} \;
#find libsrc -type f -exec $(INSTALL) -m 664 {,$(prefix_share)/}{} \;
# Needs to have a dependency on libs
test: $(ALL)
$(MAKE) -C test
testsuite: $(BINS)
ifeq ($(CROSS),0)
$(MAKE) -C testsuite
endif
clean: bins-clean
$(MAKE) -C libsrc clean
$(RM) lib/clibs/*.lib
$(RM) lib/z80asm*.lib
bins-clean:
$(MAKE) -C src/appmake clean
$(MAKE) -C src/common clean
$(MAKE) -C src/copt clean
$(MAKE) -C src/sccz80 clean
$(MAKE) -C src/ticks clean
$(MAKE) -C src/ucpp clean
$(MAKE) -C src/z80asm clean
$(MAKE) -C src/z80nm clean
$(MAKE) -C src/z88dk-lib clean
$(MAKE) -C src/zcc clean
$(MAKE) -C src/zobjcopy clean
$(MAKE) -C src/zpragma clean
$(MAKE) -C src/zx7 clean
$(MAKE) -C src/zx0 clean
$(MAKE) -C examples clean
$(MAKE) -C support clean
$(MAKE) -C test clean
$(MAKE) -C testsuite clean
$(MAKE) -C src/z88dk-lib clean
$(RM) -r $(SDCC_PATH)
ifdef BUILD_SDCC
ifdef BUILD_SDCC_HTTP
$(RM) $(SDCC_DEPS)
endif
endif
#if [ -d bin ]; then find bin -type f -exec rm -f {} ';' ; fi
test-clean:
$(MAKE) -C test clean
testsuite-clean:
$(MAKE) -C testsuite clean
examples-clean:
$(MAKE) -C examples clean
.PHONY: test testsuite