dotfiles/.bin/obsdmake

123 lines
2.4 KiB
Plaintext
Raw Normal View History

2023-02-22 08:31:38 +01:00
#!/bin/ksh -xe
umask 022
JOBS="${JOBS:=$(sysctl -n hw.ncpuonline)}"
export GLOBAL_AUTOCONF_CACHE="/var/ccache/config.cache"
export CCACHE_DIR="/var/ccache"
export CCACHE_SLOPPINESS="locale,time_macros,random_seed"
# base llvm?
export LLVM_CCACHE_BUILD=1
2023-02-22 08:31:38 +01:00
export LLVM_CCACHE_DIR="/var/ccache"
export CMAKE_CXX_COMPILER_LAUNCHER="ccache"
export CMAKE_C_COMPILER_LAUNCHER="ccache"
2023-02-25 20:17:14 +01:00
FLAGS="-fno-stack-protector -fno-ret-protector -mno-retpoline -march=native"
2023-02-22 08:31:38 +01:00
export CC="/opt/ccache/bin/cc $FLAGS"
export CXX="/opt/ccache/bin/c++ $FLAGS"
if [ -z "$1" ]; then
echo "Usage: ${0} [kernel, base, xenocara, release, all] [clean]"
exit 2
fi
doas mkdir -p /usr/obj /usr/xobj
doas chown build /usr/obj /usr/xobj
mkkernel() {
set -xe
cd /sys/arch/$(machine)/compile/GENERIC.MP
doas make clean
doas make obj
doas make config
time doas -u build make -j${JOBS}
doas make install
}
mkbase() {
set -xe
cd /usr/src
doas make obj
doas make -j${JOBS} build
doas make install
doas sysmerge
cd /dev
doas ./MAKEDEV all
}
mkxenocara() {
set -xe
cd /usr/xenocara
doas make clean
doas make bootstrap
doas make obj
doas make -j${JOBS} build
doas make install
}
mkrelease() {
set -xe
doas mkdir -p /data/{OpenBSD,Release}
doas chown -R build /data
doas chmod -R 700 /data
export DESTDIR=/data/OpenBSD
export RELEASEDIR=/data/Release
export RELDIR=/data/Release
export RELXDIR=/data/Release
cd /usr/src/etc
doas make release
cd /usr/src/distrib/sets
doas sh checkflist
cd /usr/xenocara
doas make release
doas make checkdist
cd /usr/src/distrib/$(machine)/iso
doas make
doas make install
}
kernelclean() {
cd /usr/src && doas make clean
}
baseclean() {
doas rm -rf /usr/obj/{,.}*
}
xenocaraclean() {
doas rm -rf /usr/xobj/{,.}*
}
releaseclean() {
doas rm -rf /data/OpenBSD/{,.}*
doas rm -rf /data/Release/{,.}*
}
allclean() {
kernelclean
baseclean
xenocaraclean
releaseclean
}
if [ "$2" == "clean" ]; then
case "$1" in
kernel) kernelclean; ;;
base) baseclean; ;;
xenocara) xenocaraclean; ;;
release) releaseclean; ;;
all) allclean; ;;
esac
exit 0;
fi
case "$1" in
kernel) mkkernel; ;;
base) mkbase; ;;
xenocara) mkxenocara; ;;
release) mkrelease; ;;
all) mkkernel; mkbase; mkxenocara; ;;
esac
sync