forked from GaryOderNichts/moonlight-wiiu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
261 lines (225 loc) · 9.13 KB
/
Dockerfile
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
# build wut
FROM devkitpro/devkitppc:20220531 AS wutbuild
ENV PATH=$DEVKITPPC/bin:$PATH
WORKDIR /
RUN git clone https://github.com/devkitPro/wut
WORKDIR /wut
RUN git checkout f1b5da996f4c4a58beb3d3ab93aa8e8b9f66e775
RUN make -j$(nproc)
RUN make install
WORKDIR /
# set up builder image
FROM devkitpro/devkitppc:20220531 AS builder
RUN apt-get update && apt-get -y install --no-install-recommends wget tar autoconf automake libtool && rm -rf /var/lib/apt/lists/*
COPY --from=wutbuild /opt/devkitpro/wut /opt/devkitpro/wut
# build SDL2
FROM builder AS sdlbuild
ENV WUT_ROOT=$DEVKITPRO/wut
RUN git clone -b wiiu-2.0.9 --single-branch https://github.com/yawut/SDL
WORKDIR /SDL
RUN mkdir build
WORKDIR /SDL/build
# Need to set CFLAGS manually for now until issues with SDL and wiiu-cmake get resolved
ENV CFLAGS="-mcpu=750 -meabi -mhard-float -ffunction-sections -fdata-sections -DESPRESSO -D__WIIU__ -D__WUT__ -O3"
RUN /opt/devkitpro/portlibs/wiiu/bin/powerpc-eabi-cmake .. -DCMAKE_INSTALL_PREFIX=$DEVKITPRO/portlibs/wiiu -DCMAKE_BUILD_TYPE=Release
RUN make -j$(nproc) && make install
WORKDIR /
# build openssl
FROM builder AS opensslbuild
ARG openssl_ver=1.1.1q
RUN wget https://www.openssl.org/source/openssl-$openssl_ver.tar.gz && mkdir /openssl && tar xf openssl-$openssl_ver.tar.gz -C /openssl --strip-components=1
WORKDIR /openssl
RUN echo 'diff --git a/Configurations/10-main.conf b/Configurations/10-main.conf\n\
index 61c6689..efe686a 100644\n\
--- a/Configurations/10-main.conf\n\
+++ b/Configurations/10-main.conf\n\
@@ -627,6 +627,27 @@ my %targets = (\n\
shared_extension => ".so",\n\
},\n\
\n\
+### Wii U target\n\
+ "wiiu" => {\n\
+ inherit_from => [ "BASE_unix" ],\n\
+ CC => "$ENV{DEVKITPPC}/bin/powerpc-eabi-gcc",\n\
+ CXX => "$ENV{DEVKITPPC}/bin/powerpc-eabi-g++",\n\
+ AR => "$ENV{DEVKITPPC}/bin/powerpc-eabi-ar",\n\
+ CFLAGS => picker(default => "-Wall",\n\
+ debug => "-O0 -g",\n\
+ release => "-O3"),\n\
+ CXXFLAGS => picker(default => "-Wall",\n\
+ debug => "-O0 -g",\n\
+ release => "-O3"),\n\
+ LDFLAGS => "-L$ENV{DEVKITPRO}/wut/lib",\n\
+ cflags => add("-mcpu=750 -meabi -mhard-float -ffunction-sections -fdata-sections"),\n\
+ cxxflags => add("-std=c++11"),\n\
+ lib_cppflags => "-DOPENSSL_USE_NODELETE -DB_ENDIAN -DNO_SYS_UN_H -DNO_SYSLOG -D__WIIU__ -D__WUT__ -I$ENV{DEVKITPRO}/wut/include",\n\
+ ex_libs => add("-lwut -lm"),\n\
+ bn_ops => "BN_LLONG RC4_CHAR",\n\
+ asm_arch => '"'"'ppc32'"'"',\n\
+ },\n\
+\n ####\n #### Variety of LINUX:-)\n ####\n\
diff --git a/crypto/rand/rand_unix.c b/crypto/rand/rand_unix.c\n\
index 0f45251..d303e8e 100644\n\
--- a/crypto/rand/rand_unix.c\n\
+++ b/crypto/rand/rand_unix.c\n\
@@ -202,6 +202,41 @@ void rand_pool_keep_random_devices_open(int keep)\n\
{\n\
}\n\
\n\
+# elif defined(__WIIU__)\n\
+\n\
+#include <coreinit/time.h>\n\
+\n\
+size_t rand_pool_acquire_entropy(RAND_POOL *pool)\n\
+{\n\
+ int i;\n\
+ size_t bytes_needed;\n\
+ unsigned char v;\n\
+\n\
+ bytes_needed = rand_pool_bytes_needed(pool, 4 /*entropy_factor*/);\n\
+\n\
+ for (i = 0; i < bytes_needed; i++) {\n\
+ srand(OSGetSystemTick());\n\
+ v = rand() & 0xff;\n\
+\n\
+ rand_pool_add(pool, &v, sizeof(v), 2);\n\
+ }\n\
+\n\
+ return rand_pool_entropy_available(pool);\n\
+}\n\
+\n\
+int rand_pool_init(void)\n\
+{\n\
+ return 1;\n\
+}\n\
+\n\
+void rand_pool_cleanup(void)\n\
+{\n\
+}\n\
+\n\
+void rand_pool_keep_random_devices_open(int keep)\n\
+{\n\
+}\n\
+\n # else\n\
\n # if defined(OPENSSL_RAND_SEED_EGD) && \\\n\
diff --git a/crypto/uid.c b/crypto/uid.c\n\
index a9eae36..4a81d98 100644\n\
--- a/crypto/uid.c\n\
+++ b/crypto/uid.c\n\
@@ -10,7 +10,7 @@\n #include <openssl/crypto.h>\n #include <openssl/opensslconf.h>\n\
\n\
-#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_UEFI)\n\
+#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_UEFI) || defined(__WIIU__)\n\
\n\
int OPENSSL_issetugid(void)\n\
{\
' >> wiiu.patch && git apply wiiu.patch
RUN ./Configure wiiu \
no-threads no-shared no-asm no-ui-console no-unit-test no-tests no-buildtest-c++ no-external-tests no-autoload-config \
--with-rand-seed=os -static
RUN make build_generated
RUN make libssl.a libcrypto.a -j$(nproc)
WORKDIR /
# build curl
FROM builder as curlbuild
ARG curl_ver=7.84.0
# copy in openssl
COPY --from=opensslbuild /openssl/libcrypto.a /openssl/libssl.a /opt/devkitpro/portlibs/wiiu/lib/
COPY --from=opensslbuild /openssl/include/openssl /opt/devkitpro/portlibs/wiiu/include/openssl/
COPY --from=opensslbuild /openssl/include/crypto /opt/devkitpro/portlibs/wiiu/include/crypto/
RUN wget https://curl.se/download/curl-$curl_ver.tar.gz && mkdir /curl && tar xf curl-$curl_ver.tar.gz -C /curl --strip-components=1
WORKDIR /curl
ENV CFLAGS "-mcpu=750 -meabi -mhard-float -O3 -ffunction-sections -fdata-sections"
ENV CXXFLAGS "${CFLAGS}"
ENV CPPFLAGS "-D__WIIU__ -D__WUT__ -I${DEVKITPRO}/wut/include"
ENV LDFLAGS "-L${DEVKITPRO}/wut/lib"
ENV LIBS "-lwut -lm"
RUN autoreconf -fi
RUN ./configure \
--prefix=$DEVKITPRO/portlibs/wiiu/ \
--host=powerpc-eabi \
--enable-static \
--disable-threaded-resolver \
--disable-pthreads \
--with-ssl=$DEVKITPRO/portlibs/wiiu/ \
--disable-ipv6 \
--disable-unix-sockets \
--disable-socketpair \
--disable-ntlm-wb \
CC=$DEVKITPPC/bin/powerpc-eabi-gcc \
AR=$DEVKITPPC/bin/powerpc-eabi-ar \
RANLIB=$DEVKITPPC/bin/powerpc-eabi-ranlib \
PKG_CONFIG=$DEVKITPRO/portlibs/wiiu/bin/powerpc-eabi-pkg-config
WORKDIR /curl/lib
RUN make -j$(nproc) install
WORKDIR /curl/include
RUN make -j$(nproc) install
WORKDIR /
FROM builder as expatbuild
ARG expat_tag=2_4_8
ARG expat_ver=2.4.8
RUN wget https://github.com/libexpat/libexpat/releases/download/R_$expat_tag/expat-$expat_ver.tar.gz && mkdir /expat && tar xf expat-$expat_ver.tar.gz -C /expat --strip-components=1
WORKDIR /expat
ENV CFLAGS "-mcpu=750 -meabi -mhard-float -O3 -ffunction-sections -fdata-sections"
ENV CXXFLAGS "${CFLAGS}"
ENV CPPFLAGS "-D__WIIU__ -D__WUT__ -I${DEVKITPRO}/wut/include"
ENV LDFLAGS "-L${DEVKITPRO}/wut/lib"
ENV LIBS "-lwut -lm"
RUN autoreconf -fi
RUN ./configure \
--prefix=$DEVKITPRO/portlibs/wiiu/ \
--host=powerpc-eabi \
--enable-static \
--without-examples \
--without-tests \
--without-docbook \
CC=$DEVKITPPC/bin/powerpc-eabi-gcc \
AR=$DEVKITPPC/bin/powerpc-eabi-ar \
RANLIB=$DEVKITPPC/bin/powerpc-eabi-ranlib \
PKG_CONFIG=$DEVKITPRO/portlibs/wiiu/bin/powerpc-eabi-pkg-config
RUN make -j$(nproc) && make install
WORKDIR /
FROM builder as opusbuild
ARG opus_ver=1.1.2
RUN wget https://github.com/xiph/opus/releases/download/v$opus_ver/opus-$opus_ver.tar.gz && mkdir /opus && tar xf opus-$opus_ver.tar.gz -C /opus --strip-components=1
WORKDIR /opus
ENV CFLAGS "-mcpu=750 -meabi -mhard-float -O3 -ffunction-sections -fdata-sections"
ENV CXXFLAGS "${CFLAGS}"
ENV CPPFLAGS "-D__WIIU__ -D__WUT__ -I${DEVKITPRO}/wut/include"
ENV LDFLAGS "-L${DEVKITPRO}/wut/lib"
ENV LIBS "-lwut -lm"
RUN ./configure \
--prefix=$DEVKITPRO/portlibs/wiiu/ \
--host=powerpc-eabi \
--enable-static \
--disable-doc \
--disable-extra-programs \
CC=$DEVKITPPC/bin/powerpc-eabi-gcc \
AR=$DEVKITPPC/bin/powerpc-eabi-ar \
RANLIB=$DEVKITPPC/bin/powerpc-eabi-ranlib \
PKG_CONFIG=$DEVKITPRO/portlibs/wiiu/bin/powerpc-eabi-pkg-config \
CFLAGS="$CFLAGS -Wno-expansion-to-defined"
RUN make -j$(nproc) && make install
# build final container
FROM devkitpro/devkitppc:20220531 AS final
# copy in wut
COPY --from=wutbuild /opt/devkitpro/wut /opt/devkitpro/wut
# copy in SDL2
COPY --from=sdlbuild /opt/devkitpro/portlibs/wiiu/lib/libSDL2.a /opt/devkitpro/portlibs/wiiu/lib/
COPY --from=sdlbuild /opt/devkitpro/portlibs/wiiu/include/SDL2 /opt/devkitpro/portlibs/wiiu/include/SDL2/
# copy in openssl
COPY --from=opensslbuild /openssl/libcrypto.a /openssl/libssl.a /opt/devkitpro/portlibs/wiiu/lib/
COPY --from=opensslbuild /openssl/include/openssl /opt/devkitpro/portlibs/wiiu/include/openssl/
COPY --from=opensslbuild /openssl/include/crypto /opt/devkitpro/portlibs/wiiu/include/crypto/
# copy in curl
COPY --from=curlbuild /opt/devkitpro/portlibs/wiiu/lib/libcurl.a /opt/devkitpro/portlibs/wiiu/lib/
COPY --from=curlbuild /opt/devkitpro/portlibs/wiiu/include/curl /opt/devkitpro/portlibs/wiiu/include/curl/
# copy in expat
COPY --from=expatbuild /opt/devkitpro/portlibs/wiiu/lib/libexpat.a /opt/devkitpro/portlibs/wiiu/lib/
COPY --from=expatbuild /opt/devkitpro/portlibs/wiiu/include/expat.h /opt/devkitpro/portlibs/wiiu/include/expat.h
COPY --from=expatbuild /opt/devkitpro/portlibs/wiiu/include/expat_config.h /opt/devkitpro/portlibs/wiiu/include/expat_config.h
COPY --from=expatbuild /opt/devkitpro/portlibs/wiiu/include/expat_external.h /opt/devkitpro/portlibs/wiiu/include/expat_external.h
# copy in opus
COPY --from=opusbuild /opt/devkitpro/portlibs/wiiu/lib/libopus.a /opt/devkitpro/portlibs/wiiu/lib/
COPY --from=opusbuild /opt/devkitpro/portlibs/wiiu/include/opus /opt/devkitpro/portlibs/wiiu/include/opus/
WORKDIR /project