NGINX_SOURCE_DIR = nginx

ifeq (, $(shell which bear))
MUNIN_BEAR=make
else
MUNIN_BEAR=bear --
endif

ifneq ($(MUNINN_NGINX_DEBUG),)
MUNINN_NGINX_DEBUG="--with-debug"
endif

CURDIR = $(.CURDIR)

.PHONY: all clean build

all: nginx/objs/nginx

nginx/objs/Makefile:
	cd $(NGINX_SOURCE_DIR) && \
		./auto/configure \
			$(MUNINN_NGINX_DEBUG) \
			--with-http_ssl_module \
			--with-compat \
			--add-module=$(.CURDIR)

nginx/objs/nginx: nginx/objs/Makefile
	$(MUNIN_BEAR) make -C $(NGINX_SOURCE_DIR)

clean:
	make -C $(NGINX_SOURCE_DIR) clean

