-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
1848 lines (1671 loc) · 63 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
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Refer to the README file to understand how Fedora on RISC-V is
# bootstrapped.
# Absolute path to the current directory.
ROOT := $(shell pwd)
# Add host tools to the path.
PATH := $(ROOT)/host-tools/bin:$(PATH)
all: stage1 stage2 stage3 stage4
clean:
find -name '*~' -delete
rm -f stamp-*
rm -rf host-tools
rm -f riscv-linux/vmlinux
rm -rf stage3-chroot
rm -f $(STAGE3_DISK)
rm -f stage4-disk.img
#----------------------------------------------------------------------
# Stage 1
# riscv-qemu qemu-upstream-v8
RISCV_QEMU_COMMIT = b6e0a38a922005d4015e2fdb42e8a783b3cc8e41
RISCV_QEMU_SHORTCOMMIT = b6e0a38a
RISCV_QEMU_VERSION = 2.11.50
RISCV_QEMU_RELEASE = 0.10
stage1: stage1-riscv-qemu/riscv-qemu-$(RISCV_QEMU_SHORTCOMMIT).tar.gz \
stage1-riscv-qemu/keycodemapdb.tar.gz \
stage1-riscv-qemu/riscv-qemu.spec \
stage1-riscv-qemu/riscv-qemu-$(RISCV_QEMU_VERSION)-$(RISCV_QEMU_RELEASE).git$(RISCV_QEMU_SHORTCOMMIT).fc28.src.rpm \
stamp-riscv-qemu-installed
stage1-riscv-qemu/riscv-qemu-$(RISCV_QEMU_SHORTCOMMIT).tar.gz:
rm -f $@ $@-t
wget -O $@-t 'https://github.com/riscv/riscv-qemu/archive/$(RISCV_QEMU_COMMIT)/riscv-qemu-$(RISCV_QEMU_SHORTCOMMIT).tar.gz'
mv $@-t $@
# UGH
stage1-riscv-qemu/keycodemapdb.tar.gz:
rm -f $@ $@-t
wget -O $@-t 'https://git.qemu.org/?p=keycodemapdb.git;a=snapshot;h=a8bc2f6ec822491c2b816314352a9ae459456ec9;sf=tgz'
mv $@-t $@
stage1-riscv-qemu/riscv-qemu.spec: stage1-riscv-qemu/riscv-qemu.spec.in
rm -f $@
sed -e 's/@COMMIT@/$(RISCV_QEMU_COMMIT)/g' \
-e 's/@SHORTCOMMIT@/$(RISCV_QEMU_SHORTCOMMIT)/g' \
-e 's/@VERSION@/$(RISCV_QEMU_VERSION)/g' \
-e 's/@RELEASE@/$(RISCV_QEMU_RELEASE)/g' \
< $^ > $@-t
mv $@-t $@
stage1-riscv-qemu/riscv-qemu-$(RISCV_QEMU_VERSION)-$(RISCV_QEMU_RELEASE).git$(RISCV_QEMU_SHORTCOMMIT).fc28.src.rpm: stage1-riscv-qemu/riscv-qemu.spec
cd stage1-riscv-qemu && \
rpmbuild -bs --define "_sourcedir $(ROOT)/stage1-riscv-qemu" --define "_srcrpmdir $(ROOT)/stage1-riscv-qemu" riscv-qemu.spec
stamp-riscv-qemu-installed:
rm -f $@
@rpm -q riscv-qemu >/dev/null || { \
echo "ERROR: You must install riscv-qemu:"; \
echo; \
echo " dnf copr enable rjones/riscv"; \
echo " dnf install riscv-qemu"; \
echo; \
echo "OR: you can build it yourself from the stage1-riscv-qemu directory."; \
echo; \
exit 1; \
}
@qemu-system-riscv64 --version || { \
echo "ERROR: qemu-system-riscv is not working."; \
echo "Make sure you installed the riscv-qemu package."; \
exit 1; \
}
touch $@
#----------------------------------------------------------------------
# Stage 2
stage2: stage2-cross-tools/configure \
stage2-cross-tools/linux-headers/include/asm/auxvec.h \
host-tools/bin/riscv64-unknown-linux-gnu-gcc
stage2-cross-tools/configure:
cd stage2-cross-tools && autoconf
stage2-cross-tools/linux-headers/include/asm/auxvec.h:
cd riscv-linux && \
make headers_install \
ARCH=riscv \
INSTALL_HDR_PATH=$(ROOT)/stage2-cross-tools/linux-headers
host-tools/bin/riscv64-unknown-linux-gnu-gcc:
rm -f host-tools/bin/riscv64-unknown-linux-gnu-*
-make -C stage2-cross-tools clean
export GLIBC_TARGET_FLAGS_EXTRA="--enable-obsolete-nsl --enable-obsolete-rpc"; \
cd stage2-cross-tools && \
./configure --prefix=$(ROOT)/host-tools
export GLIBC_TARGET_FLAGS_EXTRA="--enable-obsolete-nsl --enable-obsolete-rpc"; \
cd stage2-cross-tools && \
$(MAKE) linux
# The versions of riscv64-unknown-linux-{gcc,g++} built above
# are (possibly) broken in that they require an explicit --sysroot
# parameter.
#
# Work around that using a wrapper.
#
# Note this should only be used when building stage3.
cd host-tools/bin && \
for f in gcc g++; do \
t=riscv64-unknown-linux-gnu-$$f; \
mv $$t $$t.real; \
echo $(ROOT)/host-tools/bin/$$t.real --sysroot=$(ROOT)/stage3-chroot '"$$@"' > $$t; \
chmod 0755 $$t; \
done
cd host-tools/bin && \
ln -sf riscv64-unknown-linux-gnu-gcc riscv64-unknown-linux-gnu-cc
cd host-tools/bin && \
ln -sf riscv64-unknown-linux-gnu-g++ riscv64-unknown-linux-gnu-c++
#----------------------------------------------------------------------
# Stage 3
# You can set STAGE3_DISK in your environment in order to
# use multiple disks for doing builds of different packages
# in parallel. eg.
# export STAGE3_DISK=systemd-disk.img
# make stage3 # builds systemd-disk.img
# make boot-stage3-in-qemu # boots systemd-disk.img
STAGE3_DISK ?= stage3-disk.img
# The root packages (plus their dependencies) that we want to in the
# stage 3 chroot. This must include all the cross-compiled packages
# below, and may also include any noarch package we like.
STAGE3_PACKAGES = iso-codes \
ncurses-devel readline-devel bash coreutils gmp-devel \
mpfr-devel libmpc-devel binutils gcc gcc-c++ util-linux tar \
gzip zlib-devel file-devel popt-devel beecrypt-devel \
rpm rpm-build rpm-devel libdb-utils libdb-devel nano \
grep less strace bzip2-devel make diffutils findutils \
sed patch hostname gettext-devel lua-devel xz-devel gawk \
vim screen m4 flex bison autoconf automake elfutils \
git
# Versions of cross-compiled packages.
NCURSES_VERSION = 6.0-20171216
READLINE_VERSION = 6.3
BASH_VERSION = 4.3
COREUTILS_VERSION = 8.25
GMP_VERSION = 6.1.2
MPFR_VERSION = 3.1.6
MPC_VERSION = 1.0.3
UTIL_LINUX_VERSION = 2.31
TAR_VERSION = 1.29
GZIP_VERSION = 1.8
ZLIB_VERSION = 1.2.11
# Needs to match the version of 'file' installed (on host), otherwise:
# "Cannot use the installed version of file (xx) to cross-compile file yy"
# Also note that 5.25 is definitely broken (segfaults in libmagic:magic_close).
FILE_VERSION = 5.32
POPT_VERSION = 1.16
BEECRYPT_VERSION = 4.2.1
RPM_COMMIT = b22f9609d82625ec451d48515d6d318c5bf72d83
RPM_SHORT_COMMIT = b22f9609
BDB_VERSION = 4.5.20
NANO_VERSION = 2.6.2
GREP_VERSION = 2.25
LESS_VERSION = 481
STRACE_COMMIT = 4b69c4736cb9b44e0bd7bef16f7f8602b5d2f113
STRACE_SHORT_COMMIT = 4b69c473
BZIP2_VERSION = 1.0.6
MAKE_VERSION = 4.2.1
DIFFUTILS_VERSION = 3.6
FINDUTILS_VERSION = 4.6.0
SED_VERSION = 4.2
PATCH_VERSION = 2.7.5
HOSTNAME_VERSION = 3.18
GETTEXT_VERSION = 0.19.8
LUA_VERSION = 5.3.4
XZ_VERSION = 5.2.2
GAWK_VERSION = 4.1.3
VIM_VERSION = 7.4
SCREEN_VERSION = 4.4.0
M4_VERSION = 1.4.17
FLEX_VERSION = 2.6.0
BISON_VERSION = 3.0.4
AUTOCONF_VERSION = 2.69
AUTOMAKE_VERSION = 1.15
PERL_VERSION = 5.24.0
PERL_CROSS_VERSION = 1.0.3
ELFUTILS_VERSION = 0.170
GIT_VERSION = 2.9.3
JSONCPP_VERSION = 1.7.4
# There is no Tiny DNF (tdnf) RPM in Fedora, so we build our own
# starting from this version:
TDNF_VERSION = 1.0.9
stage3: riscv-linux/vmlinux \
stage3-chroot-original/etc/fedora-release \
stage3-chroot/etc/fedora-release \
stage3-chroot/lib64/libc.so.6 \
stage3-chroot/usr/include/asm/ptrace.h \
host-tools/riscv64-unknown-elf/bin/bbl \
stage3-chroot/usr/bin/tic \
stage3-chroot/usr/lib64/libhistory.so.6 \
stage3-chroot/bin/bash \
stage3-chroot/bin/ls \
stage3-chroot/usr/lib64/libgmp.so.10 \
stage3-chroot/usr/lib64/libmpfr.so.4 \
stage3-chroot/usr/lib64/libmpc.so.3 \
stage3-chroot/usr/bin/as \
stage3-chroot/usr/bin/gcc \
stage3-chroot/usr/lib64/libstdc++.so \
stage3-chroot/usr/lib64/libgomp.so \
stage3-chroot/usr/lib64/libatomic.so \
stage3-chroot/usr/bin/mount \
stage3-chroot/usr/bin/tar \
stage3-chroot/usr/bin/gzip \
stage3-chroot/usr/lib64/libz.so \
stage3-chroot/usr/bin/file \
stage3-chroot/usr/lib64/libpopt.so \
stage3-chroot/usr/lib64/libbeecrypt.so \
stage3-chroot/usr/bin/nano \
stage3-chroot/usr/bin/grep \
stage3-chroot/usr/bin/less \
stage3-chroot/usr/bin/strace \
stage3-chroot/usr/bin/bzip2 \
stage3-chroot/usr/bin/make \
stage3-chroot/usr/bin/diff \
stage3-chroot/usr/bin/find \
stage3-chroot/usr/bin/sed \
stage3-chroot/usr/bin/patch \
stage3-chroot/usr/bin/hostname \
stage3-chroot/usr/bin/gettext \
stage3-chroot/usr/bin/lua \
stage3-chroot/usr/bin/xz \
stage3-chroot/usr/bin/eu-readelf \
stage3-chroot/usr/bin/rpm \
stage3-chroot/usr/bin/gawk \
stage3-chroot/usr/bin/vim \
stage3-chroot/usr/bin/screen \
stage3-chroot/usr/bin/m4 \
stage3-chroot/usr/bin/flex \
stage3-chroot/usr/bin/bison \
stage3-chroot/usr/bin/poweroff \
stage3-chroot/usr/bin/autoconf \
stage3-chroot/usr/bin/automake \
stage3-chroot/usr/bin/perl \
stage3-chroot/usr/bin/git \
stage3-chroot/usr/lib64/libjsoncpp.so \
stage3-chroot/etc/profile.d/aliases.sh \
stage3-chroot/usr/lib/rpm/config.guess \
stage3-chroot/usr/lib/rpm/config.sub \
stage3-chroot/etc/ld.so.conf.d/lib64.conf \
stage3-chroot/etc/resolv.conf \
stage3-chroot/rpmbuild \
stage3-chroot/rpmbuild/RPMS/noarch/kernel-headers-4.15-1.fc27.noarch.rpm \
stage3-tdnf/tdnf-$(TDNF_VERSION)-2.fc27.src.rpm \
stage3-chroot/etc/yum.repos.d/local.repo \
stage3-chroot/usr/lib/libtinfo.so.6 \
$(STAGE3_DISK)
riscv-linux/vmlinux: riscv-linux/arch/riscv/include/asm/serial.h riscv-linux/.config
cd riscv-linux && \
$(MAKE) ARCH=riscv CROSS_COMPILE=riscv64-unknown-linux-gnu- vmlinux
cd riscv-linux && \
$(MAKE) ARCH=riscv CROSS_COMPILE=riscv64-unknown-linux-gnu- headers_install INSTALL_HDR_PATH=$(ROOT)/stage3-chroot/usr
ls -l $@
# See https://github.com/riscv/riscv-qemu/commit/039dbd521277bc0aab672203a1a199e4519094da
riscv-linux/arch/riscv/include/asm/serial.h: asm-serial.h
rm -f $@
cp asm-serial.h riscv-linux/arch/riscv/include/asm/serial.h
riscv-linux/.config: kernel-config
rm -f $@
cd riscv-linux && \
$(MAKE) ARCH=riscv CROSS_COMPILE=riscv64-unknown-linux-gnu- defconfig
cat $< >> $@
cd riscv-linux && \
$(MAKE) ARCH=riscv CROSS_COMPILE=riscv64-unknown-linux-gnu- olddefconfig
# Build the bbl with embedded kernel.
host-tools/riscv64-unknown-elf/bin/bbl: riscv-linux/vmlinux
rm -rf riscv-pk/build
mkdir -p riscv-pk/build
cd riscv-pk/build && \
RISCV=$(ROOT)/host-tools \
../configure --prefix=$(ROOT)/host-tools --host=riscv64-unknown-linux-gnu --with-payload=$(ROOT)/$<
cd riscv-pk/build && \
RISCV=$(ROOT)/host-tools \
$(MAKE)
cd riscv-pk/build && \
RISCV=$(ROOT)/host-tools \
$(MAKE) install
# Build the phony kernel-headers RPM.
stage3-chroot/rpmbuild/RPMS/noarch/kernel-headers-4.15-1.fc27.noarch.rpm: riscv-linux/vmlinux
rm -rf kernel-headers
mkdir -p kernel-headers/usr
cd riscv-linux && \
make ARCH=riscv CROSS_COMPILE=riscv64-unknown-linux-gnu- headers_install INSTALL_HDR_PATH=$(ROOT)/kernel-headers/usr
sed -e 's,@ROOT@,$(ROOT),g' < kernel-headers.spec.in > kernel-headers.spec
mkdir -p stage3-chroot/rpmbuild/RPMS/noarch
rpmbuild -ba kernel-headers.spec --define "_topdir $(ROOT)/stage3-chroot/rpmbuild"
rm -rf kernel-headers
# Tiny DNF, not in Fedora.
stage3-tdnf/tdnf-$(TDNF_VERSION)-2.fc27.src.rpm: stage3-tdnf/tdnf.spec stage3-tdnf/tdnf-$(TDNF_VERSION).tar.gz
rm -f $@
cd stage3-tdnf && rpmbuild -bs --define "_sourcedir `pwd`" --define "_srcrpmdir `pwd`" tdnf.spec
stage3-tdnf/tdnf.spec: stage3-tdnf/tdnf.spec.in
rm -f $@ $@-t
sed 's/@TDNF_VERSION@/$(TDNF_VERSION)/g' < $^ > $@-t
mv $@-t $@
stage3-tdnf/tdnf-$(TDNF_VERSION).tar.gz:
rm -f $@ $@-t
wget -O $@-t https://github.com/vmware/tdnf/archive/v$(TDNF_VERSION).tar.gz
mv $@-t $@
# Build an original (x86-64) chroot using supermin. We then aim to
# rebuild (using cross-compiled versions) every ELF binary in this
# chroot.
stage3-chroot-original/etc/fedora-release:
rm -rf stage3-chroot-original-t stage3-chroot-original tmp-supermin.d
supermin -v --prepare $(STAGE3_PACKAGES) -o tmp-supermin.d
supermin -v --build -f chroot tmp-supermin.d -o stage3-chroot-original-t
rm -r tmp-supermin.d
mv stage3-chroot-original-t stage3-chroot-original
@echo -n "Total files in chroot: "
@find stage3-chroot-original -type f | wc -l
@echo -n "ELF files to be rebuilt: "
@find stage3-chroot-original -type f | xargs file -N | grep -E '\bELF.*LSB\b' | wc -l
# Copy the original chroot to the final chroot, remove all the ELF
# files.
stage3-chroot/etc/fedora-release: stage3-chroot-original/etc/fedora-release
rm -rf stage3-chroot-t stage3-chroot
cp -a stage3-chroot-original stage3-chroot-t
find stage3-chroot-t -type d -print0 | xargs -0 chmod u+w
find stage3-chroot-t -type f -print0 | xargs -0 chmod u+w
find stage3-chroot-t -type f -print0 | xargs -0 file -N | grep -E '\bELF.*LSB\b' | awk -F: '{print $$1}' | xargs rm -f
rm -f stage3-chroot-t/lib64/libc.so.6
mv stage3-chroot-t stage3-chroot
rm -f stage3-chroot/usr/include/asm/ptrace.h
# Copy in compiled glibc from the stage2-cross-tools sysroot. Only
# copy files and symlinks, leave the target directory structure
# intact.
stage3-chroot/lib64/libc.so.6:
mkdir -p stage3-chroot/usr/lib/audit
mkdir -p stage3-chroot/usr/lib/gconv
mkdir -p stage3-chroot/usr/lib/ldscripts
mkdir -p stage3-chroot/usr/include/rpcsvc
for f in `cd host-tools/sysroot && find -type f -o -type l`; do \
cp -d host-tools/sysroot/$$f stage3-chroot/$$f; \
done
cd stage3-chroot/lib64 && for f in ../lib/*; do ln -sf $$f; done
rm -f stage3-chroot/usr/include/asm/ptrace.h
# Copy in the correct Linux header files.
stage3-chroot/usr/include/asm/ptrace.h: riscv-linux/vmlinux
cd riscv-linux && \
make ARCH=riscv CROSS_COMPILE=riscv64-unknown-linux-gnu- headers_install INSTALL_HDR_PATH=$(ROOT)/stage3-chroot/usr
# Cross-compile ncurses.
stage3-chroot/usr/bin/tic: ncurses-$(NCURSES_VERSION).tgz
tar zxf $^
cd ncurses-$(NCURSES_VERSION) && \
./configure --host=riscv64-unknown-linux-gnu \
--prefix=/usr --libdir=/usr/lib64 \
--with-shared \
--with-termlib=tinfo \
--enable-widec
cd ncurses-$(NCURSES_VERSION) && $(MAKE)
cd ncurses-$(NCURSES_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot
ncurses-$(NCURSES_VERSION).tgz:
rm -f $@ $@-t
wget -O $@-t https://invisible-mirror.net/archives/ncurses/current/ncurses-$(NCURSES_VERSION).tgz
mv $@-t $@
# Cross-compile readline.
stage3-chroot/usr/lib64/libhistory.so.6: readline-$(READLINE_VERSION).tar.gz
rm -rf readline-$(READLINE_VERSION)
tar zxf $^
cd readline-$(READLINE_VERSION) && \
bash_cv_wcwidth_broken=no \
./configure --host=riscv64-unknown-linux-gnu \
--prefix=/usr --libdir=/usr/lib64
cd readline-$(READLINE_VERSION) && $(MAKE)
cd readline-$(READLINE_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot
rm -f stage3-chroot/usr/lib64/*.la
readline-$(READLINE_VERSION).tar.gz:
rm -f $@ $@-t
wget -O $@-t ftp://ftp.gnu.org/gnu/readline/readline-$(READLINE_VERSION).tar.gz
mv $@-t $@
# Cross-compile bash.
stage3-chroot/bin/bash: bash-$(BASH_VERSION).tar.gz
rm -rf bash-$(BASH_VERSION)
tar zxf $^
cd bash-$(BASH_VERSION) && \
./configure --host=riscv64-unknown-linux-gnu \
--prefix=/usr --libdir=/usr/lib64
cd bash-$(BASH_VERSION) && $(MAKE)
cd bash-$(BASH_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot
bash-$(BASH_VERSION).tar.gz:
rm -f $@ $@-t
wget -O $@-t ftp://ftp.gnu.org/gnu/bash/bash-$(BASH_VERSION).tar.gz
mv $@-t $@
# Cross-compile coreutils. Bleah, coreutils cross-compilation is
# known-broken and upstream don't care, hence the 'touch' command.
COREUTILS_PROGRAMS = arch base32 base64 basename cat chcon chgrp chmod chown chroot cksum comm cp csplit cut date dd df dir dircolors dirname du echo env expand expr factor false fmt fold ginstall groups head hostid hostname id install join kill link ln logname ls md5sum mkdir mkfifo mknod mktemp mv nice nl nohup nproc numfmt od paste pathchk pinky pr printenv printf ptx pwd readlink realpath rm rmdir runcon seq sha1sum sha224sum sha256sum sha384sum sha512sum shred shuf sleep sort split stat stdbuf stty sum sync tac tail tee test timeout touch tr true truncate tsort tty uname unexpand uniq unlink uptime users vdir wc who whoami yes
stage3-chroot/bin/ls: coreutils-$(COREUTILS_VERSION).tar.xz
rm -rf coreutils-$(COREUTILS_VERSION)
tar Jxf $^
cd coreutils-$(COREUTILS_VERSION) && \
./configure --host=riscv64-unknown-linux-gnu \
--prefix=/usr --libdir=/usr/lib64
-cd coreutils-$(COREUTILS_VERSION) && make -j1 -k
cd coreutils-$(COREUTILS_VERSION)/man && \
for f in $(COREUTILS_PROGRAMS); do touch $$f.1; done
cd coreutils-$(COREUTILS_VERSION) && $(MAKE)
cd coreutils-$(COREUTILS_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot
coreutils-$(COREUTILS_VERSION).tar.xz:
rm -f $@ $@-t
wget -O $@-t ftp://ftp.gnu.org/gnu/coreutils/coreutils-$(COREUTILS_VERSION).tar.xz
mv $@-t $@
# Cross-compile binutils.
stage3-chroot/usr/bin/as:
# We want to patch this tree so we have to make a copy.
rm -rf binutils-gdb
cp -a stage2-cross-tools/binutils-gdb binutils-gdb
rm -rf binutils-gdb/build-x
mkdir binutils-gdb/build-x
cd binutils-gdb/build-x && \
../configure \
--host=riscv64-unknown-linux-gnu \
--target=riscv64-unknown-linux-gnu \
--prefix=/usr --libdir=/usr/lib64 --disable-werror
cd binutils-gdb/build-x && \
$(MAKE)
cd binutils-gdb/build-x && \
make DESTDIR=$(ROOT)/stage3-chroot install
# Cross-compile GMP, MPFR and MPC (deps of GCC).
stage3-chroot/usr/lib64/libgmp.so.10: gmp-$(GMP_VERSION).tar.lz
rm -rf gmp-$(GMP_VERSION)
tar --lzip -xf gmp-$(GMP_VERSION).tar.lz
cd gmp-$(GMP_VERSION) && \
./configure --host=riscv64-unknown-linux-gnu \
--prefix=/usr --libdir=/usr/lib64
cd gmp-$(GMP_VERSION) && $(MAKE)
cd gmp-$(GMP_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot
gmp-$(GMP_VERSION).tar.lz:
rm -f $@ $@-t
wget -O $@-t https://gmplib.org/download/gmp/gmp-$(GMP_VERSION).tar.lz
mv $@-t $@
stage3-chroot/usr/lib64/libmpfr.so.4: mpfr-$(MPFR_VERSION).tar.gz
rm -rf mpfr-$(MPFR_VERSION)
tar -zxf mpfr-$(MPFR_VERSION).tar.gz
cd mpfr-$(MPFR_VERSION) && \
./configure --host=riscv64-unknown-linux-gnu \
--prefix=/usr --libdir=/usr/lib64 \
--with-gmp=$(ROOT)/stage3-chroot/usr
cd mpfr-$(MPFR_VERSION) && $(MAKE)
cd mpfr-$(MPFR_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot
cd stage3-chroot/usr/lib && ln -s ../lib64/libmpfr.so
rm -f stage3-chroot/usr/lib64/*.la
mpfr-$(MPFR_VERSION).tar.gz:
rm -f $@ $@-t
wget -O $@-t http://www.mpfr.org/mpfr-current/mpfr-$(MPFR_VERSION).tar.gz
mv $@-t $@
stage3-chroot/usr/lib64/libmpc.so.3: mpc-$(MPC_VERSION).tar.gz
rm -rf mpc-$(MPC_VERSION)
tar -zxf mpc-$(MPC_VERSION).tar.gz
cd mpc-$(MPC_VERSION) && \
./configure --host=riscv64-unknown-linux-gnu \
--prefix=/usr --libdir=/usr/lib64 \
--with-gmp=$(ROOT)/stage3-chroot/usr \
--with-mpfr=$(ROOT)/stage3-chroot/usr
cd mpc-$(MPC_VERSION) && $(MAKE)
cd mpc-$(MPC_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot
cd stage3-chroot/usr/lib && ln -s ../lib64/libmpc.so
rm -f stage3-chroot/usr/lib64/*.la
mpc-$(MPC_VERSION).tar.gz:
rm -f $@ $@-t
wget -O $@-t ftp://ftp.gnu.org/gnu/mpc/mpc-$(MPC_VERSION).tar.gz
mv $@-t $@
# Cross-compile GCC.
stage3-chroot/usr/bin/gcc:
# We want to patch this tree so we have to make a copy.
rm -rf gcc
cp -a stage2-cross-tools/gcc gcc
cd gcc && \
patch -p1 < ../0001-HACKS-TO-GET-GCC-TO-COMPILE.patch
rm -rf gcc/build-x
mkdir gcc/build-x
cd gcc/build-x && \
gcc_cv_as_leb128=no \
../configure \
--host=riscv64-unknown-linux-gnu \
--prefix=/usr --libdir=/usr/lib64 \
--enable-shared \
--enable-tls \
--enable-languages=c,c++ \
--disable-libmudflap \
--disable-libssp \
--disable-libquadmath \
--disable-nls \
--disable-multilib \
--enable-__cxa_atexit \
--disable-libunwind-exceptions \
--enable-gnu-unique-object \
--enable-linker-build-id \
--with-linker-hash-style=gnu \
--enable-initfini-array \
--disable-libgcj \
--with-gcc-major-version-only
cd gcc/build-x && \
gcc_cv_as_leb128=no \
$(MAKE)
cd gcc/build-x && \
make install DESTDIR=$(ROOT)/stage3-chroot
rm -f stage3-chroot/usr/lib64/*.la
# See next rule for why we do this ...
rm -f stage3-chroot/usr/lib64/libstdc++*
rm -f stage3-chroot/usr/lib64/libgomp*
rm -f stage3-chroot/usr/lib64/libatomic*
# libstdc++ isn't built correctly. I believe it installs an x86
# executable into /usr/lib64 and ignores the --libdir parameter
# entirely. Fix this mess.
stage3-chroot/usr/lib64/libstdc++.so: stage3-chroot/usr/bin/gcc
cd gcc/build-x/riscv64-unknown-linux-gnu/libstdc++-v3 && \
../../../libstdc++-v3/configure \
--host=riscv64-unknown-linux-gnu \
--prefix=/usr --libdir=/usr/lib64
cd gcc/build-x/riscv64-unknown-linux-gnu/libstdc++-v3 && \
make clean
cd gcc/build-x/riscv64-unknown-linux-gnu/libstdc++-v3 && \
$(MAKE)
cd gcc/build-x/riscv64-unknown-linux-gnu/libstdc++-v3 && \
make install DESTDIR=$(ROOT)/stage3-chroot
# libgomp isn't built correctly.
stage3-chroot/usr/lib64/libgomp.so: stage3-chroot/usr/bin/gcc
cd gcc/build-x/riscv64-unknown-linux-gnu/libgomp && \
../../../libgomp/configure \
--host=riscv64-unknown-linux-gnu \
--prefix=/usr --libdir=/usr/lib64
cd gcc/build-x/riscv64-unknown-linux-gnu/libgomp && \
make clean
cd gcc/build-x/riscv64-unknown-linux-gnu/libgomp && \
$(MAKE)
cd gcc/build-x/riscv64-unknown-linux-gnu/libgomp && \
make install DESTDIR=$(ROOT)/stage3-chroot
# We don't have cross-compiled libatomic for riscv64, but libgcc_s.so refers to symbols from this library
stage3-chroot/usr/lib64/libatomic.so: stage3-chroot/usr/bin/gcc
cd gcc/build-x/riscv64-unknown-linux-gnu/libatomic && \
../../../libatomic/configure \
--host=riscv64-unknown-linux-gnu \
--prefix=/usr --libdir=/usr/lib64
cd gcc/build-x/riscv64-unknown-linux-gnu/libatomic && \
make clean
cd gcc/build-x/riscv64-unknown-linux-gnu/libatomic && \
$(MAKE)
cd gcc/build-x/riscv64-unknown-linux-gnu/libatomic && \
make install DESTDIR=$(ROOT)/stage3-chroot
# Cross-compile util-linux.
stage3-chroot/usr/bin/mount: util-linux-$(UTIL_LINUX_VERSION).tar.xz
rm -rf util-linux-$(UTIL_LINUX_VERSION)
tar -Jxf $^
cd util-linux-$(UTIL_LINUX_VERSION) && \
LDFLAGS=-L$(ROOT)/stage3-chroot/usr/lib64 \
./configure \
--host=riscv64-unknown-linux-gnu \
--prefix=/usr --libdir=/usr/lib64 \
--without-python \
--without-systemd \
--disable-makeinstall-chown \
--disable-eject \
--enable-static-programs=mount
cd util-linux-$(UTIL_LINUX_VERSION) && $(MAKE)
cd util-linux-$(UTIL_LINUX_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot
rm -f stage3-chroot/usr/lib64/*.la
util-linux-$(UTIL_LINUX_VERSION).tar.xz:
rm -f $@ $@-t
wget -O $@-t https://www.kernel.org/pub/linux/utils/util-linux/v$(UTIL_LINUX_VERSION)/util-linux-$(UTIL_LINUX_VERSION).tar.xz
mv $@-t $@
# Cross-compile GNU tar.
stage3-chroot/usr/bin/tar: tar-$(TAR_VERSION).tar.xz
rm -rf tar-$(TAR_VERSION)
tar -Jxf $^
cd tar-$(TAR_VERSION) && \
./configure \
--host=riscv64-unknown-linux-gnu \
--prefix=/usr --libdir=/usr/lib64
cd tar-$(TAR_VERSION) && $(MAKE)
cd tar-$(TAR_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot
tar-$(TAR_VERSION).tar.xz:
rm -f $@ $@-t
wget -O $@-t https://ftp.gnu.org/gnu/tar/tar-$(TAR_VERSION).tar.xz
mv $@-t $@
# Cross-compile GNU gzip.
stage3-chroot/usr/bin/gzip: gzip-$(GZIP_VERSION).tar.gz
rm -rf gzip-$(GZIP_VERSION)
tar -zxf $^
cd gzip-$(GZIP_VERSION) && \
./configure \
--host=riscv64-unknown-linux-gnu \
--prefix=/usr --libdir=/usr/lib64
cd gzip-$(GZIP_VERSION) && $(MAKE)
cd gzip-$(GZIP_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot
gzip-$(GZIP_VERSION).tar.gz:
rm -f $@ $@-t
wget -O $@-t https://ftp.gnu.org/gnu/gzip/gzip-$(GZIP_VERSION).tar.gz
mv $@-t $@
# Cross-compile zlib.
stage3-chroot/usr/lib64/libz.so: zlib-$(ZLIB_VERSION).tar.gz
rm -rf zlib-$(ZLIB_VERSION)
tar -zxf $^
cd zlib-$(ZLIB_VERSION) && \
CC=riscv64-unknown-linux-gnu-gcc \
CFLAGS="-I$(ROOT)/stage3-chroot/usr/include -L$(ROOT)/stage3-chroot/usr/lib" \
./configure \
--prefix=/usr --libdir=/usr/lib64
cd zlib-$(ZLIB_VERSION) && $(MAKE) shared
cd zlib-$(ZLIB_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot
zlib-$(ZLIB_VERSION).tar.gz:
rm -f $@ $@-t
wget -O $@-t http://zlib.net/zlib-$(ZLIB_VERSION).tar.gz
mv $@-t $@
# Cross-compile file/libmagic.
stage3-chroot/usr/bin/file: file-$(FILE_VERSION).tar.gz
rm -rf file-$(FILE_VERSION)
tar -zxf $^
cd file-$(FILE_VERSION) && \
LDFLAGS=-L$(ROOT)/stage3-chroot/usr/lib64 \
./configure \
--host=riscv64-unknown-linux-gnu \
--prefix=/usr --libdir=/usr/lib64 \
--disable-static --enable-shared
cd file-$(FILE_VERSION) && $(MAKE) V=1
cd file-$(FILE_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot
rm -f stage3-chroot/usr/lib64/*.la
file-$(FILE_VERSION).tar.gz:
rm -f $@ $@-t
wget -O $@-t ftp://ftp.astron.com/pub/file/file-$(FILE_VERSION).tar.gz
mv $@-t $@
# Cross-compile popt.
stage3-chroot/usr/lib64/libpopt.so: popt-$(POPT_VERSION).tar.gz
rm -rf popt-$(POPT_VERSION)
tar -zxf $^
cd popt-$(POPT_VERSION) && \
LDFLAGS=-L$(ROOT)/stage3-chroot/usr/lib64 \
./configure \
--host=riscv64-unknown-linux-gnu \
--prefix=/usr --libdir=/usr/lib64 \
--disable-static --enable-shared
cd popt-$(POPT_VERSION) && $(MAKE) V=1
cd popt-$(POPT_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot
rm -f stage3-chroot/usr/lib64/*.la
popt-$(POPT_VERSION).tar.gz:
rm -f $@ $@-t
wget -O $@-t http://rpm5.org/files/popt/popt-$(POPT_VERSION).tar.gz
mv $@-t $@
# Cross-compile beecrypt.
stage3-chroot/usr/lib64/libbeecrypt.so: beecrypt-$(BEECRYPT_VERSION).tar.gz
rm -rf beecrypt-$(BEECRYPT_VERSION)
tar -zxf $^
cd beecrypt-$(BEECRYPT_VERSION) && patch -p0 < ../beecrypt-disable-cplusplus.patch
cd beecrypt-$(BEECRYPT_VERSION) && autoreconf -i
cd beecrypt-$(BEECRYPT_VERSION) && \
LDFLAGS=-L$(ROOT)/stage3-chroot/usr/lib64 \
./configure \
--host=riscv64-unknown-linux-gnu \
--prefix=/usr --libdir=/usr/lib64 \
--without-cplusplus \
--without-java \
--disable-openmp \
--disable-static \
--enable-shared
cd beecrypt-$(BEECRYPT_VERSION) && $(MAKE) V=1
cd beecrypt-$(BEECRYPT_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot V=1
chrpath -d stage3-chroot/usr/lib64/libbeecrypt.so.*
rm -f stage3-chroot/usr/lib64/*.la
beecrypt-$(BEECRYPT_VERSION).tar.gz:
rm -f $@ $@-t
wget -O $@-t http://downloads.sourceforge.net/sourceforge/beecrypt/beecrypt-$(BEECRYPT_VERSION).tar.gz
mv $@-t $@
# Cross-compile GNU nano (editor).
stage3-chroot/usr/bin/nano: nano-$(NANO_VERSION).tar.gz
rm -rf nano-$(NANO_VERSION)
tar -zxf $^
cd nano-$(NANO_VERSION) && \
LDFLAGS=-L$(ROOT)/stage3-chroot/usr/lib64 \
./configure \
--host=riscv64-unknown-linux-gnu \
--prefix=/usr --libdir=/usr/lib64
cd nano-$(NANO_VERSION) && $(MAKE)
cd nano-$(NANO_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot
nano-$(NANO_VERSION).tar.gz:
rm -f $@ $@-t
wget -O $@-t https://www.nano-editor.org/dist/v2.6/nano-$(NANO_VERSION).tar.gz
mv $@-t $@
# Cross-compile GNU grep.
stage3-chroot/usr/bin/grep: grep-$(GREP_VERSION).tar.xz
rm -rf grep-$(GREP_VERSION)
tar -Jxf $^
cd grep-$(GREP_VERSION) && \
./configure \
--host=riscv64-unknown-linux-gnu \
--prefix=/usr --libdir=/usr/lib64
cd grep-$(GREP_VERSION) && $(MAKE)
cd grep-$(GREP_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot
grep-$(GREP_VERSION).tar.xz:
rm -f $@ $@-t
wget -O $@-t https://ftp.gnu.org/gnu/grep/grep-$(GREP_VERSION).tar.xz
mv $@-t $@
# Cross-compile less.
stage3-chroot/usr/bin/less: less-$(LESS_VERSION).tar.gz
rm -rf less-$(LESS_VERSION)
tar -zxf $^
cd less-$(LESS_VERSION) && \
LDFLAGS=-L$(ROOT)/stage3-chroot/usr/lib64 \
./configure \
--host=riscv64-unknown-linux-gnu \
--prefix=/usr --libdir=/usr/lib64
cd less-$(LESS_VERSION) && $(MAKE)
cd less-$(LESS_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot
less-$(LESS_VERSION).tar.gz:
rm -f $@ $@-t
wget -O $@-t http://www.greenwoodsoftware.com/less/less-$(LESS_VERSION).tar.gz
mv $@-t $@
# Cross-compile strace.
stage3-chroot/usr/bin/strace: strace-$(STRACE_SHORT_COMMIT).tar.gz stage3-chroot/usr/include/asm/ptrace.h
rm -rf strace-$(STRACE_COMMIT)
tar -zxf $<
cd strace-$(STRACE_COMMIT) && patch -p1 < ../0001-Build-strace-for-RISC-V.patch
cd strace-$(STRACE_COMMIT) && ./bootstrap
cd strace-$(STRACE_COMMIT) && \
LDFLAGS=-L$(ROOT)/stage3-chroot/usr/lib64 \
./configure \
--host=riscv64-unknown-linux-gnu \
--prefix=/usr --libdir=/usr/lib64
cd strace-$(STRACE_COMMIT) && $(MAKE)
cd strace-$(STRACE_COMMIT) && make install DESTDIR=$(ROOT)/stage3-chroot
strace-$(STRACE_SHORT_COMMIT).tar.gz:
rm -f $@ $@-t
wget -O $@-t 'https://github.com/strace/strace/archive/$(STRACE_COMMIT)/strace-$(STRACE_SHORTCOMMIT).tar.gz'
mv $@-t $@
# Cross-compile bzip2.
stage3-chroot/usr/bin/bzip2: bzip2-$(BZIP2_VERSION).tar.gz
rm -rf bzip2-$(BZIP2_VERSION)
tar -zxf $^
cd bzip2-$(BZIP2_VERSION) && \
$(MAKE) libbz2.a bzip2 bzip2recover \
PREFIX=/usr \
CC=riscv64-unknown-linux-gnu-gcc \
AR=riscv64-unknown-linux-gnu-ar \
RANLIB=riscv64-unknown-linux-gnu-ranlib \
CFLAGS="-Wall -Winline -O2 -g -D_FILE_OFFSET_BITS=64 -fPIC"
cd bzip2-$(BZIP2_VERSION) && \
make install PREFIX=$(ROOT)/stage3-chroot/usr
bzip2-$(BZIP2_VERSION).tar.gz:
rm -f $@ $@-t
wget -O $@-t http://www.bzip.org/1.0.6/bzip2-$(BZIP2_VERSION).tar.gz
mv $@-t $@
# Cross-compile GNU make.
stage3-chroot/usr/bin/make: make-$(MAKE_VERSION).tar.gz
rm -rf make-$(MAKE_VERSION)
tar -zxf $^
# Unclear why this patch is needed but upstream make has other
# fixes for the way it misuses glibc.
cd make-$(MAKE_VERSION) && \
patch -p1 < ../make-4.2.1-fix-alloca.patch
cd make-$(MAKE_VERSION) && \
./configure \
--without-guile \
--host=riscv64-unknown-linux-gnu \
--prefix=/usr --libdir=/usr/lib64
cd make-$(MAKE_VERSION) && $(MAKE)
cd make-$(MAKE_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot
make-$(MAKE_VERSION).tar.gz:
rm -f $@ $@-t
wget -O $@-t https://ftp.gnu.org/gnu/make/make-$(MAKE_VERSION).tar.gz
mv $@-t $@
# Cross-compile GNU diffutils.
stage3-chroot/usr/bin/diff: diffutils-$(DIFFUTILS_VERSION).tar.xz
rm -rf diffutils-$(DIFFUTILS_VERSION)
tar -Jxf $^
cd diffutils-$(DIFFUTILS_VERSION) && \
./configure \
--host=riscv64-unknown-linux-gnu \
--prefix=/usr --libdir=/usr/lib64
# ./configure misdetects getopt when cross-compiling.
perl -pi.bak -e 's{^#define __GETOPT_PREFIX.*}{}' diffutils-$(DIFFUTILS_VERSION)/lib/config.h
cd diffutils-$(DIFFUTILS_VERSION) && $(MAKE)
cd diffutils-$(DIFFUTILS_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot
diffutils-$(DIFFUTILS_VERSION).tar.xz:
rm -f $@ $@-t
wget -O $@-t https://ftp.gnu.org/gnu/diffutils/diffutils-$(DIFFUTILS_VERSION).tar.xz
mv $@-t $@
# Cross-compile GNU findutils.
stage3-chroot/usr/bin/find: findutils-$(FINDUTILS_VERSION).tar.gz
rm -rf findutils-$(FINDUTILS_VERSION)
tar -zxf $^
cd findutils-$(FINDUTILS_VERSION) && \
./configure \
--host=riscv64-unknown-linux-gnu \
--prefix=/usr --libdir=/usr/lib64
cd findutils-$(FINDUTILS_VERSION) && $(MAKE)
cd findutils-$(FINDUTILS_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot
findutils-$(FINDUTILS_VERSION).tar.gz:
rm -f $@ $@-t
wget -O $@-t https://ftp.gnu.org/gnu/findutils/findutils-$(FINDUTILS_VERSION).tar.gz
mv $@-t $@
# Cross-compile GNU sed.
stage3-chroot/usr/bin/sed: sed-$(SED_VERSION).tar.gz
rm -rf sed-$(SED_VERSION)
tar -zxf $^
cd sed-$(SED_VERSION) && \
./configure \
--host=riscv64-unknown-linux-gnu \
--prefix=/usr --libdir=/usr/lib64
cd sed-$(SED_VERSION) && $(MAKE)
cd sed-$(SED_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot
sed-$(SED_VERSION).tar.gz:
rm -f $@ $@-t
wget -O $@-t https://ftp.gnu.org/gnu/sed/sed-$(SED_VERSION).tar.gz
mv $@-t $@
# Cross-compile patch.
stage3-chroot/usr/bin/patch: patch-$(PATCH_VERSION).tar.gz
rm -rf patch-$(PATCH_VERSION)
tar -zxf $^
cd patch-$(PATCH_VERSION) && \
./configure \
--host=riscv64-unknown-linux-gnu \
--prefix=/usr --libdir=/usr/lib64
cd patch-$(PATCH_VERSION) && $(MAKE)
cd patch-$(PATCH_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot
patch-$(PATCH_VERSION).tar.gz:
rm -f $@ $@-t
wget -O $@-t https://ftp.gnu.org/gnu/patch/patch-$(PATCH_VERSION).tar.gz
mv $@-t $@
# Cross-compile hostname.
stage3-chroot/usr/bin/hostname: hostname-$(HOSTNAME_VERSION).tar.gz
rm -rf hostname
tar -zxf $^
cd hostname && patch -p1 < ../hostname-rh.patch
cd hostname && \
CC=riscv64-unknown-linux-gnu-gcc \
CFLAGS="-O2 -g" \
$(MAKE)
cd hostname && \
make install BASEDIR=$(ROOT)/stage3-chroot
hostname-$(HOSTNAME_VERSION).tar.gz:
rm -f $@ $@-t
wget -O $@-t http://ftp.de.debian.org/debian/pool/main/h/hostname/hostname_$(HOSTNAME_VERSION).tar.gz
mv $@-t $@
# Cross-compile GNU gettext.
stage3-chroot/usr/bin/gettext: gettext-$(GETTEXT_VERSION).tar.gz
rm -rf gettext-$(GETTEXT_VERSION)
tar -zxf $^
cd gettext-$(GETTEXT_VERSION) && \
./configure \
--host=riscv64-unknown-linux-gnu \
--prefix=/usr --libdir=/usr/lib64
cd gettext-$(GETTEXT_VERSION) && $(MAKE)
cd gettext-$(GETTEXT_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot
rm -f stage3-chroot/usr/lib64/*.la
gettext-$(GETTEXT_VERSION).tar.gz:
rm -f $@ $@-t
wget -O $@-t https://ftp.gnu.org/gnu/gettext/gettext-$(GETTEXT_VERSION).tar.gz
mv $@-t $@
# Cross-compile lua.
stage3-chroot/usr/bin/lua: lua-$(LUA_VERSION).tar.gz
rm -rf lua-$(LUA_VERSION)
tar -zxf $^
# Missing inclusion of <sys/ucontext.h>.
cd lua-$(LUA_VERSION) && \
patch -p1 < ../lua-5.3.4-include-ucontext.patch
cd lua-$(LUA_VERSION) && \
$(MAKE) PLAT=linux INSTALL_TOP=/usr \
CC=riscv64-unknown-linux-gnu-gcc \
AR="riscv64-unknown-linux-gnu-ar rcu" \
RANLIB="riscv64-unknown-linux-gnu-ranlib" \
MYLDFLAGS=-L$(ROOT)/stage3-chroot/usr/lib64 \
MYLIBS=-ltinfo \
MYCFLAGS="-fPIC -DLUA_COMPAT_5_1"
cd lua-$(LUA_VERSION) && \
make install INSTALL_TOP=$(ROOT)/stage3-chroot/usr INSTALL_LIB=$(ROOT)/stage3-chroot/usr/lib64
lua-$(LUA_VERSION).tar.gz:
rm -f $@ $@-t
wget -O $@-t https://www.lua.org/ftp/lua-$(LUA_VERSION).tar.gz
mv $@-t $@
# Cross-compile xz.
stage3-chroot/usr/bin/xz: xz-$(XZ_VERSION).tar.gz
rm -rf xz-$(XZ_VERSION)
tar -zxf $^
cd xz-$(XZ_VERSION) && \
./configure \
--host=riscv64-unknown-linux-gnu \
--prefix=/usr --libdir=/usr/lib64
cd xz-$(XZ_VERSION) && $(MAKE)
cd xz-$(XZ_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot
rm -f stage3-chroot/usr/lib64/*.la
xz-$(XZ_VERSION).tar.gz:
rm -f $@ $@-t
wget -O $@-t http://tukaani.org/xz/xz-$(XZ_VERSION).tar.gz
mv $@-t $@
# Cross-compile git.
stage3-chroot/usr/bin/git: git-$(GIT_VERSION).tar.gz
rm -rf git-$(GIT_VERSION)
tar -zxf $^
cd git-$(GIT_VERSION) && \
./configure \
--host=riscv64-unknown-linux-gnu \
--prefix=/usr --libdir=/usr/lib64 \
ac_cv_fread_reads_directories=no \
ac_cv_snprintf_returns_bogus=no \
LDFLAGS=-L$(ROOT)/stage3-chroot/usr/lib64
cd git-$(GIT_VERSION) && $(MAKE) NO_PERL=1
cd git-$(GIT_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot NO_PERL=1
git-$(GIT_VERSION).tar.gz:
rm -f $@ $@-t
wget -O $@-t https://www.kernel.org/pub/software/scm/git/git-$(GIT_VERSION).tar.gz
mv $@-t $@
# Cross-compile GNU awk.
stage3-chroot/usr/bin/gawk: gawk-$(GAWK_VERSION).tar.gz
rm -rf gawk-$(GAWK_VERSION)
tar -zxf $^
cd gawk-$(GAWK_VERSION) && \
./configure \