-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
175 lines (153 loc) · 8.72 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
# SPDX-License-Identifier: GPL-2.0-only
# Contributed by William Fonkou Tambe
.PHONY: all linux-menuconfig linux-savedefconfig buildroot-menuconfig touch-binutils touch-gcc touch-linux touch-glibc touch-buildroot touch-fontamsoc-sw clean
NPROC ?= $(shell nproc)
SUDO := $(shell test $$(id -u) -eq 0 || echo -n sudo)
all: pu32-toolchain.tar.xz
pu32-build: pu32
echo - $@: NPROC == ${NPROC} >&2
${SUDO} apt install -y build-essential bsdmainutils dosfstools parted wget curl rsync bc cpio unzip texinfo bison flex gawk dejagnu gettext libncurses-dev python-is-python3 libelf-dev zlib1g-dev libgmp-dev libmpfr-dev libexpat-dev
${SUDO} mkdir -p /opt/pu32-toolchain
${SUDO} chown "${USER}" /opt/pu32-toolchain
mkdir -p pu32-build
touch $@
pu32-build/binutils: pu32/binutils
echo - $@: NPROC == ${NPROC} >&2
if [ ! -e binutils-build ]; then mkdir -p binutils-build && cd binutils-build && \
${PWD}/pu32/binutils/configure --target=pu32-elf --prefix=/opt/pu32-toolchain --with-expat --disable-nls --disable-tui; fi
if [ -e binutils-build ]; then cd binutils-build && make -j${NPROC} && make install; fi
ln -snf ../include /opt/pu32-toolchain/pu32-elf/include
rm -f $$(find /opt/pu32-toolchain/ | fgrep -e .so -e .la)
if [ -n "${USEGIT}" ]; then cd /opt/pu32-toolchain/; if [ ! -d .git ]; then git init; fi; git add .; git commit -m "$@"; fi
touch $@
gcc-build: pu32/gcc
echo - $@: NPROC == ${NPROC} >&2
if [ ! -e gcc-build ]; then cd pu32/gcc && ./contrib/download_prerequisites && cd - && \
mkdir -p gcc-build && cd gcc-build && \
${PWD}/pu32/gcc/configure --target=pu32-elf --prefix=/opt/pu32-toolchain --libexecdir=/opt/pu32-toolchain/lib --without-headers \
--disable-libssp --disable-multilib --disable-gcov --disable-lto --disable-libatomic --enable-languages=c --disable-nls && \
make -j${NPROC} && make install; fi
rm -f $$(find /opt/pu32-toolchain/ | fgrep -e .so -e .la)
if [ -n "${USEGIT}" ]; then cd /opt/pu32-toolchain/; if [ ! -d .git ]; then git init; fi; git add .; git commit -m "$@"; fi
touch $@
pu32-build/linux: pu32/linux
echo - $@: NPROC == ${NPROC} >&2
$(eval KERNEL_BUILD := "${PWD}/linux-build/")
$(eval KERNEL_SOURCE := "${PWD}/pu32/linux/")
if [ ! -e ${KERNEL_BUILD} ]; then mkdir -p ${KERNEL_BUILD} && cd ${KERNEL_BUILD} && \
make -C ${KERNEL_SOURCE} O=${KERNEL_BUILD} ARCH=pu32 defconfig && \
make ARCH=pu32 CROSS_COMPILE=pu32-elf- V=1 INSTALL_HDR_PATH=/opt/pu32-toolchain headers_install; fi
if [ -e ${KERNEL_BUILD} ]; then cd ${KERNEL_BUILD} && make ARCH=pu32 CROSS_COMPILE=pu32-elf- V=1 vmlinux.bin && \
mv vmlinux ../pu32-vmlinux.elf && mv arch/pu32/boot/vmlinux.bin ../pu32-vmlinux.bin; fi
if [ -n "${USEGIT}" ]; then cd /opt/pu32-toolchain/; if [ ! -d .git ]; then git init; fi; git add .; git commit -m "$@"; fi
touch $@
pu32-build/glibc: pu32/glibc
echo - $@: NPROC == ${NPROC} >&2
if [ ! -e glibc-build ]; then mkdir -p glibc-build && cd glibc-build && \
CXX=no ${PWD}/pu32/glibc/configure --host=pu32-elf --target=pu32-elf --prefix=/opt/pu32-toolchain/pu32-elf --libexecdir=/opt/pu32-toolchain/pu32-elf/lib \
--enable-kernel=6.0 --with-headers=/opt/pu32-toolchain/include --disable-profile --enable-static-nss --disable-nscd --disable-werror --without-gd --disable-nls \
--enable-crypt && \
make update-syscall-lists; fi
if [ -e glibc-build ]; then cd glibc-build && make -j${NPROC} && make install; fi
rm -f $$(find /opt/pu32-toolchain/ | fgrep -e .so -e .la)
rm -f /opt/pu32-toolchain/pu32-elf/bin/{ldd,pldd,sotruss,sprof}
rm -f /opt/pu32-toolchain/pu32-elf/sbin/{ldconfig,sln}
if [ -n "${USEGIT}" ]; then cd /opt/pu32-toolchain/; if [ ! -d .git ]; then git init; fi; git add .; git commit -m "$@"; fi
touch $@
pu32-build/gcc: pu32/gcc
echo - $@: NPROC == ${NPROC} >&2
if [ ! -e $@ ]; then cd gcc-build && \
${PWD}/pu32/gcc/configure --target=pu32-elf --prefix=/opt/pu32-toolchain --libexecdir=/opt/pu32-toolchain/lib --without-headers \
--disable-libssp --disable-multilib --disable-gcov --disable-lto --enable-libatomic --enable-languages=c,c++ --disable-nls; fi
if [ -e gcc-build ]; then cd gcc-build && make -j${NPROC} && make install; fi
rm -f $$(find /opt/pu32-toolchain/ | fgrep -e .so -e .la)
if [ -n "${USEGIT}" ]; then cd /opt/pu32-toolchain/; if [ ! -d .git ]; then git init; fi; git add .; git commit -m "$@"; fi
touch $@
pu32-build/fontamsoc-sw: pu32/fontamsoc-sw
echo - $@: NPROC == ${NPROC} >&2
cd pu32/fontamsoc-sw/bios && make clean && make -j${NPROC} install;
${SUDO} apt install -y autoconf libconfuse-dev pkg-config genext2fs mtools
cd pu32/fontamsoc-sw/mksocimg && make clean && make -j${NPROC} install;
if [ -n "${USEGIT}" ]; then cd /opt/pu32-toolchain/; if [ ! -d .git ]; then git init; fi; git add .; git commit -m "$@"; fi
touch $@
pu32-build/buildroot: pu32/buildroot
echo - $@: NPROC == ${NPROC} >&2
$(eval BUILDROOT_BUILD := "${PWD}/buildroot-build/")
$(eval BUILDROOT_SOURCE := "${PWD}/pu32/buildroot/")
if [ ! -e ${BUILDROOT_BUILD} ]; then mkdir -p ${BUILDROOT_BUILD} && cd ${BUILDROOT_BUILD} && \
make -C ${BUILDROOT_SOURCE} O=${BUILDROOT_BUILD} pu32_defconfig; fi
if [ -e ${BUILDROOT_BUILD} ]; then cd ${BUILDROOT_BUILD} && make -j${NPROC} V=1 && \
mv images/rootfs.ext2 ../pu32-rootfs.ext2; fi
touch $@
pu32-toolchain.tar.xz: \
pu32-build \
pu32-build/binutils \
gcc-build \
pu32-build/linux \
pu32-build/glibc \
pu32-build/gcc \
pu32-build/fontamsoc-sw \
pu32-build/buildroot
echo - $@: NPROC == ${NPROC} >&2
if [ -n "${USETAR}" ]; then tar -caf pu32-toolchain.tar.xz --owner=0 --group=0 -C /opt/ --exclude pu32-toolchain/.git pu32-toolchain && \
ls -lha >&2; fi
pu32-build/linux-headers:
echo - $@: NPROC == ${NPROC} >&2
$(eval KERNEL_BUILD := "${PWD}/linux-build/")
$(eval KERNEL_INSTALL_HDR_PATH := "${PWD}/pu32/linux-headers/")
mkdir -p ${KERNEL_INSTALL_HDR_PATH}
[ -e ${KERNEL_BUILD} ] && cd ${KERNEL_BUILD} && \
make ARCH=pu32 CROSS_COMPILE=pu32-elf- V=1 INSTALL_HDR_PATH=${KERNEL_INSTALL_HDR_PATH} headers_install
tar -caf ${PWD}/pu32/linux-headers.tar.xz --owner=0 --group=0 -C ${KERNEL_INSTALL_HDR_PATH} include && rm -rf ${KERNEL_INSTALL_HDR_PATH}
linux-menuconfig:
$(eval KERNEL_BUILD := "${PWD}/linux-build/")
$(eval KERNEL_SOURCE := "${PWD}/pu32/linux/")
if [ ! -e ${KERNEL_BUILD} ]; then mkdir -p ${KERNEL_BUILD} && cd ${KERNEL_BUILD} && \
make -C ${KERNEL_SOURCE} O=${KERNEL_BUILD} ARCH=pu32 defconfig; fi
if [ -e ${KERNEL_BUILD} ]; then cd ${KERNEL_BUILD} && make ARCH=pu32 CROSS_COMPILE=pu32-elf- menuconfig; fi
linux-savedefconfig:
$(eval KERNEL_BUILD := "${PWD}/linux-build/")
$(eval KERNEL_SOURCE := "${PWD}/pu32/linux/")
if [ ! -e ${KERNEL_BUILD} ]; then mkdir -p ${KERNEL_BUILD} && cd ${KERNEL_BUILD} && \
make -C ${KERNEL_SOURCE} O=${KERNEL_BUILD} ARCH=pu32 defconfig; fi
if [ -e ${KERNEL_BUILD} ]; then cd ${KERNEL_BUILD} && make ARCH=pu32 CROSS_COMPILE=pu32-elf- savedefconfig; fi
cp -a ${KERNEL_BUILD}/defconfig ${KERNEL_SOURCE}/arch/pu32/configs/defconfig
buildroot-menuconfig:
$(eval BUILDROOT_BUILD := "${PWD}/buildroot-build/")
$(eval BUILDROOT_SOURCE := "${PWD}/pu32/buildroot/")
if [ ! -e ${BUILDROOT_BUILD} ]; then mkdir -p ${BUILDROOT_BUILD} && cd ${BUILDROOT_BUILD} && \
make -C ${BUILDROOT_SOURCE} O=${BUILDROOT_BUILD} pu32_defconfig; fi
if [ -e ${BUILDROOT_BUILD} ]; then cd ${BUILDROOT_BUILD} && make menuconfig; fi
buildroot-savedefconfig:
$(eval BUILDROOT_BUILD := "${PWD}/buildroot-build/")
$(eval BUILDROOT_SOURCE := "${PWD}/pu32/buildroot/")
if [ ! -e ${BUILDROOT_BUILD} ]; then mkdir -p ${BUILDROOT_BUILD} && cd ${BUILDROOT_BUILD} && \
make -C ${BUILDROOT_SOURCE} O=${BUILDROOT_BUILD} pu32_defconfig; fi
if [ -e ${BUILDROOT_BUILD} ]; then cd ${BUILDROOT_BUILD} && make savedefconfig; fi
buildroot-busybox-menuconfig:
$(eval BUILDROOT_BUILD := "${PWD}/buildroot-build/")
$(eval BUILDROOT_SOURCE := "${PWD}/pu32/buildroot/")
if [ ! -e ${BUILDROOT_BUILD} ]; then mkdir -p ${BUILDROOT_BUILD} && cd ${BUILDROOT_BUILD} && \
make -C ${BUILDROOT_SOURCE} O=${BUILDROOT_BUILD} pu32_defconfig; fi
if [ -e ${BUILDROOT_BUILD} ]; then cd ${BUILDROOT_BUILD} && make busybox-menuconfig; fi
buildroot-busybox-savedefconfig:
$(eval BUILDROOT_BUILD := "${PWD}/buildroot-build/")
$(eval BUILDROOT_SOURCE := "${PWD}/pu32/buildroot/")
if [ ! -e ${BUILDROOT_BUILD} ]; then mkdir -p ${BUILDROOT_BUILD} && cd ${BUILDROOT_BUILD} && \
make -C ${BUILDROOT_SOURCE} O=${BUILDROOT_BUILD} pu32_defconfig; fi
cp -a ${BUILDROOT_BUILD}/build/busybox-*/.config ${BUILDROOT_SOURCE}/package/busybox/busybox.config
touch-binutils:
touch pu32/binutils
touch-gcc:
touch pu32/gcc
touch-linux:
touch pu32/linux
touch-glibc:
touch pu32/glibc
touch-buildroot:
touch pu32/buildroot
touch-fontamsoc-sw:
touch pu32/fontamsoc-sw
clean:
rm -rf pu32-build binutils-build linux-build glibc-build gcc-build buildroot-build \
pu32-vmlinux.elf pu32-vmlinux.bin pu32-rootfs.ext2 pu32-toolchain.tar.xz