bsys5/linux-base/Makefile
2022-11-17 11:24:04 +01:00

156 lines
5.5 KiB
Makefile

.PHONY : help fetch all clean build dir bootstrap winsdk setup-debian setup-fedora veryclean docker-build docker-run docker-shell docker-clean artifacts pre-build post-package update
version:=$(shell cat version)
release:=$(shell cat release)
source_release:=$(shell cat source_release)
full_version:=$(version)-$(source_release)$(shell [ $(release) -gt 1 ] && echo "-$(release)")
mozbuild=~/.mozbuild
assets=assets/linux-base
ifeq ($(target_type),)
target_type:=flatpak
endif
ifeq ($(arch),)
arch:=x86_64
endif
docker_image_name=linux-base-$(arch)
help :
@echo "use: make [help] [all] [clean] [build] [package] [artifacts]"
@echo ""
@echo " fetch - get the latest tarball. must be done first, at least once."
@echo " update - Only fetch the LibreWolf version-release files. used by 'fetch'"
@echo ""
@echo " all - Build librewolf and it's artifacts."
@echo ""
@echo " dir - just extract and patch the LW tarball."
@echo " pre-build - Perform 'target_type' specific pre-build tasks."
@echo " build - Perform './mach build' on the extracted tarball."
@echo " package - Build symbols, and multilocale package."
@echo " post-package - Perform 'target_type' specific post-package tasks."
@echo " artifacts - Build the artifacts"
@echo ""
@echo " clean - Remove output files and temporary files."
@echo " veryclean - Remove even more stuff."
@echo " bootstrap - try to set up the build environment."
@echo " setup-debian, setup-fedora - needed packages."
@echo ""
@echo " docker-build - Run 'docker build' for " $(docker_image_name) " image."
@echo " docker-run - Run LW build using 'docker run' on then image."
@echo " docker-shell - Run a shell in the docker image."
@echo " docker-clean - Remove the docker image."
@echo ""
@echo "Use arch=x86_64 or arch=aarch64 to specify the target architecture."
@echo "Use target_type=flatpak or target_type=appimage to specify artifacts type."
all : dir pre-build build package post-package artifacts
update :
@wget -q -O version "https://gitlab.com/librewolf-community/browser/source/-/raw/main/version"
@wget -q -O source_release "https://gitlab.com/librewolf-community/browser/source/-/raw/main/release"
@echo "Using LibreWolf version $$(cat version)-$$(cat source_release)."
@echo "Targeting: $(target_type), architecture: $(arch)."
fetch : update
@wget -q -O "librewolf-$$(cat version)-$$(cat source_release).source.tar.gz.sha256sum" "https://gitlab.com/librewolf-community/browser/source/-/jobs/artifacts/main/raw/librewolf-$$(cat version)-$$(cat source_release).source.tar.gz.sha256sum?job=Build"
wget --progress=bar:force -O "librewolf-$$(cat version)-$$(cat source_release).source.tar.gz" "https://gitlab.com/librewolf-community/browser/source/-/jobs/artifacts/main/raw/librewolf-$$(cat version)-$$(cat source_release).source.tar.gz?job=Build"
cat "librewolf-$$(cat version)-$$(cat source_release).source.tar.gz.sha256sum"
sha256sum -c "librewolf-$$(cat version)-$$(cat source_release).source.tar.gz.sha256sum"
clean :
rm -rf librewolf-$(full_version) work
veryclean : clean
rm -rf firefox-$(full_version).en-US.win64.zip librewolf-$(full_version).en-US.win64-setup.exe librewolf-$(full_version).en-US.win64-portable.zip
rm -f "librewolf-$$(cat version)-$$(cat source_release).source.tar.gz" "librewolf-$$(cat version)-$$(cat source_release).source.tar.gz.sha256sum"
rm -f version source_release
rm -f librewolf-*.en-US.linux-*.tar.bz2
# this is the place to apply patches and create a custom mozconfig
pre-build :
./assets/pre_build_patches_mozconfig.sh
build : dir
(cd librewolf-$(full_version) && ./mach build)
package : dir
( cd librewolf-$(full_version) && ./mach buildsymbols )
( cd librewolf-$(full_version) && echo 'Packaging... (output hidden)' && \
cat browser/locales/shipped-locales | xargs ./mach package-multi-locale --locales >/dev/null )
post-package :
cp -v librewolf-$(full_version)/obj-$(arch)-pc-linux-gnu/dist/librewolf-$(full_version).en-US.linux-$(arch).tar.bz2 .
ARCH=$(arch) ./assets/post_package_distini_etc.sh
artifacts :
${MAKE} -f assets/$(target_type)/artifacts.mk artifacts
dir : librewolf-$(full_version)
librewolf-$(full_version) : librewolf-$(full_version).source.tar.gz
rm -rf $@
tar xf $<
touch $@
# we include the standard mozconfig from our $(arch)-specific one
mv librewolf-$(full_version)/mozconfig librewolf-$(full_version)/mozconfig.std
cp assets/mozconfig.$(arch) librewolf-$(full_version)/mozconfig
docker-build :
docker build --no-cache --build-arg "arch=$(arch)" -t $(docker_image_name) - < assets/Dockerfile
docker-run :
docker run --rm $(docker_image_name) sh -c "git pull && make fetch && make arch=$(arch) all"
docker-shell :
docker run -it --rm $(docker_image_name) sh -c "/bin/bash"
docker-clean :
docker rmi $(docker_image_name)
bootstrap : dir
(cd librewolf-$(full_version) && ./mach --no-interactive bootstrap --application-choice=browser)
( export t=$$(pwd)/librewolf-$(full_version) && \
cd $(mozbuild) && \
$$t/mach artifact toolchain --from-build sysroot-aarch64-linux-gnu && \
$$t/mach artifact toolchain --from-build linux64-binutils && \
$$t/mach artifact toolchain --from-build linux64-cctools-port && \
true )
/root/.cargo/bin/rustup target add aarch64-unknown-linux-gnu
setup-debian :
apt-get -y install mercurial python3 python3-dev python3-pip curl wget dpkg-sig libssl-dev zstd
setup-fedora :
dnf -y install python3 curl wget zstd python3-devel python3-pip mercurial openssl-devel