From 26d7114ac82195cd4f7db606d7762a6cff9132ad Mon Sep 17 00:00:00 2001
From: Hiroaki Nakamura <hnakamur@gmail.com>
Date: Fri, 12 Feb 2016 09:03:35 +0900
Subject: [PATCH] Convert a config file to build a dynamic module
Origin: other, https://github.com/FRiCKLE/ngx_cache_purge/pull/45

---
 config | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/config b/config
index 34f42ec..b900680 100644
--- a/config
+++ b/config
@@ -15,7 +15,17 @@ if [ "$HTTP_UWSGI" = "YES" ]; then
 fi
 
 ngx_addon_name=ngx_http_cache_purge_module
-HTTP_MODULES="$HTTP_MODULES ngx_http_cache_purge_module"
-NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_cache_purge_module.c"
+CACHE_PURGE_SRCS="$ngx_addon_dir/ngx_cache_purge_module.c"
+
+if [ -n "$ngx_module_link" ]; then
+    ngx_module_type=HTTP
+    ngx_module_name="$ngx_addon_name"
+    ngx_module_srcs="$CACHE_PURGE_SRCS"
+
+    . auto/module
+else
+    HTTP_MODULES="$HTTP_MODULES $ngx_addon_name"
+    NGX_ADDON_SRCS="$NGX_ADDON_SRCS $CACHE_PURGE_SRCS"
+fi
 
 have=NGX_CACHE_PURGE_MODULE . auto/have
