Packages requiring nonstandard rpmbuild Makefile

annobin
PKG=annobin
DIST=.el8_5
annobin:
	./rpmbuild --target=i586 -v -bb \
	-D '_annotated_cflags %{nil}' \
	--without tests \
	-D 'dist $(DIST)' \
	SPECS/$(PKG).spec 2>&1 | \
	while IFS="" read line; do echo `date '+%Y-%m-%d %T'` "$$line"; done | \
	tee log

src:
	./rpmbuild --target=i586 -v -bs \
	-D '_annotated_cflags %{nil}' \
	--without tests \
	SPECS/annobin.spec
bind
PKG=bind
DIST=.el8
binary:
	## jsoncpp-devel (EPEL) conflicts with build
	-sudo rpm -ev jsoncpp-devel
	:
	## need PKCS11, else et al will be orphand
	./rpmbuild --target=i586 -v -bb \
	-D 'dist $(DIST)' \
	--with PKCS11 --without SDB \
	--without UNITTEST --without GEOIP2 \
	SPECS/$(PKG).spec 2>&1 | \
	while IFS="" read line; do echo `date '+%Y-%m-%d %T'` "$$line"; done | \
	tee log

src:
	./rpmbuild --target=i586 -v -bs \
	-D 'dist $(DIST)' \
	--with PKCS11 --without SDB \
	--without UNITTEST --without GEOIP2 \
	SPECS/$(PKG).spec
binutils
PKG=binutils
DIST=.el8_5
binary:
	./rpmbuild --target=i586 -v -ba \
		--with=bootstrap \
	-D 'dist $(DIST)' \
	SPECS/$(PKG).spec | \
	while IFS="" read line; do echo `date '+%Y-%m-%d %T'` "$$line"; done | \
	tee log

src:
	./rpmbuild --target=i586 -v -bs \
		--with=bootstrap \
	-D 'dist $(DIST)' \
	SPECS/$(PKG).spec

binutils-cross:
	setarch i686 \
	./rpmbuild --target=i686 -v -ba \
		--with=bootstrap \
	-D 'dist $(DIST)' \
	SPECS/$(PKG).spec | \
	while IFS="" read line; do echo `date '+%Y-%m-%d %T'` "$$line"; done | \
	tee $@.log

	#	--define="binutils_target  i686-redhat-linux" \
	#	--define="_target_platform i686-redhat-linux" \
	#
ghc
PKG=ghc
DIST=.el8
binary-self:
	./rpmbuild --target=i586 -v -bb \
	-D 'dist $(DIST)' \
	--with docs \
	SPECS/$(PKG).spec 2>&1 | \
	while IFS="" read line; do echo `date '+%Y-%m-%d %T'` "$$line"; done | \
	tee log

src:
	./rpmbuild --target=i586 -v -bs \
	-D 'dist $(DIST)' \
	SPECS/$(PKG).spec

binary-cross:
	./rpmbuild --target=i586 -v -bb \
	-D 'dist $(DIST)' \
	--without docs \
	SPECS/$(PKG).spec 2>&1 | \
	while IFS="" read line; do echo `date '+%Y-%m-%d %T'` "$$line"; done | \
	tee log.cross

gpgme
PKG=gpgme
DIST=.el8
binary:
	./rpmbuild --target=i586 -v -bb \
	--with python2 \
	-D 'dist $(DIST)' \
	SPECS/$(PKG).spec 2>&1 | \
	while IFS="" read line; do echo `date '+%Y-%m-%d %T'` "$$line"; done | \
	tee log

src:
	./rpmbuild --target=i586 -v -bs \
	-D 'dist $(DIST)' \
	SPECS/$(PKG).spec
java-1.8.0-openjdk
PKG=java-1.8.0-openjdk
DIST=.el8_5
binary:
	./rpmbuild --target=i586 -v -bb \
	-D 'dist $(DIST)' \
	SPECS/$(PKG).spec 2>&1 | \
	while IFS="" read line; do echo `date '+%Y-%m-%d %T'` "$$line"; done | \
	tee log

src:
	./rpmbuild --target=i586 -v -bs \
	-D 'dist $(DIST)' \
	SPECS/$(PKG).spec

cross:
	setarch i686 \
	./rpmbuild --target=i586 -v -bb \
	-D 'dist $(DIST)' \
	SPECS/$(PKG).spec 2>&1 | \
	while IFS="" read line; do echo `date '+%Y-%m-%d %T'` "$$line"; done| \
	tee log-cross
kernel
all:
	echo 'Use "make kernel-i686" or "make kernel-i586" .'
	false

kernel-i686:
	#--without perf \
	# RHEL8.3 made %define with_perf 0 on %{with_baseonly};
	# needs omitting --with baseonly to build python3-perf package
	#
	./rpmbuild --target=i686 -v -bb \
	--without debug --without debuginfo \
	--without kabidupchk --without kabidwchk --without kabidw_base \
	SPECS/kernel.spec 2>&1 | \
	while IFS="" read line; do echo `date '+%Y-%m-%d %T'` "$$line"; done | \
	tee log.i686

kernel-i586:
	# --without perf \
	# --with baseonly \
	#
	./rpmbuild --target=i586 -v -bb \
	--without debug --without debuginfo \
	--without kabidupchk --without kabidwchk --without kabidw_base \
	SPECS/kernel.spec 2>&1 | \
	while IFS="" read line; do echo `date '+%Y-%m-%d %T'` "$$line"; done | \
	tee log.i586

src:
	./rpmbuild -v -bs \
	--without debug --without debuginfo \
	--without kabidupchk --without kabidwchk --without kabidw_base \
	SPECS/kernel.spec

kf5-prison
PKG=kf5-prison
DIST=.el8
	# -D '__cmake_in_source_build 1' 
binary:
	./rpmbuild --target=i586 -v -bb \
	--with qtquick \
	-D 'dist $(DIST)' \
	SPECS/$(PKG).spec 2>&1 | \
	while IFS="" read line; do echo `date '+%Y-%m-%d %T'` "$$line"; done | \
	tee log

src:
	./rpmbuild --target=i586 -v -bs \
	--with qtquick \
	-D 'dist $(DIST)' \
	SPECS/$(PKG).spec
kf5-solid
PKG=kf5-solid
DIST=.el8
binary:
	## __cmake_configure seems not defined anywhere?
	./rpmbuild --target=i586 -v -bb \
	-D '__cmake_configure cmake' \
	-D 'dist $(DIST)' \
	SPECS/$(PKG).spec 2>&1 | \
	while IFS="" read line; do echo `date '+%Y-%m-%d %T'` "$$line"; done | \
	tee log

src:
	./rpmbuild --target=i586 -v -bs \
	-D 'dist $(DIST)' \
	SPECS/$(PKG).spec
librepo
PKG=librepo
DIST=.el8
binary:
	# test fails with permission denied without sudo
	sudo \
	./rpmbuild --target=i586 -v -bb \
	-D 'dist $(DIST)' \
	SPECS/$(PKG).spec 2>&1 | \
	while IFS="" read line; do echo `date '+%Y-%m-%d %T'` "$$line"; done | \
	tee log
	sudo chown -R `id -u`:`id -g` RPMS

src:
	./rpmbuild --target=i586 -v -bs \
	-D 'dist $(DIST)' \
	SPECS/$(PKG).spec
libtalloc
PKG=libtalloc
DIST=.el8
binary:
	## uninstall libbsd(EPEL) beforehand
	-sudo rpm -ev --nodeps libbsd libbsd-devel
	:
	./rpmbuild --target=i586 -v -bb \
	-D 'dist $(DIST)' \
	SPECS/$(PKG).spec 2>&1 | \
	while IFS="" read line; do echo `date '+%Y-%m-%d %T'` "$$line"; done | \
	tee log

src:
	./rpmbuild --target=i586 -v -bs \
	-D 'dist $(DIST)' \
	SPECS/$(PKG).spec
lvm2
PKG=lvm2
DIST=.el8
binary:
	## otherwise lvm2-dbusd.noarch depends on /bin/python (should be /usr/bin/python)
	PATH="/usr/sbin:/usr/bin" \
	./rpmbuild --target=i586 -v -bb \
	-D 'dist $(DIST)' \
	SPECS/$(PKG).spec 2>&1 | \
	while IFS="" read line; do echo `date '+%Y-%m-%d %T'` "$$line"; done | \
	tee log

src:
	./rpmbuild --target=i586 -v -bs \
	-D 'dist $(DIST)' \
	SPECS/$(PKG).spec
metacity
PKG=metacity
DIST=.el8
binary:
	# vulkan is not a dependency. configure --disable-vulkan
	env enable_vulkan=no \
	./rpmbuild --target=i586 -v -bb \
	-D 'dist $(DIST)' \
	SPECS/$(PKG).spec 2>&1 | \
	while IFS="" read line; do echo `date '+%Y-%m-%d %T'` "$$line"; done | \
	tee log

src:
	./rpmbuild --target=i586 -v -bs \
	-D 'dist $(DIST)' \
	SPECS/$(PKG).spec
mingw-gcc
PKG=mingw-gcc
DIST=.el8
binary:
	./rpmbuild --target=i586 -v -bb \
	-D 'dist $(DIST)' \
	--without winpthreads \
	SPECS/$(PKG).spec 2>&1 | \
	while IFS="" read line; do echo `date '+%Y-%m-%d %T'` "$$line"; done | \
	tee log

src:
	./rpmbuild --target=i586 -v -bs \
	-D 'dist $(DIST)' \
	SPECS/$(PKG).spec
newt
PKG=newt
binary:
	./rpmbuild --target=i586 -v -bb \
	-D 'dist .el8' \
	-D 'with_python2 1' \
	SPECS/$(PKG).spec 2>&1 | \
	(IFS=""; while read line; do echo `date '+%Y-%m-%d %T'` "$$line"; done )| \
	tee log
nodejs
PKG=nodejs
DIST=.module_el8.3.0+717+fa496f1d
binary:
	./rpmbuild --target=i586 -v -bb \
	--with bootstrap \
	-D 'dist $(DIST)' \
	SPECS/$(PKG).spec 2>&1 | \
	while IFS="" read line; do echo `date '+%Y-%m-%d %T'` "$$line"; done | \
	tee log

src:
	./rpmbuild --target=i586 -v -bs \
	--with bootstrap \
	-D 'dist $(DIST)' \
	SPECS/$(PKG).spec
nss
PKG=nss
DIST=.el8_5
binary:
	./rpmbuild --target=i586 -v -bb \
	-D 'dist $(DIST)' \
	--without tests \
	SPECS/$(PKG).spec 2>&1 | \
	while IFS="" read line; do echo `date '+%Y-%m-%d %T'` "$$line"; done | \
	tee log

src:
	./rpmbuild --target=i586 -v -bs \
	-D 'dist $(DIST)' \
	SPECS/$(PKG).spec
patchutils
patchutils:
	## do not let it use /bin/perl; use /usr/bin/perl
	## otherwise dnf cannot derive perl-interpreter package
	env PATH=/usr/bin:/usr/sbin:/bin:/sbin \
	./rpmbuild --target=i586 -v -bb SPECS/$@.spec
perl
PKG=perl
DIST=.el8

#test fails
#2020-01-08 11:27:37 #   Failed test 'timelocal year for 1970 1 2 0 0 0'
#2020-01-08 11:27:37 #   at t/Local.t line 109.
#2020-01-08 11:27:37 #          got: '170'
#2020-01-08 11:27:37 #     expected: '70'

#test fails with perl-Net-SSLeay version mismatch
#2021-01-01 17:35:20 SSLeay.c: loadable library and perl binaries are mismatched (got handshake key 0x8200080, needed 0x80c0080)
#2021-01-01 17:35:20 # Failed test 1 - config information dumped with -d at ../lib/perlbug.t line 51
#2021-01-01 17:35:20 #      got ''
#2021-01-01 17:35:20 # expected /(?^:Site configuration information)/
#...
#2021-01-01 17:35:23 ../lib/perlbug.t ................................................... 
#2021-01-01 17:35:23 Failed 19/25 subtests 
#	--without test

binary:
	TZ=GMT+0 \
	./rpmbuild --target=i586 -v -bb \
	-D 'dist $(DIST)' \
	SPECS/$(PKG).spec 2>&1 | \
	while IFS="" read line; do echo `date '+%Y-%m-%d %T'` "$$line"; done | \
	tee log

src:
	./rpmbuild --target=i586 -v -bs \
	-D 'dist $(DIST)' \
	SPECS/$(PKG).spec
postfix
PKG=postfix
DIST=.el8
binary:
	./rpmbuild --target=i586 -v -bb \
	-D 'dist $(DIST)' \
	--without pgsql --without mysql --without cdb \
	SPECS/$(PKG).spec 2>&1 | \
	while IFS="" read line; do echo `date '+%Y-%m-%d %T'` "$$line"; done | \
	tee log

src:
	./rpmbuild --target=i586 -v -bs \
	-D 'dist $(DIST)' \
	SPECS/$(PKG).spec
python-cffi
python-cffi:
	## demands defining %{__python}
	./rpmbuild --target=i586 -v -bb \
	-D '__python /usr/bin/python3' \
	SPECS/$@.spec
python3
PKG=python3
DIST=.el8
binary:
	## Needs to move out existing /usr/lib/python3.6/site-packages ,
	## otherwise test.test_site.StartupImportTests FAILs
	-sudo mv /usr/lib/python3.6/site-packages /usr/lib/python3.6/site-packages81
	./rpmbuild --target=i586 -v -bb \
	-D 'dist $(DIST)' \
	SPECS/$(PKG).spec 2>&1 | \
	while IFS="" read line; do echo `date '+%Y-%m-%d %T'` "$$line"; done | \
	tee log
	sudo mv /usr/lib/python3.6/site-packages81 /usr/lib/python3.6/site-packages

src:
	./rpmbuild --target=i586 -v -bs \
	-D 'dist $(DIST)' \
	SPECS/$(PKG).spec
qt5-qttools
PKG=qt5-qttools
DIST=.el8
binary:
	## otherwise EPEL /usr/lib/libQt5WebKit.so dependency will be builtin
	sudo rpm -ev --nodeps qt5-qtwebkit-devel
	:
	./rpmbuild --target=i586 -v -bb \
	-D 'dist $(DIST)' \
	SPECS/$(PKG).spec 2>&1 | \
	while IFS="" read line; do echo `date '+%Y-%m-%d %T'` "$$line"; done | \
	tee log

src:
	./rpmbuild --target=i586 -v -bs \
	-D 'dist $(DIST)' \
	SPECS/$(PKG).spec
qt5-qtwebengine
PKG=$(shell ls SPECS/*.spec | sed -ne 's:SPECS/\(.*\)\.spec$$:\1:p')
DIST=.el8
binary:
	## existing old qt5-qtwebengine-devel inteferes,
	## with obscure error involving Q_WEBENGINECORE_EXPORT macro
	## not defined properly
	if rpm -q qt5-qtwebengine-devel; then sudo rpm -ev qt5-qtwebengine-devel; fi
	./rpmbuild --target=i586 -v -bb \
	-D 'dist $(DIST)' \
	SPECS/$(PKG).spec 2>&1 | \
	while IFS="" read line; do echo `date '+%Y-%m-%d %T'` "$$line"; done | \
	tee log

src:
	./rpmbuild --target=i586 -v -bs \
	-D 'dist $(DIST)' \
	SPECS/$(PKG).spec
ruby
PKG=ruby
DIST=.module_el8.4.0+875+807aec38
binary:
	## move out existing ones else TestOpenURI#test_200 freezes
	-sudo sh -c 'mv /usr/share/rubygems{,81}; mv /usr/share/ruby{,81}; mv /usr/lib/ruby{,81}'
	:
	# needs sudo to resolve EPERM in "make test"
	#sudo
	# USER= needed to be reset to the running user, else euid tests fail
	# (i686env sets these to "root")
	# --without jit needed to circumvent "hardened" gcc 8.3
	# otherwise %check fails with
	# "error: one or more PCH files were found, but they were invalid";
	# needs patched SPECS/ruby.spec
	:
	USER=`whoami` USERNAME=`whoami` LOGNAME=`whoami` \
	./rpmbuild --target=i586 -v -bb \
	-D 'dist $(DIST)' \
	--without jit \
	SPECS/$(PKG).spec </dev/null 2>&1 | \
	while IFS="" read line; do echo `date '+%Y-%m-%d %T'` "$$line"; done | \
	tee log
	:
	sudo sh -c 'mv /usr/share/rubygems{81,}; mv /usr/share/ruby{81,}; mv /usr/lib/ruby{81,}'
	

src:
	./rpmbuild --target=i586 -v -bs \
	-D 'dist $(DIST)' \
	--without jit \
	SPECS/$(PKG).spec

perm:
	sudo chown -R $$LOGNAME RPMS
rust
#1.45:DIST=.module_el8.3.0+485+0058aead
#1.47 #DIST=.module_el8.3.0+702+c3b74dac
#1.49 DIST=.module+el8.4.0+9446+1a463e08
#1.54
DIST=.module_el8.5.0+1023+0c63d3d6

## Run "make rust-bootstrap" to bootstrap from rust-lang.org provided
## https://static.rust-lang.org/dist/rust-1.48.0-i686-unknown-linux-gnu.tar.xz
## https://static.rust-lang.org/dist/rust-1.53.0-i686-unknown-linux-gnu.tar.xz
## Install the resulting .i686 rust first.
## Then, run "make rust-i586" to "cross compile" rust.i586

default:
	echo "Use make rust-bootstrap or rust-i586"
	false

rust-bootstrap:
	# --with bundled_llvm
	#
	## from rust-1.41, 32bit /bin/ld.bfd barfs with
	## /bin/ld: failed to set dynamic section sizes: Memory exhausted
	## try using /bin/ld.gold
	sudo alternatives --set ld /usr/bin/ld.gold

	# test [debuginfo-lldb] debuginfo/constant-in-match-pattern.rs ... ok
	# test [debuginfo-lldb] debuginfo/cross-crate-spans.rs ... ignored
	# (freezing in cross-crate-type-uniquing.lldb)
	# try "uninstalling" /usr/bin/lldb beforehand
	# try --without lldb
	if [ ! -f /usr/bin/lldb- -a -f /usr/bin/lldb ]; then sudo mv -i /usr/bin/lldb{,-}; fi
	
	./rpmbuild --target=i686 -v -bb \
	-D 'channel stable' \
	-D 'dist $(DIST)' \
	-D 'bootstrap_arches i686' \
	--without lldb \
	SPECS/rust.spec 2>&1 | \
	while IFS="" read line; do echo `date '+%Y-%m-%d %T'` "$$line"; done | \
	tee log.boot
	sudo alternatives --auto ld ## return to ld.bfd
	if [ -f /usr/bin/lldb- ]; then sudo mv -i /usr/bin/lldb{-,}; fi

rust-i586:
	## from rust-1.41, 32bit /bin/ld.bfd barfs with
	## /bin/ld: failed to set dynamic section sizes: Memory exhausted
	## try using /bin/ld.gold
	sudo alternatives --set ld /usr/bin/ld.gold

	# freeze (no load) during test: try --without lldb
	# test [debuginfo-lldb] debuginfo/constant-in-match-pattern.rs ... ok
	# test [debuginfo-lldb] debuginfo/cross-crate-spans.rs ... ignored
	# (freezing in cross-crate-type-uniquing.lldb)
	# try "uninstalling" /usr/bin/lldb beforehand
	if [ ! -f /usr/bin/lldb- -a -f /usr/bin/lldb ]; then sudo mv -i /usr/bin/lldb{,-}; fi

	./rpmbuild --target=i586 -v -bb \
	-D 'channel stable' \
	-D 'dist $(DIST)' \
	--without bundled_llvm \
	--without lldb \
	SPECS/rust.spec 2>&1 | \
	while IFS="" read line; do echo `date '+%Y-%m-%d %T'` "$$line"; done | \
	tee log.i586
	sudo alternatives --auto ld ## return to ld.bfd
	if [ -f /usr/bin/lldb- ]; then sudo mv -i /usr/bin/lldb{-,}; fi

src:
	./rpmbuild --target=i686 -v -bs \
	-D 'channel stable' \
	-D 'dist $(DIST)' \
	-D 'srcrpm 1' \
	SPECS/rust.spec

	# -D 'bootstrap_arches i686' \

samba
PKG=samba
DIST=.el8_5
binary:
	if rpm -q libbsd; then \
		echo '*** uninstalling EPEL libbsd package beforehand to prevent dependency'; \
		sudo rpm -ev libbsd; \
	fi
	./rpmbuild --target=i586 -v -bb \
	-D 'dist $(DIST)' \
	SPECS/$(PKG).spec 2>&1 | \
	while IFS="" read line; do echo `date '+%Y-%m-%d %T'` "$$line"; done | \
	tee log

src:
	./rpmbuild --target=i586 -v -bs \
	-D 'dist $(DIST)' \
	SPECS/$(PKG).spec
sssd
PKG=sssd
DIST=.el8_5
binary:
	# With po4a enabled, it tries to rebuild translated manpages
	# and discards files below 80% translation rate.
	# Squelch such behavior by pretending po4a is not installed,
	# just like koji.
	env ac_cv_prog_PO4A="no" \
	./rpmbuild --target=i586 -v -bb \
	-D 'dist $(DIST)' \
	SPECS/$(PKG).spec 2>&1 | \
	while IFS="" read line; do echo `date '+%Y-%m-%d %T'` "$$line"; done | \
	tee log

src:
	./rpmbuild --target=i586 -v -bs \
	-D 'dist $(DIST)' \
	SPECS/$(PKG).spec
subversion
PKG=subversion
DIST=.module_el8.4.0+693+c49df33a
binary:
	./rpmbuild --target=i586 -v -bb \
	--without kwallet \
	--without python2 --without pyswig --with python3 \
	--without java -D 'with_java 0' \
	-D 'dist $(DIST)' \
	SPECS/$(PKG).spec 2>&1 | \
	while IFS="" read line; do echo `date '+%Y-%m-%d %T'` "$$line"; done | \
	tee log

src:
	./rpmbuild --target=i586 -v -bs \
	-D 'dist $(DIST)' \
	SPECS/$(PKG).spec
systemd
PKG=systemd
DIST=.el8_5
binary:
	# needed for "meson test test-cgroup-util":
	# parent: mount -o bind /sys/fs/cgroup/systemd /chroot/i686/sys/fs/cgroup/systemd
	# -D 'debug_package %{nil}' 
	:
	LOGNAME=`whoami` USER=`whoami` USERNAME=`whoami` \
	./rpmbuild --target=i586 -v -bb \
	-D 'dist $(DIST)' \
	SPECS/$(PKG).spec 2>&1 | \
	while IFS="" read line; do echo `date '+%Y-%m-%d %T'` "$$line"; done | \
	tee log

src:
	./rpmbuild --target=i586 -v -bs \
	-D 'dist $(DIST)' \
	SPECS/$(PKG).spec
systemtap
PKG=systemtap
DIST=.el8
binary:
	./rpmbuild --target=i586 -v -bb \
	-D 'dist $(DIST)' \
	--without virthost -D 'with_virthost 0' \
	SPECS/$(PKG).spec 2>&1 | \
	while IFS="" read line; do echo `date '+%Y-%m-%d %T'` "$$line"; done | \
	tee log

src:
	./rpmbuild --target=i586 -v -bs \
	-D 'dist $(DIST)' \
	SPECS/$(PKG).spec
webkit2gtk3
Needs to fix /lib/openjpeg-2.3/OpenJPEGConfig.cmake (provided by openjpeg2-devel package):
get_filename_component(OPENJPEG_INCLUDE_ROOT "${SELF_DIR}/../../include/openjpeg-2.3" ABSOLUTE)
to
get_filename_component(OPENJPEG_INCLUDE_ROOT "${SELF_DIR}/../../usr/include/openjpeg-2.3" ABSOLUTE)