llvm/Makefile

118 lines
3.9 KiB
Makefile
Raw Normal View History

# See ~/.config/mock/<CONFIG>.cfg or /etc/mock/<CONFIG>.cfg
# Tweak this to centos-stream-9-x86_64 to build for CentOS
MOCK_CHROOT?=fedora-rawhide-x86_64
MOCK_OPTS_RELEASE=--no-clean --no-cleanup-after
MOCK_OPTS_SNAPSHOT=$(MOCK_OPTS_RELEASE) --with snapshot_build
YYYYMMDD=$(shell date +%Y%m%d)
SOURCEDIR=$(shell pwd)
SPEC=llvm.spec
FEDPKG_RELEASE=rawhide
######### Get sources
.PHONY: get-sources-snapshot
## Downloads all sources we need for a snapshot build.
get-sources-snapshot:
YYYYMMDD=$(YYYYMMDD) ./.copr/snapshot-info.sh > $(SOURCEDIR)/version.spec.inc
spectool -g --define "_sourcedir $(SOURCEDIR)" --define "_with_snapshot_build 1" $(SPEC)
.PHONY: get-sources-release
## Downloads all sources we need for a release build.
get-sources-release:
spectool -g --define "_sourcedir $(SOURCEDIR)" $(SPEC)
######### Build/Clean SRPM
.PHONY: clean-srpm
## Removes all *.src.rpm (aka SRPMs) from the current directory.
clean-srpm:
rm -fv $(SOURCEDIR)/*.src.rpm
.PHONY: srpm-release
## Builds an SRPM that can be used for a release build.
srpm-release: clean-srpm get-sources-release
fedpkg --release $(FEDPKG_RELEASE) srpm
.PHONY: srpm-snapshot
## Builds an SRPM that can be used for a snapshot build.
srpm-snapshot: clean-srpm get-sources-snapshot
fedpkg --release $(FEDPKG_RELEASE) srpm -- --define "_with_snapshot_build 1"
######### Scrub mock chroot and cache
.PHONY: scrub-chroot
## Completely remove the fedora chroot and cache.
scrub-chroot:
mock -r $(MOCK_CHROOT) --scrub all
######### Do a mock build
.PHONY: mockbuild-release
## Start a mock build of the release SRPM.
mockbuild-release: srpm-release
mock -r $(MOCK_CHROOT) $(MOCK_OPTS_RELEASE) -N *.src.rpm
.PHONY: mockbuild-snapshot
## Start a mock build of the snapshot SRPM.
mockbuild-snapshot: srpm-snapshot
mock -r $(MOCK_CHROOT) $(MOCK_OPTS_SNAPSHOT) -N *.src.rpm
######### Edit-last-failing-script
.PHONY: edit-last-failing-script
## Opens the last failing or running script from mock in your editor
## of choice for you to edit it and later re-run it in mock with:
## "make mockbuild-rerun-last-script-...".
edit-last-failing-script:
$$EDITOR /var/lib/mock/$(MOCK_CHROOT)/root/var/tmp/rpm-tmp.*
######### Re-run the last failing script from mock
######### This is particularly useful when you have
.PHONY: mockbuild-rerun-last-script-release
## Re-runs the last failing or running script of your release mockbuild.
mockbuild-rerun-last-script-release:
mock --root=$(MOCK_CHROOT) $(MOCK_OPTS_RELEASE) --shell 'sh -e /var/tmp/rpm-tmp.*'
.PHONY: mockbuild-rerun-last-script-snapshot
## Re-runs the last failing or running script of your snapshot mockbuild.
## We have multiple flavors of this recipe.
mockbuild-rerun-last-script-snapshot:
mock --root=$(MOCK_CHROOT) $(MOCK_OPTS_SNAPSHOT) --shell 'sh -e /var/tmp/rpm-tmp.*'
.PHONY: help
# Based on https://gist.github.com/rcmachado/af3db315e31383502660
## Display this help text.
help:/
$(info Available targets)
$(info -----------------)
@awk '/^[a-zA-Z\-0-9]+:/ { \
helpMessage = match(lastLine, /^## (.*)/); \
helpCommand = substr($$1, 0, index($$1, ":")-1); \
if (helpMessage) { \
helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \
gsub(/##/, "\n ", helpMessage); \
} else { \
helpMessage = "(No documentation)"; \
} \
printf "%-37s - %s\n", helpCommand, helpMessage; \
lastLine = "" \
} \
{ hasComment = match(lastLine, /^## (.*)/); \
if(hasComment) { \
lastLine=lastLine$$0; \
} \
else { \
lastLine = $$0 \
} \
}' $(MAKEFILE_LIST)
# Map deprecated targets to new targets
.PHONY: snapshot-srpm release-srpm
snapshot-srpm release-srpm:
$(eval mapped_target:=$(subst snapshot-srpm,srpm-snapshot,$(MAKECMDGOALS)))
$(eval mapped_target:=$(subst release-srpm,srpm-release,$(mapped_target)))
$(info WARNING: "$(MAKECMDGOALS)" is deprecated. Instead running "$(mapped_target)")
$(MAKE) $(mapped_target)