-
Notifications
You must be signed in to change notification settings - Fork 112
/
Makefile
99 lines (88 loc) · 3.69 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
HOME=$(shell pwd)
MAINVERSION?=2.4
NO_SUDO?=0
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"
endif
RELEASE?=1
EXTRA_CFLAGS?=0
PREREQ:=pcre-devel make gcc openssl-devel rpm-build systemd-devel curl sed zlib-devel
ifeq ($(NO_SUDO),1)
SUDO=
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
CONTAINER_RUNTIME=docker
endif
all: build
install_prereq:
# Check if the prereqs are there before trying to sudo
rpm -q $(PREREQ) || \
$(SUDO) $(PACKAGE_MANAGER) install $(INSTALL_FLAGS) $(PREREQ)
clean:
rm -f ./SOURCES/haproxy-*.tar.gz
rm -rf ./SOURCES/lua-*
rm -rf ./rpmbuild
mkdir -p ./rpmbuild/SPECS/ ./rpmbuild/SOURCES/ ./rpmbuild/RPMS/ ./rpmbuild/SRPMS/
download-upstream:
curl -o ./SOURCES/haproxy-${VERSION}.tar.gz http://www.haproxy.org/download/${MAINVERSION}/src/haproxy-${VERSION}.tar.gz
build_lua:
rpm -q readline-devel || $(SUDO) yum install -y readline-devel
curl -o ./SOURCES/lua-${LUA_VERSION}.tar.gz https://www.lua.org/ftp/lua-${LUA_VERSION}.tar.gz
cd ./SOURCES
tar xzf lua-${LUA_VERSION}.tar.gz
cd lua-${LUA_VERSION}
$(MAKE) -C lua-${LUA_VERSION} clean
$(SUDO) $(MAKE) -C lua-${LUA_VERSION} MYCFLAGS=-fPIC linux test # MYCFLAGS=-fPIC is required during linux ld
$(SUDO) $(MAKE) -C lua-${LUA_VERSION} install
build_stages := install_prereq clean download-upstream
ifeq ($(USE_LUA),1)
build_stages += build_lua
endif
build-docker:
$(CONTAINER_RUNTIME) build -t haproxy-rpm-builder7:${VERSION}-${RELEASE} -f Dockerfile7 .
$(CONTAINER_RUNTIME) build -t haproxy-rpm-builder8:${VERSION}-${RELEASE} -f Dockerfile8 .
$(CONTAINER_RUNTIME) build -t haproxy-rpm-builder9:${VERSION}-${RELEASE} -f Dockerfile9 .
$(CONTAINER_RUNTIME) build -t haproxy-rpm-builder-amzn2:${VERSION}-${RELEASE} -f Dockerfile-amzn2 .
$(CONTAINER_RUNTIME) build -t haproxy-rpm-builder-amzn2023:${VERSION}-${RELEASE} -f Dockerfile-amzn2023 .
run-docker: build-docker
mkdir -p RPMS
chcon -Rt svirt_sandbox_file_t RPMS || true
$(CONTAINER_RUNTIME) run --volume $(HOME)/RPMS:/RPMS --rm -e USE_PROMETHEUS=${USE_PROMETHEUS} -e RELEASE=${RELEASE} haproxy-rpm-builder7:${VERSION}-${RELEASE}
$(CONTAINER_RUNTIME) run --volume $(HOME)/RPMS:/RPMS --rm -e USE_PROMETHEUS=${USE_PROMETHEUS} -e RELEASE=${RELEASE} haproxy-rpm-builder8:${VERSION}-${RELEASE}
$(CONTAINER_RUNTIME) run --volume $(HOME)/RPMS:/RPMS --rm -e USE_PROMETHEUS=${USE_PROMETHEUS} -e RELEASE=${RELEASE} haproxy-rpm-builder9:${VERSION}-${RELEASE}
$(CONTAINER_RUNTIME) run --volume $(HOME)/RPMS:/RPMS --rm -e USE_PROMETHEUS=${USE_PROMETHEUS} -e RELEASE=${RELEASE} haproxy-rpm-builder-amzn2:${VERSION}-${RELEASE}
$(CONTAINER_RUNTIME) run --volume $(HOME)/RPMS:/RPMS --rm -e USE_PROMETHEUS=${USE_PROMETHEUS} -e RELEASE=${RELEASE} haproxy-rpm-builder-amzn2023:${VERSION}-${RELEASE}
build: $(build_stages)
cp -r ./SPECS/* ./rpmbuild/SPECS/ || true
cp -r ./SOURCES/* ./rpmbuild/SOURCES/ || true
rpmbuild -ba SPECS/haproxy.spec \
--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" \
--define "_buildroot %{_topdir}/BUILDROOT" \
--define "_rpmdir %{_topdir}/RPMS" \
--define "_srcrpmdir %{_topdir}/SRPMS" \
--define "_use_lua ${USE_LUA}" \
--define "_use_prometheus ${USE_PROMETHEUS}"