Skip to content

Commit

Permalink
Merge pull request #65 from izzyleung/dev
Browse files Browse the repository at this point in the history
Add dnf installation, allow passing in CPU flag
  • Loading branch information
DBezemer committed Apr 16, 2024
2 parents 8a53695 + fb33ae2 commit b190c2b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
14 changes: 13 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:.*>\(.*\)</a>.*:\1:p' | sed 's/^.//' | sort -rV | head -1)
ifeq ("${VERSION}","./")
VERSION="${MAINVERSION}.0"
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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" \
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/`
Expand Down
7 changes: 6 additions & 1 deletion SPECS/haproxy.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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}"

Expand Down

0 comments on commit b190c2b

Please sign in to comment.