-
Notifications
You must be signed in to change notification settings - Fork 26
/
Makefile.in
235 lines (172 loc) · 5.87 KB
/
Makefile.in
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
# Copyright (c) 2015-2021 Damien Ciabrini
# This file is part of ngdevkit
#
# ngdevkit is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# ngdevkit is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with ngdevkit. If not, see <http://www.gnu.org/licenses/>.
include Makefile.config
# External subpackages
EMUDBG_GIT=https://github.com/dciabrin/emudbg
GNGEO_GIT=https://github.com/dciabrin/gngeo
TOOLCHAIN_GIT=https://github.com/dciabrin/ngdevkit-toolchain
EXAMPLES_GIT=https://github.com/dciabrin/ngdevkit-examples
# ------ base targets ------
# <all> and <install> may be extended with targets from
# toolchain, emudbg and gngeo if enabled
all: build-tools
install: install-tools install-pkgconfig
clean: clean-tools
clean:
rm -rf local/*
distclean: clean clean-pkgconfig
rm -rf build local config.log config.status
find . \( -name '*~' -or -name Makefile -or -name Makefile.config \) \
-exec rm {} \;
build local:
mkdir $@
.PHONY: clean distclean
# ------ toolchain (gcc, binutils, newlib, gdb) ------
ifeq ($(EXTERNAL_TOOLCHAIN), no)
build-tools: build-toolchain | $(prefix)/bin
distclean: distclean-toolchain
endif
download-toolchain: | toolchain
toolchain:
$(GIT) clone $(TOOLCHAIN_GIT) $@
build-toolchain: | download-toolchain build
$(MAKE) -Ctoolchain all BUILD=$(PWD)/build DESTDIR= prefix=$(prefix) EXTRA_BUILD_CMD='$(EXTRA_BUILD_CMD_TOOLCHAIN)' EXTRA_BUILD_FLAGS='$(EXTRA_BUILD_FLAGS_TOOLCHAIN)'
install-toolchain: $(prefix)/bin
$(prefix)/bin: build/ngbinutils build/nggcc build/nggdb build/ngnewlib build/ngsdcc
$(MAKE) -Ctoolchain install BUILD=$(PWD)/build DESTDIR= prefix=$(prefix) EXTRA_BUILD_CMD='$(EXTRA_BUILD_CMD_TOOLCHAIN)' EXTRA_BUILD_FLAGS='$(EXTRA_BUILD_FLAGS_TOOLCHAIN)'
distclean-toolchain:
rm -rf toolchain
# ------ ngdevkit ------
build-tools:
$(EXTRA_BUILD_CMD) && \
set -e; \
for i in nullsound nullbios runtime include tools; do \
$(MAKE) -C $$i; \
done
install-tools:
$(EXTRA_BUILD_CMD) && \
set -e; \
for i in nullsound nullbios runtime include tools; do \
$(MAKE) -C $$i install; \
done
install-pkgconfig:
$(INSTALL) -d $(DESTDIR)$(prefix)/share/pkgconfig && \
$(INSTALL) ngdevkit.pc $(DESTDIR)$(prefix)/share/pkgconfig
clean-tools:
set -e; \
for i in nullsound nullbios runtime include tools; do \
$(MAKE) -C $$i clean; \
done
clean-pkgconfig:
rm -f ngdevkit.pc
ifneq ($(EXAMPLES), no)
all: download-examples
distclean: distclean-examples
endif
download-examples: | examples
examples:
$(GIT) clone --recursive $(EXAMPLES_GIT) $@ && \
cd examples && autoreconf -iv
distclean-examples:
rm -rf examples
# ------ emudbg ------
ifeq ($(EXTERNAL_EMUDBG), no)
all: build-emudbg
build-gngeo: install-emudbg
install: install-emudbg
distclean: distclean-emudbg
endif
emudbg:
$(GIT) clone $(EMUDBG_GIT) $@ && \
cd emudbg && autoreconf -iv
build-emudbg: build/emudbg
build/emudbg: emudbg
@echo compiling emudbg...
CURPWD=$$(pwd) && \
$(EXTRA_BUILD_CMD) && \
mkdir -p build/emudbg && \
cd build/emudbg && \
$$CURPWD/emudbg/configure --prefix=$(prefix) \
$(EMUDBG_BUILD_FLAGS) -v && $(MAKE)
install-emudbg: $(prefix)/lib/libemudbg.a
$(prefix)/lib/libemudbg.a: build/emudbg
$(MAKE) -C build/emudbg install
distclean-emudbg:
rm -rf emudbg
# ------ gngeo ------
ifeq ($(EXTERNAL_GNGEO), no)
all: build-gngeo
install: install-gngeo
ifeq ($(ENABLE_MSYS2), yes)
install: install-gngeo-dll
install-gngeo-dll: install-gngeo
endif
distclean: distclean-gngeo
endif
ifeq ($(ENABLE_MSYS2), yes)
GNGEO=$(GNGEO_INSTALL_PATH)/ngdevkit-gngeo.exe
GNGEOPKGDATADIR=$(GNGEO_INSTALL_PATH)/share
else
GNGEO=$(prefix)/bin/ngdevkit-gngeo
GNGEOPKGDATADIR=$(prefix)/share/ngdevkit-gngeo
endif
gngeo:
$(GIT) clone --branch ngdevkit $(GNGEO_GIT) $@ && \
cd gngeo && autoreconf -iv $(GNGEO_ACLOCAL_PATH)
build-gngeo: build/gngeo
build-emulator-config: $(GNGEO_CFG)
build/gngeo: gngeo
@echo compiling gngeo...
CURPWD=$$(pwd) && \
$(EXTRA_BUILD_CMD) && \
mkdir -p build/gngeo && \
cd build/gngeo && \
$$CURPWD/gngeo/configure --program-prefix=ngdevkit- $(GNGEO_BUILD_FLAGS) \
CPPFLAGS="$$CPPFLAGS -Wno-implicit-function-declaration -I$(prefix)/include" CFLAGS="$$CFLAGS -Wno-implicit-function-declaration -I$(prefix)/include -DGNGEORC=\\\"ngdevkit-gngeorc\\\"" LDFLAGS="-L$(prefix)/lib" PKG_CONFIG_PATH="$(prefix)/lib/pkgconfig" \
-v && $(MAKE) -j1 pkgdatadir=$(GNGEOPKGDATADIR)
install-gngeo: $(GNGEO)
$(GNGEO): build/gngeo
$(MAKE) -C build/gngeo install pkgdatadir=$(GNGEOPKGDATADIR)
ifeq ($(ENABLE_MSYS2), yes)
install-gngeo-dll: build/gngeo
cp $(SDL2_DLL) $(ZLIB1_DLL) $(GLEW_DLL) $(GNGEO_INSTALL_PATH)
endif
$(GNGEO_CFG): export INPUT_SETTINGS:=$(GNGEO_DEFAULT_INPUT_SETTINGS)
$(GNGEO_CFG):
@ echo generating a default input config for gngeo; \
mkdir -p $(dir $(GNGEO_CFG)) && \
echo "$$INPUT_SETTINGS" > $(GNGEO_CFG)
distclean-gngeo:
rm -rf gngeo
# ------ Target to set up shell environment ------
SHELL_BIN_PATH := $(prefix)/bin
ifeq ($(ENABLE_MSYS2), yes)
ifeq ($(EXTERNAL_GNGEO), no)
ifneq ($(prefix),$(GNGEO_INSTALL_PATH))
SHELL_BIN_PATH := $(SHELL_BIN_PATH):$(GNGEO_INSTALL_PATH)
endif
endif
endif
shellinit:
@ echo Variables set with eval $$\(make shellinit\) >&2
@ echo export PATH="$(SHELL_BIN_PATH):\$$PATH"
@ echo export PKG_CONFIG_PATH="$(prefix)/share/pkgconfig:\$$PKG_CONFIG_PATH"
ifeq ($(shell uname), Darwin)
@ echo export DYLD_LIBRARY_PATH="$(prefix)/lib:\$$DYLD_LIBRARY_PATH"
else
@ echo export LD_LIBRARY_PATH="$(prefix)/lib:\$$LD_LIBRARY_PATH"
endif
@ echo export PYTHONPATH="$(prefix)/bin:\$$PYTHONPATH"