From ca3af0adfde075f681ecbb24215840ecd55a7366 Mon Sep 17 00:00:00 2001 From: Haitao Pan Date: Thu, 7 Aug 2025 00:25:28 +0800 Subject: [PATCH] Makefile: add OpenResty install with GeoIP build and fallback to source on macOS 26 --- Makefile | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b2e5804..efd61ca 100644 --- a/Makefile +++ b/Makefile @@ -12,8 +12,33 @@ install: install-openresty install-redis install-postgresql install-pgvector install-openresty: ifeq ($(OS),Darwin) - brew install openresty/brew/openresty + @echo "Detected macOS. Installing GeoIP library into /opt/homebrew/geoip..." + @curl -LO https://github.com/maxmind/geoip-api-c/releases/download/v1.6.12/GeoIP-1.6.12.tar.gz && \ + tar zxvf GeoIP-1.6.12.tar.gz && \ + cd GeoIP-1.6.12 && \ + ./configure --prefix=/opt/homebrew/geoip && \ + make -j$(CORES) && \ + sudo make install && \ + cd .. && rm -rf GeoIP-1.6.12 GeoIP-1.6.12.tar.gz + + @echo "Trying Homebrew build of OpenResty with GeoIP..." + env CPPFLAGS="-I/opt/homebrew/geoip/include" \ + LDFLAGS="-L/opt/homebrew/geoip/lib" \ + brew install --build-from-source openresty/brew/openresty || \ + (echo "Homebrew failed, falling back to manual source build..." && \ + curl -LO https://openresty.org/download/openresty-1.27.1.2.tar.gz && \ + tar zxvf openresty-1.27.1.2.tar.gz && \ + cd openresty-1.27.1.2 && \ + ./configure \ + --prefix=/opt/homebrew/openresty \ + --with-http_geoip_module \ + --with-cc-opt="-I/opt/homebrew/geoip/include" \ + --with-ld-opt="-L/opt/homebrew/geoip/lib" && \ + make -j$(CORES) && \ + sudo make install && \ + cd .. && rm -rf openresty-1.27.1.2 openresty-1.27.1.2.tar.gz) else + @echo "Detected Linux. Installing via apt..." sudo apt-get update && \ sudo apt-get install -y openresty || echo "Please install OpenResty manually." endif