Makefile: add OpenResty install with GeoIP build and fallback to source on macOS 26

This commit is contained in:
Haitao Pan 2025-08-07 00:25:28 +08:00
parent 7e6327d6a7
commit ca3af0adfd

View File

@ -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