diff --git a/Makefile b/Makefile index 884faaf..6b262f2 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,7 @@ USE_PODMAN?=0 LUA_VERSION?=5.4.3 USE_LUA?=0 USE_PROMETHEUS?=0 +CPU?=0 VERSION=$(shell curl -s http://git.haproxy.org/git/haproxy-${MAINVERSION}.git/refs/tags/ | sed -n 's:.*>\(.*\).*:\1:p' | sed 's/^.//' | sort -rV | head -1) ifeq ("${VERSION}","./") VERSION="${MAINVERSION}.0" @@ -17,6 +18,16 @@ ifeq ($(NO_SUDO),1) else SUDO=sudo endif + +HAS_DNF:=$(shell command -v dnf 2> /dev/null) +ifdef HAS_DNF + PACKAGE_MANAGER=dnf + INSTALL_FLAGS=-y --allowerasing +else + PACKAGE_MANAGER=yum + INSTALL_FLAGS=-y +endif + ifeq ($(USE_PODMAN),1) CONTAINER_RUNTIME=podman else @@ -28,7 +39,7 @@ all: build install_prereq: # Check if the prereqs are there before trying to sudo rpm -q $(PREREQ) || \ - $(SUDO) yum install -y $(PREREQ) + $(SUDO) $(PACKAGE_MANAGER) install $(INSTALL_FLAGS) $(PREREQ) clean: rm -f ./SOURCES/haproxy-${VERSION}.tar.gz @@ -76,6 +87,7 @@ build: $(build_stages) --define "mainversion ${MAINVERSION}" \ --define "version ${VERSION}" \ --define "release ${RELEASE}" \ + --define "_cpu ${CPU}" \ --define "_extra_cflags ${EXTRA_CFLAGS}" \ --define "_topdir %(pwd)/rpmbuild" \ --define "_builddir %{_topdir}/BUILD" \ diff --git a/README.md b/README.md index fd7ae1a..376088f 100644 --- a/README.md +++ b/README.md @@ -37,13 +37,16 @@ Perform the following steps on a build box as a regular user. ### With Prometheus Module support make USE_PROMETHEUS=1 -### Without sudo for yum (for building in Docker) +### Without `sudo` for `yum` (for building in Docker) make NO_SUDO=1 ### With a custom release iteration, e.g. '2' (default '1'): make RELEASE=2 -### Custom CFLAGS, e.g. '-O0' to disable optimization for debug: +### With a custom target `CPU`, e.g. `armv81` + make CPU=armv81 + +### Custom `CFLAGS`, e.g. '-O0' to disable optimization for debug: make EXTRA_CFLAGS=-O0 Resulting RPMs will be in `/opt/rpm-haproxy/rpmbuild/RPMS/x86_64/` diff --git a/SPECS/haproxy.spec b/SPECS/haproxy.spec index c6a2430..de153e3 100644 --- a/SPECS/haproxy.spec +++ b/SPECS/haproxy.spec @@ -120,7 +120,12 @@ USE_PROMEX="USE_PROMEX=1" CFLAGS="$CFLAGS %{_extra_cflags}" %endif -%{__make} -j$RPM_BUILD_NCPUS %{?_smp_mflags} ${USE_LUA} CPU="generic" TARGET="linux-glibc" ${systemd_opts} ${pcre_opts} USE_OPENSSL=1 USE_ZLIB=1 ${regparm_opts} ADDINC="$CFLAGS" USE_LINUX_TPROXY=1 USE_THREAD=1 USE_TFO=${USE_TFO} USE_NS=${USE_NS} ${USE_PROMEX} ADDLIB="%{__global_ldflags}" +CPU="generic" +%if "%{_cpu}" != "0" + CPU="%{_cpu}" +%endif + +%{__make} -j$RPM_BUILD_NCPUS %{?_smp_mflags} ${USE_LUA} CPU="${CPU}" TARGET="linux-glibc" ${systemd_opts} ${pcre_opts} USE_OPENSSL=1 USE_ZLIB=1 ${regparm_opts} ADDINC="$CFLAGS" USE_LINUX_TPROXY=1 USE_THREAD=1 USE_TFO=${USE_TFO} USE_NS=${USE_NS} ${USE_PROMEX} ADDLIB="%{__global_ldflags}" %{__make} admin/halog/halog OPTIMIZE="%{optflags} %{__global_ldflags}"