• Home
  • Raw
  • Download

Lines Matching +full:bare +full:- +full:cross +full:- +full:build

3 # Clear environment variables by restarting script w/bare minimum passed through
4 [ -z "$NOCLEAR" ] && exec env -i NOCLEAR=1 HOME="$HOME" PATH="$PATH" \
5 "LINUX=$LINUX" "CROSS=$CROSS" CROSS_COMPILE="$CROSS_COMPILE" "$0" "$@"
8 while [ $# -ne 0 ]; do
10 { [ "$1" != '--' ] && PKG="${PKG:-plumbing} $1"; }
15 announce() { echo -e "\033]2;$CROSS $*\007\n=== $*"; }
17 # Create target-independent working directories (cmdline can change locations)
19 mkdir -p ${BUILD:=$TOP/build} ${AIRLOCK:=$TOP/airlock} ${LOG:=$TOP/log} ||exit 1
21 # set CROSS_COMPILE from $CROSS using ccc. Handle "all" w/log, list, and err chk
22 if [ ! -z "$CROSS" ]; then
23 [ ! -d "${CCC:=$PWD/ccc}" ] && die "No ccc symlink to compiler directory."
24 CROSS_COMPILE="$(echo "$CCC/$CROSS"-*cross/bin/"$CROSS"*-cc | sed 's/cc$//')"
25 if [ "${CROSS::3}" == all ]; then
26 for i in $(ls "$CCC" | sed -n 's/-.*//p' | sort -u | xargs); do
27 { rm -f "$LOG/$i-log".{failed,success}
28 "$0" "$@" CROSS=$i ; [ $? -eq 0 ] && mv "$LOG/$i".{txt,success}
30 [ ! -e "$LOG/$i.success" ] &&
31 { mv "$LOG/$i".{txt,failed};[ "$CROSS" != allnonstop ] && exit 1; }
34 elif [ ! -e "${CROSS_COMPILE}cc" ]; then
35 ls "$CCC" | sed -n 's/-.*//p' | sort -u | xargs
40 ${CROSS_COMPILE}cc --static -xc - -o /dev/null <<< "int main(void){return 0;}"||
44 if [ ! -z "$CROSS_COMPILE" ]; then
46 [ -z "$CROSS_PATH" ] && die "no ${CROSS_COMPILE}cc in path"
47 : ${CROSS_BASE:=$(basename "$CROSS_COMPILE")} ${CROSS:=${CROSS_BASE/-*/}}
49 echo "Building for ${CROSS:=host}"
51 # Create target-specific work/output directories
52 : ${OUTPUT:=$TOP/$CROSS} ${PKGDIR:=$PWD/scripts/root}
53 MYBUILD="$BUILD/${CROSS_BASE:-host-}tmp"
54 rm -rf "$MYBUILD" && mkdir -p "$MYBUILD" || exit 1
55 [ -z "$ROOT" ] && ROOT="$OUTPUT/fs" && rm -rf "$ROOT" # only blank if NOT set
57 # When cross compiling build everything under a host toybox with known behavior
58 if [ ! -z "$CROSS_COMPILE" ]; then
59 if [ ! -e "$AIRLOCK/toybox" ]; then
68 mkdir -p "$ROOT"/{etc,tmp,proc,sys,dev,home,mnt,root,usr/{bin,sbin,lib},var} &&
69 chmod a+rwxt "$ROOT"/tmp && ln -s usr/{bin,sbin,lib} "$ROOT" || exit 1
77 if ! mountpoint -q dev; then
78 mount -t devtmpfs dev dev || mdev -s
79 [ $$ -eq 1 ] && exec >/dev/console 2>&1
81 do ln -sf /proc/self/fd${i/,*/} dev/${i/*,/}; done
82 mkdir -p dev/{shm,pts}
83 mountpoint -q dev/pts || mount -t devpts dev/pts dev/pts
86 mountpoint -q proc || mount -t proc proc proc
87 mountpoint -q sys || mount -t sysfs sys sys
89 if [ $$ -eq 1 ]; then # Setup networking for QEMU (needs /proc)
93 [ "$(date +%s)" -lt 1000 ] && timeout 2 sntp -sq 10.0.2.2 # Ask host
94 [ "$(date +%s)" -lt 10000000 ] && sntp -sq time.google.com
97 [ -e /etc/rc ] && for i in $(echo /etc/rc/* | sort); do . $i; done
99 [ -z "$CONSOLE" ] && CONSOLE="$(</sys/class/tty/console/active)"
100 [ -z "$HANDOFF" ] && HANDOFF=/bin/sh && echo Type exit when done.
102 exec oneit -c /dev/"${CONSOLE:-console}" $HANDOFF
117 echo -e 'root:x:0:\nguest:x:500:\nnobody:x:65534:' > "$ROOT"/etc/group || exit 1
119 # Build static toybox with existing .config if there is one, else defconfig+sh
121 [ -e .config ] && [ -z "$PENDING" ] && CONF=silentoldconfig || unset CONF
123 make clean ${CONF:-defconfig KCONFIG_ALLCONFIG=<(echo "$XX")} &&
124 LDFLAGS=--static PREFIX="$ROOT" make toybox install || exit 1
126 # Build any packages listed on command line
128 announce "$i"; PATH="$PKGDIR:$PATH" source $i; [ $? -ne 0 ] && die $i
131 if [ -z "$LINUX" ] || [ ! -d "$LINUX/kernel" ]; then
132 echo 'No $LINUX directory, kernel build skipped.'
136 [ -z "$TARGET" ] && TARGET="${CROSS_BASE/-*/}"
137 [ -z "$TARGET" ] && TARGET="$(uname -m)"
139 # Target-specific info in an (alphabetical order) if/else staircase
145 QEMU="arm -M versatilepb -net nic,model=rtl8139 -net user"
149 DTB=arch/arm/boot/dts/versatile-pb.dtb
152 QEMU="aarch64 -M virt -cpu cortex-a57"
155 QEMU="arm -M virt" KARCH=arm VMLINUX=arch/arm/boot/zImage
162 QEMU="i386 -cpu 486 -global fw_cfg.dma_enabled=false" KCONF=M486
164 QEMU="i386 -cpu pentium3" KCONF=MPENTIUMII
172 QEMU="m68k -M q800" KARCH=m68k KARGS=ttyS0 VMLINUX=vmlinux
175 QEMU="mips -M malta" KARCH=mips KARGS=ttyS0 VMLINUX=vmlinux
178 QEMU="mipsel -M malta"
180 KARCH=powerpc QEMU="ppc -M g3beige" KARGS=ttyS0 VMLINUX=vmlinux
183 KARCH=powerpc QEMU="ppc64 -M pseries -vga none" KARGS=/dev/hvc0
194 QEMU="sh4 -M r2d -serial null -serial mon:stdio" KARCH=sh
203 if [ ! -z "$QEMU" ]; then
204 [ -z "$BUILTIN" ] && INITRD="-initrd ${CROSS_BASE}root.cpio.gz"
205 echo qemu-system-"$QEMU" '"$@"' $QEMU_MORE -nographic -no-reboot -m 256 \
206 -kernel $(basename $VMLINUX) $INITRD \
207 "-append \"panic=1 HOST=$TARGET console=$KARGS \$KARGS\"" \
208 ${DTB:+-dtb "$(basename "$DTB")"} ";echo -e '\e[?7h'" \
209 > "$OUTPUT/qemu-$TARGET.sh" &&
210 chmod +x "$OUTPUT/qemu-$TARGET.sh" || exit 1
213 announce "linux-$KARCH"
215 cp -sfR "$LINUX" "$MYBUILD/linux" && pushd "$MYBUILD/linux" &&
219 echo -e "# make ARCH=$KARCH -j \$(nproc)\n# boot $VMLINUX\n\n"
222 # Expand list of =y symbols, first generic then architecture-specific
224 echo "# architecture ${X:-independent}"
225 sed -E '/^$/d;s/([^,]*)($|,)/CONFIG_\1=y\n/g' <<< "$i"
228 [ ! -z "$BUILTIN" ] && echo -e CONFIG_INITRAMFS_SOURCE="\"$OUTPUT/fs\""
230 } > "$OUTPUT/miniconfig-$TARGET" &&
231 make ARCH=$KARCH allnoconfig KCONFIG_ALLCONFIG="$OUTPUT/miniconfig-$TARGET" &&
235 sed -e 's/# CONFIG_EXPERT .*/CONFIG_EXPERT=y/' -e "$(sed -E -e '/^$/d' \
236 -e 's@([^,]*)($|,)@/^CONFIG_\1=y/d;$a# CONFIG_\1 is not set/\n@g' \
237 <<< VT,SCHED_DEBUG,DEBUG_MISC,X86_DEBUG_FPU)" -i .config &&
240 # Build kernel. Copy config, device tree binary, and kernel binary to output
241 make ARCH=$KARCH CROSS_COMPILE="$CROSS_COMPILE" -j $(nproc) &&
242 cp .config "$OUTPUT/linux-fullconfig" || exit 1
243 [ ! -z "$DTB" ] && { cp "$DTB" "$OUTPUT" || exit 1 ;}
244 cp "$VMLINUX" "$OUTPUT" && cd .. && rm -rf linux && popd || exit 1
248 [ -z "$BUILTIN" ] && announce "${CROSS_BASE}root.cpio.gz" &&
249 (cd "$ROOT" && find . | cpio -o -H newc ${CROSS_COMPILE:+--no-preserve-owner} | gzip) \
251 rmdir "$MYBUILD" "$BUILD" 2>/dev/null # remove if empty