Skip to content

Commit

Permalink
Makefile: change build environment
Browse files Browse the repository at this point in the history
  • Loading branch information
amd64 committed Mar 24, 2022
1 parent d3892a5 commit e4ddb98
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 12 deletions.
8 changes: 8 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,11 @@
path = release
url = https://github.com/b1ad3runn3r/AnyKernel3.git
branch = master
[submodule "toolchain/clang"]
path = toolchain/clang
url = https://github.com/b1ad3runn3r/proton-clang.git
shallow = true
[submodule "toolchain/gcc"]
path = toolchain/gcc
url = https://github.com/b1ad3runn3r/android_prebuilts_gcc_linux-x86_aarch64_aarch64-linux-android-4.9.git
shallow = true
13 changes: 8 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ include scripts/subarch.include
# Default value for CROSS_COMPILE is not to prefix executables
# Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile
ARCH ?= arm64
CROSS_COMPILE ?= /home/amd64/toolchains/gcc-494/bin/aarch64-linux-gnu-
CROSS_COMPILE ?= $(srctree)/toolchain/gcc/bin/aarch64-linux-android-

# Architecture as present in compile.h
UTS_MACHINE := $(ARCH)
Expand Down Expand Up @@ -371,7 +371,7 @@ KBUILD_HOSTLDLIBS := $(HOST_LFS_LIBS) $(HOSTLDLIBS)
# Make variables (CC, etc...)
AS = $(CROSS_COMPILE)as
LD = $(CROSS_COMPILE)ld
REAL_CC = /home/amd64/toolchains/clang-r377782d/bin/clang
REAL_CC = $(srctree)/toolchain/clang/bin/clang
CPP = $(CC) -E
AR = $(CROSS_COMPILE)ar
NM = $(CROSS_COMPILE)nm
Expand All @@ -392,7 +392,7 @@ CHECK = sparse

# Use the wrapper for the compiler. This wrapper scans for new
# warnings and causes the build to stop upon encountering them
CC = $(REAL_CC)
CC = $(srctree)/scripts/gcc-wrapper.py $(REAL_CC)

CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
-Wbitwise -Wno-return-void -Wno-unknown-attribute $(CF)
Expand Down Expand Up @@ -427,7 +427,10 @@ KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
-Werror-implicit-function-declaration \
-Wno-format-security \
-std=gnu89 \
-fdiagnostics-color=always -pipe
-mcpu=cortex-a55 -fdiagnostics-color=always -pipe \
-Wno-void-pointer-to-enum-cast -Wno-misleading-indentation -Wno-unused-function -Wno-bool-operation \
-Wno-unsequenced -Wno-void-pointer-to-int-cast -Wno-unused-variable -Wno-pointer-to-int-cast -Wno-pointer-to-enum-cast \
-Wno-fortify-source -Wno-strlcpy-strlcat-size -Wno-align-mismatch

KBUILD_CPPFLAGS := -D__KERNEL__
KBUILD_AFLAGS_KERNEL :=
Expand Down Expand Up @@ -800,7 +803,7 @@ KBUILD_CFLAGS += $(call cc-option, -gdwarf-4,)
endif

ifdef CONFIG_CFP
CFP_CC ?= /home/amd64/toolchains/clang-r377782d/bin/clang
CFP_CC ?= $(srctree)/toolchain/clang/bin/clang
CC = $(srctree)/scripts/gcc-wrapper.py $(CFP_CC)
endif

Expand Down
79 changes: 72 additions & 7 deletions build_kernel.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,79 @@
#!/bin/bash
rm -rf out

ccache -M 4.5

export ARCH=arm64
mkdir out

BUILD_CROSS_COMPILE=$(pwd)/toolchain/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin/aarch64-linux-android-
KERNEL_LLVM_BIN=$(pwd)/toolchain/llvm-arm-toolchain-ship/10.0/bin/clang
echo
echo "Clean Repository"
echo

make clean & make mrproper
#git clean -xfd # failsafe

find . -name "*.orig" -type f -delete

if [ -d out ]; then
rm -rf out;
fi

if [ -f "release/dtb" ]; then
rm release/dtb;
fi
if [ -f "release/Image.gz" ]; then
rm release/Image.gz
fi
if [ -f "release/Image" ]; then
rm release/Image
fi
if compgen -G "release/modules/system/vendor/lib/modules/*.ko" > /dev/null; then
rm release/modules/system/vendor/lib/modules/*.ko;
fi
#find "release/modules/system/vendor/lib/modules" -name "*.ko" -type f -delete

if compgen -G "release/*.zip" > /dev/null; then
rm release/*.zip;
fi
#find "release" -name "*.zip" -type f -delete

echo
echo "Compile Source"
echo

mkdir -p out
mkdir -p release/modules/system/vendor/lib/modules

BUILD_CROSS_COMPILE=$(pwd)/toolchain/gcc/bin/aarch64-linux-android-
KERNEL_LLVM_BIN=$(pwd)/toolchain/clang/bin/clang
CLANG_TRIPLE=aarch64-linux-gnu-
KERNEL_MAKE_ENV="DTC_EXT=$(pwd)/tools/dtc CONFIG_BUILD_ARM64_DT_OVERLAY=y"

make -j8 -C $(pwd) O=$(pwd)/out $KERNEL_MAKE_ENV ARCH=arm64 CROSS_COMPILE=$BUILD_CROSS_COMPILE REAL_CC=$KERNEL_LLVM_BIN CLANG_TRIPLE=$CLANG_TRIPLE vendor/gts7xl_eur_open_defconfig
make -j8 -C $(pwd) O=$(pwd)/out $KERNEL_MAKE_ENV ARCH=arm64 CROSS_COMPILE=$BUILD_CROSS_COMPILE REAL_CC=$KERNEL_LLVM_BIN CLANG_TRIPLE=$CLANG_TRIPLE

cp out/arch/arm64/boot/Image $(pwd)/arch/arm64/boot/Image
make -j$(nproc) -C $(pwd) O=$(pwd)/out $KERNEL_MAKE_ENV ARCH=arm64 CROSS_COMPILE=$BUILD_CROSS_COMPILE REAL_CC=$KERNEL_LLVM_BIN CLANG_TRIPLE=$CLANG_TRIPLE vendor/gts7xl_eur_open_defconfig
make -j$(nproc) -C $(pwd) O=$(pwd)/out $KERNEL_MAKE_ENV ARCH=arm64 CROSS_COMPILE=$BUILD_CROSS_COMPILE REAL_CC=$KERNEL_LLVM_BIN CLANG_TRIPLE=$CLANG_TRIPLE

cat out/arch/arm64/boot/dts/vendor/qcom/kona-v2.1.dtb \
out/arch/arm64/boot/dts/vendor/qcom/kona-v2.dtb \
out/arch/arm64/boot/dts/vendor/qcom/kona.dtb \
> out/arch/arm64/boot/dtb

echo
echo "Package Kernel"
echo

if [ -f out/arch/arm64/boot/Image ]; then
cp -f out/arch/arm64/boot/dtb release/
if [ -f out/arch/arm64/boot/Image.gz ]; then
cp -f out/arch/arm64/boot/Image.gz release/
else
cp -f out/arch/arm64/boot/Image release/
fi
find out -type f -name "*.ko" -exec cp -Rf "{}" release/modules/system/vendor/lib/modules/ \;

HASH=$(git rev-parse --short HEAD)

cd release
zip -r9 "dragkernel-gts7xl-$HASH.zip" * -x *.DS_Store .git* README.md *placeholder LICENSE
cd ../
fi

1 change: 1 addition & 0 deletions toolchain/clang
Submodule clang added at 9fb011
1 change: 1 addition & 0 deletions toolchain/gcc
Submodule gcc added at be79a1

0 comments on commit e4ddb98

Please sign in to comment.